Merge branch 'release' of master.kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6

This commit is contained in:
Linus Torvalds 2005-09-08 07:21:59 -07:00
commit 6a4b170c54
249 changed files with 28674 additions and 32043 deletions

View File

@ -35,4 +35,4 @@ created. Please use command "cat /proc/acpi/hotkey/polling_method"
to retrieve it.
Note: Use cmdline "acpi_generic_hotkey" to over-ride
loading any platform specific drivers.
platform-specific with generic driver.

View File

@ -1,16 +1,16 @@
IBM ThinkPad ACPI Extras Driver
Version 0.8
8 November 2004
Version 0.12
17 August 2005
Borislav Deianov <borislav@users.sf.net>
http://ibm-acpi.sf.net/
This is a Linux ACPI driver for the IBM ThinkPad laptops. It aims to
support various features of these laptops which are accessible through
the ACPI framework but not otherwise supported by the generic Linux
ACPI drivers.
This is a Linux ACPI driver for the IBM ThinkPad laptops. It supports
various features of these laptops which are accessible through the
ACPI framework but not otherwise supported by the generic Linux ACPI
drivers.
Status
@ -25,9 +25,14 @@ detailed description):
- ThinkLight on and off
- limited docking and undocking
- UltraBay eject
- Experimental: CMOS control
- Experimental: LED control
- Experimental: ACPI sounds
- CMOS control
- LED control
- ACPI sounds
- temperature sensors
- Experimental: embedded controller register dump
- Experimental: LCD brightness control
- Experimental: volume control
- Experimental: fan speed, fan enable/disable
A compatibility table by model and feature is maintained on the web
site, http://ibm-acpi.sf.net/. I appreciate any success or failure
@ -91,12 +96,12 @@ driver is still in the alpha stage, the exact proc file format and
commands supported by the various features is guaranteed to change
frequently.
Driver Version -- /proc/acpi/ibm/driver
--------------------------------------
Driver version -- /proc/acpi/ibm/driver
---------------------------------------
The driver name and version. No commands can be written to this file.
Hot Keys -- /proc/acpi/ibm/hotkey
Hot keys -- /proc/acpi/ibm/hotkey
---------------------------------
Without this driver, only the Fn-F4 key (sleep button) generates an
@ -188,7 +193,7 @@ and, on the X40, video corruption. By disabling automatic switching,
the flickering or video corruption can be avoided.
The video_switch command cycles through the available video outputs
(it sumulates the behavior of Fn-F7).
(it simulates the behavior of Fn-F7).
Video expansion can be toggled through this feature. This controls
whether the display is expanded to fill the entire LCD screen when a
@ -201,6 +206,12 @@ Fn-F7 from working. This also disables the video output switching
features of this driver, as it uses the same ACPI methods as
Fn-F7. Video switching on the console should still work.
UPDATE: There's now a patch for the X.org Radeon driver which
addresses this issue. Some people are reporting success with the patch
while others are still having problems. For more information:
https://bugs.freedesktop.org/show_bug.cgi?id=2000
ThinkLight control -- /proc/acpi/ibm/light
------------------------------------------
@ -211,7 +222,7 @@ models which do not make the status available will show it as
echo on > /proc/acpi/ibm/light
echo off > /proc/acpi/ibm/light
Docking / Undocking -- /proc/acpi/ibm/dock
Docking / undocking -- /proc/acpi/ibm/dock
------------------------------------------
Docking and undocking (e.g. with the X4 UltraBase) requires some
@ -228,11 +239,15 @@ NOTE: These events will only be generated if the laptop was docked
when originally booted. This is due to the current lack of support for
hot plugging of devices in the Linux ACPI framework. If the laptop was
booted while not in the dock, the following message is shown in the
logs: "ibm_acpi: dock device not present". No dock-related events are
generated but the dock and undock commands described below still
work. They can be executed manually or triggered by Fn key
combinations (see the example acpid configuration files included in
the driver tarball package available on the web site).
logs:
Mar 17 01:42:34 aero kernel: ibm_acpi: dock device not present
In this case, no dock-related events are generated but the dock and
undock commands described below still work. They can be executed
manually or triggered by Fn key combinations (see the example acpid
configuration files included in the driver tarball package available
on the web site).
When the eject request button on the dock is pressed, the first event
above is generated. The handler for this event should issue the
@ -267,7 +282,7 @@ the only docking stations currently supported are the X-series
UltraBase docks and "dumb" port replicators like the Mini Dock (the
latter don't need any ACPI support, actually).
UltraBay Eject -- /proc/acpi/ibm/bay
UltraBay eject -- /proc/acpi/ibm/bay
------------------------------------
Inserting or ejecting an UltraBay device requires some actions to be
@ -284,8 +299,11 @@ when the laptop was originally booted (on the X series, the UltraBay
is in the dock, so it may not be present if the laptop was undocked).
This is due to the current lack of support for hot plugging of devices
in the Linux ACPI framework. If the laptop was booted without the
UltraBay, the following message is shown in the logs: "ibm_acpi: bay
device not present". No bay-related events are generated but the eject
UltraBay, the following message is shown in the logs:
Mar 17 01:42:34 aero kernel: ibm_acpi: bay device not present
In this case, no bay-related events are generated but the eject
command described below still works. It can be executed manually or
triggered by a hot key combination.
@ -306,22 +324,33 @@ necessary to enable the UltraBay device (e.g. call idectl).
The contents of the /proc/acpi/ibm/bay file shows the current status
of the UltraBay, as provided by the ACPI framework.
Experimental Features
---------------------
EXPERIMENTAL warm eject support on the 600e/x, A22p and A3x (To use
this feature, you need to supply the experimental=1 parameter when
loading the module):
The following features are marked experimental because using them
involves guessing the correct values of some parameters. Guessing
incorrectly may have undesirable effects like crashing your
ThinkPad. USE THESE WITH CAUTION! To activate them, you'll need to
supply the experimental=1 parameter when loading the module.
These models do not have a button near the UltraBay device to request
a hot eject but rather require the laptop to be put to sleep
(suspend-to-ram) before the bay device is ejected or inserted).
The sequence of steps to eject the device is as follows:
Experimental: CMOS control - /proc/acpi/ibm/cmos
------------------------------------------------
echo eject > /proc/acpi/ibm/bay
put the ThinkPad to sleep
remove the drive
resume from sleep
cat /proc/acpi/ibm/bay should show that the drive was removed
On the A3x, both the UltraBay 2000 and UltraBay Plus devices are
supported. Use "eject2" instead of "eject" for the second bay.
Note: the UltraBay eject support on the 600e/x, A22p and A3x is
EXPERIMENTAL and may not work as expected. USE WITH CAUTION!
CMOS control -- /proc/acpi/ibm/cmos
-----------------------------------
This feature is used internally by the ACPI firmware to control the
ThinkLight on most newer ThinkPad models. It appears that it can also
control LCD brightness, sounds volume and more, but only on some
models.
ThinkLight on most newer ThinkPad models. It may also control LCD
brightness, sounds volume and more, but only on some models.
The commands are non-negative integer numbers:
@ -330,10 +359,9 @@ The commands are non-negative integer numbers:
echo 2 >/proc/acpi/ibm/cmos
...
The range of numbers which are used internally by various models is 0
to 21, but it's possible that numbers outside this range have
interesting behavior. Here is the behavior on the X40 (tpb is the
ThinkPad Buttons utility):
The range of valid numbers is 0 to 21, but not all have an effect and
the behavior varies from model to model. Here is the behavior on the
X40 (tpb is the ThinkPad Buttons utility):
0 - no effect but tpb reports "Volume down"
1 - no effect but tpb reports "Volume up"
@ -346,26 +374,18 @@ ThinkPad Buttons utility):
13 - ThinkLight off
14 - no effect but tpb reports ThinkLight status change
If you try this feature, please send me a report similar to the
above. On models which allow control of LCD brightness or sound
volume, I'd like to provide this functionality in an user-friendly
way, but first I need a way to identify the models which this is
possible.
Experimental: LED control - /proc/acpi/ibm/LED
----------------------------------------------
LED control -- /proc/acpi/ibm/led
---------------------------------
Some of the LED indicators can be controlled through this feature. The
available commands are:
echo <led number> on >/proc/acpi/ibm/led
echo <led number> off >/proc/acpi/ibm/led
echo <led number> blink >/proc/acpi/ibm/led
echo '<led number> on' >/proc/acpi/ibm/led
echo '<led number> off' >/proc/acpi/ibm/led
echo '<led number> blink' >/proc/acpi/ibm/led
The <led number> parameter is a non-negative integer. The range of LED
numbers used internally by various models is 0 to 7 but it's possible
that numbers outside this range are also valid. Here is the mapping on
the X40:
The <led number> range is 0 to 7. The set of LEDs that can be
controlled varies from model to model. Here is the mapping on the X40:
0 - power
1 - battery (orange)
@ -376,49 +396,224 @@ the X40:
All of the above can be turned on and off and can be made to blink.
If you try this feature, please send me a report similar to the
above. I'd like to provide this functionality in an user-friendly way,
but first I need to identify the which numbers correspond to which
LEDs on various models.
Experimental: ACPI sounds - /proc/acpi/ibm/beep
-----------------------------------------------
ACPI sounds -- /proc/acpi/ibm/beep
----------------------------------
The BEEP method is used internally by the ACPI firmware to provide
audible alerts in various situtation. This feature allows the same
audible alerts in various situations. This feature allows the same
sounds to be triggered manually.
The commands are non-negative integer numbers:
echo 0 >/proc/acpi/ibm/beep
echo 1 >/proc/acpi/ibm/beep
echo 2 >/proc/acpi/ibm/beep
...
echo <number> >/proc/acpi/ibm/beep
The range of numbers which are used internally by various models is 0
to 17, but it's possible that numbers outside this range are also
valid. Here is the behavior on the X40:
The valid <number> range is 0 to 17. Not all numbers trigger sounds
and the sounds vary from model to model. Here is the behavior on the
X40:
2 - two beeps, pause, third beep
0 - stop a sound in progress (but use 17 to stop 16)
2 - two beeps, pause, third beep ("low battery")
3 - single beep
4 - "unable"
4 - high, followed by low-pitched beep ("unable")
5 - single beep
6 - "AC/DC"
6 - very high, followed by high-pitched beep ("AC/DC")
7 - high-pitched beep
9 - three short beeps
10 - very long beep
12 - low-pitched beep
15 - three high-pitched beeps repeating constantly, stop with 0
16 - one medium-pitched beep repeating constantly, stop with 17
17 - stop 16
(I've only been able to identify a couple of them).
Temperature sensors -- /proc/acpi/ibm/thermal
---------------------------------------------
If you try this feature, please send me a report similar to the
above. I'd like to provide this functionality in an user-friendly way,
but first I need to identify the which numbers correspond to which
sounds on various models.
Most ThinkPads include six or more separate temperature sensors but
only expose the CPU temperature through the standard ACPI methods.
This feature shows readings from up to eight different sensors. Some
readings may not be valid, e.g. may show large negative values. For
example, on the X40, a typical output may be:
temperatures: 42 42 45 41 36 -128 33 -128
Thomas Gruber took his R51 apart and traced all six active sensors in
his laptop (the location of sensors may vary on other models):
1: CPU
2: Mini PCI Module
3: HDD
4: GPU
5: Battery
6: N/A
7: Battery
8: N/A
No commands can be written to this file.
EXPERIMENTAL: Embedded controller reigster dump -- /proc/acpi/ibm/ecdump
------------------------------------------------------------------------
This feature is marked EXPERIMENTAL because the implementation
directly accesses hardware registers and may not work as expected. USE
WITH CAUTION! To use this feature, you need to supply the
experimental=1 parameter when loading the module.
This feature dumps the values of 256 embedded controller
registers. Values which have changed since the last time the registers
were dumped are marked with a star:
[root@x40 ibm-acpi]# cat /proc/acpi/ibm/ecdump
EC +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +0a +0b +0c +0d +0e +0f
EC 0x00: a7 47 87 01 fe 96 00 08 01 00 cb 00 00 00 40 00
EC 0x10: 00 00 ff ff f4 3c 87 09 01 ff 42 01 ff ff 0d 00
EC 0x20: 00 00 00 00 00 00 00 00 00 00 00 03 43 00 00 80
EC 0x30: 01 07 1a 00 30 04 00 00 *85 00 00 10 00 50 00 00
EC 0x40: 00 00 00 00 00 00 14 01 00 04 00 00 00 00 00 00
EC 0x50: 00 c0 02 0d 00 01 01 02 02 03 03 03 03 *bc *02 *bc
EC 0x60: *02 *bc *02 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0x70: 00 00 00 00 00 12 30 40 *24 *26 *2c *27 *20 80 *1f 80
EC 0x80: 00 00 00 06 *37 *0e 03 00 00 00 0e 07 00 00 00 00
EC 0x90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0xa0: *ff 09 ff 09 ff ff *64 00 *00 *00 *a2 41 *ff *ff *e0 00
EC 0xb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0xc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0xd0: 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0xe0: 00 00 00 00 00 00 00 00 11 20 49 04 24 06 55 03
EC 0xf0: 31 55 48 54 35 38 57 57 08 2f 45 73 07 65 6c 1a
This feature can be used to determine the register holding the fan
speed on some models. To do that, do the following:
- make sure the battery is fully charged
- make sure the fan is running
- run 'cat /proc/acpi/ibm/ecdump' several times, once per second or so
The first step makes sure various charging-related values don't
vary. The second ensures that the fan-related values do vary, since
the fan speed fluctuates a bit. The third will (hopefully) mark the
fan register with a star:
[root@x40 ibm-acpi]# cat /proc/acpi/ibm/ecdump
EC +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +0a +0b +0c +0d +0e +0f
EC 0x00: a7 47 87 01 fe 96 00 08 01 00 cb 00 00 00 40 00
EC 0x10: 00 00 ff ff f4 3c 87 09 01 ff 42 01 ff ff 0d 00
EC 0x20: 00 00 00 00 00 00 00 00 00 00 00 03 43 00 00 80
EC 0x30: 01 07 1a 00 30 04 00 00 85 00 00 10 00 50 00 00
EC 0x40: 00 00 00 00 00 00 14 01 00 04 00 00 00 00 00 00
EC 0x50: 00 c0 02 0d 00 01 01 02 02 03 03 03 03 bc 02 bc
EC 0x60: 02 bc 02 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0x70: 00 00 00 00 00 12 30 40 24 27 2c 27 21 80 1f 80
EC 0x80: 00 00 00 06 *be 0d 03 00 00 00 0e 07 00 00 00 00
EC 0x90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0xa0: ff 09 ff 09 ff ff 64 00 00 00 a2 41 ff ff e0 00
EC 0xb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0xc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0xd0: 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
EC 0xe0: 00 00 00 00 00 00 00 00 11 20 49 04 24 06 55 03
EC 0xf0: 31 55 48 54 35 38 57 57 08 2f 45 73 07 65 6c 1a
Another set of values that varies often is the temperature
readings. Since temperatures don't change vary fast, you can take
several quick dumps to eliminate them.
You can use a similar method to figure out the meaning of other
embedded controller registers - e.g. make sure nothing else changes
except the charging or discharging battery to determine which
registers contain the current battery capacity, etc. If you experiment
with this, do send me your results (including some complete dumps with
a description of the conditions when they were taken.)
EXPERIMENTAL: LCD brightness control -- /proc/acpi/ibm/brightness
-----------------------------------------------------------------
This feature is marked EXPERIMENTAL because the implementation
directly accesses hardware registers and may not work as expected. USE
WITH CAUTION! To use this feature, you need to supply the
experimental=1 parameter when loading the module.
This feature allows software control of the LCD brightness on ThinkPad
models which don't have a hardware brightness slider. The available
commands are:
echo up >/proc/acpi/ibm/brightness
echo down >/proc/acpi/ibm/brightness
echo 'level <level>' >/proc/acpi/ibm/brightness
The <level> number range is 0 to 7, although not all of them may be
distinct. The current brightness level is shown in the file.
EXPERIMENTAL: Volume control -- /proc/acpi/ibm/volume
-----------------------------------------------------
This feature is marked EXPERIMENTAL because the implementation
directly accesses hardware registers and may not work as expected. USE
WITH CAUTION! To use this feature, you need to supply the
experimental=1 parameter when loading the module.
This feature allows volume control on ThinkPad models which don't have
a hardware volume knob. The available commands are:
echo up >/proc/acpi/ibm/volume
echo down >/proc/acpi/ibm/volume
echo mute >/proc/acpi/ibm/volume
echo 'level <level>' >/proc/acpi/ibm/volume
The <level> number range is 0 to 15 although not all of them may be
distinct. The unmute the volume after the mute command, use either the
up or down command (the level command will not unmute the volume).
The current volume level and mute state is shown in the file.
EXPERIMENTAL: fan speed, fan enable/disable -- /proc/acpi/ibm/fan
-----------------------------------------------------------------
This feature is marked EXPERIMENTAL because the implementation
directly accesses hardware registers and may not work as expected. USE
WITH CAUTION! To use this feature, you need to supply the
experimental=1 parameter when loading the module.
This feature attempts to show the current fan speed. The speed is read
directly from the hardware registers of the embedded controller. This
is known to work on later R, T and X series ThinkPads but may show a
bogus value on other models.
The fan may be enabled or disabled with the following commands:
echo enable >/proc/acpi/ibm/fan
echo disable >/proc/acpi/ibm/fan
WARNING WARNING WARNING: do not leave the fan disabled unless you are
monitoring the temperature sensor readings and you are ready to enable
it if necessary to avoid overheating.
The fan only runs if it's enabled *and* the various temperature
sensors which control it read high enough. On the X40, this seems to
depend on the CPU and HDD temperatures. Specifically, the fan is
turned on when either the CPU temperature climbs to 56 degrees or the
HDD temperature climbs to 46 degrees. The fan is turned off when the
CPU temperature drops to 49 degrees and the HDD temperature drops to
41 degrees. These thresholds cannot currently be controlled.
On the X31 and X40 (and ONLY on those models), the fan speed can be
controlled to a certain degree. Once the fan is running, it can be
forced to run faster or slower with the following command:
echo 'speed <speed>' > /proc/acpi/ibm/thermal
The sustainable range of fan speeds on the X40 appears to be from
about 3700 to about 7350. Values outside this range either do not have
any effect or the fan speed eventually settles somewhere in that
range. The fan cannot be stopped or started with this command.
On the 570, temperature readings are not available through this
feature and the fan control works a little differently. The fan speed
is reported in levels from 0 (off) to 7 (max) and can be controlled
with the following command:
echo 'level <level>' > /proc/acpi/ibm/thermal
Multiple Command, Module Parameters
-----------------------------------
Multiple Commands, Module Parameters
------------------------------------
Multiple commands can be written to the proc files in one shot by
separating them with commas, for example:
@ -451,24 +646,19 @@ scripts (included with ibm-acpi for completeness):
/usr/local/sbin/laptop_mode -- from the Linux kernel source
distribution, see Documentation/laptop-mode.txt
/sbin/service -- comes with Redhat/Fedora distributions
/usr/sbin/hibernate -- from the Software Suspend 2 distribution,
see http://softwaresuspend.berlios.de/
Toan T Nguyen <ntt@control.uchicago.edu> has written a SuSE powersave
script for the X20, included in config/usr/sbin/ibm_hotkeys_X20
Toan T Nguyen <ntt@physics.ucla.edu> notes that Suse uses the
powersave program to suspend ('powersave --suspend-to-ram') or
hibernate ('powersave --suspend-to-disk'). This means that the
hibernate script is not needed on that distribution.
Henrik Brix Andersen <brix@gentoo.org> has written a Gentoo ACPI event
handler script for the X31. You can get the latest version from
http://dev.gentoo.org/~brix/files/x31.sh
David Schweikert <dws@ee.eth.ch> has written an alternative blank.sh
script which works on Debian systems, included in
configs/etc/acpi/actions/blank-debian.sh
TODO
----
I'd like to implement the following features but haven't yet found the
time and/or I don't yet know how to implement them:
- UltraBay floppy drive support
script which works on Debian systems. This scripts has now been
extended to also work on Fedora systems and included as the default
blank.sh in the distribution.

View File

@ -1212,7 +1212,6 @@ config PCI_DIRECT
config PCI_MMCONFIG
bool
depends on PCI && ACPI && (PCI_GOMMCONFIG || PCI_GOANY)
select ACPI_BOOT
default y
source "drivers/pci/pcie/Kconfig"

View File

@ -131,8 +131,6 @@ CONFIG_SOFTWARE_SUSPEND=y
# ACPI (Advanced Configuration and Power Interface) Support
#
CONFIG_ACPI=y
CONFIG_ACPI_BOOT=y
CONFIG_ACPI_INTERPRETER=y
CONFIG_ACPI_SLEEP=y
CONFIG_ACPI_SLEEP_PROC_FS=y
CONFIG_ACPI_AC=y
@ -144,10 +142,8 @@ CONFIG_ACPI_THERMAL=y
# CONFIG_ACPI_ASUS is not set
# CONFIG_ACPI_TOSHIBA is not set
# CONFIG_ACPI_DEBUG is not set
CONFIG_ACPI_BUS=y
CONFIG_ACPI_EC=y
CONFIG_ACPI_POWER=y
CONFIG_ACPI_PCI=y
CONFIG_ACPI_SYSTEM=y
# CONFIG_X86_PM_TIMER is not set

View File

@ -11,7 +11,7 @@ obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \
obj-y += cpu/
obj-y += timers/
obj-$(CONFIG_ACPI_BOOT) += acpi/
obj-$(CONFIG_ACPI) += acpi/
obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o
obj-$(CONFIG_MCA) += mca.o
obj-$(CONFIG_X86_MSR) += msr.o

View File

@ -1,4 +1,4 @@
obj-$(CONFIG_ACPI_BOOT) := boot.o
obj-y := boot.o
obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o
obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o

File diff suppressed because it is too large Load Diff

View File

@ -8,44 +8,44 @@
#include <asm/pci-direct.h>
#include <asm/acpi.h>
static int __init check_bridge(int vendor, int device)
static int __init check_bridge(int vendor, int device)
{
/* According to Nvidia all timer overrides are bogus. Just ignore
them all. */
if (vendor == PCI_VENDOR_ID_NVIDIA) {
acpi_skip_timer_override = 1;
if (vendor == PCI_VENDOR_ID_NVIDIA) {
acpi_skip_timer_override = 1;
}
return 0;
}
void __init check_acpi_pci(void)
{
int num,slot,func;
void __init check_acpi_pci(void)
{
int num, slot, func;
/* Assume the machine supports type 1. If not it will
always read ffffffff and should not have any side effect. */
/* Poor man's PCI discovery */
for (num = 0; num < 32; num++) {
for (slot = 0; slot < 32; slot++) {
for (func = 0; func < 8; func++) {
for (num = 0; num < 32; num++) {
for (slot = 0; slot < 32; slot++) {
for (func = 0; func < 8; func++) {
u32 class;
u32 vendor;
class = read_pci_config(num,slot,func,
class = read_pci_config(num, slot, func,
PCI_CLASS_REVISION);
if (class == 0xffffffff)
break;
break;
if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
continue;
vendor = read_pci_config(num, slot, func,
continue;
vendor = read_pci_config(num, slot, func,
PCI_VENDOR_ID);
if (check_bridge(vendor&0xffff, vendor >> 16))
return;
}
if (check_bridge(vendor & 0xffff, vendor >> 16))
return;
}
}
}
}

View File

@ -20,12 +20,13 @@ extern void zap_low_mappings(void);
extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long));
static void init_low_mapping(pgd_t *pgd, int pgd_limit)
static void init_low_mapping(pgd_t * pgd, int pgd_limit)
{
int pgd_ofs = 0;
while ((pgd_ofs < pgd_limit) && (pgd_ofs + USER_PTRS_PER_PGD < PTRS_PER_PGD)) {
set_pgd(pgd, *(pgd+USER_PTRS_PER_PGD));
while ((pgd_ofs < pgd_limit)
&& (pgd_ofs + USER_PTRS_PER_PGD < PTRS_PER_PGD)) {
set_pgd(pgd, *(pgd + USER_PTRS_PER_PGD));
pgd_ofs++, pgd++;
}
flush_tlb_all();
@ -37,12 +38,13 @@ static void init_low_mapping(pgd_t *pgd, int pgd_limit)
* Create an identity mapped page table and copy the wakeup routine to
* low memory.
*/
int acpi_save_state_mem (void)
int acpi_save_state_mem(void)
{
if (!acpi_wakeup_address)
return 1;
init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD);
memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start);
memcpy((void *)acpi_wakeup_address, &wakeup_start,
&wakeup_end - &wakeup_start);
acpi_copy_wakeup_routine(acpi_wakeup_address);
return 0;
@ -51,7 +53,7 @@ int acpi_save_state_mem (void)
/*
* acpi_restore_state - undo effects of acpi_save_state_mem
*/
void acpi_restore_state_mem (void)
void acpi_restore_state_mem(void)
{
zap_low_mappings();
}
@ -67,7 +69,8 @@ void acpi_restore_state_mem (void)
void __init acpi_reserve_bootmem(void)
{
if ((&wakeup_end - &wakeup_start) > PAGE_SIZE) {
printk(KERN_ERR "ACPI: Wakeup code way too big, S3 disabled.\n");
printk(KERN_ERR
"ACPI: Wakeup code way too big, S3 disabled.\n");
return;
}
@ -90,10 +93,8 @@ static int __init acpi_sleep_setup(char *str)
return 1;
}
__setup("acpi_sleep=", acpi_sleep_setup);
static __init int reset_videomode_after_s3(struct dmi_system_id *d)
{
acpi_video_flags |= 2;
@ -101,14 +102,14 @@ static __init int reset_videomode_after_s3(struct dmi_system_id *d)
}
static __initdata struct dmi_system_id acpisleep_dmi_table[] = {
{ /* Reset video mode after returning from ACPI S3 sleep */
.callback = reset_videomode_after_s3,
.ident = "Toshiba Satellite 4030cdt",
.matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),
},
},
{ }
{ /* Reset video mode after returning from ACPI S3 sleep */
.callback = reset_videomode_after_s3,
.ident = "Toshiba Satellite 4030cdt",
.matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),
},
},
{}
};
static int __init acpisleep_dmi_init(void)

View File

@ -31,6 +31,7 @@
#include <linux/cpufreq.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/compiler.h>
#include <asm/io.h>
#include <asm/delay.h>
#include <asm/uaccess.h>
@ -57,6 +58,8 @@ static struct cpufreq_acpi_io *acpi_io_data[NR_CPUS];
static struct cpufreq_driver acpi_cpufreq_driver;
static unsigned int acpi_pstate_strict;
static int
acpi_processor_write_port(
u16 port,
@ -163,34 +166,44 @@ acpi_processor_set_performance (
}
/*
* Then we read the 'status_register' and compare the value with the
* target state's 'status' to make sure the transition was successful.
* Note that we'll poll for up to 1ms (100 cycles of 10us) before
* giving up.
* Assume the write went through when acpi_pstate_strict is not used.
* As read status_register is an expensive operation and there
* are no specific error cases where an IO port write will fail.
*/
if (acpi_pstate_strict) {
/* Then we read the 'status_register' and compare the value
* with the target state's 'status' to make sure the
* transition was successful.
* Note that we'll poll for up to 1ms (100 cycles of 10us)
* before giving up.
*/
port = data->acpi_data.status_register.address;
bit_width = data->acpi_data.status_register.bit_width;
port = data->acpi_data.status_register.address;
bit_width = data->acpi_data.status_register.bit_width;
dprintk("Looking for 0x%08x from port 0x%04x\n",
(u32) data->acpi_data.states[state].status, port);
dprintk("Looking for 0x%08x from port 0x%04x\n",
(u32) data->acpi_data.states[state].status, port);
for (i=0; i<100; i++) {
ret = acpi_processor_read_port(port, bit_width, &value);
if (ret) {
dprintk("Invalid port width 0x%04x\n", bit_width);
retval = ret;
goto migrate_end;
for (i=0; i<100; i++) {
ret = acpi_processor_read_port(port, bit_width, &value);
if (ret) {
dprintk("Invalid port width 0x%04x\n", bit_width);
retval = ret;
goto migrate_end;
}
if (value == (u32) data->acpi_data.states[state].status)
break;
udelay(10);
}
if (value == (u32) data->acpi_data.states[state].status)
break;
udelay(10);
} else {
i = 0;
value = (u32) data->acpi_data.states[state].status;
}
/* notify cpufreq */
cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
if (value != (u32) data->acpi_data.states[state].status) {
if (unlikely(value != (u32) data->acpi_data.states[state].status)) {
unsigned int tmp = cpufreq_freqs.new;
cpufreq_freqs.new = cpufreq_freqs.old;
cpufreq_freqs.old = tmp;
@ -537,6 +550,8 @@ acpi_cpufreq_exit (void)
return;
}
module_param(acpi_pstate_strict, uint, 0644);
MODULE_PARM_DESC(acpi_pstate_strict, "value 0 or non-zero. non-zero -> strict ACPI checks are performed during frequency changes.");
late_initcall(acpi_cpufreq_init);
module_exit(acpi_cpufreq_exit);

View File

@ -2423,7 +2423,7 @@ device_initcall(ioapic_init_sysfs);
ACPI-based IOAPIC Configuration
-------------------------------------------------------------------------- */
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
int __init io_apic_get_unique_id (int ioapic, int apic_id)
{
@ -2577,4 +2577,4 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
return 0;
}
#endif /*CONFIG_ACPI_BOOT*/
#endif /* CONFIG_ACPI */

View File

@ -668,8 +668,6 @@ void __init get_smp_config (void)
struct intel_mp_floating *mpf = mpf_found;
/*
* ACPI may be used to obtain the entire SMP configuration or just to
* enumerate/configure processors (CONFIG_ACPI_BOOT). Note that
* ACPI supports both logical (e.g. Hyper-Threading) and physical
* processors, where MPS only supports physical.
*/
@ -825,7 +823,7 @@ void __init find_smp_config (void)
ACPI-based MP Configuration
-------------------------------------------------------------------------- */
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
void __init mp_register_lapic_address (
u64 address)
@ -871,7 +869,7 @@ void __init mp_register_lapic (
MP_processor_info(&processor);
}
#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
#ifdef CONFIG_X86_IO_APIC
#define MP_ISA_BUS 0
#define MP_MAX_IOAPIC_PIN 127
@ -1086,11 +1084,9 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
*/
static int gsi_to_irq[MAX_GSI_NUM];
#ifdef CONFIG_ACPI_BUS
/* Don't set up the ACPI SCI because it's already set up */
if (acpi_fadt.sci_int == gsi)
return gsi;
#endif
ioapic = mp_find_ioapic(gsi);
if (ioapic < 0) {
@ -1133,13 +1129,11 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
if (gsi < MAX_GSI_NUM) {
if (gsi > 15)
gsi = pci_irq++;
#ifdef CONFIG_ACPI_BUS
/*
* Don't assign IRQ used by ACPI SCI
*/
if (gsi == acpi_fadt.sci_int)
gsi = pci_irq++;
#endif
gsi_to_irq[irq] = gsi;
} else {
printk(KERN_ERR "GSI %u is too high\n", gsi);
@ -1153,5 +1147,5 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
return gsi;
}
#endif /*CONFIG_X86_IO_APIC && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)*/
#endif /*CONFIG_ACPI_BOOT*/
#endif /* CONFIG_X86_IO_APIC */
#endif /* CONFIG_ACPI */

View File

@ -87,14 +87,14 @@ EXPORT_SYMBOL(boot_cpu_data);
unsigned long mmu_cr4_features;
#ifdef CONFIG_ACPI_INTERPRETER
#ifdef CONFIG_ACPI
int acpi_disabled = 0;
#else
int acpi_disabled = 1;
#endif
EXPORT_SYMBOL(acpi_disabled);
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
int __initdata acpi_force = 0;
extern acpi_interrupt_flags acpi_sci_flags;
#endif
@ -798,7 +798,7 @@ static void __init parse_cmdline_early (char ** cmdline_p)
}
#endif
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
/* "acpi=off" disables both ACPI table parsing and interpreter */
else if (!memcmp(from, "acpi=off", 8)) {
disable_acpi();
@ -854,7 +854,7 @@ static void __init parse_cmdline_early (char ** cmdline_p)
else if (!memcmp(from, "noapic", 6))
disable_ioapic_setup();
#endif /* CONFIG_X86_LOCAL_APIC */
#endif /* CONFIG_ACPI_BOOT */
#endif /* CONFIG_ACPI */
#ifdef CONFIG_X86_LOCAL_APIC
/* enable local APIC */
@ -1579,7 +1579,7 @@ void __init setup_arch(char **cmdline_p)
if (efi_enabled)
efi_map_memmap();
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
/*
* Parse the ACPI tables for possible boot-time SMP configuration.
*/

View File

@ -51,7 +51,7 @@ struct mip_reg *host_reg;
int mip_port;
unsigned long mip_addr, host_addr;
#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI)
/*
* GSI override for ES7000 platforms.
@ -73,7 +73,7 @@ es7000_rename_gsi(int ioapic, int gsi)
return gsi;
}
#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)
#endif /* (CONFIG_X86_IO_APIC) && (CONFIG_ACPI) */
void __init
setup_unisys ()

View File

@ -5,7 +5,7 @@ obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o
obj-$(CONFIG_PCI_DIRECT) += direct.o
pci-y := fixup.o
pci-$(CONFIG_ACPI_PCI) += acpi.o
pci-$(CONFIG_ACPI) += acpi.o
pci-y += legacy.o irq.o
pci-$(CONFIG_X86_VISWS) := visws.o fixup.o

View File

@ -1075,7 +1075,7 @@ static void pirq_penalize_isa_irq(int irq, int active)
void pcibios_penalize_isa_irq(int irq, int active)
{
#ifdef CONFIG_ACPI_PCI
#ifdef CONFIG_ACPI
if (!acpi_noirq)
acpi_penalize_isa_irq(irq, active);
else

View File

@ -60,6 +60,7 @@ choice
config IA64_GENERIC
bool "generic"
select ACPI
select NUMA
select ACPI_NUMA
select VIRTUAL_MEM_MAP
@ -340,6 +341,7 @@ config IA64_PALINFO
config ACPI_DEALLOCATE_IRQ
bool
depends on ACPI
depends on IOSAPIC && EXPERIMENTAL
default y
@ -351,38 +353,10 @@ endmenu
menu "Power management and ACPI"
config PM
bool "Power Management support"
depends on !IA64_HP_SIM
default y
help
"Power Management" means that parts of your computer are shut
off or put into a power conserving "sleep" mode if they are not
being used. There are two competing standards for doing this: APM
and ACPI. If you want to use either one, say Y here and then also
to the requisite support below.
Power Management is most important for battery powered laptop
computers; if you have a laptop, check out the Linux Laptop home
page on the WWW at <http://www.linux-on-laptops.com/> and the
Battery Powered Linux mini-HOWTO, available from
<http://www.tldp.org/docs.html#howto>.
Note that, even if you say N here, Linux on the x86 architecture
will issue the hlt instruction if nothing is to be done, thereby
sending the processor to sleep and saving power.
config ACPI
bool
depends on !IA64_HP_SIM
default y
if !IA64_HP_SIM
source "kernel/power/Kconfig"
source "drivers/acpi/Kconfig"
endif
if PM
source "arch/ia64/kernel/cpufreq/Kconfig"

View File

@ -107,18 +107,12 @@ CONFIG_ACPI=y
#
# ACPI (Advanced Configuration and Power Interface) Support
#
CONFIG_ACPI_BOOT=y
CONFIG_ACPI_INTERPRETER=y
CONFIG_ACPI_BUTTON=m
CONFIG_ACPI_VIDEO=m
CONFIG_ACPI_FAN=m
CONFIG_ACPI_PROCESSOR=m
CONFIG_ACPI_THERMAL=m
CONFIG_ACPI_BLACKLIST_YEAR=0
# CONFIG_ACPI_DEBUG is not set
CONFIG_ACPI_BUS=y
CONFIG_ACPI_POWER=y
CONFIG_ACPI_PCI=y
CONFIG_ACPI_SYSTEM=y
#

View File

@ -130,19 +130,12 @@ CONFIG_ACPI=y
#
# ACPI (Advanced Configuration and Power Interface) Support
#
CONFIG_ACPI_BOOT=y
CONFIG_ACPI_INTERPRETER=y
# CONFIG_ACPI_BUTTON is not set
CONFIG_ACPI_VIDEO=m
CONFIG_ACPI_HOTKEY=m
# CONFIG_ACPI_FAN is not set
# CONFIG_ACPI_PROCESSOR is not set
CONFIG_ACPI_NUMA=y
CONFIG_ACPI_BLACKLIST_YEAR=0
# CONFIG_ACPI_DEBUG is not set
CONFIG_ACPI_BUS=y
CONFIG_ACPI_POWER=y
CONFIG_ACPI_PCI=y
CONFIG_ACPI_SYSTEM=y
# CONFIG_ACPI_CONTAINER is not set

View File

@ -128,20 +128,13 @@ CONFIG_ACPI=y
#
# ACPI (Advanced Configuration and Power Interface) Support
#
CONFIG_ACPI_BOOT=y
CONFIG_ACPI_INTERPRETER=y
CONFIG_ACPI_BUTTON=m
# CONFIG_ACPI_VIDEO is not set
# CONFIG_ACPI_HOTKEY is not set
CONFIG_ACPI_FAN=m
CONFIG_ACPI_PROCESSOR=m
# CONFIG_ACPI_HOTPLUG_CPU is not set
CONFIG_ACPI_THERMAL=m
CONFIG_ACPI_BLACKLIST_YEAR=0
# CONFIG_ACPI_DEBUG is not set
CONFIG_ACPI_BUS=y
CONFIG_ACPI_POWER=y
CONFIG_ACPI_PCI=y
CONFIG_ACPI_SYSTEM=y
# CONFIG_ACPI_CONTAINER is not set

View File

@ -128,19 +128,12 @@ CONFIG_ACPI=y
#
# ACPI (Advanced Configuration and Power Interface) Support
#
CONFIG_ACPI_BOOT=y
CONFIG_ACPI_INTERPRETER=y
CONFIG_ACPI_BUTTON=y
CONFIG_ACPI_VIDEO=m
CONFIG_ACPI_HOTKEY=m
CONFIG_ACPI_FAN=y
CONFIG_ACPI_PROCESSOR=y
CONFIG_ACPI_THERMAL=y
CONFIG_ACPI_BLACKLIST_YEAR=0
# CONFIG_ACPI_DEBUG is not set
CONFIG_ACPI_BUS=y
CONFIG_ACPI_POWER=y
CONFIG_ACPI_PCI=y
CONFIG_ACPI_SYSTEM=y
# CONFIG_ACPI_CONTAINER is not set

View File

@ -118,20 +118,14 @@ CONFIG_ACPI=y
#
# ACPI (Advanced Configuration and Power Interface) Support
#
CONFIG_ACPI_BOOT=y
CONFIG_ACPI_INTERPRETER=y
CONFIG_ACPI_BUTTON=m
CONFIG_ACPI_VIDEO=m
CONFIG_ACPI_FAN=m
CONFIG_ACPI_PROCESSOR=m
CONFIG_ACPI_HOTPLUG_CPU=y
CONFIG_ACPI_THERMAL=m
CONFIG_ACPI_NUMA=y
CONFIG_ACPI_BLACKLIST_YEAR=0
# CONFIG_ACPI_DEBUG is not set
CONFIG_ACPI_BUS=y
CONFIG_ACPI_POWER=y
CONFIG_ACPI_PCI=y
CONFIG_ACPI_SYSTEM=y
CONFIG_ACPI_CONTAINER=m

View File

@ -17,20 +17,20 @@
#include <asm/acpi-ext.h>
struct acpi_vendor_descriptor {
u8 guid_id;
efi_guid_t guid;
u8 guid_id;
efi_guid_t guid;
};
struct acpi_vendor_info {
struct acpi_vendor_descriptor *descriptor;
u8 *data;
u32 length;
struct acpi_vendor_descriptor *descriptor;
u8 *data;
u32 length;
};
acpi_status
acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
{
struct acpi_vendor_info *info = (struct acpi_vendor_info *) context;
struct acpi_vendor_info *info = (struct acpi_vendor_info *)context;
struct acpi_resource_vendor *vendor;
struct acpi_vendor_descriptor *descriptor;
u32 length;
@ -38,8 +38,8 @@ acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
if (resource->id != ACPI_RSTYPE_VENDOR)
return AE_OK;
vendor = (struct acpi_resource_vendor *) &resource->data;
descriptor = (struct acpi_vendor_descriptor *) vendor->reserved;
vendor = (struct acpi_resource_vendor *)&resource->data;
descriptor = (struct acpi_vendor_descriptor *)vendor->reserved;
if (vendor->length <= sizeof(*info->descriptor) ||
descriptor->guid_id != info->descriptor->guid_id ||
efi_guidcmp(descriptor->guid, info->descriptor->guid))
@ -50,21 +50,24 @@ acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
if (!info->data)
return AE_NO_MEMORY;
memcpy(info->data, vendor->reserved + sizeof(struct acpi_vendor_descriptor), length);
memcpy(info->data,
vendor->reserved + sizeof(struct acpi_vendor_descriptor),
length);
info->length = length;
return AE_CTRL_TERMINATE;
}
acpi_status
acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor *id,
u8 **data, u32 *length)
acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
u8 ** data, u32 * length)
{
struct acpi_vendor_info info;
info.descriptor = id;
info.data = NULL;
acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match, &info);
acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match,
&info);
if (!info.data)
return AE_NOT_FOUND;
@ -75,17 +78,19 @@ acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor *id,
struct acpi_vendor_descriptor hp_ccsr_descriptor = {
.guid_id = 2,
.guid = EFI_GUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2, 0x01, 0x37, 0x0e, 0xad)
.guid =
EFI_GUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2, 0x01,
0x37, 0x0e, 0xad)
};
acpi_status
hp_acpi_csr_space(acpi_handle obj, u64 *csr_base, u64 *csr_length)
acpi_status hp_acpi_csr_space(acpi_handle obj, u64 * csr_base, u64 * csr_length)
{
acpi_status status;
u8 *data;
u32 length;
status = acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length);
status =
acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length);
if (ACPI_FAILURE(status) || length != 16)
return AE_NOT_FOUND;

View File

@ -74,12 +74,11 @@ unsigned int acpi_cpei_override;
unsigned int acpi_cpei_phys_cpuid;
#define MAX_SAPICS 256
u16 ia64_acpiid_to_sapicid[MAX_SAPICS] =
{ [0 ... MAX_SAPICS - 1] = -1 };
u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = {[0 ... MAX_SAPICS - 1] = -1 };
EXPORT_SYMBOL(ia64_acpiid_to_sapicid);
const char *
acpi_get_sysname (void)
const char *acpi_get_sysname(void)
{
#ifdef CONFIG_IA64_GENERIC
unsigned long rsdp_phys;
@ -89,27 +88,29 @@ acpi_get_sysname (void)
rsdp_phys = acpi_find_rsdp();
if (!rsdp_phys) {
printk(KERN_ERR "ACPI 2.0 RSDP not found, default to \"dig\"\n");
printk(KERN_ERR
"ACPI 2.0 RSDP not found, default to \"dig\"\n");
return "dig";
}
rsdp = (struct acpi20_table_rsdp *) __va(rsdp_phys);
rsdp = (struct acpi20_table_rsdp *)__va(rsdp_phys);
if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) {
printk(KERN_ERR "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n");
printk(KERN_ERR
"ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n");
return "dig";
}
xsdt = (struct acpi_table_xsdt *) __va(rsdp->xsdt_address);
xsdt = (struct acpi_table_xsdt *)__va(rsdp->xsdt_address);
hdr = &xsdt->header;
if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) {
printk(KERN_ERR "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n");
printk(KERN_ERR
"ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n");
return "dig";
}
if (!strcmp(hdr->oem_id, "HP")) {
return "hpzx1";
}
else if (!strcmp(hdr->oem_id, "SGI")) {
} else if (!strcmp(hdr->oem_id, "SGI")) {
return "sn2";
}
@ -131,7 +132,7 @@ acpi_get_sysname (void)
#endif
}
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
#define ACPI_MAX_PLATFORM_INTERRUPTS 256
@ -146,8 +147,7 @@ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC;
* Interrupt routing API for device drivers. Provides interrupt vector for
* a generic platform event. Currently only CPEI is implemented.
*/
int
acpi_request_vector (u32 int_type)
int acpi_request_vector(u32 int_type)
{
int vector = -1;
@ -155,12 +155,12 @@ acpi_request_vector (u32 int_type)
/* corrected platform error interrupt */
vector = platform_intr_list[int_type];
} else
printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n");
printk(KERN_ERR
"acpi_request_vector(): invalid interrupt type\n");
return vector;
}
char *
__acpi_map_table (unsigned long phys_addr, unsigned long size)
char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
{
return __va(phys_addr);
}
@ -169,19 +169,18 @@ __acpi_map_table (unsigned long phys_addr, unsigned long size)
Boot-time Table Parsing
-------------------------------------------------------------------------- */
static int total_cpus __initdata;
static int available_cpus __initdata;
struct acpi_table_madt * acpi_madt __initdata;
static u8 has_8259;
static int total_cpus __initdata;
static int available_cpus __initdata;
struct acpi_table_madt *acpi_madt __initdata;
static u8 has_8259;
static int __init
acpi_parse_lapic_addr_ovr (
acpi_table_entry_header *header, const unsigned long end)
acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
const unsigned long end)
{
struct acpi_table_lapic_addr_ovr *lapic;
lapic = (struct acpi_table_lapic_addr_ovr *) header;
lapic = (struct acpi_table_lapic_addr_ovr *)header;
if (BAD_MADT_ENTRY(lapic, end))
return -EINVAL;
@ -193,22 +192,23 @@ acpi_parse_lapic_addr_ovr (
return 0;
}
static int __init
acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end)
acpi_parse_lsapic(acpi_table_entry_header * header, const unsigned long end)
{
struct acpi_table_lsapic *lsapic;
lsapic = (struct acpi_table_lsapic *) header;
lsapic = (struct acpi_table_lsapic *)header;
if (BAD_MADT_ENTRY(lsapic, end))
return -EINVAL;
if (lsapic->flags.enabled) {
#ifdef CONFIG_SMP
smp_boot_data.cpu_phys_id[available_cpus] = (lsapic->id << 8) | lsapic->eid;
smp_boot_data.cpu_phys_id[available_cpus] =
(lsapic->id << 8) | lsapic->eid;
#endif
ia64_acpiid_to_sapicid[lsapic->acpi_id] = (lsapic->id << 8) | lsapic->eid;
ia64_acpiid_to_sapicid[lsapic->acpi_id] =
(lsapic->id << 8) | lsapic->eid;
++available_cpus;
}
@ -216,13 +216,12 @@ acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end)
return 0;
}
static int __init
acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end)
acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
{
struct acpi_table_lapic_nmi *lacpi_nmi;
lacpi_nmi = (struct acpi_table_lapic_nmi*) header;
lacpi_nmi = (struct acpi_table_lapic_nmi *)header;
if (BAD_MADT_ENTRY(lacpi_nmi, end))
return -EINVAL;
@ -231,13 +230,12 @@ acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end)
return 0;
}
static int __init
acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end)
acpi_parse_iosapic(acpi_table_entry_header * header, const unsigned long end)
{
struct acpi_table_iosapic *iosapic;
iosapic = (struct acpi_table_iosapic *) header;
iosapic = (struct acpi_table_iosapic *)header;
if (BAD_MADT_ENTRY(iosapic, end))
return -EINVAL;
@ -245,15 +243,14 @@ acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end)
return iosapic_init(iosapic->address, iosapic->global_irq_base);
}
static int __init
acpi_parse_plat_int_src (
acpi_table_entry_header *header, const unsigned long end)
acpi_parse_plat_int_src(acpi_table_entry_header * header,
const unsigned long end)
{
struct acpi_table_plat_int_src *plintsrc;
int vector;
plintsrc = (struct acpi_table_plat_int_src *) header;
plintsrc = (struct acpi_table_plat_int_src *)header;
if (BAD_MADT_ENTRY(plintsrc, end))
return -EINVAL;
@ -267,8 +264,12 @@ acpi_parse_plat_int_src (
plintsrc->iosapic_vector,
plintsrc->eid,
plintsrc->id,
(plintsrc->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
(plintsrc->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
(plintsrc->flags.polarity ==
1) ? IOSAPIC_POL_HIGH :
IOSAPIC_POL_LOW,
(plintsrc->flags.trigger ==
1) ? IOSAPIC_EDGE :
IOSAPIC_LEVEL);
platform_intr_list[plintsrc->type] = vector;
if (acpi_madt_rev > 1) {
@ -283,7 +284,6 @@ acpi_parse_plat_int_src (
return 0;
}
unsigned int can_cpei_retarget(void)
{
extern int cpe_vector;
@ -322,29 +322,30 @@ unsigned int get_cpei_target_cpu(void)
}
static int __init
acpi_parse_int_src_ovr (
acpi_table_entry_header *header, const unsigned long end)
acpi_parse_int_src_ovr(acpi_table_entry_header * header,
const unsigned long end)
{
struct acpi_table_int_src_ovr *p;
p = (struct acpi_table_int_src_ovr *) header;
p = (struct acpi_table_int_src_ovr *)header;
if (BAD_MADT_ENTRY(p, end))
return -EINVAL;
iosapic_override_isa_irq(p->bus_irq, p->global_irq,
(p->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
(p->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
(p->flags.polarity ==
1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
(p->flags.trigger ==
1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
return 0;
}
static int __init
acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end)
acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
{
struct acpi_table_nmi_src *nmi_src;
nmi_src = (struct acpi_table_nmi_src*) header;
nmi_src = (struct acpi_table_nmi_src *)header;
if (BAD_MADT_ENTRY(nmi_src, end))
return -EINVAL;
@ -353,11 +354,9 @@ acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end)
return 0;
}
static void __init
acpi_madt_oem_check (char *oem_id, char *oem_table_id)
static void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
{
if (!strncmp(oem_id, "IBM", 3) &&
(!strncmp(oem_table_id, "SERMOW", 6))) {
if (!strncmp(oem_id, "IBM", 3) && (!strncmp(oem_table_id, "SERMOW", 6))) {
/*
* Unfortunately ITC_DRIFT is not yet part of the
@ -370,19 +369,18 @@ acpi_madt_oem_check (char *oem_id, char *oem_table_id)
}
}
static int __init
acpi_parse_madt (unsigned long phys_addr, unsigned long size)
static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
{
if (!phys_addr || !size)
return -EINVAL;
acpi_madt = (struct acpi_table_madt *) __va(phys_addr);
acpi_madt = (struct acpi_table_madt *)__va(phys_addr);
acpi_madt_rev = acpi_madt->header.revision;
/* remember the value for reference after free_initmem() */
#ifdef CONFIG_ITANIUM
has_8259 = 1; /* Firmware on old Itanium systems is broken */
has_8259 = 1; /* Firmware on old Itanium systems is broken */
#else
has_8259 = acpi_madt->flags.pcat_compat;
#endif
@ -396,19 +394,18 @@ acpi_parse_madt (unsigned long phys_addr, unsigned long size)
printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr);
acpi_madt_oem_check(acpi_madt->header.oem_id,
acpi_madt->header.oem_table_id);
acpi_madt->header.oem_table_id);
return 0;
}
#ifdef CONFIG_ACPI_NUMA
#undef SLIT_DEBUG
#define PXM_FLAG_LEN ((MAX_PXM_DOMAINS + 1)/32)
static int __initdata srat_num_cpus; /* number of cpus */
static int __initdata srat_num_cpus; /* number of cpus */
static u32 __devinitdata pxm_flag[PXM_FLAG_LEN];
#define pxm_bit_set(bit) (set_bit(bit,(void *)pxm_flag))
#define pxm_bit_test(bit) (test_bit(bit,(void *)pxm_flag))
@ -421,15 +418,15 @@ static struct acpi_table_slit __initdata *slit_table;
* ACPI 2.0 SLIT (System Locality Information Table)
* http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf
*/
void __init
acpi_numa_slit_init (struct acpi_table_slit *slit)
void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
{
u32 len;
len = sizeof(struct acpi_table_header) + 8
+ slit->localities * slit->localities;
+ slit->localities * slit->localities;
if (slit->header.length != len) {
printk(KERN_ERR "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n",
printk(KERN_ERR
"ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n",
len, slit->header.length);
memset(numa_slit, 10, sizeof(numa_slit));
return;
@ -438,19 +435,20 @@ acpi_numa_slit_init (struct acpi_table_slit *slit)
}
void __init
acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa)
acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
{
/* record this node in proximity bitmap */
pxm_bit_set(pa->proximity_domain);
node_cpuid[srat_num_cpus].phys_id = (pa->apic_id << 8) | (pa->lsapic_eid);
node_cpuid[srat_num_cpus].phys_id =
(pa->apic_id << 8) | (pa->lsapic_eid);
/* nid should be overridden as logical node id later */
node_cpuid[srat_num_cpus].nid = pa->proximity_domain;
srat_num_cpus++;
}
void __init
acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma)
acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
{
unsigned long paddr, size;
u8 pxm;
@ -487,8 +485,7 @@ acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma)
num_node_memblks++;
}
void __init
acpi_numa_arch_fixup (void)
void __init acpi_numa_arch_fixup(void)
{
int i, j, node_from, node_to;
@ -534,21 +531,24 @@ acpi_numa_arch_fixup (void)
for (i = 0; i < srat_num_cpus; i++)
node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid];
printk(KERN_INFO "Number of logical nodes in system = %d\n", num_online_nodes());
printk(KERN_INFO "Number of memory chunks in system = %d\n", num_node_memblks);
printk(KERN_INFO "Number of logical nodes in system = %d\n",
num_online_nodes());
printk(KERN_INFO "Number of memory chunks in system = %d\n",
num_node_memblks);
if (!slit_table) return;
if (!slit_table)
return;
memset(numa_slit, -1, sizeof(numa_slit));
for (i=0; i<slit_table->localities; i++) {
for (i = 0; i < slit_table->localities; i++) {
if (!pxm_bit_test(i))
continue;
node_from = pxm_to_nid_map[i];
for (j=0; j<slit_table->localities; j++) {
for (j = 0; j < slit_table->localities; j++) {
if (!pxm_bit_test(j))
continue;
node_to = pxm_to_nid_map[j];
node_distance(node_from, node_to) =
slit_table->entry[i*slit_table->localities + j];
slit_table->entry[i * slit_table->localities + j];
}
}
@ -556,36 +556,43 @@ acpi_numa_arch_fixup (void)
printk("ACPI 2.0 SLIT locality table:\n");
for_each_online_node(i) {
for_each_online_node(j)
printk("%03d ", node_distance(i,j));
printk("%03d ", node_distance(i, j));
printk("\n");
}
#endif
}
#endif /* CONFIG_ACPI_NUMA */
#endif /* CONFIG_ACPI_NUMA */
unsigned int
acpi_register_gsi (u32 gsi, int edge_level, int active_high_low)
/*
* success: return IRQ number (>=0)
* failure: return < 0
*/
int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
{
if (has_8259 && gsi < 16)
return isa_irq_to_vector(gsi);
return iosapic_register_intr(gsi,
(active_high_low == ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
(edge_level == ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
(active_high_low ==
ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH :
IOSAPIC_POL_LOW,
(edge_level ==
ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE :
IOSAPIC_LEVEL);
}
EXPORT_SYMBOL(acpi_register_gsi);
#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
void
acpi_unregister_gsi (u32 gsi)
void acpi_unregister_gsi(u32 gsi)
{
iosapic_unregister_intr(gsi);
}
EXPORT_SYMBOL(acpi_unregister_gsi);
#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */
static int __init
acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
EXPORT_SYMBOL(acpi_unregister_gsi);
#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */
static int __init acpi_parse_fadt(unsigned long phys_addr, unsigned long size)
{
struct acpi_table_header *fadt_header;
struct fadt_descriptor_rev2 *fadt;
@ -593,11 +600,11 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
if (!phys_addr || !size)
return -EINVAL;
fadt_header = (struct acpi_table_header *) __va(phys_addr);
fadt_header = (struct acpi_table_header *)__va(phys_addr);
if (fadt_header->revision != 3)
return -ENODEV; /* Only deal with ACPI 2.0 FADT */
return -ENODEV; /* Only deal with ACPI 2.0 FADT */
fadt = (struct fadt_descriptor_rev2 *) fadt_header;
fadt = (struct fadt_descriptor_rev2 *)fadt_header;
if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER))
acpi_kbd_controller_present = 0;
@ -609,22 +616,19 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
return 0;
}
unsigned long __init
acpi_find_rsdp (void)
unsigned long __init acpi_find_rsdp(void)
{
unsigned long rsdp_phys = 0;
if (efi.acpi20)
rsdp_phys = __pa(efi.acpi20);
else if (efi.acpi)
printk(KERN_WARNING PREFIX "v1.0/r0.71 tables no longer supported\n");
printk(KERN_WARNING PREFIX
"v1.0/r0.71 tables no longer supported\n");
return rsdp_phys;
}
int __init
acpi_boot_init (void)
int __init acpi_boot_init(void)
{
/*
@ -642,31 +646,43 @@ acpi_boot_init (void)
/* Local APIC */
if (acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0)
printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
if (acpi_table_parse_madt
(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0)
printk(KERN_ERR PREFIX
"Error parsing LAPIC address override entry\n");
if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS) < 1)
printk(KERN_ERR PREFIX "Error parsing MADT - no LAPIC entries\n");
if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS)
< 1)
printk(KERN_ERR PREFIX
"Error parsing MADT - no LAPIC entries\n");
if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0) < 0)
if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0)
< 0)
printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
/* I/O APIC */
if (acpi_table_parse_madt(ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1)
printk(KERN_ERR PREFIX "Error parsing MADT - no IOSAPIC entries\n");
if (acpi_table_parse_madt
(ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1)
printk(KERN_ERR PREFIX
"Error parsing MADT - no IOSAPIC entries\n");
/* System-Level Interrupt Routing */
if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src, ACPI_MAX_PLATFORM_INTERRUPTS) < 0)
printk(KERN_ERR PREFIX "Error parsing platform interrupt source entry\n");
if (acpi_table_parse_madt
(ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src,
ACPI_MAX_PLATFORM_INTERRUPTS) < 0)
printk(KERN_ERR PREFIX
"Error parsing platform interrupt source entry\n");
if (acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0)
printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n");
if (acpi_table_parse_madt
(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0)
printk(KERN_ERR PREFIX
"Error parsing interrupt source overrides entry\n");
if (acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, 0) < 0)
printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
skip_madt:
skip_madt:
/*
* FADT says whether a legacy keyboard controller is present.
@ -681,8 +697,9 @@ acpi_boot_init (void)
if (available_cpus == 0) {
printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n");
printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id());
smp_boot_data.cpu_phys_id[available_cpus] = hard_smp_processor_id();
available_cpus = 1; /* We've got at least one of these, no? */
smp_boot_data.cpu_phys_id[available_cpus] =
hard_smp_processor_id();
available_cpus = 1; /* We've got at least one of these, no? */
}
smp_boot_data.cpu_count = available_cpus;
@ -691,8 +708,10 @@ acpi_boot_init (void)
if (srat_num_cpus == 0) {
int cpu, i = 1;
for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++)
if (smp_boot_data.cpu_phys_id[cpu] != hard_smp_processor_id())
node_cpuid[i++].phys_id = smp_boot_data.cpu_phys_id[cpu];
if (smp_boot_data.cpu_phys_id[cpu] !=
hard_smp_processor_id())
node_cpuid[i++].phys_id =
smp_boot_data.cpu_phys_id[cpu];
}
# endif
#endif
@ -700,12 +719,12 @@ acpi_boot_init (void)
build_cpu_to_node_map();
#endif
/* Make boot-up look pretty */
printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus);
printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus,
total_cpus);
return 0;
}
int
acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
{
int vector;
@ -726,11 +745,10 @@ acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
*/
#ifdef CONFIG_ACPI_HOTPLUG_CPU
static
int
acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
int acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
{
#ifdef CONFIG_ACPI_NUMA
int pxm_id;
int pxm_id;
pxm_id = acpi_get_pxm(handle);
@ -738,31 +756,28 @@ acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
* Assuming that the container driver would have set the proximity
* domain and would have initialized pxm_to_nid_map[pxm_id] && pxm_flag
*/
node_cpuid[cpu].nid = (pxm_id < 0) ? 0:
pxm_to_nid_map[pxm_id];
node_cpuid[cpu].nid = (pxm_id < 0) ? 0 : pxm_to_nid_map[pxm_id];
node_cpuid[cpu].phys_id = physid;
node_cpuid[cpu].phys_id = physid;
#endif
return(0);
return (0);
}
int
acpi_map_lsapic(acpi_handle handle, int *pcpu)
int acpi_map_lsapic(acpi_handle handle, int *pcpu)
{
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *obj;
struct acpi_table_lsapic *lsapic;
cpumask_t tmp_map;
long physid;
int cpu;
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
return -EINVAL;
if (!buffer.length || !buffer.pointer)
if (!buffer.length || !buffer.pointer)
return -EINVAL;
obj = buffer.pointer;
if (obj->type != ACPI_TYPE_BUFFER ||
obj->buffer.length < sizeof(*lsapic)) {
@ -778,7 +793,7 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu)
return -EINVAL;
}
physid = ((lsapic->id <<8) | (lsapic->eid));
physid = ((lsapic->id << 8) | (lsapic->eid));
acpi_os_free(buffer.pointer);
buffer.length = ACPI_ALLOCATE_BUFFER;
@ -786,50 +801,49 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu)
cpus_complement(tmp_map, cpu_present_map);
cpu = first_cpu(tmp_map);
if(cpu >= NR_CPUS)
if (cpu >= NR_CPUS)
return -EINVAL;
acpi_map_cpu2node(handle, cpu, physid);
cpu_set(cpu, cpu_present_map);
cpu_set(cpu, cpu_present_map);
ia64_cpu_to_sapicid[cpu] = physid;
ia64_acpiid_to_sapicid[lsapic->acpi_id] = ia64_cpu_to_sapicid[cpu];
*pcpu = cpu;
return(0);
return (0);
}
EXPORT_SYMBOL(acpi_map_lsapic);
int
acpi_unmap_lsapic(int cpu)
int acpi_unmap_lsapic(int cpu)
{
int i;
for (i=0; i<MAX_SAPICS; i++) {
if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) {
ia64_acpiid_to_sapicid[i] = -1;
break;
}
}
for (i = 0; i < MAX_SAPICS; i++) {
if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) {
ia64_acpiid_to_sapicid[i] = -1;
break;
}
}
ia64_cpu_to_sapicid[cpu] = -1;
cpu_clear(cpu,cpu_present_map);
cpu_clear(cpu, cpu_present_map);
#ifdef CONFIG_ACPI_NUMA
/* NUMA specific cleanup's */
#endif
return(0);
return (0);
}
EXPORT_SYMBOL(acpi_unmap_lsapic);
#endif /* CONFIG_ACPI_HOTPLUG_CPU */
#endif /* CONFIG_ACPI_HOTPLUG_CPU */
#ifdef CONFIG_ACPI_NUMA
acpi_status __devinit
acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret)
acpi_map_iosapic(acpi_handle handle, u32 depth, void *context, void **ret)
{
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *obj;
struct acpi_table_iosapic *iosapic;
unsigned int gsi_base;
@ -878,10 +892,9 @@ acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret)
map_iosapic_to_node(gsi_base, node);
return AE_OK;
}
#endif /* CONFIG_NUMA */
#endif /* CONFIG_NUMA */
int
acpi_register_ioapic (acpi_handle handle, u64 phys_addr, u32 gsi_base)
int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
{
int err;
@ -890,17 +903,18 @@ acpi_register_ioapic (acpi_handle handle, u64 phys_addr, u32 gsi_base)
#if CONFIG_ACPI_NUMA
acpi_map_iosapic(handle, 0, NULL, NULL);
#endif /* CONFIG_ACPI_NUMA */
#endif /* CONFIG_ACPI_NUMA */
return 0;
}
EXPORT_SYMBOL(acpi_register_ioapic);
int
acpi_unregister_ioapic (acpi_handle handle, u32 gsi_base)
int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
{
return iosapic_remove(gsi_base);
}
EXPORT_SYMBOL(acpi_unregister_ioapic);
#endif /* CONFIG_ACPI_BOOT */
#endif /* CONFIG_ACPI */

View File

@ -561,7 +561,7 @@ static inline int vector_is_shared (int vector)
return (iosapic_intr_info[vector].count > 1);
}
static void
static int
register_intr (unsigned int gsi, int vector, unsigned char delivery,
unsigned long polarity, unsigned long trigger)
{
@ -576,7 +576,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
index = find_iosapic(gsi);
if (index < 0) {
printk(KERN_WARNING "%s: No IOSAPIC for GSI %u\n", __FUNCTION__, gsi);
return;
return -ENODEV;
}
iosapic_address = iosapic_lists[index].addr;
@ -587,7 +587,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
rte = iosapic_alloc_rte();
if (!rte) {
printk(KERN_WARNING "%s: cannot allocate memory\n", __FUNCTION__);
return;
return -ENOMEM;
}
rte_index = gsi - gsi_base;
@ -603,7 +603,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
struct iosapic_intr_info *info = &iosapic_intr_info[vector];
if (info->trigger != trigger || info->polarity != polarity) {
printk (KERN_WARNING "%s: cannot override the interrupt\n", __FUNCTION__);
return;
return -EINVAL;
}
}
@ -623,6 +623,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
__FUNCTION__, vector, idesc->handler->typename, irq_type->typename);
idesc->handler = irq_type;
}
return 0;
}
static unsigned int
@ -710,7 +711,7 @@ int
iosapic_register_intr (unsigned int gsi,
unsigned long polarity, unsigned long trigger)
{
int vector, mask = 1;
int vector, mask = 1, err;
unsigned int dest;
unsigned long flags;
struct iosapic_rte_info *rte;
@ -737,8 +738,8 @@ again:
vector = assign_irq_vector(AUTO_ASSIGN);
if (vector < 0) {
vector = iosapic_find_sharable_vector(trigger, polarity);
if (vector < 0)
panic("%s: out of interrupt vectors!\n", __FUNCTION__);
if (vector < 0)
return -ENOSPC;
}
spin_lock_irqsave(&irq_descp(vector)->lock, flags);
@ -753,8 +754,13 @@ again:
}
dest = get_target_cpu(gsi, vector);
register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY,
err = register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY,
polarity, trigger);
if (err < 0) {
spin_unlock(&iosapic_lock);
spin_unlock_irqrestore(&irq_descp(vector)->lock, flags);
return err;
}
/*
* If the vector is shared and already unmasked for

View File

@ -384,7 +384,7 @@ setup_arch (char **cmdline_p)
if (early_console_setup(*cmdline_p) == 0)
mark_bsp_online();
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
/* Initialize the ACPI boot-time table parser */
acpi_table_init();
# ifdef CONFIG_ACPI_NUMA
@ -420,7 +420,7 @@ setup_arch (char **cmdline_p)
cpu_init(); /* initialize the bootstrap CPU */
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
acpi_boot_init();
#endif

View File

@ -36,7 +36,7 @@ int arch_register_cpu(int num)
parent = &sysfs_nodes[cpu_to_node(num)];
#endif /* CONFIG_NUMA */
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
/*
* If CPEI cannot be re-targetted, and this is
* CPEI target, then dont create the control file

View File

@ -23,7 +23,7 @@ static void force_interrupt(int irq);
static void register_intr_pda(struct sn_irq_info *sn_irq_info);
static void unregister_intr_pda(struct sn_irq_info *sn_irq_info);
extern int sn_force_interrupt_flag;
int sn_force_interrupt_flag = 1;
extern int sn_ioif_inited;
static struct list_head **sn_irq_lh;
static spinlock_t sn_irq_info_lock = SPIN_LOCK_UNLOCKED; /* non-IRQ lock */

View File

@ -52,7 +52,7 @@ static int licenseID_open(struct inode *inode, struct file *file)
* the bridge chip. The hardware will then send an interrupt message if the
* interrupt line is active. This mimics a level sensitive interrupt.
*/
int sn_force_interrupt_flag = 1;
extern int sn_force_interrupt_flag;
static int sn_force_interrupt_show(struct seq_file *s, void *p)
{

View File

@ -152,7 +152,6 @@ config X86_CPUID
with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to
/dev/cpu/31/cpuid.
# disable it for opteron optimized builds because it pulls in ACPI_BOOT
config X86_HT
bool
depends on SMP && !MK8
@ -474,7 +473,6 @@ config PCI_DIRECT
config PCI_MMCONFIG
bool "Support mmconfig PCI config space access"
depends on PCI && ACPI
select ACPI_BOOT
config UNORDERED_IO
bool "Unordered IO mapping access"

View File

@ -135,8 +135,6 @@ CONFIG_PM_STD_PARTITION=""
# ACPI (Advanced Configuration and Power Interface) Support
#
CONFIG_ACPI=y
CONFIG_ACPI_BOOT=y
CONFIG_ACPI_INTERPRETER=y
CONFIG_ACPI_AC=y
CONFIG_ACPI_BATTERY=y
CONFIG_ACPI_BUTTON=y
@ -151,10 +149,8 @@ CONFIG_ACPI_NUMA=y
CONFIG_ACPI_TOSHIBA=y
CONFIG_ACPI_BLACKLIST_YEAR=2001
# CONFIG_ACPI_DEBUG is not set
CONFIG_ACPI_BUS=y
CONFIG_ACPI_EC=y
CONFIG_ACPI_POWER=y
CONFIG_ACPI_PCI=y
CONFIG_ACPI_SYSTEM=y
# CONFIG_ACPI_CONTAINER is not set

View File

@ -12,7 +12,7 @@ obj-y := process.o signal.o entry.o traps.o irq.o \
obj-$(CONFIG_X86_MCE) += mce.o
obj-$(CONFIG_X86_MCE_INTEL) += mce_intel.o
obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/
obj-$(CONFIG_ACPI_BOOT) += acpi/
obj-$(CONFIG_ACPI) += acpi/
obj-$(CONFIG_X86_MSR) += msr.o
obj-$(CONFIG_MICROCODE) += microcode.o
obj-$(CONFIG_X86_CPUID) += cpuid.o

View File

@ -1,3 +1,3 @@
obj-$(CONFIG_ACPI_BOOT) := boot.o
boot-$(CONFIG_ACPI_BOOT) := ../../../i386/kernel/acpi/boot.o
obj-y := boot.o
boot-y := ../../../i386/kernel/acpi/boot.o
obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o

View File

@ -47,7 +47,6 @@
#include <asm/proto.h>
#include <asm/tlbflush.h>
/* --------------------------------------------------------------------------
Low-Level Sleep Support
-------------------------------------------------------------------------- */
@ -77,11 +76,12 @@ static void init_low_mapping(void)
* Create an identity mapped page table and copy the wakeup routine to
* low memory.
*/
int acpi_save_state_mem (void)
int acpi_save_state_mem(void)
{
init_low_mapping();
memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start);
memcpy((void *)acpi_wakeup_address, &wakeup_start,
&wakeup_end - &wakeup_start);
acpi_copy_wakeup_routine(acpi_wakeup_address);
return 0;
@ -90,7 +90,7 @@ int acpi_save_state_mem (void)
/*
* acpi_restore_state
*/
void acpi_restore_state_mem (void)
void acpi_restore_state_mem(void)
{
set_pgd(pgd_offset(current->mm, 0UL), low_ptr);
flush_tlb_all();
@ -108,7 +108,8 @@ void __init acpi_reserve_bootmem(void)
{
acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE);
if ((&wakeup_end - &wakeup_start) > PAGE_SIZE)
printk(KERN_CRIT "ACPI: Wakeup code way too big, will crash on attempt to suspend\n");
printk(KERN_CRIT
"ACPI: Wakeup code way too big, will crash on attempt to suspend\n");
}
static int __init acpi_sleep_setup(char *str)
@ -127,6 +128,8 @@ static int __init acpi_sleep_setup(char *str)
__setup("acpi_sleep=", acpi_sleep_setup);
#endif /*CONFIG_ACPI_SLEEP*/
#endif /*CONFIG_ACPI_SLEEP */
void acpi_pci_link_exit(void) {}
void acpi_pci_link_exit(void)
{
}

View File

@ -20,7 +20,7 @@
#include <asm/smp.h>
#include <asm/ipi.h>
#if defined(CONFIG_ACPI_BUS)
#if defined(CONFIG_ACPI)
#include <acpi/acpi_bus.h>
#endif
@ -47,7 +47,7 @@ void __init clustered_apic_check(void)
u8 cluster_cnt[NUM_APIC_CLUSTERS];
int num_cpus = 0;
#if defined(CONFIG_ACPI_BUS)
#if defined(CONFIG_ACPI)
/*
* Some x86_64 machines use physical APIC mode regardless of how many
* procs/clusters are present (x86_64 ES7000 is an example).

View File

@ -1864,7 +1864,7 @@ device_initcall(ioapic_init_sysfs);
ACPI-based IOAPIC Configuration
-------------------------------------------------------------------------- */
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
#define IO_APIC_MAX_ID 0xFE
@ -1947,7 +1947,7 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
return 0;
}
#endif /*CONFIG_ACPI_BOOT*/
#endif /* CONFIG_ACPI */
/*

View File

@ -74,7 +74,7 @@ static unsigned int num_processors = 0;
physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
/* ACPI MADT entry parsing functions */
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
extern struct acpi_boot_flags acpi_boot;
#ifdef CONFIG_X86_LOCAL_APIC
extern int acpi_parse_lapic (acpi_table_entry_header *header);
@ -84,7 +84,7 @@ extern int acpi_parse_lapic_nmi (acpi_table_entry_header *header);
#ifdef CONFIG_X86_IO_APIC
extern int acpi_parse_ioapic (acpi_table_entry_header *header);
#endif /*CONFIG_X86_IO_APIC*/
#endif /*CONFIG_ACPI_BOOT*/
#endif /*CONFIG_ACPI*/
u8 bios_cpu_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
@ -519,8 +519,6 @@ void __init get_smp_config (void)
struct intel_mp_floating *mpf = mpf_found;
/*
* ACPI may be used to obtain the entire SMP configuration or just to
* enumerate/configure processors (CONFIG_ACPI_BOOT). Note that
* ACPI supports both logical (e.g. Hyper-Threading) and physical
* processors, where MPS only supports physical.
*/
@ -673,7 +671,7 @@ void __init find_smp_config (void)
ACPI-based MP Configuration
-------------------------------------------------------------------------- */
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
void __init mp_register_lapic_address (
u64 address)
@ -929,11 +927,9 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
return gsi;
#ifdef CONFIG_ACPI_BUS
/* Don't set up the ACPI SCI because it's already set up */
if (acpi_fadt.sci_int == gsi)
return gsi;
#endif
ioapic = mp_find_ioapic(gsi);
if (ioapic < 0) {
@ -973,13 +969,11 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
if (gsi < MAX_GSI_NUM) {
if (gsi > 15)
gsi = pci_irq++;
#ifdef CONFIG_ACPI_BUS
/*
* Don't assign IRQ used by ACPI SCI
*/
if (gsi == acpi_fadt.sci_int)
gsi = pci_irq++;
#endif
gsi_to_irq[irq] = gsi;
} else {
printk(KERN_ERR "GSI %u is too high\n", gsi);
@ -994,4 +988,4 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
}
#endif /*CONFIG_X86_IO_APIC*/
#endif /*CONFIG_ACPI_BOOT*/
#endif /*CONFIG_ACPI*/

View File

@ -71,7 +71,7 @@ unsigned long mmu_cr4_features;
int acpi_disabled;
EXPORT_SYMBOL(acpi_disabled);
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
extern int __initdata acpi_ht;
extern acpi_interrupt_flags acpi_sci_flags;
int __initdata acpi_force = 0;
@ -294,7 +294,7 @@ static __init void parse_cmdline_early (char ** cmdline_p)
maxcpus = simple_strtoul(from + 8, NULL, 0);
}
#endif
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
/* "acpi=off" disables both ACPI table parsing and interpreter init */
if (!memcmp(from, "acpi=off", 8))
disable_acpi();
@ -566,7 +566,7 @@ void __init setup_arch(char **cmdline_p)
init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
/*
* Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
* Call this early for SRAT node setup.
@ -658,7 +658,7 @@ void __init setup_arch(char **cmdline_p)
check_ioapic();
#ifdef CONFIG_ACPI_BOOT
#ifdef CONFIG_ACPI
/*
* Read APIC and some other early information from ACPI tables.
*/

View File

@ -8,7 +8,7 @@ CFLAGS += -Iarch/i386/pci
obj-y := i386.o
obj-$(CONFIG_PCI_DIRECT)+= direct.o
obj-y += fixup.o
obj-$(CONFIG_ACPI_PCI) += acpi.o
obj-$(CONFIG_ACPI) += acpi.o
obj-y += legacy.o irq.o common.o
# mmconfig has a 64bit special
obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o

View File

@ -8,7 +8,7 @@ CFLAGS += -I arch/i386/pci
obj-y := i386.o
obj-$(CONFIG_PCI_DIRECT)+= direct.o
obj-y += fixup.o
obj-$(CONFIG_ACPI_PCI) += acpi.o
obj-$(CONFIG_ACPI) += acpi.o
obj-y += legacy.o irq.o common.o
# mmconfig has a 64bit special
obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o

View File

@ -8,7 +8,7 @@
obj-$(CONFIG_PCI) += pci/
obj-$(CONFIG_PARISC) += parisc/
obj-y += video/
obj-$(CONFIG_ACPI_BOOT) += acpi/
obj-$(CONFIG_ACPI) += acpi/
# PnP must come after ACPI since it will eventually need to check if acpi
# was used and do nothing if so
obj-$(CONFIG_PNP) += pnp/

View File

@ -3,7 +3,6 @@
#
menu "ACPI (Advanced Configuration and Power Interface) Support"
depends on PM
depends on !X86_VISWS
depends on !IA64_HP_SIM
depends on IA64 || X86
@ -11,6 +10,8 @@ menu "ACPI (Advanced Configuration and Power Interface) Support"
config ACPI
bool "ACPI Support"
depends on IA64 || X86
select PM
select PCI
default y
---help---
@ -43,20 +44,10 @@ config ACPI
if ACPI
config ACPI_BOOT
bool
default y
config ACPI_INTERPRETER
bool
default y
if ACPI_INTERPRETER
config ACPI_SLEEP
bool "Sleep States (EXPERIMENTAL)"
bool "Sleep States"
depends on X86 && (!SMP || SUSPEND_SMP)
depends on EXPERIMENTAL && PM
depends on PM
default y
---help---
This option adds support for ACPI suspend states.
@ -90,16 +81,16 @@ config ACPI_SLEEP_PROC_SLEEP
config ACPI_AC
tristate "AC Adapter"
depends on X86
default m
default y
help
This driver adds support for the AC Adapter object, which indicates
whether a system is on AC, or not. Typically, only mobile systems
have this object, since desktops are always on AC.
whether a system is on AC, or not. If you have a system that can
switch between A/C and battery, say Y.
config ACPI_BATTERY
tristate "Battery"
depends on X86
default m
default y
help
This driver adds support for battery information through
/proc/acpi/battery. If you have a mobile system with a battery,
@ -107,18 +98,17 @@ config ACPI_BATTERY
config ACPI_BUTTON
tristate "Button"
default m
default y
help
This driver registers for events based on buttons, such as the
power, sleep, and lid switch. In the future, a daemon will read
/proc/acpi/event and perform user-defined actions such as shutting
down the system. Until then, you can cat it, and see output when
a button is pressed.
This driver handles events on the power, sleep and lid buttons.
A daemon reads /proc/acpi/event and perform user-defined actions
such as shutting down the system. This is necessary for
software controlled poweroff.
config ACPI_VIDEO
tristate "Video"
depends on EXPERIMENTAL
default m
depends on X86
default y
help
This driver implement the ACPI Extensions For Display Adapters
for integrated graphics devices on motherboard, as specified in
@ -129,10 +119,9 @@ config ACPI_VIDEO
for your integrated video device.
config ACPI_HOTKEY
tristate "Generic Hotkey"
depends on ACPI_INTERPRETER
tristate "Generic Hotkey (EXPERIMENTAL)"
depends on EXPERIMENTAL
depends on !IA64_SGI_SN
depends on X86
default n
help
Experimental consolidated hotkey driver.
@ -140,31 +129,30 @@ config ACPI_HOTKEY
config ACPI_FAN
tristate "Fan"
default m
default y
help
This driver adds support for ACPI fan devices, allowing user-mode
applications to perform basic fan control (on, off, status).
config ACPI_PROCESSOR
tristate "Processor"
default m
default y
help
This driver installs ACPI as the idle handler for Linux, and uses
ACPI C2 and C3 processor states to save power, on systems that
support it.
support it. It is required by several flavors of cpufreq
Performance-state drivers.
config ACPI_HOTPLUG_CPU
bool "Processor Hotplug (EXPERIMENTAL)"
depends on ACPI_PROCESSOR && HOTPLUG_CPU && EXPERIMENTAL
bool
depends on ACPI_PROCESSOR && HOTPLUG_CPU
select ACPI_CONTAINER
default n
---help---
Select this option if your platform support physical CPU hotplug.
default y
config ACPI_THERMAL
tristate "Thermal Zone"
depends on ACPI_PROCESSOR
default m
default y
help
This driver adds support for ACPI thermal zones. Most mobile and
some desktop systems support ACPI thermal zones. It is HIGHLY
@ -180,7 +168,7 @@ config ACPI_NUMA
config ACPI_ASUS
tristate "ASUS/Medion Laptop Extras"
depends on X86
default m
default y
---help---
This driver provides support for extra features of ACPI-compatible
ASUS laptops. As some of Medion laptops are made by ASUS, it may also
@ -209,7 +197,7 @@ config ACPI_ASUS
config ACPI_IBM
tristate "IBM ThinkPad Laptop Extras"
depends on X86
default m
default y
---help---
This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds
support for Fn-Fx key combinations, Bluetooth control, video
@ -222,7 +210,7 @@ config ACPI_IBM
config ACPI_TOSHIBA
tristate "Toshiba Laptop Extras"
depends on X86
default m
default y
---help---
This driver adds support for access to certain system settings
on "legacy free" Toshiba laptops. These laptops can be recognized by
@ -263,7 +251,7 @@ config ACPI_CUSTOM_DSDT_FILE
config ACPI_BLACKLIST_YEAR
int "Disable ACPI for systems before Jan 1st this year"
depends on ACPI_INTERPRETER
depends on X86
default 0
help
enter a 4-digit year, eg. 2001 to disable ACPI by default
@ -281,10 +269,6 @@ config ACPI_DEBUG
of verbosity. Saying Y enables these statements. This will increase
your kernel size by around 50K.
config ACPI_BUS
bool
default y
config ACPI_EC
bool
depends on X86
@ -298,10 +282,6 @@ config ACPI_POWER
bool
default y
config ACPI_PCI
bool
default PCI
config ACPI_SYSTEM
bool
default y
@ -309,14 +289,11 @@ config ACPI_SYSTEM
This driver will enable your system to shut down using ACPI, and
dump your ACPI DSDT table using /proc/acpi/dsdt.
endif # ACPI_INTERPRETER
config X86_PM_TIMER
bool "Power Management Timer Support"
depends on X86
depends on ACPI_BOOT && EXPERIMENTAL
depends on !X86_64
default n
default y
help
The Power Management Timer is available on all ACPI-capable,
in most cases even if ACPI is unusable or blacklisted.

View File

@ -15,13 +15,13 @@ EXTRA_CFLAGS += $(ACPI_CFLAGS)
#
# ACPI Boot-Time Table Parsing
#
obj-$(CONFIG_ACPI_BOOT) += tables.o
obj-$(CONFIG_ACPI_INTERPRETER) += blacklist.o
obj-y += tables.o
obj-y += blacklist.o
#
# ACPI Core Subsystem (Interpreter)
#
obj-$(CONFIG_ACPI_INTERPRETER) += osl.o utils.o \
obj-y += osl.o utils.o \
dispatcher/ events/ executer/ hardware/ \
namespace/ parser/ resources/ tables/ \
utilities/
@ -35,8 +35,8 @@ ifdef CONFIG_CPU_FREQ
processor-objs += processor_perflib.o
endif
obj-$(CONFIG_ACPI_BUS) += sleep/
obj-$(CONFIG_ACPI_BUS) += bus.o glue.o
obj-y += sleep/
obj-y += bus.o glue.o
obj-$(CONFIG_ACPI_AC) += ac.o
obj-$(CONFIG_ACPI_BATTERY) += battery.o
obj-$(CONFIG_ACPI_BUTTON) += button.o
@ -44,7 +44,7 @@ obj-$(CONFIG_ACPI_EC) += ec.o
obj-$(CONFIG_ACPI_FAN) += fan.o
obj-$(CONFIG_ACPI_VIDEO) += video.o
obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o
obj-$(CONFIG_ACPI_PCI) += pci_root.o pci_link.o pci_irq.o pci_bind.o
obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
obj-$(CONFIG_ACPI_POWER) += power.o
obj-$(CONFIG_ACPI_PROCESSOR) += processor.o
obj-$(CONFIG_ACPI_CONTAINER) += container.o
@ -55,5 +55,5 @@ obj-$(CONFIG_ACPI_NUMA) += numa.o
obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o
obj-$(CONFIG_ACPI_IBM) += ibm_acpi.o
obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o
obj-$(CONFIG_ACPI_BUS) += scan.o motherboard.o
obj-y += scan.o motherboard.o
obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o

View File

@ -32,7 +32,6 @@
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#define ACPI_AC_COMPONENT 0x00020000
#define ACPI_AC_CLASS "ac_adapter"
#define ACPI_AC_HID "ACPI0003"
@ -45,47 +44,45 @@
#define ACPI_AC_STATUS_UNKNOWN 0xFF
#define _COMPONENT ACPI_AC_COMPONENT
ACPI_MODULE_NAME ("acpi_ac")
ACPI_MODULE_NAME("acpi_ac")
MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME);
MODULE_LICENSE("GPL");
static int acpi_ac_add (struct acpi_device *device);
static int acpi_ac_remove (struct acpi_device *device, int type);
static int acpi_ac_add(struct acpi_device *device);
static int acpi_ac_remove(struct acpi_device *device, int type);
static int acpi_ac_open_fs(struct inode *inode, struct file *file);
static struct acpi_driver acpi_ac_driver = {
.name = ACPI_AC_DRIVER_NAME,
.class = ACPI_AC_CLASS,
.ids = ACPI_AC_HID,
.ops = {
.add = acpi_ac_add,
.remove = acpi_ac_remove,
},
.name = ACPI_AC_DRIVER_NAME,
.class = ACPI_AC_CLASS,
.ids = ACPI_AC_HID,
.ops = {
.add = acpi_ac_add,
.remove = acpi_ac_remove,
},
};
struct acpi_ac {
acpi_handle handle;
unsigned long state;
acpi_handle handle;
unsigned long state;
};
static struct file_operations acpi_ac_fops = {
.open = acpi_ac_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.open = acpi_ac_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/* --------------------------------------------------------------------------
AC Adapter Management
-------------------------------------------------------------------------- */
static int
acpi_ac_get_state (
struct acpi_ac *ac)
static int acpi_ac_get_state(struct acpi_ac *ac)
{
acpi_status status = AE_OK;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("acpi_ac_get_state");
@ -95,24 +92,23 @@ acpi_ac_get_state (
status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error reading AC Adapter state\n"));
"Error reading AC Adapter state\n"));
ac->state = ACPI_AC_STATUS_UNKNOWN;
return_VALUE(-ENODEV);
}
return_VALUE(0);
}
/* --------------------------------------------------------------------------
FS Interface (/proc)
-------------------------------------------------------------------------- */
static struct proc_dir_entry *acpi_ac_dir;
static struct proc_dir_entry *acpi_ac_dir;
static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_ac *ac = (struct acpi_ac *) seq->private;
struct acpi_ac *ac = (struct acpi_ac *)seq->private;
ACPI_FUNCTION_TRACE("acpi_ac_seq_show");
@ -139,23 +135,21 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
return_VALUE(0);
}
static int acpi_ac_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_ac_seq_show, PDE(inode)->data);
}
static int
acpi_ac_add_fs (
struct acpi_device *device)
static int acpi_ac_add_fs(struct acpi_device *device)
{
struct proc_dir_entry *entry = NULL;
struct proc_dir_entry *entry = NULL;
ACPI_FUNCTION_TRACE("acpi_ac_add_fs");
if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_ac_dir);
acpi_ac_dir);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
acpi_device_dir(device)->owner = THIS_MODULE;
@ -163,11 +157,11 @@ acpi_ac_add_fs (
/* 'state' [R] */
entry = create_proc_entry(ACPI_AC_FILE_STATE,
S_IRUGO, acpi_device_dir(device));
S_IRUGO, acpi_device_dir(device));
if (!entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_AC_FILE_STATE));
"Unable to create '%s' fs entry\n",
ACPI_AC_FILE_STATE));
else {
entry->proc_fops = &acpi_ac_fops;
entry->data = acpi_driver_data(device);
@ -177,16 +171,12 @@ acpi_ac_add_fs (
return_VALUE(0);
}
static int
acpi_ac_remove_fs (
struct acpi_device *device)
static int acpi_ac_remove_fs(struct acpi_device *device)
{
ACPI_FUNCTION_TRACE("acpi_ac_remove_fs");
if (acpi_device_dir(device)) {
remove_proc_entry(ACPI_AC_FILE_STATE,
acpi_device_dir(device));
remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device));
remove_proc_entry(acpi_device_bid(device), acpi_ac_dir);
acpi_device_dir(device) = NULL;
@ -195,19 +185,14 @@ acpi_ac_remove_fs (
return_VALUE(0);
}
/* --------------------------------------------------------------------------
Driver Model
-------------------------------------------------------------------------- */
static void
acpi_ac_notify (
acpi_handle handle,
u32 event,
void *data)
static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_ac *ac = (struct acpi_ac *) data;
struct acpi_device *device = NULL;
struct acpi_ac *ac = (struct acpi_ac *)data;
struct acpi_device *device = NULL;
ACPI_FUNCTION_TRACE("acpi_ac_notify");
@ -224,21 +209,18 @@ acpi_ac_notify (
break;
default:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Unsupported event [0x%x]\n", event));
"Unsupported event [0x%x]\n", event));
break;
}
return_VOID;
}
static int
acpi_ac_add (
struct acpi_device *device)
static int acpi_ac_add(struct acpi_device *device)
{
int result = 0;
acpi_status status = AE_OK;
struct acpi_ac *ac = NULL;
int result = 0;
acpi_status status = AE_OK;
struct acpi_ac *ac = NULL;
ACPI_FUNCTION_TRACE("acpi_ac_add");
@ -264,19 +246,20 @@ acpi_ac_add (
goto end;
status = acpi_install_notify_handler(ac->handle,
ACPI_DEVICE_NOTIFY, acpi_ac_notify, ac);
ACPI_DEVICE_NOTIFY, acpi_ac_notify,
ac);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error installing notify handler\n"));
"Error installing notify handler\n"));
result = -ENODEV;
goto end;
}
printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
acpi_device_name(device), acpi_device_bid(device),
ac->state?"on-line":"off-line");
printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
acpi_device_name(device), acpi_device_bid(device),
ac->state ? "on-line" : "off-line");
end:
end:
if (result) {
acpi_ac_remove_fs(device);
kfree(ac);
@ -285,27 +268,23 @@ end:
return_VALUE(result);
}
static int
acpi_ac_remove (
struct acpi_device *device,
int type)
static int acpi_ac_remove(struct acpi_device *device, int type)
{
acpi_status status = AE_OK;
struct acpi_ac *ac = NULL;
acpi_status status = AE_OK;
struct acpi_ac *ac = NULL;
ACPI_FUNCTION_TRACE("acpi_ac_remove");
if (!device || !acpi_driver_data(device))
return_VALUE(-EINVAL);
ac = (struct acpi_ac *) acpi_driver_data(device);
ac = (struct acpi_ac *)acpi_driver_data(device);
status = acpi_remove_notify_handler(ac->handle,
ACPI_DEVICE_NOTIFY, acpi_ac_notify);
ACPI_DEVICE_NOTIFY, acpi_ac_notify);
if (ACPI_FAILURE(status))
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error removing notify handler\n"));
"Error removing notify handler\n"));
acpi_ac_remove_fs(device);
@ -314,11 +293,9 @@ acpi_ac_remove (
return_VALUE(0);
}
static int __init
acpi_ac_init (void)
static int __init acpi_ac_init(void)
{
int result = 0;
int result = 0;
ACPI_FUNCTION_TRACE("acpi_ac_init");
@ -336,9 +313,7 @@ acpi_ac_init (void)
return_VALUE(0);
}
static void __exit
acpi_ac_exit (void)
static void __exit acpi_ac_exit(void)
{
ACPI_FUNCTION_TRACE("acpi_ac_exit");
@ -349,6 +324,5 @@ acpi_ac_exit (void)
return_VOID;
}
module_init(acpi_ac_init);
module_exit(acpi_ac_exit);

View File

@ -32,7 +32,6 @@
#include <linux/memory_hotplug.h>
#include <acpi/acpi_drivers.h>
#define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000UL
#define ACPI_MEMORY_DEVICE_CLASS "memory"
#define ACPI_MEMORY_DEVICE_HID "PNP0C80"
@ -41,8 +40,8 @@
#define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT
ACPI_MODULE_NAME ("acpi_memory")
MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>");
ACPI_MODULE_NAME("acpi_memory")
MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>");
MODULE_DESCRIPTION(ACPI_MEMORY_DEVICE_DRIVER_NAME);
MODULE_LICENSE("GPL");
@ -56,34 +55,33 @@ MODULE_LICENSE("GPL");
#define MEMORY_POWER_ON_STATE 1
#define MEMORY_POWER_OFF_STATE 2
static int acpi_memory_device_add (struct acpi_device *device);
static int acpi_memory_device_remove (struct acpi_device *device, int type);
static int acpi_memory_device_add(struct acpi_device *device);
static int acpi_memory_device_remove(struct acpi_device *device, int type);
static struct acpi_driver acpi_memory_device_driver = {
.name = ACPI_MEMORY_DEVICE_DRIVER_NAME,
.class = ACPI_MEMORY_DEVICE_CLASS,
.ids = ACPI_MEMORY_DEVICE_HID,
.ops = {
.add = acpi_memory_device_add,
.remove = acpi_memory_device_remove,
},
.name = ACPI_MEMORY_DEVICE_DRIVER_NAME,
.class = ACPI_MEMORY_DEVICE_CLASS,
.ids = ACPI_MEMORY_DEVICE_HID,
.ops = {
.add = acpi_memory_device_add,
.remove = acpi_memory_device_remove,
},
};
struct acpi_memory_device {
acpi_handle handle;
unsigned int state; /* State of the memory device */
unsigned int state; /* State of the memory device */
unsigned short cache_attribute; /* memory cache attribute */
unsigned short read_write_attribute;/* memory read/write attribute */
u64 start_addr; /* Memory Range start physical addr */
u64 end_addr; /* Memory Range end physical addr */
unsigned short read_write_attribute; /* memory read/write attribute */
u64 start_addr; /* Memory Range start physical addr */
u64 end_addr; /* Memory Range end physical addr */
};
static int
acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
{
acpi_status status;
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_resource *resource = NULL;
struct acpi_resource_address64 address64;
@ -94,15 +92,15 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
if (ACPI_FAILURE(status))
return_VALUE(-EINVAL);
resource = (struct acpi_resource *) buffer.pointer;
resource = (struct acpi_resource *)buffer.pointer;
status = acpi_resource_to_address64(resource, &address64);
if (ACPI_SUCCESS(status)) {
if (address64.resource_type == ACPI_MEMORY_RANGE) {
/* Populate the structure */
mem_device->cache_attribute =
address64.attribute.memory.cache_attribute;
address64.attribute.memory.cache_attribute;
mem_device->read_write_attribute =
address64.attribute.memory.read_write_attribute;
address64.attribute.memory.read_write_attribute;
mem_device->start_addr = address64.min_address_range;
mem_device->end_addr = address64.max_address_range;
}
@ -114,7 +112,7 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
static int
acpi_memory_get_device(acpi_handle handle,
struct acpi_memory_device **mem_device)
struct acpi_memory_device **mem_device)
{
acpi_status status;
acpi_handle phandle;
@ -128,8 +126,7 @@ acpi_memory_get_device(acpi_handle handle,
status = acpi_get_parent(handle, &phandle);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error in acpi_get_parent\n"));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_get_parent\n"));
return_VALUE(-EINVAL);
}
@ -137,7 +134,7 @@ acpi_memory_get_device(acpi_handle handle,
status = acpi_bus_get_device(phandle, &pdevice);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error in acpi_bus_get_device\n"));
"Error in acpi_bus_get_device\n"));
return_VALUE(-EINVAL);
}
@ -147,23 +144,21 @@ acpi_memory_get_device(acpi_handle handle,
*/
status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error in acpi_bus_add\n"));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_bus_add\n"));
return_VALUE(-EINVAL);
}
end:
end:
*mem_device = acpi_driver_data(device);
if (!(*mem_device)) {
printk(KERN_ERR "\n driver data not found" );
printk(KERN_ERR "\n driver data not found");
return_VALUE(-ENODEV);
}
return_VALUE(0);
}
static int
acpi_memory_check_device(struct acpi_memory_device *mem_device)
static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
{
unsigned long current_status;
@ -171,22 +166,21 @@ acpi_memory_check_device(struct acpi_memory_device *mem_device)
/* Get device present/absent information from the _STA */
if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA",
NULL, &current_status)))
NULL, &current_status)))
return_VALUE(-ENODEV);
/*
* Check for device status. Device should be
* present/enabled/functioning.
*/
if (!((current_status & ACPI_MEMORY_STA_PRESENT)
&& (current_status & ACPI_MEMORY_STA_ENABLED)
&& (current_status & ACPI_MEMORY_STA_FUNCTIONAL)))
&& (current_status & ACPI_MEMORY_STA_ENABLED)
&& (current_status & ACPI_MEMORY_STA_FUNCTIONAL)))
return_VALUE(-ENODEV);
return_VALUE(0);
}
static int
acpi_memory_enable_device(struct acpi_memory_device *mem_device)
static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
{
int result;
@ -196,7 +190,7 @@ acpi_memory_enable_device(struct acpi_memory_device *mem_device)
result = acpi_memory_get_device_resources(mem_device);
if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"\nget_device_resources failed\n"));
"\nget_device_resources failed\n"));
mem_device->state = MEMORY_INVALID_STATE;
return result;
}
@ -206,11 +200,10 @@ acpi_memory_enable_device(struct acpi_memory_device *mem_device)
* Note: Assume that this function returns zero on success
*/
result = add_memory(mem_device->start_addr,
(mem_device->end_addr - mem_device->start_addr) + 1,
mem_device->read_write_attribute);
(mem_device->end_addr - mem_device->start_addr) + 1,
mem_device->read_write_attribute);
if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"\nadd_memory failed\n"));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n"));
mem_device->state = MEMORY_INVALID_STATE;
return result;
}
@ -218,11 +211,10 @@ acpi_memory_enable_device(struct acpi_memory_device *mem_device)
return result;
}
static int
acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
{
acpi_status status;
struct acpi_object_list arg_list;
struct acpi_object_list arg_list;
union acpi_object arg;
unsigned long current_status;
@ -234,16 +226,16 @@ acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
arg.type = ACPI_TYPE_INTEGER;
arg.integer.value = 1;
status = acpi_evaluate_object(mem_device->handle,
"_EJ0", &arg_list, NULL);
"_EJ0", &arg_list, NULL);
/* Return on _EJ0 failure */
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"_EJ0 failed.\n"));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_EJ0 failed.\n"));
return_VALUE(-ENODEV);
}
/* Evalute _STA to check if the device is disabled */
status = acpi_evaluate_integer(mem_device->handle, "_STA",
NULL, &current_status);
NULL, &current_status);
if (ACPI_FAILURE(status))
return_VALUE(-ENODEV);
@ -254,8 +246,7 @@ acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
return_VALUE(0);
}
static int
acpi_memory_disable_device(struct acpi_memory_device *mem_device)
static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
{
int result;
u64 start = mem_device->start_addr;
@ -278,7 +269,7 @@ acpi_memory_disable_device(struct acpi_memory_device *mem_device)
result = acpi_memory_powerdown_device(mem_device);
if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Device Power Down failed.\n"));
"Device Power Down failed.\n"));
/* Set the status of the device to invalid */
mem_device->state = MEMORY_INVALID_STATE;
return result;
@ -288,8 +279,7 @@ acpi_memory_disable_device(struct acpi_memory_device *mem_device)
return result;
}
static void
acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_memory_device *mem_device;
struct acpi_device *device;
@ -299,37 +289,37 @@ acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
switch (event) {
case ACPI_NOTIFY_BUS_CHECK:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"\nReceived BUS CHECK notification for device\n"));
"\nReceived BUS CHECK notification for device\n"));
/* Fall Through */
case ACPI_NOTIFY_DEVICE_CHECK:
if (event == ACPI_NOTIFY_DEVICE_CHECK)
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"\nReceived DEVICE CHECK notification for device\n"));
"\nReceived DEVICE CHECK notification for device\n"));
if (acpi_memory_get_device(handle, &mem_device)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error in finding driver data\n"));
"Error in finding driver data\n"));
return_VOID;
}
if (!acpi_memory_check_device(mem_device)) {
if (acpi_memory_enable_device(mem_device))
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error in acpi_memory_enable_device\n"));
"Error in acpi_memory_enable_device\n"));
}
break;
case ACPI_NOTIFY_EJECT_REQUEST:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"\nReceived EJECT REQUEST notification for device\n"));
"\nReceived EJECT REQUEST notification for device\n"));
if (acpi_bus_get_device(handle, &device)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Device doesn't exist\n"));
"Device doesn't exist\n"));
break;
}
mem_device = acpi_driver_data(device);
if (!mem_device) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Driver Data is NULL\n"));
"Driver Data is NULL\n"));
break;
}
@ -337,26 +327,25 @@ acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
* Currently disabling memory device from kernel mode
* TBD: Can also be disabled from user mode scripts
* TBD: Can also be disabled by Callback registration
* with generic sysfs driver
* with generic sysfs driver
*/
if (acpi_memory_disable_device(mem_device))
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error in acpi_memory_disable_device\n"));
"Error in acpi_memory_disable_device\n"));
/*
* TBD: Invoke acpi_bus_remove to cleanup data structures
*/
break;
default:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Unsupported event [0x%x]\n", event));
"Unsupported event [0x%x]\n", event));
break;
}
return_VOID;
}
static int
acpi_memory_device_add(struct acpi_device *device)
static int acpi_memory_device_add(struct acpi_device *device)
{
int result;
struct acpi_memory_device *mem_device = NULL;
@ -391,8 +380,7 @@ acpi_memory_device_add(struct acpi_device *device)
return_VALUE(result);
}
static int
acpi_memory_device_remove (struct acpi_device *device, int type)
static int acpi_memory_device_remove(struct acpi_device *device, int type)
{
struct acpi_memory_device *mem_device = NULL;
@ -401,7 +389,7 @@ acpi_memory_device_remove (struct acpi_device *device, int type)
if (!device || !acpi_driver_data(device))
return_VALUE(-EINVAL);
mem_device = (struct acpi_memory_device *) acpi_driver_data(device);
mem_device = (struct acpi_memory_device *)acpi_driver_data(device);
kfree(mem_device);
return_VALUE(0);
@ -410,12 +398,11 @@ acpi_memory_device_remove (struct acpi_device *device, int type)
/*
* Helper function to check for memory device
*/
static acpi_status
is_memory_device(acpi_handle handle)
static acpi_status is_memory_device(acpi_handle handle)
{
char *hardware_id;
acpi_status status;
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_device_info *info;
ACPI_FUNCTION_TRACE("is_memory_device");
@ -432,7 +419,7 @@ is_memory_device(acpi_handle handle)
hardware_id = info->hardware_id.value;
if ((hardware_id == NULL) ||
(strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID)))
(strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID)))
status = AE_ERROR;
acpi_os_free(buffer.pointer);
@ -440,8 +427,8 @@ is_memory_device(acpi_handle handle)
}
static acpi_status
acpi_memory_register_notify_handler (acpi_handle handle,
u32 level, void *ctxt, void **retv)
acpi_memory_register_notify_handler(acpi_handle handle,
u32 level, void *ctxt, void **retv)
{
acpi_status status;
@ -452,10 +439,10 @@ acpi_memory_register_notify_handler (acpi_handle handle,
return_ACPI_STATUS(AE_OK); /* continue */
status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
acpi_memory_device_notify, NULL);
acpi_memory_device_notify, NULL);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error installing notify handler\n"));
"Error installing notify handler\n"));
return_ACPI_STATUS(AE_OK); /* continue */
}
@ -463,8 +450,8 @@ acpi_memory_register_notify_handler (acpi_handle handle,
}
static acpi_status
acpi_memory_deregister_notify_handler (acpi_handle handle,
u32 level, void *ctxt, void **retv)
acpi_memory_deregister_notify_handler(acpi_handle handle,
u32 level, void *ctxt, void **retv)
{
acpi_status status;
@ -475,18 +462,18 @@ acpi_memory_deregister_notify_handler (acpi_handle handle,
return_ACPI_STATUS(AE_OK); /* continue */
status = acpi_remove_notify_handler(handle,
ACPI_SYSTEM_NOTIFY, acpi_memory_device_notify);
ACPI_SYSTEM_NOTIFY,
acpi_memory_device_notify);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error removing notify handler\n"));
"Error removing notify handler\n"));
return_ACPI_STATUS(AE_OK); /* continue */
}
return_ACPI_STATUS(status);
}
static int __init
acpi_memory_device_init (void)
static int __init acpi_memory_device_init(void)
{
int result;
acpi_status status;
@ -499,21 +486,20 @@ acpi_memory_device_init (void)
return_VALUE(-ENODEV);
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
acpi_memory_register_notify_handler,
NULL, NULL);
ACPI_UINT32_MAX,
acpi_memory_register_notify_handler,
NULL, NULL);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed\n"));
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n"));
acpi_bus_unregister_driver(&acpi_memory_device_driver);
return_VALUE(-ENODEV);
}
}
return_VALUE(0);
}
static void __exit
acpi_memory_device_exit (void)
static void __exit acpi_memory_device_exit(void)
{
acpi_status status;
@ -524,12 +510,12 @@ acpi_memory_device_exit (void)
* handles.
*/
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
acpi_memory_deregister_notify_handler,
NULL, NULL);
ACPI_UINT32_MAX,
acpi_memory_deregister_notify_handler,
NULL, NULL);
if (ACPI_FAILURE (status))
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed\n"));
if (ACPI_FAILURE(status))
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n"));
acpi_bus_unregister_driver(&acpi_memory_device_driver);
@ -538,5 +524,3 @@ acpi_memory_device_exit (void)
module_init(acpi_memory_device_init);
module_exit(acpi_memory_device_exit);

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,6 @@
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF
#define ACPI_BATTERY_FORMAT_BIF "NNNNNNNNNSSSS"
@ -53,87 +52,85 @@
#define ACPI_BATTERY_UNITS_WATTS "mW"
#define ACPI_BATTERY_UNITS_AMPS "mA"
#define _COMPONENT ACPI_BATTERY_COMPONENT
ACPI_MODULE_NAME ("acpi_battery")
ACPI_MODULE_NAME("acpi_battery")
MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME);
MODULE_LICENSE("GPL");
static int acpi_battery_add (struct acpi_device *device);
static int acpi_battery_remove (struct acpi_device *device, int type);
static int acpi_battery_add(struct acpi_device *device);
static int acpi_battery_remove(struct acpi_device *device, int type);
static struct acpi_driver acpi_battery_driver = {
.name = ACPI_BATTERY_DRIVER_NAME,
.class = ACPI_BATTERY_CLASS,
.ids = ACPI_BATTERY_HID,
.ops = {
.add = acpi_battery_add,
.remove = acpi_battery_remove,
},
.name = ACPI_BATTERY_DRIVER_NAME,
.class = ACPI_BATTERY_CLASS,
.ids = ACPI_BATTERY_HID,
.ops = {
.add = acpi_battery_add,
.remove = acpi_battery_remove,
},
};
struct acpi_battery_status {
acpi_integer state;
acpi_integer present_rate;
acpi_integer remaining_capacity;
acpi_integer present_voltage;
acpi_integer state;
acpi_integer present_rate;
acpi_integer remaining_capacity;
acpi_integer present_voltage;
};
struct acpi_battery_info {
acpi_integer power_unit;
acpi_integer design_capacity;
acpi_integer last_full_capacity;
acpi_integer battery_technology;
acpi_integer design_voltage;
acpi_integer design_capacity_warning;
acpi_integer design_capacity_low;
acpi_integer battery_capacity_granularity_1;
acpi_integer battery_capacity_granularity_2;
acpi_string model_number;
acpi_string serial_number;
acpi_string battery_type;
acpi_string oem_info;
acpi_integer power_unit;
acpi_integer design_capacity;
acpi_integer last_full_capacity;
acpi_integer battery_technology;
acpi_integer design_voltage;
acpi_integer design_capacity_warning;
acpi_integer design_capacity_low;
acpi_integer battery_capacity_granularity_1;
acpi_integer battery_capacity_granularity_2;
acpi_string model_number;
acpi_string serial_number;
acpi_string battery_type;
acpi_string oem_info;
};
struct acpi_battery_flags {
u8 present:1; /* Bay occupied? */
u8 power_unit:1; /* 0=watts, 1=apms */
u8 alarm:1; /* _BTP present? */
u8 reserved:5;
u8 present:1; /* Bay occupied? */
u8 power_unit:1; /* 0=watts, 1=apms */
u8 alarm:1; /* _BTP present? */
u8 reserved:5;
};
struct acpi_battery_trips {
unsigned long warning;
unsigned long low;
unsigned long warning;
unsigned long low;
};
struct acpi_battery {
acpi_handle handle;
acpi_handle handle;
struct acpi_battery_flags flags;
struct acpi_battery_trips trips;
unsigned long alarm;
unsigned long alarm;
struct acpi_battery_info *info;
};
/* --------------------------------------------------------------------------
Battery Management
-------------------------------------------------------------------------- */
static int
acpi_battery_get_info (
struct acpi_battery *battery,
struct acpi_battery_info **bif)
acpi_battery_get_info(struct acpi_battery *battery,
struct acpi_battery_info **bif)
{
int result = 0;
acpi_status status = 0;
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BIF),
ACPI_BATTERY_FORMAT_BIF};
struct acpi_buffer data = {0, NULL};
union acpi_object *package = NULL;
int result = 0;
acpi_status status = 0;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF),
ACPI_BATTERY_FORMAT_BIF
};
struct acpi_buffer data = { 0, NULL };
union acpi_object *package = NULL;
ACPI_FUNCTION_TRACE("acpi_battery_get_info");
@ -148,7 +145,7 @@ acpi_battery_get_info (
return_VALUE(-ENODEV);
}
package = (union acpi_object *) buffer.pointer;
package = (union acpi_object *)buffer.pointer;
/* Extract Package Data */
@ -174,27 +171,27 @@ acpi_battery_get_info (
goto end;
}
end:
end:
acpi_os_free(buffer.pointer);
if (!result)
(*bif) = (struct acpi_battery_info *) data.pointer;
(*bif) = (struct acpi_battery_info *)data.pointer;
return_VALUE(result);
}
static int
acpi_battery_get_status (
struct acpi_battery *battery,
struct acpi_battery_status **bst)
acpi_battery_get_status(struct acpi_battery *battery,
struct acpi_battery_status **bst)
{
int result = 0;
acpi_status status = 0;
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BST),
ACPI_BATTERY_FORMAT_BST};
struct acpi_buffer data = {0, NULL};
union acpi_object *package = NULL;
int result = 0;
acpi_status status = 0;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST),
ACPI_BATTERY_FORMAT_BST
};
struct acpi_buffer data = { 0, NULL };
union acpi_object *package = NULL;
ACPI_FUNCTION_TRACE("acpi_battery_get_status");
@ -209,7 +206,7 @@ acpi_battery_get_status (
return_VALUE(-ENODEV);
}
package = (union acpi_object *) buffer.pointer;
package = (union acpi_object *)buffer.pointer;
/* Extract Package Data */
@ -235,24 +232,21 @@ acpi_battery_get_status (
goto end;
}
end:
end:
acpi_os_free(buffer.pointer);
if (!result)
(*bst) = (struct acpi_battery_status *) data.pointer;
(*bst) = (struct acpi_battery_status *)data.pointer;
return_VALUE(result);
}
static int
acpi_battery_set_alarm (
struct acpi_battery *battery,
unsigned long alarm)
acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
{
acpi_status status = 0;
union acpi_object arg0 = {ACPI_TYPE_INTEGER};
struct acpi_object_list arg_list = {1, &arg0};
acpi_status status = 0;
union acpi_object arg0 = { ACPI_TYPE_INTEGER };
struct acpi_object_list arg_list = { 1, &arg0 };
ACPI_FUNCTION_TRACE("acpi_battery_set_alarm");
@ -275,19 +269,16 @@ acpi_battery_set_alarm (
return_VALUE(0);
}
static int
acpi_battery_check (
struct acpi_battery *battery)
static int acpi_battery_check(struct acpi_battery *battery)
{
int result = 0;
acpi_status status = AE_OK;
acpi_handle handle = NULL;
struct acpi_device *device = NULL;
int result = 0;
acpi_status status = AE_OK;
acpi_handle handle = NULL;
struct acpi_device *device = NULL;
struct acpi_battery_info *bif = NULL;
ACPI_FUNCTION_TRACE("acpi_battery_check");
if (!battery)
return_VALUE(-EINVAL);
@ -336,18 +327,17 @@ acpi_battery_check (
return_VALUE(result);
}
/* --------------------------------------------------------------------------
FS Interface (/proc)
-------------------------------------------------------------------------- */
static struct proc_dir_entry *acpi_battery_dir;
static struct proc_dir_entry *acpi_battery_dir;
static int acpi_battery_read_info(struct seq_file *seq, void *offset)
{
int result = 0;
struct acpi_battery *battery = (struct acpi_battery *) seq->private;
int result = 0;
struct acpi_battery *battery = (struct acpi_battery *)seq->private;
struct acpi_battery_info *bif = NULL;
char *units = "?";
char *units = "?";
ACPI_FUNCTION_TRACE("acpi_battery_read_info");
@ -369,19 +359,21 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
goto end;
}
units = bif->power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
units =
bif->
power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
seq_printf(seq, "design capacity: unknown\n");
else
seq_printf(seq, "design capacity: %d %sh\n",
(u32) bif->design_capacity, units);
(u32) bif->design_capacity, units);
if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
seq_printf(seq, "last full capacity: unknown\n");
else
seq_printf(seq, "last full capacity: %d %sh\n",
(u32) bif->last_full_capacity, units);
(u32) bif->last_full_capacity, units);
switch ((u32) bif->battery_technology) {
case 0:
@ -399,26 +391,22 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
seq_printf(seq, "design voltage: unknown\n");
else
seq_printf(seq, "design voltage: %d mV\n",
(u32) bif->design_voltage);
seq_printf(seq, "design capacity warning: %d %sh\n",
(u32) bif->design_capacity_warning, units);
seq_printf(seq, "design capacity low: %d %sh\n",
(u32) bif->design_capacity_low, units);
seq_printf(seq, "capacity granularity 1: %d %sh\n",
(u32) bif->battery_capacity_granularity_1, units);
seq_printf(seq, "capacity granularity 2: %d %sh\n",
(u32) bif->battery_capacity_granularity_2, units);
seq_printf(seq, "model number: %s\n",
bif->model_number);
seq_printf(seq, "serial number: %s\n",
bif->serial_number);
seq_printf(seq, "battery type: %s\n",
bif->battery_type);
seq_printf(seq, "OEM info: %s\n",
bif->oem_info);
(u32) bif->design_voltage);
end:
seq_printf(seq, "design capacity warning: %d %sh\n",
(u32) bif->design_capacity_warning, units);
seq_printf(seq, "design capacity low: %d %sh\n",
(u32) bif->design_capacity_low, units);
seq_printf(seq, "capacity granularity 1: %d %sh\n",
(u32) bif->battery_capacity_granularity_1, units);
seq_printf(seq, "capacity granularity 2: %d %sh\n",
(u32) bif->battery_capacity_granularity_2, units);
seq_printf(seq, "model number: %s\n", bif->model_number);
seq_printf(seq, "serial number: %s\n", bif->serial_number);
seq_printf(seq, "battery type: %s\n", bif->battery_type);
seq_printf(seq, "OEM info: %s\n", bif->oem_info);
end:
kfree(bif);
return_VALUE(0);
@ -429,14 +417,12 @@ static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
return single_open(file, acpi_battery_read_info, PDE(inode)->data);
}
static int
acpi_battery_read_state (struct seq_file *seq, void *offset)
static int acpi_battery_read_state(struct seq_file *seq, void *offset)
{
int result = 0;
struct acpi_battery *battery = (struct acpi_battery *) seq->private;
int result = 0;
struct acpi_battery *battery = (struct acpi_battery *)seq->private;
struct acpi_battery_status *bst = NULL;
char *units = "?";
char *units = "?";
ACPI_FUNCTION_TRACE("acpi_battery_read_state");
@ -452,7 +438,9 @@ acpi_battery_read_state (struct seq_file *seq, void *offset)
/* Battery Units */
units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
units =
battery->flags.
power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
/* Battery Status (_BST) */
@ -467,12 +455,12 @@ acpi_battery_read_state (struct seq_file *seq, void *offset)
else
seq_printf(seq, "capacity state: critical\n");
if ((bst->state & 0x01) && (bst->state & 0x02)){
seq_printf(seq, "charging state: charging/discharging\n");
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Battery Charging and Discharging?\n"));
}
else if (bst->state & 0x01)
if ((bst->state & 0x01) && (bst->state & 0x02)) {
seq_printf(seq,
"charging state: charging/discharging\n");
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Battery Charging and Discharging?\n"));
} else if (bst->state & 0x01)
seq_printf(seq, "charging state: discharging\n");
else if (bst->state & 0x02)
seq_printf(seq, "charging state: charging\n");
@ -484,21 +472,21 @@ acpi_battery_read_state (struct seq_file *seq, void *offset)
seq_printf(seq, "present rate: unknown\n");
else
seq_printf(seq, "present rate: %d %s\n",
(u32) bst->present_rate, units);
(u32) bst->present_rate, units);
if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
seq_printf(seq, "remaining capacity: unknown\n");
else
seq_printf(seq, "remaining capacity: %d %sh\n",
(u32) bst->remaining_capacity, units);
(u32) bst->remaining_capacity, units);
if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
seq_printf(seq, "present voltage: unknown\n");
else
seq_printf(seq, "present voltage: %d mV\n",
(u32) bst->present_voltage);
(u32) bst->present_voltage);
end:
end:
kfree(bst);
return_VALUE(0);
@ -509,12 +497,10 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
return single_open(file, acpi_battery_read_state, PDE(inode)->data);
}
static int
acpi_battery_read_alarm (struct seq_file *seq, void *offset)
static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
{
struct acpi_battery *battery = (struct acpi_battery *) seq->private;
char *units = "?";
struct acpi_battery *battery = (struct acpi_battery *)seq->private;
char *units = "?";
ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");
@ -527,8 +513,10 @@ acpi_battery_read_alarm (struct seq_file *seq, void *offset)
}
/* Battery Units */
units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
units =
battery->flags.
power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
/* Battery Alarm */
@ -538,22 +526,19 @@ acpi_battery_read_alarm (struct seq_file *seq, void *offset)
else
seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units);
end:
end:
return_VALUE(0);
}
static ssize_t
acpi_battery_write_alarm (
struct file *file,
const char __user *buffer,
size_t count,
loff_t *ppos)
acpi_battery_write_alarm(struct file *file,
const char __user * buffer,
size_t count, loff_t * ppos)
{
int result = 0;
char alarm_string[12] = {'\0'};
struct seq_file *m = (struct seq_file *)file->private_data;
struct acpi_battery *battery = (struct acpi_battery *)m->private;
int result = 0;
char alarm_string[12] = { '\0' };
struct seq_file *m = (struct seq_file *)file->private_data;
struct acpi_battery *battery = (struct acpi_battery *)m->private;
ACPI_FUNCTION_TRACE("acpi_battery_write_alarm");
@ -565,11 +550,11 @@ acpi_battery_write_alarm (
if (copy_from_user(alarm_string, buffer, count))
return_VALUE(-EFAULT);
alarm_string[count] = '\0';
result = acpi_battery_set_alarm(battery,
simple_strtoul(alarm_string, NULL, 0));
result = acpi_battery_set_alarm(battery,
simple_strtoul(alarm_string, NULL, 0));
if (result)
return_VALUE(result);
@ -582,41 +567,39 @@ static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
}
static struct file_operations acpi_battery_info_ops = {
.open = acpi_battery_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.open = acpi_battery_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};
static struct file_operations acpi_battery_state_ops = {
.open = acpi_battery_state_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.open = acpi_battery_state_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};
static struct file_operations acpi_battery_alarm_ops = {
.open = acpi_battery_alarm_open_fs,
.read = seq_read,
.write = acpi_battery_write_alarm,
.llseek = seq_lseek,
.release = single_release,
.open = acpi_battery_alarm_open_fs,
.read = seq_read,
.write = acpi_battery_write_alarm,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};
static int
acpi_battery_add_fs (
struct acpi_device *device)
static int acpi_battery_add_fs(struct acpi_device *device)
{
struct proc_dir_entry *entry = NULL;
struct proc_dir_entry *entry = NULL;
ACPI_FUNCTION_TRACE("acpi_battery_add_fs");
if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_battery_dir);
acpi_battery_dir);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
acpi_device_dir(device)->owner = THIS_MODULE;
@ -624,24 +607,24 @@ acpi_battery_add_fs (
/* 'info' [R] */
entry = create_proc_entry(ACPI_BATTERY_FILE_INFO,
S_IRUGO, acpi_device_dir(device));
S_IRUGO, acpi_device_dir(device));
if (!entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_BATTERY_FILE_INFO));
"Unable to create '%s' fs entry\n",
ACPI_BATTERY_FILE_INFO));
else {
entry->proc_fops = &acpi_battery_info_ops;
entry->proc_fops = &acpi_battery_info_ops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'status' [R] */
entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS,
S_IRUGO, acpi_device_dir(device));
S_IRUGO, acpi_device_dir(device));
if (!entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_BATTERY_FILE_STATUS));
"Unable to create '%s' fs entry\n",
ACPI_BATTERY_FILE_STATUS));
else {
entry->proc_fops = &acpi_battery_state_ops;
entry->data = acpi_driver_data(device);
@ -650,11 +633,12 @@ acpi_battery_add_fs (
/* 'alarm' [R/W] */
entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM,
S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device));
if (!entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_BATTERY_FILE_ALARM));
"Unable to create '%s' fs entry\n",
ACPI_BATTERY_FILE_ALARM));
else {
entry->proc_fops = &acpi_battery_alarm_ops;
entry->data = acpi_driver_data(device);
@ -664,10 +648,7 @@ acpi_battery_add_fs (
return_VALUE(0);
}
static int
acpi_battery_remove_fs (
struct acpi_device *device)
static int acpi_battery_remove_fs(struct acpi_device *device)
{
ACPI_FUNCTION_TRACE("acpi_battery_remove_fs");
@ -686,19 +667,14 @@ acpi_battery_remove_fs (
return_VALUE(0);
}
/* --------------------------------------------------------------------------
Driver Interface
-------------------------------------------------------------------------- */
static void
acpi_battery_notify (
acpi_handle handle,
u32 event,
void *data)
static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_battery *battery = (struct acpi_battery *) data;
struct acpi_device *device = NULL;
struct acpi_battery *battery = (struct acpi_battery *)data;
struct acpi_device *device = NULL;
ACPI_FUNCTION_TRACE("acpi_battery_notify");
@ -716,24 +692,21 @@ acpi_battery_notify (
break;
default:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Unsupported event [0x%x]\n", event));
"Unsupported event [0x%x]\n", event));
break;
}
return_VOID;
}
static int
acpi_battery_add (
struct acpi_device *device)
static int acpi_battery_add(struct acpi_device *device)
{
int result = 0;
acpi_status status = 0;
struct acpi_battery *battery = NULL;
int result = 0;
acpi_status status = 0;
struct acpi_battery *battery = NULL;
ACPI_FUNCTION_TRACE("acpi_battery_add");
if (!device)
return_VALUE(-EINVAL);
@ -756,19 +729,20 @@ acpi_battery_add (
goto end;
status = acpi_install_notify_handler(battery->handle,
ACPI_DEVICE_NOTIFY, acpi_battery_notify, battery);
ACPI_DEVICE_NOTIFY,
acpi_battery_notify, battery);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error installing notify handler\n"));
"Error installing notify handler\n"));
result = -ENODEV;
goto end;
}
printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
device->status.battery_present?"present":"absent");
end:
ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
device->status.battery_present ? "present" : "absent");
end:
if (result) {
acpi_battery_remove_fs(device);
kfree(battery);
@ -777,27 +751,24 @@ end:
return_VALUE(result);
}
static int
acpi_battery_remove (
struct acpi_device *device,
int type)
static int acpi_battery_remove(struct acpi_device *device, int type)
{
acpi_status status = 0;
struct acpi_battery *battery = NULL;
acpi_status status = 0;
struct acpi_battery *battery = NULL;
ACPI_FUNCTION_TRACE("acpi_battery_remove");
if (!device || !acpi_driver_data(device))
return_VALUE(-EINVAL);
battery = (struct acpi_battery *) acpi_driver_data(device);
battery = (struct acpi_battery *)acpi_driver_data(device);
status = acpi_remove_notify_handler(battery->handle,
ACPI_DEVICE_NOTIFY, acpi_battery_notify);
ACPI_DEVICE_NOTIFY,
acpi_battery_notify);
if (ACPI_FAILURE(status))
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error removing notify handler\n"));
"Error removing notify handler\n"));
acpi_battery_remove_fs(device);
@ -806,11 +777,9 @@ acpi_battery_remove (
return_VALUE(0);
}
static int __init
acpi_battery_init (void)
static int __init acpi_battery_init(void)
{
int result = 0;
int result = 0;
ACPI_FUNCTION_TRACE("acpi_battery_init");
@ -828,9 +797,7 @@ acpi_battery_init (void)
return_VALUE(0);
}
static void __exit
acpi_battery_exit (void)
static void __exit acpi_battery_exit(void)
{
ACPI_FUNCTION_TRACE("acpi_battery_exit");
@ -841,6 +808,5 @@ acpi_battery_exit (void)
return_VOID;
}
module_init(acpi_battery_init);
module_exit(acpi_battery_exit);

View File

@ -26,7 +26,6 @@
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
@ -34,49 +33,49 @@
#include <acpi/acpi_bus.h>
#include <linux/dmi.h>
enum acpi_blacklist_predicates
{
all_versions,
less_than_or_equal,
equal,
greater_than_or_equal,
enum acpi_blacklist_predicates {
all_versions,
less_than_or_equal,
equal,
greater_than_or_equal,
};
struct acpi_blacklist_item
{
char oem_id[7];
char oem_table_id[9];
u32 oem_revision;
acpi_table_type table;
enum acpi_blacklist_predicates oem_revision_predicate;
char *reason;
u32 is_critical_error;
struct acpi_blacklist_item {
char oem_id[7];
char oem_table_id[9];
u32 oem_revision;
acpi_table_type table;
enum acpi_blacklist_predicates oem_revision_predicate;
char *reason;
u32 is_critical_error;
};
/*
* POLICY: If *anything* doesn't work, put it on the blacklist.
* If they are critical errors, mark it critical, and abort driver load.
*/
static struct acpi_blacklist_item acpi_blacklist[] __initdata =
{
static struct acpi_blacklist_item acpi_blacklist[] __initdata = {
/* Compaq Presario 1700 */
{"PTLTD ", " DSDT ", 0x06040000, ACPI_DSDT, less_than_or_equal, "Multiple problems", 1},
{"PTLTD ", " DSDT ", 0x06040000, ACPI_DSDT, less_than_or_equal,
"Multiple problems", 1},
/* Sony FX120, FX140, FX150? */
{"SONY ", "U0 ", 0x20010313, ACPI_DSDT, less_than_or_equal, "ACPI driver problem", 1},
{"SONY ", "U0 ", 0x20010313, ACPI_DSDT, less_than_or_equal,
"ACPI driver problem", 1},
/* Compaq Presario 800, Insyde BIOS */
{"INT440", "SYSFexxx", 0x00001001, ACPI_DSDT, less_than_or_equal, "Does not use _REG to protect EC OpRegions", 1},
{"INT440", "SYSFexxx", 0x00001001, ACPI_DSDT, less_than_or_equal,
"Does not use _REG to protect EC OpRegions", 1},
/* IBM 600E - _ADR should return 7, but it returns 1 */
{"IBM ", "TP600E ", 0x00000105, ACPI_DSDT, less_than_or_equal, "Incorrect _ADR", 1},
{"ASUS\0\0", "P2B-S ", 0, ACPI_DSDT, all_versions, "Bogus PCI routing", 1},
{"IBM ", "TP600E ", 0x00000105, ACPI_DSDT, less_than_or_equal,
"Incorrect _ADR", 1},
{"ASUS\0\0", "P2B-S ", 0, ACPI_DSDT, all_versions,
"Bogus PCI routing", 1},
{""}
};
#if CONFIG_ACPI_BLACKLIST_YEAR
static int __init
blacklist_by_year(void)
static int __init blacklist_by_year(void)
{
int year;
char *s = dmi_get_system_info(DMI_BIOS_DATE);
@ -92,36 +91,38 @@ blacklist_by_year(void)
s += 1;
year = simple_strtoul(s,NULL,0);
year = simple_strtoul(s, NULL, 0);
if (year < 100) { /* 2-digit year */
if (year < 100) { /* 2-digit year */
year += 1900;
if (year < 1996) /* no dates < spec 1.0 */
year += 100;
}
if (year < CONFIG_ACPI_BLACKLIST_YEAR) {
printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), "
"acpi=force is required to enable ACPI\n",
year, CONFIG_ACPI_BLACKLIST_YEAR);
printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), "
"acpi=force is required to enable ACPI\n",
year, CONFIG_ACPI_BLACKLIST_YEAR);
return 1;
}
return 0;
}
#else
static inline int blacklist_by_year(void) { return 0; }
static inline int blacklist_by_year(void)
{
return 0;
}
#endif
int __init
acpi_blacklisted(void)
int __init acpi_blacklisted(void)
{
int i = 0;
int blacklisted = 0;
struct acpi_table_header *table_header;
while (acpi_blacklist[i].oem_id[0] != '\0')
{
if (acpi_get_table_header_early(acpi_blacklist[i].table, &table_header)) {
while (acpi_blacklist[i].oem_id[0] != '\0') {
if (acpi_get_table_header_early
(acpi_blacklist[i].table, &table_header)) {
i++;
continue;
}
@ -131,33 +132,43 @@ acpi_blacklisted(void)
continue;
}
if (strncmp(acpi_blacklist[i].oem_table_id, table_header->oem_table_id, 8)) {
if (strncmp
(acpi_blacklist[i].oem_table_id, table_header->oem_table_id,
8)) {
i++;
continue;
}
if ((acpi_blacklist[i].oem_revision_predicate == all_versions)
|| (acpi_blacklist[i].oem_revision_predicate == less_than_or_equal
&& table_header->oem_revision <= acpi_blacklist[i].oem_revision)
|| (acpi_blacklist[i].oem_revision_predicate == greater_than_or_equal
&& table_header->oem_revision >= acpi_blacklist[i].oem_revision)
|| (acpi_blacklist[i].oem_revision_predicate ==
less_than_or_equal
&& table_header->oem_revision <=
acpi_blacklist[i].oem_revision)
|| (acpi_blacklist[i].oem_revision_predicate ==
greater_than_or_equal
&& table_header->oem_revision >=
acpi_blacklist[i].oem_revision)
|| (acpi_blacklist[i].oem_revision_predicate == equal
&& table_header->oem_revision == acpi_blacklist[i].oem_revision)) {
&& table_header->oem_revision ==
acpi_blacklist[i].oem_revision)) {
printk(KERN_ERR PREFIX "Vendor \"%6.6s\" System \"%8.8s\" "
"Revision 0x%x has a known ACPI BIOS problem.\n",
acpi_blacklist[i].oem_id,
acpi_blacklist[i].oem_table_id,
acpi_blacklist[i].oem_revision);
printk(KERN_ERR PREFIX
"Vendor \"%6.6s\" System \"%8.8s\" "
"Revision 0x%x has a known ACPI BIOS problem.\n",
acpi_blacklist[i].oem_id,
acpi_blacklist[i].oem_table_id,
acpi_blacklist[i].oem_revision);
printk(KERN_ERR PREFIX "Reason: %s. This is a %s error\n",
acpi_blacklist[i].reason,
(acpi_blacklist[i].is_critical_error ? "non-recoverable" : "recoverable"));
printk(KERN_ERR PREFIX
"Reason: %s. This is a %s error\n",
acpi_blacklist[i].reason,
(acpi_blacklist[i].
is_critical_error ? "non-recoverable" :
"recoverable"));
blacklisted = acpi_blacklist[i].is_critical_error;
break;
}
else {
} else {
i++;
}
}
@ -166,4 +177,3 @@ acpi_blacklisted(void)
return blacklisted;
}

View File

@ -36,19 +36,17 @@
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#define _COMPONENT ACPI_BUS_COMPONENT
ACPI_MODULE_NAME ("acpi_bus")
ACPI_MODULE_NAME("acpi_bus")
#ifdef CONFIG_X86
extern void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger);
#endif
FADT_DESCRIPTOR acpi_fadt;
FADT_DESCRIPTOR acpi_fadt;
EXPORT_SYMBOL(acpi_fadt);
struct acpi_device *acpi_root;
struct proc_dir_entry *acpi_root_dir;
struct acpi_device *acpi_root;
struct proc_dir_entry *acpi_root_dir;
EXPORT_SYMBOL(acpi_root_dir);
#define STRUCT_TO_INT(s) (*((int*)&s))
@ -57,12 +55,9 @@ EXPORT_SYMBOL(acpi_root_dir);
Device Management
-------------------------------------------------------------------------- */
int
acpi_bus_get_device (
acpi_handle handle,
struct acpi_device **device)
int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
{
acpi_status status = AE_OK;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("acpi_bus_get_device");
@ -71,24 +66,23 @@ acpi_bus_get_device (
/* TBD: Support fixed-feature devices */
status = acpi_get_data(handle, acpi_bus_data_handler, (void**) device);
status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
if (ACPI_FAILURE(status) || !*device) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No context for object [%p]\n",
handle));
handle));
return_VALUE(-ENODEV);
}
return_VALUE(0);
}
EXPORT_SYMBOL(acpi_bus_get_device);
int
acpi_bus_get_status (
struct acpi_device *device)
int acpi_bus_get_status(struct acpi_device *device)
{
acpi_status status = AE_OK;
unsigned long sta = 0;
acpi_status status = AE_OK;
unsigned long sta = 0;
ACPI_FUNCTION_TRACE("acpi_bus_get_status");
if (!device)
@ -98,10 +92,11 @@ acpi_bus_get_status (
* Evaluate _STA if present.
*/
if (device->flags.dynamic_status) {
status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
status =
acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
if (ACPI_FAILURE(status))
return_VALUE(-ENODEV);
STRUCT_TO_INT(device->status) = (int) sta;
STRUCT_TO_INT(device->status) = (int)sta;
}
/*
@ -115,33 +110,30 @@ acpi_bus_get_status (
if (device->status.functional && !device->status.present) {
printk(KERN_WARNING PREFIX "Device [%s] status [%08x]: "
"functional but not present; setting present\n",
device->pnp.bus_id,
(u32) STRUCT_TO_INT(device->status));
"functional but not present; setting present\n",
device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status));
device->status.present = 1;
}
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status)));
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
device->pnp.bus_id,
(u32) STRUCT_TO_INT(device->status)));
return_VALUE(0);
}
EXPORT_SYMBOL(acpi_bus_get_status);
EXPORT_SYMBOL(acpi_bus_get_status);
/* --------------------------------------------------------------------------
Power Management
-------------------------------------------------------------------------- */
int
acpi_bus_get_power (
acpi_handle handle,
int *state)
int acpi_bus_get_power(acpi_handle handle, int *state)
{
int result = 0;
acpi_status status = 0;
struct acpi_device *device = NULL;
unsigned long psc = 0;
int result = 0;
acpi_status status = 0;
struct acpi_device *device = NULL;
unsigned long psc = 0;
ACPI_FUNCTION_TRACE("acpi_bus_get_power");
@ -157,20 +149,18 @@ acpi_bus_get_power (
*state = device->parent->power.state;
else
*state = ACPI_STATE_D0;
}
else {
} else {
/*
* Get the device's power state either directly (via _PSC) or
* indirectly (via power resources).
*/
if (device->power.flags.explicit_get) {
status = acpi_evaluate_integer(device->handle, "_PSC",
NULL, &psc);
status = acpi_evaluate_integer(device->handle, "_PSC",
NULL, &psc);
if (ACPI_FAILURE(status))
return_VALUE(-ENODEV);
device->power.state = (int) psc;
}
else if (device->power.flags.power_resources) {
device->power.state = (int)psc;
} else if (device->power.flags.power_resources) {
result = acpi_power_get_inferred_state(device);
if (result)
return_VALUE(result);
@ -180,22 +170,19 @@ acpi_bus_get_power (
}
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
device->pnp.bus_id, device->power.state));
device->pnp.bus_id, device->power.state));
return_VALUE(0);
}
EXPORT_SYMBOL(acpi_bus_get_power);
int
acpi_bus_set_power (
acpi_handle handle,
int state)
int acpi_bus_set_power(acpi_handle handle, int state)
{
int result = 0;
acpi_status status = AE_OK;
struct acpi_device *device = NULL;
char object_name[5] = {'_','P','S','0'+state,'\0'};
int result = 0;
acpi_status status = AE_OK;
struct acpi_device *device = NULL;
char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' };
ACPI_FUNCTION_TRACE("acpi_bus_set_power");
@ -209,7 +196,8 @@ acpi_bus_set_power (
/* Make sure this is a valid target state */
if (!device->flags.power_manageable) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n"));
ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"Device is not power manageable\n"));
return_VALUE(-ENODEV);
}
/*
@ -219,15 +207,18 @@ acpi_bus_set_power (
if (device->power.state == ACPI_STATE_UNKNOWN)
acpi_bus_get_power(device->handle, &device->power.state);
if (state == device->power.state) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state));
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
state));
return_VALUE(0);
}
if (!device->power.states[state].flags.valid) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", state));
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n",
state));
return_VALUE(-ENODEV);
}
if (device->parent && (state < device->parent->power.state)) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Cannot set device to a higher-powered state than parent\n"));
ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"Cannot set device to a higher-powered state than parent\n"));
return_VALUE(-ENODEV);
}
@ -245,18 +236,17 @@ acpi_bus_set_power (
goto end;
}
if (device->power.states[state].flags.explicit_set) {
status = acpi_evaluate_object(device->handle,
object_name, NULL, NULL);
status = acpi_evaluate_object(device->handle,
object_name, NULL, NULL);
if (ACPI_FAILURE(status)) {
result = -ENODEV;
goto end;
}
}
}
else {
} else {
if (device->power.states[state].flags.explicit_set) {
status = acpi_evaluate_object(device->handle,
object_name, NULL, NULL);
status = acpi_evaluate_object(device->handle,
object_name, NULL, NULL);
if (ACPI_FAILURE(status)) {
result = -ENODEV;
goto end;
@ -269,20 +259,21 @@ acpi_bus_set_power (
}
}
end:
end:
if (result)
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error transitioning device [%s] to D%d\n",
device->pnp.bus_id, state));
ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"Error transitioning device [%s] to D%d\n",
device->pnp.bus_id, state));
else
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] transitioned to D%d\n",
device->pnp.bus_id, state));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Device [%s] transitioned to D%d\n",
device->pnp.bus_id, state));
return_VALUE(result);
}
EXPORT_SYMBOL(acpi_bus_set_power);
/* --------------------------------------------------------------------------
Event Management
-------------------------------------------------------------------------- */
@ -292,16 +283,12 @@ static DEFINE_SPINLOCK(acpi_bus_event_lock);
LIST_HEAD(acpi_bus_event_list);
DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
extern int event_is_open;
extern int event_is_open;
int
acpi_bus_generate_event (
struct acpi_device *device,
u8 type,
int data)
int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
{
struct acpi_bus_event *event = NULL;
unsigned long flags = 0;
struct acpi_bus_event *event = NULL;
unsigned long flags = 0;
ACPI_FUNCTION_TRACE("acpi_bus_generate_event");
@ -329,14 +316,13 @@ acpi_bus_generate_event (
return_VALUE(0);
}
EXPORT_SYMBOL(acpi_bus_generate_event);
int
acpi_bus_receive_event (
struct acpi_bus_event *event)
int acpi_bus_receive_event(struct acpi_bus_event *event)
{
unsigned long flags = 0;
struct acpi_bus_event *entry = NULL;
unsigned long flags = 0;
struct acpi_bus_event *entry = NULL;
DECLARE_WAITQUEUE(wait, current);
@ -361,7 +347,8 @@ acpi_bus_receive_event (
}
spin_lock_irqsave(&acpi_bus_event_lock, flags);
entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node);
entry =
list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node);
if (entry)
list_del(&entry->node);
spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
@ -375,19 +362,17 @@ acpi_bus_receive_event (
return_VALUE(0);
}
EXPORT_SYMBOL(acpi_bus_receive_event);
EXPORT_SYMBOL(acpi_bus_receive_event);
/* --------------------------------------------------------------------------
Notification Handling
-------------------------------------------------------------------------- */
static int
acpi_bus_check_device (
struct acpi_device *device,
int *status_changed)
acpi_bus_check_device(struct acpi_device *device, int *status_changed)
{
acpi_status status = 0;
acpi_status status = 0;
struct acpi_device_status old_status;
ACPI_FUNCTION_TRACE("acpi_bus_check_device");
@ -422,15 +407,14 @@ acpi_bus_check_device (
if (status_changed)
*status_changed = 1;
/*
* Device Insertion/Removal
*/
if ((device->status.present) && !(old_status.present)) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
/* TBD: Handle device insertion */
}
else if (!(device->status.present) && (old_status.present)) {
} else if (!(device->status.present) && (old_status.present)) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
/* TBD: Handle device removal */
}
@ -438,13 +422,10 @@ acpi_bus_check_device (
return_VALUE(0);
}
static int
acpi_bus_check_scope (
struct acpi_device *device)
static int acpi_bus_check_scope(struct acpi_device *device)
{
int result = 0;
int status_changed = 0;
int result = 0;
int status_changed = 0;
ACPI_FUNCTION_TRACE("acpi_bus_check_scope");
@ -467,20 +448,15 @@ acpi_bus_check_scope (
return_VALUE(0);
}
/**
* acpi_bus_notify
* ---------------
* Callback for all 'system-level' device notifications (values 0x00-0x7F).
*/
static void
acpi_bus_notify (
acpi_handle handle,
u32 type,
void *data)
static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
{
int result = 0;
struct acpi_device *device = NULL;
int result = 0;
struct acpi_device *device = NULL;
ACPI_FUNCTION_TRACE("acpi_bus_notify");
@ -490,64 +466,73 @@ acpi_bus_notify (
switch (type) {
case ACPI_NOTIFY_BUS_CHECK:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS CHECK notification for device [%s]\n",
device->pnp.bus_id));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Received BUS CHECK notification for device [%s]\n",
device->pnp.bus_id));
result = acpi_bus_check_scope(device);
/*
* TBD: We'll need to outsource certain events to non-ACPI
* drivers via the device manager (device.c).
* drivers via the device manager (device.c).
*/
break;
case ACPI_NOTIFY_DEVICE_CHECK:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK notification for device [%s]\n",
device->pnp.bus_id));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Received DEVICE CHECK notification for device [%s]\n",
device->pnp.bus_id));
result = acpi_bus_check_device(device, NULL);
/*
* TBD: We'll need to outsource certain events to non-ACPI
* drivers via the device manager (device.c).
* drivers via the device manager (device.c).
*/
break;
case ACPI_NOTIFY_DEVICE_WAKE:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE WAKE notification for device [%s]\n",
device->pnp.bus_id));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Received DEVICE WAKE notification for device [%s]\n",
device->pnp.bus_id));
/* TBD */
break;
case ACPI_NOTIFY_EJECT_REQUEST:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received EJECT REQUEST notification for device [%s]\n",
device->pnp.bus_id));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Received EJECT REQUEST notification for device [%s]\n",
device->pnp.bus_id));
/* TBD */
break;
case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK LIGHT notification for device [%s]\n",
device->pnp.bus_id));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Received DEVICE CHECK LIGHT notification for device [%s]\n",
device->pnp.bus_id));
/* TBD: Exactly what does 'light' mean? */
break;
case ACPI_NOTIFY_FREQUENCY_MISMATCH:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received FREQUENCY MISMATCH notification for device [%s]\n",
device->pnp.bus_id));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Received FREQUENCY MISMATCH notification for device [%s]\n",
device->pnp.bus_id));
/* TBD */
break;
case ACPI_NOTIFY_BUS_MODE_MISMATCH:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS MODE MISMATCH notification for device [%s]\n",
device->pnp.bus_id));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Received BUS MODE MISMATCH notification for device [%s]\n",
device->pnp.bus_id));
/* TBD */
break;
case ACPI_NOTIFY_POWER_FAULT:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received POWER FAULT notification for device [%s]\n",
device->pnp.bus_id));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Received POWER FAULT notification for device [%s]\n",
device->pnp.bus_id));
/* TBD */
break;
default:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received unknown/unsupported notification [%08x]\n",
type));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Received unknown/unsupported notification [%08x]\n",
type));
break;
}
@ -558,13 +543,12 @@ acpi_bus_notify (
Initialization/Cleanup
-------------------------------------------------------------------------- */
static int __init
acpi_bus_init_irq (void)
static int __init acpi_bus_init_irq(void)
{
acpi_status status = AE_OK;
union acpi_object arg = {ACPI_TYPE_INTEGER};
struct acpi_object_list arg_list = {1, &arg};
char *message = NULL;
acpi_status status = AE_OK;
union acpi_object arg = { ACPI_TYPE_INTEGER };
struct acpi_object_list arg_list = { 1, &arg };
char *message = NULL;
ACPI_FUNCTION_TRACE("acpi_bus_init_irq");
@ -601,12 +585,10 @@ acpi_bus_init_irq (void)
return_VALUE(0);
}
void __init
acpi_early_init (void)
void __init acpi_early_init(void)
{
acpi_status status = AE_OK;
struct acpi_buffer buffer = {sizeof(acpi_fadt), &acpi_fadt};
acpi_status status = AE_OK;
struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt };
ACPI_FUNCTION_TRACE("acpi_early_init");
@ -619,13 +601,15 @@ acpi_early_init (void)
status = acpi_initialize_subsystem();
if (ACPI_FAILURE(status)) {
printk(KERN_ERR PREFIX "Unable to initialize the ACPI Interpreter\n");
printk(KERN_ERR PREFIX
"Unable to initialize the ACPI Interpreter\n");
goto error0;
}
status = acpi_load_tables();
if (ACPI_FAILURE(status)) {
printk(KERN_ERR PREFIX "Unable to load the System Description Tables\n");
printk(KERN_ERR PREFIX
"Unable to load the System Description Tables\n");
goto error0;
}
@ -637,7 +621,6 @@ acpi_early_init (void)
printk(KERN_ERR PREFIX "Unable to get the FADT\n");
goto error0;
}
#ifdef CONFIG_X86
if (!acpi_ioapic) {
extern acpi_interrupt_flags acpi_sci_flags;
@ -647,7 +630,8 @@ acpi_early_init (void)
acpi_sci_flags.trigger = 3;
/* Set PIC-mode SCI trigger type */
acpi_pic_sci_set_trigger(acpi_fadt.sci_int, acpi_sci_flags.trigger);
acpi_pic_sci_set_trigger(acpi_fadt.sci_int,
acpi_sci_flags.trigger);
} else {
extern int acpi_sci_override_gsi;
/*
@ -658,7 +642,10 @@ acpi_early_init (void)
}
#endif
status = acpi_enable_subsystem(~(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE));
status =
acpi_enable_subsystem(~
(ACPI_NO_HARDWARE_INIT |
ACPI_NO_ACPI_ENABLE));
if (ACPI_FAILURE(status)) {
printk(KERN_ERR PREFIX "Unable to enable ACPI\n");
goto error0;
@ -666,30 +653,32 @@ acpi_early_init (void)
return_VOID;
error0:
error0:
disable_acpi();
return_VOID;
}
static int __init
acpi_bus_init (void)
static int __init acpi_bus_init(void)
{
int result = 0;
acpi_status status = AE_OK;
extern acpi_status acpi_os_initialize1(void);
int result = 0;
acpi_status status = AE_OK;
extern acpi_status acpi_os_initialize1(void);
ACPI_FUNCTION_TRACE("acpi_bus_init");
status = acpi_os_initialize1();
status = acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE);
status =
acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE);
if (ACPI_FAILURE(status)) {
printk(KERN_ERR PREFIX "Unable to start the ACPI Interpreter\n");
printk(KERN_ERR PREFIX
"Unable to start the ACPI Interpreter\n");
goto error1;
}
if (ACPI_FAILURE(status)) {
printk(KERN_ERR PREFIX "Unable to initialize ACPI OS objects\n");
printk(KERN_ERR PREFIX
"Unable to initialize ACPI OS objects\n");
goto error1;
}
#ifdef CONFIG_ACPI_EC
@ -723,9 +712,12 @@ acpi_bus_init (void)
/*
* Register the for all standard device notifications.
*/
status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &acpi_bus_notify, NULL);
status =
acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
&acpi_bus_notify, NULL);
if (ACPI_FAILURE(status)) {
printk(KERN_ERR PREFIX "Unable to register for device notifications\n");
printk(KERN_ERR PREFIX
"Unable to register for device notifications\n");
goto error1;
}
@ -737,21 +729,20 @@ acpi_bus_init (void)
return_VALUE(0);
/* Mimic structured exception handling */
error1:
error1:
acpi_terminate();
return_VALUE(-ENODEV);
}
decl_subsys(acpi,NULL,NULL);
decl_subsys(acpi, NULL, NULL);
static int __init acpi_init (void)
static int __init acpi_init(void)
{
int result = 0;
int result = 0;
ACPI_FUNCTION_TRACE("acpi_init");
printk(KERN_INFO PREFIX "Subsystem revision %08x\n",
ACPI_CA_VERSION);
printk(KERN_INFO PREFIX "Subsystem revision %08x\n", ACPI_CA_VERSION);
if (acpi_disabled) {
printk(KERN_INFO PREFIX "Interpreter disabled.\n");
@ -767,7 +758,8 @@ static int __init acpi_init (void)
if (!PM_IS_ACTIVE())
pm_active = 1;
else {
printk(KERN_INFO PREFIX "APM is already active, exiting\n");
printk(KERN_INFO PREFIX
"APM is already active, exiting\n");
disable_acpi();
result = -ENODEV;
}

View File

@ -32,7 +32,6 @@
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#define ACPI_BUTTON_COMPONENT 0x00080000
#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver"
#define ACPI_BUTTON_CLASS "button"
@ -42,7 +41,7 @@
#define ACPI_BUTTON_NOTIFY_STATUS 0x80
#define ACPI_BUTTON_SUBCLASS_POWER "power"
#define ACPI_BUTTON_HID_POWER "PNP0C0C"
#define ACPI_BUTTON_HID_POWER "PNP0C0C"
#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)"
#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)"
#define ACPI_BUTTON_TYPE_POWER 0x01
@ -61,65 +60,65 @@
#define ACPI_BUTTON_TYPE_LID 0x05
#define _COMPONENT ACPI_BUTTON_COMPONENT
ACPI_MODULE_NAME ("acpi_button")
ACPI_MODULE_NAME("acpi_button")
MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME);
MODULE_LICENSE("GPL");
static int acpi_button_add (struct acpi_device *device);
static int acpi_button_remove (struct acpi_device *device, int type);
static int acpi_button_add(struct acpi_device *device);
static int acpi_button_remove(struct acpi_device *device, int type);
static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
static struct acpi_driver acpi_button_driver = {
.name = ACPI_BUTTON_DRIVER_NAME,
.class = ACPI_BUTTON_CLASS,
.ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E",
.ops = {
.add = acpi_button_add,
.remove = acpi_button_remove,
},
.name = ACPI_BUTTON_DRIVER_NAME,
.class = ACPI_BUTTON_CLASS,
.ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E",
.ops = {
.add = acpi_button_add,
.remove = acpi_button_remove,
},
};
struct acpi_button {
acpi_handle handle;
struct acpi_device *device; /* Fixed button kludge */
u8 type;
unsigned long pushed;
acpi_handle handle;
struct acpi_device *device; /* Fixed button kludge */
u8 type;
unsigned long pushed;
};
static struct file_operations acpi_button_info_fops = {
.open = acpi_button_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.open = acpi_button_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations acpi_button_state_fops = {
.open = acpi_button_state_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.open = acpi_button_state_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/* --------------------------------------------------------------------------
FS Interface (/proc)
-------------------------------------------------------------------------- */
static struct proc_dir_entry *acpi_button_dir;
static struct proc_dir_entry *acpi_button_dir;
static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_button *button = (struct acpi_button *) seq->private;
struct acpi_button *button = (struct acpi_button *)seq->private;
ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
if (!button || !button->device)
return_VALUE(0);
seq_printf(seq, "type: %s\n",
acpi_device_name(button->device));
seq_printf(seq, "type: %s\n",
acpi_device_name(button->device));
return_VALUE(0);
}
@ -128,24 +127,24 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_button_info_seq_show, PDE(inode)->data);
}
static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_button *button = (struct acpi_button *) seq->private;
acpi_status status;
unsigned long state;
struct acpi_button *button = (struct acpi_button *)seq->private;
acpi_status status;
unsigned long state;
ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
if (!button || !button->device)
return_VALUE(0);
status = acpi_evaluate_integer(button->handle,"_LID",NULL,&state);
status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state);
if (ACPI_FAILURE(status)) {
seq_printf(seq, "state: unsupported\n");
}
else{
seq_printf(seq, "state: %s\n", (state ? "open" : "closed"));
} else {
seq_printf(seq, "state: %s\n",
(state ? "open" : "closed"));
}
return_VALUE(0);
@ -160,12 +159,10 @@ static struct proc_dir_entry *acpi_power_dir;
static struct proc_dir_entry *acpi_sleep_dir;
static struct proc_dir_entry *acpi_lid_dir;
static int
acpi_button_add_fs (
struct acpi_device *device)
static int acpi_button_add_fs(struct acpi_device *device)
{
struct proc_dir_entry *entry = NULL;
struct acpi_button *button = NULL;
struct proc_dir_entry *entry = NULL;
struct acpi_button *button = NULL;
ACPI_FUNCTION_TRACE("acpi_button_add_fs");
@ -178,21 +175,21 @@ acpi_button_add_fs (
case ACPI_BUTTON_TYPE_POWER:
case ACPI_BUTTON_TYPE_POWERF:
if (!acpi_power_dir)
acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER,
acpi_button_dir);
acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER,
acpi_button_dir);
entry = acpi_power_dir;
break;
case ACPI_BUTTON_TYPE_SLEEP:
case ACPI_BUTTON_TYPE_SLEEPF:
if (!acpi_sleep_dir)
acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
acpi_button_dir);
acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
acpi_button_dir);
entry = acpi_sleep_dir;
break;
case ACPI_BUTTON_TYPE_LID:
if (!acpi_lid_dir)
acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
acpi_button_dir);
acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
acpi_button_dir);
entry = acpi_lid_dir;
break;
}
@ -208,11 +205,11 @@ acpi_button_add_fs (
/* 'info' [R] */
entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
S_IRUGO, acpi_device_dir(device));
S_IRUGO, acpi_device_dir(device));
if (!entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_BUTTON_FILE_INFO));
"Unable to create '%s' fs entry\n",
ACPI_BUTTON_FILE_INFO));
else {
entry->proc_fops = &acpi_button_info_fops;
entry->data = acpi_driver_data(device);
@ -222,11 +219,11 @@ acpi_button_add_fs (
/* show lid state [R] */
if (button->type == ACPI_BUTTON_TYPE_LID) {
entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
S_IRUGO, acpi_device_dir(device));
S_IRUGO, acpi_device_dir(device));
if (!entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_BUTTON_FILE_INFO));
"Unable to create '%s' fs entry\n",
ACPI_BUTTON_FILE_INFO));
else {
entry->proc_fops = &acpi_button_state_fops;
entry->data = acpi_driver_data(device);
@ -237,12 +234,9 @@ acpi_button_add_fs (
return_VALUE(0);
}
static int
acpi_button_remove_fs (
struct acpi_device *device)
static int acpi_button_remove_fs(struct acpi_device *device)
{
struct acpi_button *button = NULL;
struct acpi_button *button = NULL;
ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
@ -250,30 +244,25 @@ acpi_button_remove_fs (
if (acpi_device_dir(device)) {
if (button->type == ACPI_BUTTON_TYPE_LID)
remove_proc_entry(ACPI_BUTTON_FILE_STATE,
acpi_device_dir(device));
acpi_device_dir(device));
remove_proc_entry(ACPI_BUTTON_FILE_INFO,
acpi_device_dir(device));
acpi_device_dir(device));
remove_proc_entry(acpi_device_bid(device),
acpi_device_dir(device)->parent);
acpi_device_dir(device)->parent);
acpi_device_dir(device) = NULL;
}
return_VALUE(0);
}
/* --------------------------------------------------------------------------
Driver Interface
-------------------------------------------------------------------------- */
static void
acpi_button_notify (
acpi_handle handle,
u32 event,
void *data)
static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_button *button = (struct acpi_button *) data;
struct acpi_button *button = (struct acpi_button *)data;
ACPI_FUNCTION_TRACE("acpi_button_notify");
@ -282,24 +271,22 @@ acpi_button_notify (
switch (event) {
case ACPI_BUTTON_NOTIFY_STATUS:
acpi_bus_generate_event(button->device, event, ++button->pushed);
acpi_bus_generate_event(button->device, event,
++button->pushed);
break;
default:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Unsupported event [0x%x]\n", event));
"Unsupported event [0x%x]\n", event));
break;
}
return_VOID;
}
static acpi_status
acpi_button_notify_fixed (
void *data)
static acpi_status acpi_button_notify_fixed(void *data)
{
struct acpi_button *button = (struct acpi_button *) data;
struct acpi_button *button = (struct acpi_button *)data;
ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
if (!button)
@ -310,14 +297,11 @@ acpi_button_notify_fixed (
return_ACPI_STATUS(AE_OK);
}
static int
acpi_button_add (
struct acpi_device *device)
static int acpi_button_add(struct acpi_device *device)
{
int result = 0;
acpi_status status = AE_OK;
struct acpi_button *button = NULL;
int result = 0;
acpi_status status = AE_OK;
struct acpi_button *button = NULL;
ACPI_FUNCTION_TRACE("acpi_button_add");
@ -339,42 +323,34 @@ acpi_button_add (
*/
if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) {
button->type = ACPI_BUTTON_TYPE_POWER;
strcpy(acpi_device_name(device),
ACPI_BUTTON_DEVICE_NAME_POWER);
sprintf(acpi_device_class(device), "%s/%s",
strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_POWER);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) {
} else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) {
button->type = ACPI_BUTTON_TYPE_POWERF;
strcpy(acpi_device_name(device),
ACPI_BUTTON_DEVICE_NAME_POWERF);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_DEVICE_NAME_POWERF);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) {
} else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) {
button->type = ACPI_BUTTON_TYPE_SLEEP;
strcpy(acpi_device_name(device),
ACPI_BUTTON_DEVICE_NAME_SLEEP);
sprintf(acpi_device_class(device), "%s/%s",
strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_SLEEP);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) {
} else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) {
button->type = ACPI_BUTTON_TYPE_SLEEPF;
strcpy(acpi_device_name(device),
ACPI_BUTTON_DEVICE_NAME_SLEEPF);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_DEVICE_NAME_SLEEPF);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) {
} else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) {
button->type = ACPI_BUTTON_TYPE_LID;
strcpy(acpi_device_name(device),
ACPI_BUTTON_DEVICE_NAME_LID);
sprintf(acpi_device_class(device), "%s/%s",
strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_LID);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
}
else {
} else {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n",
acpi_device_hid(device)));
acpi_device_hid(device)));
result = -ENODEV;
goto end;
}
@ -385,46 +361,46 @@ acpi_button_add (
switch (button->type) {
case ACPI_BUTTON_TYPE_POWERF:
status = acpi_install_fixed_event_handler (
ACPI_EVENT_POWER_BUTTON,
acpi_button_notify_fixed,
button);
status =
acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
acpi_button_notify_fixed,
button);
break;
case ACPI_BUTTON_TYPE_SLEEPF:
status = acpi_install_fixed_event_handler (
ACPI_EVENT_SLEEP_BUTTON,
acpi_button_notify_fixed,
button);
status =
acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
acpi_button_notify_fixed,
button);
break;
default:
status = acpi_install_notify_handler (
button->handle,
ACPI_DEVICE_NOTIFY,
acpi_button_notify,
button);
status = acpi_install_notify_handler(button->handle,
ACPI_DEVICE_NOTIFY,
acpi_button_notify,
button);
break;
}
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error installing notify handler\n"));
"Error installing notify handler\n"));
result = -ENODEV;
goto end;
}
if (device->wakeup.flags.valid) {
/* Button's GPE is run-wake GPE */
acpi_set_gpe_type(device->wakeup.gpe_device,
device->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN);
acpi_enable_gpe(device->wakeup.gpe_device,
device->wakeup.gpe_number, ACPI_NOT_ISR);
acpi_set_gpe_type(device->wakeup.gpe_device,
device->wakeup.gpe_number,
ACPI_GPE_TYPE_WAKE_RUN);
acpi_enable_gpe(device->wakeup.gpe_device,
device->wakeup.gpe_number, ACPI_NOT_ISR);
device->wakeup.state.enabled = 1;
}
printk(KERN_INFO PREFIX "%s [%s]\n",
acpi_device_name(device), acpi_device_bid(device));
printk(KERN_INFO PREFIX "%s [%s]\n",
acpi_device_name(device), acpi_device_bid(device));
end:
end:
if (result) {
acpi_button_remove_fs(device);
kfree(button);
@ -433,12 +409,10 @@ end:
return_VALUE(result);
}
static int
acpi_button_remove (struct acpi_device *device, int type)
static int acpi_button_remove(struct acpi_device *device, int type)
{
acpi_status status = 0;
struct acpi_button *button = NULL;
acpi_status status = 0;
struct acpi_button *button = NULL;
ACPI_FUNCTION_TRACE("acpi_button_remove");
@ -450,35 +424,36 @@ acpi_button_remove (struct acpi_device *device, int type)
/* Unregister for device notifications. */
switch (button->type) {
case ACPI_BUTTON_TYPE_POWERF:
status = acpi_remove_fixed_event_handler(
ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed);
status =
acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
acpi_button_notify_fixed);
break;
case ACPI_BUTTON_TYPE_SLEEPF:
status = acpi_remove_fixed_event_handler(
ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed);
status =
acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
acpi_button_notify_fixed);
break;
default:
status = acpi_remove_notify_handler(button->handle,
ACPI_DEVICE_NOTIFY, acpi_button_notify);
ACPI_DEVICE_NOTIFY,
acpi_button_notify);
break;
}
if (ACPI_FAILURE(status))
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error removing notify handler\n"));
"Error removing notify handler\n"));
acpi_button_remove_fs(device);
acpi_button_remove_fs(device);
kfree(button);
return_VALUE(0);
}
static int __init
acpi_button_init (void)
static int __init acpi_button_init(void)
{
int result = 0;
int result = 0;
ACPI_FUNCTION_TRACE("acpi_button_init");
@ -495,15 +470,13 @@ acpi_button_init (void)
return_VALUE(0);
}
static void __exit
acpi_button_exit (void)
static void __exit acpi_button_exit(void)
{
ACPI_FUNCTION_TRACE("acpi_button_exit");
acpi_bus_unregister_driver(&acpi_button_driver);
if (acpi_power_dir)
if (acpi_power_dir)
remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir);
if (acpi_sleep_dir)
remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir);
@ -514,6 +487,5 @@ acpi_button_exit (void)
return_VOID;
}
module_init(acpi_button_init);
module_exit(acpi_button_exit);

View File

@ -44,9 +44,9 @@
#define ACPI_CONTAINER_COMPONENT 0x01000000
#define _COMPONENT ACPI_CONTAINER_COMPONENT
ACPI_MODULE_NAME ("acpi_container")
ACPI_MODULE_NAME("acpi_container")
MODULE_AUTHOR("Anil S Keshavamurthy");
MODULE_AUTHOR("Anil S Keshavamurthy");
MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME);
MODULE_LICENSE("GPL");
@ -56,41 +56,38 @@ static int acpi_container_add(struct acpi_device *device);
static int acpi_container_remove(struct acpi_device *device, int type);
static struct acpi_driver acpi_container_driver = {
.name = ACPI_CONTAINER_DRIVER_NAME,
.class = ACPI_CONTAINER_CLASS,
.ids = "ACPI0004,PNP0A05,PNP0A06",
.ops = {
.add = acpi_container_add,
.remove = acpi_container_remove,
},
.name = ACPI_CONTAINER_DRIVER_NAME,
.class = ACPI_CONTAINER_CLASS,
.ids = "ACPI0004,PNP0A05,PNP0A06",
.ops = {
.add = acpi_container_add,
.remove = acpi_container_remove,
},
};
/*******************************************************************/
static int
is_device_present(acpi_handle handle)
static int is_device_present(acpi_handle handle)
{
acpi_handle temp;
acpi_status status;
unsigned long sta;
acpi_handle temp;
acpi_status status;
unsigned long sta;
ACPI_FUNCTION_TRACE("is_device_present");
status = acpi_get_handle(handle, "_STA", &temp);
if (ACPI_FAILURE(status))
return_VALUE(1); /* _STA not found, assmue device present */
return_VALUE(1); /* _STA not found, assmue device present */
status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
if (ACPI_FAILURE(status))
return_VALUE(0); /* Firmware error */
return_VALUE(0); /* Firmware error */
return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT);
}
/*******************************************************************/
static int
acpi_container_add(struct acpi_device *device)
static int acpi_container_add(struct acpi_device *device)
{
struct acpi_container *container;
@ -102,28 +99,26 @@ acpi_container_add(struct acpi_device *device)
}
container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL);
if(!container)
if (!container)
return_VALUE(-ENOMEM);
memset(container, 0, sizeof(struct acpi_container));
container->handle = device->handle;
strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS);
acpi_driver_data(device) = container;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", \
acpi_device_name(device), acpi_device_bid(device)));
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
acpi_device_name(device), acpi_device_bid(device)));
return_VALUE(0);
}
static int
acpi_container_remove(struct acpi_device *device, int type)
static int acpi_container_remove(struct acpi_device *device, int type)
{
acpi_status status = AE_OK;
struct acpi_container *pc = NULL;
pc = (struct acpi_container*) acpi_driver_data(device);
acpi_status status = AE_OK;
struct acpi_container *pc = NULL;
pc = (struct acpi_container *)acpi_driver_data(device);
if (pc)
kfree(pc);
@ -131,9 +126,7 @@ acpi_container_remove(struct acpi_device *device, int type)
return status;
}
static int
container_device_add(struct acpi_device **device, acpi_handle handle)
static int container_device_add(struct acpi_device **device, acpi_handle handle)
{
acpi_handle phandle;
struct acpi_device *pdev;
@ -158,10 +151,9 @@ container_device_add(struct acpi_device **device, acpi_handle handle)
return_VALUE(result);
}
static void
container_notify_cb(acpi_handle handle, u32 type, void *context)
static void container_notify_cb(acpi_handle handle, u32 type, void *context)
{
struct acpi_device *device = NULL;
struct acpi_device *device = NULL;
int result;
int present;
acpi_status status;
@ -169,14 +161,14 @@ container_notify_cb(acpi_handle handle, u32 type, void *context)
ACPI_FUNCTION_TRACE("container_notify_cb");
present = is_device_present(handle);
switch (type) {
case ACPI_NOTIFY_BUS_CHECK:
/* Fall through */
case ACPI_NOTIFY_DEVICE_CHECK:
printk("Container driver received %s event\n",
(type == ACPI_NOTIFY_BUS_CHECK)?
"ACPI_NOTIFY_BUS_CHECK":"ACPI_NOTIFY_DEVICE_CHECK");
(type == ACPI_NOTIFY_BUS_CHECK) ?
"ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
status = acpi_bus_get_device(handle, &device);
if (present) {
if (ACPI_FAILURE(status) || !device) {
@ -207,15 +199,13 @@ container_notify_cb(acpi_handle handle, u32 type, void *context)
static acpi_status
container_walk_namespace_cb(acpi_handle handle,
u32 lvl,
void *context,
void **rv)
u32 lvl, void *context, void **rv)
{
char *hid = NULL;
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_device_info *info;
acpi_status status;
int *action = context;
char *hid = NULL;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_device_info *info;
acpi_status status;
int *action = context;
ACPI_FUNCTION_TRACE("container_walk_namespace_cb");
@ -233,66 +223,60 @@ container_walk_namespace_cb(acpi_handle handle,
}
if (strcmp(hid, "ACPI0004") && strcmp(hid, "PNP0A05") &&
strcmp(hid, "PNP0A06")) {
strcmp(hid, "PNP0A06")) {
goto end;
}
switch(*action) {
switch (*action) {
case INSTALL_NOTIFY_HANDLER:
acpi_install_notify_handler(handle,
ACPI_SYSTEM_NOTIFY,
container_notify_cb,
NULL);
ACPI_SYSTEM_NOTIFY,
container_notify_cb, NULL);
break;
case UNINSTALL_NOTIFY_HANDLER:
acpi_remove_notify_handler(handle,
ACPI_SYSTEM_NOTIFY,
container_notify_cb);
ACPI_SYSTEM_NOTIFY,
container_notify_cb);
break;
default:
break;
}
end:
end:
acpi_os_free(buffer.pointer);
return_ACPI_STATUS(AE_OK);
}
static int __init
acpi_container_init(void)
static int __init acpi_container_init(void)
{
int result = 0;
int action = INSTALL_NOTIFY_HANDLER;
int result = 0;
int action = INSTALL_NOTIFY_HANDLER;
result = acpi_bus_register_driver(&acpi_container_driver);
if (result < 0) {
return(result);
return (result);
}
/* register notify handler to every container device */
acpi_walk_namespace(ACPI_TYPE_DEVICE,
ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
container_walk_namespace_cb,
&action, NULL);
ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
container_walk_namespace_cb, &action, NULL);
return(0);
return (0);
}
static void __exit
acpi_container_exit(void)
static void __exit acpi_container_exit(void)
{
int action = UNINSTALL_NOTIFY_HANDLER;
int action = UNINSTALL_NOTIFY_HANDLER;
ACPI_FUNCTION_TRACE("acpi_container_exit");
acpi_walk_namespace(ACPI_TYPE_DEVICE,
ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
container_walk_namespace_cb,
&action, NULL);
ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
container_walk_namespace_cb, &action, NULL);
acpi_bus_unregister_driver(&acpi_container_driver);

View File

@ -12,17 +12,14 @@
#include <acpi/acglobal.h>
#define _COMPONENT ACPI_SYSTEM_COMPONENT
ACPI_MODULE_NAME ("debug")
ACPI_MODULE_NAME("debug")
#define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer"
#define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level"
#ifdef MODULE_PARAM_PREFIX
#undef MODULE_PARAM_PREFIX
#endif
#define MODULE_PARAM_PREFIX
module_param(acpi_dbg_layer, uint, 0400);
module_param(acpi_dbg_layer, uint, 0400);
module_param(acpi_dbg_level, uint, 0400);
struct acpi_dlayer {
@ -35,8 +32,7 @@ struct acpi_dlevel {
};
#define ACPI_DEBUG_INIT(v) { .name = #v, .value = v }
static const struct acpi_dlayer acpi_debug_layers[] =
{
static const struct acpi_dlayer acpi_debug_layers[] = {
ACPI_DEBUG_INIT(ACPI_UTILITIES),
ACPI_DEBUG_INIT(ACPI_HARDWARE),
ACPI_DEBUG_INIT(ACPI_EVENTS),
@ -53,8 +49,7 @@ static const struct acpi_dlayer acpi_debug_layers[] =
ACPI_DEBUG_INIT(ACPI_TOOLS),
};
static const struct acpi_dlevel acpi_debug_levels[] =
{
static const struct acpi_dlevel acpi_debug_levels[] = {
ACPI_DEBUG_INIT(ACPI_LV_ERROR),
ACPI_DEBUG_INIT(ACPI_LV_WARN),
ACPI_DEBUG_INIT(ACPI_LV_INIT),
@ -88,81 +83,77 @@ static const struct acpi_dlevel acpi_debug_levels[] =
ACPI_DEBUG_INIT(ACPI_LV_AML_DISASSEMBLE),
ACPI_DEBUG_INIT(ACPI_LV_VERBOSE_INFO),
ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES),
ACPI_DEBUG_INIT(ACPI_LV_EVENTS),
ACPI_DEBUG_INIT(ACPI_LV_EVENTS),
};
static int
acpi_system_read_debug (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
acpi_system_read_debug(char *page,
char **start, off_t off, int count, int *eof, void *data)
{
char *p = page;
int size = 0;
unsigned int i;
char *p = page;
int size = 0;
unsigned int i;
if (off != 0)
goto end;
p += sprintf(p, "%-25s\tHex SET\n", "Description");
switch ((unsigned long) data) {
switch ((unsigned long)data) {
case 0:
for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) {
p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
acpi_debug_layers[i].name,
acpi_debug_layers[i].value,
(acpi_dbg_layer & acpi_debug_layers[i].value) ?
'*' : ' ');
acpi_debug_layers[i].name,
acpi_debug_layers[i].value,
(acpi_dbg_layer & acpi_debug_layers[i].
value) ? '*' : ' ');
}
p += sprintf(p, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS",
ACPI_ALL_DRIVERS,
(acpi_dbg_layer & ACPI_ALL_DRIVERS) == ACPI_ALL_DRIVERS?
'*' : (acpi_dbg_layer & ACPI_ALL_DRIVERS) == 0 ?
' ' : '-');
ACPI_ALL_DRIVERS,
(acpi_dbg_layer & ACPI_ALL_DRIVERS) ==
ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer &
ACPI_ALL_DRIVERS) ==
0 ? ' ' : '-');
p += sprintf(p,
"--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n",
acpi_dbg_layer);
"--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n",
acpi_dbg_layer);
break;
case 1:
for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) {
p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
acpi_debug_levels[i].name,
acpi_debug_levels[i].value,
(acpi_dbg_level & acpi_debug_levels[i].value) ?
'*' : ' ');
acpi_debug_levels[i].name,
acpi_debug_levels[i].value,
(acpi_dbg_level & acpi_debug_levels[i].
value) ? '*' : ' ');
}
p += sprintf(p, "--\ndebug_level = 0x%08X (* = enabled)\n",
acpi_dbg_level);
acpi_dbg_level);
break;
default:
p += sprintf(p, "Invalid debug option\n");
break;
}
end:
end:
size = (p - page);
if (size <= off+count) *eof = 1;
if (size <= off + count)
*eof = 1;
*start = page + off;
size -= off;
if (size>count) size = count;
if (size<0) size = 0;
if (size > count)
size = count;
if (size < 0)
size = 0;
return size;
}
static int
acpi_system_write_debug (
struct file *file,
const char __user *buffer,
unsigned long count,
void *data)
acpi_system_write_debug(struct file *file,
const char __user * buffer,
unsigned long count, void *data)
{
char debug_string[12] = {'\0'};
char debug_string[12] = { '\0' };
ACPI_FUNCTION_TRACE("acpi_system_write_debug");
@ -174,7 +165,7 @@ acpi_system_write_debug (
debug_string[count] = '\0';
switch ((unsigned long) data) {
switch ((unsigned long)data) {
case 0:
acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0);
break;
@ -190,9 +181,9 @@ acpi_system_write_debug (
static int __init acpi_debug_init(void)
{
struct proc_dir_entry *entry;
struct proc_dir_entry *entry;
int error = 0;
char * name;
char *name;
ACPI_FUNCTION_TRACE("acpi_debug_init");
@ -201,8 +192,10 @@ static int __init acpi_debug_init(void)
/* 'debug_layer' [R/W] */
name = ACPI_SYSTEM_FILE_DEBUG_LAYER;
entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir,
acpi_system_read_debug,(void *)0);
entry =
create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
acpi_root_dir, acpi_system_read_debug,
(void *)0);
if (entry)
entry->write_proc = acpi_system_write_debug;
else
@ -210,19 +203,21 @@ static int __init acpi_debug_init(void)
/* 'debug_level' [R/W] */
name = ACPI_SYSTEM_FILE_DEBUG_LEVEL;
entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir,
acpi_system_read_debug, (void *)1);
if (entry)
entry =
create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
acpi_root_dir, acpi_system_read_debug,
(void *)1);
if (entry)
entry->write_proc = acpi_system_write_debug;
else
goto Error;
Done:
Done:
return_VALUE(error);
Error:
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' proc fs entry\n", name));
Error:
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' proc fs entry\n", name));
remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir);
remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir);

View File

@ -41,7 +41,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/amlcode.h>
#include <acpi/acdispat.h>
@ -49,18 +48,14 @@
#include <acpi/acnamesp.h>
#include <acpi/acparser.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsfield")
ACPI_MODULE_NAME("dsfield")
/* Local prototypes */
static acpi_status
acpi_ds_get_field_names (
struct acpi_create_field_info *info,
struct acpi_walk_state *walk_state,
union acpi_parse_object *arg);
acpi_ds_get_field_names(struct acpi_create_field_info *info,
struct acpi_walk_state *walk_state,
union acpi_parse_object *arg);
/*******************************************************************************
*
@ -82,41 +77,36 @@ acpi_ds_get_field_names (
******************************************************************************/
acpi_status
acpi_ds_create_buffer_field (
union acpi_parse_object *op,
struct acpi_walk_state *walk_state)
acpi_ds_create_buffer_field(union acpi_parse_object *op,
struct acpi_walk_state *walk_state)
{
union acpi_parse_object *arg;
struct acpi_namespace_node *node;
acpi_status status;
union acpi_operand_object *obj_desc;
union acpi_operand_object *second_desc = NULL;
u32 flags;
ACPI_FUNCTION_TRACE ("ds_create_buffer_field");
union acpi_parse_object *arg;
struct acpi_namespace_node *node;
acpi_status status;
union acpi_operand_object *obj_desc;
union acpi_operand_object *second_desc = NULL;
u32 flags;
ACPI_FUNCTION_TRACE("ds_create_buffer_field");
/* Get the name_string argument */
if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
arg = acpi_ps_get_arg (op, 3);
}
else {
arg = acpi_ps_get_arg(op, 3);
} else {
/* Create Bit/Byte/Word/Dword field */
arg = acpi_ps_get_arg (op, 2);
arg = acpi_ps_get_arg(op, 2);
}
if (!arg) {
return_ACPI_STATUS (AE_AML_NO_OPERAND);
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
if (walk_state->deferred_node) {
node = walk_state->deferred_node;
status = AE_OK;
}
else {
} else {
/*
* During the load phase, we want to enter the name of the field into
* the namespace. During the execute phase (when we evaluate the size
@ -124,21 +114,22 @@ acpi_ds_create_buffer_field (
*/
if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) {
flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
}
else {
} else {
flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
ACPI_NS_ERROR_IF_FOUND;
ACPI_NS_ERROR_IF_FOUND;
}
/*
* Enter the name_string into the namespace
*/
status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1,
flags, walk_state, &(node));
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (arg->common.value.string, status);
return_ACPI_STATUS (status);
status =
acpi_ns_lookup(walk_state->scope_info,
arg->common.value.string, ACPI_TYPE_ANY,
ACPI_IMODE_LOAD_PASS1, flags, walk_state,
&(node));
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(arg->common.value.string, status);
return_ACPI_STATUS(status);
}
}
@ -153,9 +144,9 @@ acpi_ds_create_buffer_field (
* and we need to create the field object. Otherwise, this was a lookup
* of an existing node and we don't want to create the field object again.
*/
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*
@ -165,7 +156,7 @@ acpi_ds_create_buffer_field (
/* Create the buffer field object */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER_FIELD);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER_FIELD);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -176,28 +167,26 @@ acpi_ds_create_buffer_field (
* opcode and operands -- since the buffer and index
* operands must be evaluated.
*/
second_desc = obj_desc->common.next_object;
second_desc = obj_desc->common.next_object;
second_desc->extra.aml_start = op->named.data;
second_desc->extra.aml_length = op->named.length;
obj_desc->buffer_field.node = node;
/* Attach constructed field descriptors to parent node */
status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_BUFFER_FIELD);
if (ACPI_FAILURE (status)) {
status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_BUFFER_FIELD);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
cleanup:
cleanup:
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_get_field_names
@ -214,17 +203,14 @@ cleanup:
******************************************************************************/
static acpi_status
acpi_ds_get_field_names (
struct acpi_create_field_info *info,
struct acpi_walk_state *walk_state,
union acpi_parse_object *arg)
acpi_ds_get_field_names(struct acpi_create_field_info *info,
struct acpi_walk_state *walk_state,
union acpi_parse_object *arg)
{
acpi_status status;
acpi_integer position;
ACPI_FUNCTION_TRACE_PTR ("ds_get_field_names", info);
acpi_status status;
acpi_integer position;
ACPI_FUNCTION_TRACE_PTR("ds_get_field_names", info);
/* First field starts at bit zero */
@ -243,18 +229,16 @@ acpi_ds_get_field_names (
case AML_INT_RESERVEDFIELD_OP:
position = (acpi_integer) info->field_bit_position
+ (acpi_integer) arg->common.value.size;
+ (acpi_integer) arg->common.value.size;
if (position > ACPI_UINT32_MAX) {
ACPI_REPORT_ERROR ((
"Bit offset within field too large (> 0xFFFFFFFF)\n"));
return_ACPI_STATUS (AE_SUPPORT);
ACPI_REPORT_ERROR(("Bit offset within field too large (> 0xFFFFFFFF)\n"));
return_ACPI_STATUS(AE_SUPPORT);
}
info->field_bit_position = (u32) position;
break;
case AML_INT_ACCESSFIELD_OP:
/*
@ -266,73 +250,70 @@ acpi_ds_get_field_names (
* ACCESS_TYPE bits
*/
info->field_flags = (u8)
((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
((u8) ((u32) arg->common.value.integer >> 8)));
((info->
field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
((u8) ((u32) arg->common.value.integer >> 8)));
info->attribute = (u8) (arg->common.value.integer);
break;
case AML_INT_NAMEDFIELD_OP:
/* Lookup the name */
status = acpi_ns_lookup (walk_state->scope_info,
(char *) &arg->named.name,
info->field_type, ACPI_IMODE_EXECUTE,
ACPI_NS_DONT_OPEN_SCOPE,
walk_state, &info->field_node);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR ((char *) &arg->named.name, status);
status = acpi_ns_lookup(walk_state->scope_info,
(char *)&arg->named.name,
info->field_type,
ACPI_IMODE_EXECUTE,
ACPI_NS_DONT_OPEN_SCOPE,
walk_state, &info->field_node);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR((char *)&arg->named.name,
status);
if (status != AE_ALREADY_EXISTS) {
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/* Already exists, ignore error */
}
else {
} else {
arg->common.node = info->field_node;
info->field_bit_length = arg->common.value.size;
/* Create and initialize an object for the new Field Node */
status = acpi_ex_prep_field_value (info);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ex_prep_field_value(info);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
/* Keep track of bit position for the next field */
position = (acpi_integer) info->field_bit_position
+ (acpi_integer) arg->common.value.size;
+ (acpi_integer) arg->common.value.size;
if (position > ACPI_UINT32_MAX) {
ACPI_REPORT_ERROR ((
"Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n",
(char *) &info->field_node->name));
return_ACPI_STATUS (AE_SUPPORT);
ACPI_REPORT_ERROR(("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", (char *)&info->field_node->name));
return_ACPI_STATUS(AE_SUPPORT);
}
info->field_bit_position += info->field_bit_length;
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Invalid opcode in field list: %X\n",
arg->common.aml_opcode));
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Invalid opcode in field list: %X\n",
arg->common.aml_opcode));
return_ACPI_STATUS(AE_AML_BAD_OPCODE);
}
arg = arg->common.next;
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_create_field
@ -348,29 +329,28 @@ acpi_ds_get_field_names (
******************************************************************************/
acpi_status
acpi_ds_create_field (
union acpi_parse_object *op,
struct acpi_namespace_node *region_node,
struct acpi_walk_state *walk_state)
acpi_ds_create_field(union acpi_parse_object *op,
struct acpi_namespace_node *region_node,
struct acpi_walk_state *walk_state)
{
acpi_status status;
union acpi_parse_object *arg;
struct acpi_create_field_info info;
ACPI_FUNCTION_TRACE_PTR ("ds_create_field", op);
acpi_status status;
union acpi_parse_object *arg;
struct acpi_create_field_info info;
ACPI_FUNCTION_TRACE_PTR("ds_create_field", op);
/* First arg is the name of the parent op_region (must already exist) */
arg = op->common.value.arg;
if (!region_node) {
status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.name,
ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state, &region_node);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (arg->common.value.name, status);
return_ACPI_STATUS (status);
status =
acpi_ns_lookup(walk_state->scope_info,
arg->common.value.name, ACPI_TYPE_REGION,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
walk_state, &region_node);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(arg->common.value.name, status);
return_ACPI_STATUS(status);
}
}
@ -385,12 +365,11 @@ acpi_ds_create_field (
info.field_type = ACPI_TYPE_LOCAL_REGION_FIELD;
info.region_node = region_node;
status = acpi_ds_get_field_names (&info, walk_state, arg->common.next);
status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_init_field_objects
@ -407,37 +386,34 @@ acpi_ds_create_field (
******************************************************************************/
acpi_status
acpi_ds_init_field_objects (
union acpi_parse_object *op,
struct acpi_walk_state *walk_state)
acpi_ds_init_field_objects(union acpi_parse_object *op,
struct acpi_walk_state *walk_state)
{
acpi_status status;
union acpi_parse_object *arg = NULL;
struct acpi_namespace_node *node;
u8 type = 0;
ACPI_FUNCTION_TRACE_PTR ("ds_init_field_objects", op);
acpi_status status;
union acpi_parse_object *arg = NULL;
struct acpi_namespace_node *node;
u8 type = 0;
ACPI_FUNCTION_TRACE_PTR("ds_init_field_objects", op);
switch (walk_state->opcode) {
case AML_FIELD_OP:
arg = acpi_ps_get_arg (op, 2);
arg = acpi_ps_get_arg(op, 2);
type = ACPI_TYPE_LOCAL_REGION_FIELD;
break;
case AML_BANK_FIELD_OP:
arg = acpi_ps_get_arg (op, 4);
arg = acpi_ps_get_arg(op, 4);
type = ACPI_TYPE_LOCAL_BANK_FIELD;
break;
case AML_INDEX_FIELD_OP:
arg = acpi_ps_get_arg (op, 3);
arg = acpi_ps_get_arg(op, 3);
type = ACPI_TYPE_LOCAL_INDEX_FIELD;
break;
default:
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/*
@ -447,16 +423,18 @@ acpi_ds_init_field_objects (
/* Ignore OFFSET and ACCESSAS terms here */
if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
status = acpi_ns_lookup (walk_state->scope_info,
(char *) &arg->named.name,
type, ACPI_IMODE_LOAD_PASS1,
ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
ACPI_NS_ERROR_IF_FOUND,
walk_state, &node);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR ((char *) &arg->named.name, status);
status = acpi_ns_lookup(walk_state->scope_info,
(char *)&arg->named.name,
type, ACPI_IMODE_LOAD_PASS1,
ACPI_NS_NO_UPSEARCH |
ACPI_NS_DONT_OPEN_SCOPE |
ACPI_NS_ERROR_IF_FOUND,
walk_state, &node);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR((char *)&arg->named.name,
status);
if (status != AE_ALREADY_EXISTS) {
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/* Name already exists, just ignore this error */
@ -472,10 +450,9 @@ acpi_ds_init_field_objects (
arg = arg->common.next;
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_create_bank_field
@ -491,41 +468,42 @@ acpi_ds_init_field_objects (
******************************************************************************/
acpi_status
acpi_ds_create_bank_field (
union acpi_parse_object *op,
struct acpi_namespace_node *region_node,
struct acpi_walk_state *walk_state)
acpi_ds_create_bank_field(union acpi_parse_object *op,
struct acpi_namespace_node *region_node,
struct acpi_walk_state *walk_state)
{
acpi_status status;
union acpi_parse_object *arg;
struct acpi_create_field_info info;
ACPI_FUNCTION_TRACE_PTR ("ds_create_bank_field", op);
acpi_status status;
union acpi_parse_object *arg;
struct acpi_create_field_info info;
ACPI_FUNCTION_TRACE_PTR("ds_create_bank_field", op);
/* First arg is the name of the parent op_region (must already exist) */
arg = op->common.value.arg;
if (!region_node) {
status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.name,
ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state, &region_node);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (arg->common.value.name, status);
return_ACPI_STATUS (status);
status =
acpi_ns_lookup(walk_state->scope_info,
arg->common.value.name, ACPI_TYPE_REGION,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
walk_state, &region_node);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(arg->common.value.name, status);
return_ACPI_STATUS(status);
}
}
/* Second arg is the Bank Register (Field) (must already exist) */
arg = arg->common.next;
status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (arg->common.value.string, status);
return_ACPI_STATUS (status);
status =
acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state,
&info.register_node);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(arg->common.value.string, status);
return_ACPI_STATUS(status);
}
/* Third arg is the bank_value */
@ -543,12 +521,11 @@ acpi_ds_create_bank_field (
info.field_type = ACPI_TYPE_LOCAL_BANK_FIELD;
info.region_node = region_node;
status = acpi_ds_get_field_names (&info, walk_state, arg->common.next);
status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_create_index_field
@ -564,39 +541,40 @@ acpi_ds_create_bank_field (
******************************************************************************/
acpi_status
acpi_ds_create_index_field (
union acpi_parse_object *op,
struct acpi_namespace_node *region_node,
struct acpi_walk_state *walk_state)
acpi_ds_create_index_field(union acpi_parse_object *op,
struct acpi_namespace_node *region_node,
struct acpi_walk_state *walk_state)
{
acpi_status status;
union acpi_parse_object *arg;
struct acpi_create_field_info info;
ACPI_FUNCTION_TRACE_PTR ("ds_create_index_field", op);
acpi_status status;
union acpi_parse_object *arg;
struct acpi_create_field_info info;
ACPI_FUNCTION_TRACE_PTR("ds_create_index_field", op);
/* First arg is the name of the Index register (must already exist) */
arg = op->common.value.arg;
status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (arg->common.value.string, status);
return_ACPI_STATUS (status);
status =
acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state,
&info.register_node);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(arg->common.value.string, status);
return_ACPI_STATUS(status);
}
/* Second arg is the data register (must already exist) */
arg = arg->common.next;
status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state, &info.data_register_node);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (arg->common.value.string, status);
return_ACPI_STATUS (status);
status =
acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state,
&info.data_register_node);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(arg->common.value.string, status);
return_ACPI_STATUS(status);
}
/* Next arg is the field flags */
@ -609,9 +587,7 @@ acpi_ds_create_index_field (
info.field_type = ACPI_TYPE_LOCAL_INDEX_FIELD;
info.region_node = region_node;
status = acpi_ds_get_field_names (&info, walk_state, arg->common.next);
status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -41,23 +41,17 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acdispat.h>
#include <acpi/acnamesp.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsinit")
ACPI_MODULE_NAME("dsinit")
/* Local prototypes */
static acpi_status
acpi_ds_init_one_object (
acpi_handle obj_handle,
u32 level,
void *context,
void **return_value);
acpi_ds_init_one_object(acpi_handle obj_handle,
u32 level, void *context, void **return_value);
/*******************************************************************************
*
@ -80,26 +74,23 @@ acpi_ds_init_one_object (
******************************************************************************/
static acpi_status
acpi_ds_init_one_object (
acpi_handle obj_handle,
u32 level,
void *context,
void **return_value)
acpi_ds_init_one_object(acpi_handle obj_handle,
u32 level, void *context, void **return_value)
{
acpi_object_type type;
acpi_status status;
struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context;
ACPI_FUNCTION_NAME ("ds_init_one_object");
struct acpi_init_walk_info *info =
(struct acpi_init_walk_info *)context;
struct acpi_namespace_node *node =
(struct acpi_namespace_node *)obj_handle;
acpi_object_type type;
acpi_status status;
ACPI_FUNCTION_NAME("ds_init_one_object");
/*
* We are only interested in objects owned by the table that
* We are only interested in NS nodes owned by the table that
* was just loaded
*/
if (((struct acpi_namespace_node *) obj_handle)->owner_id !=
info->table_desc->table_id) {
if (node->owner_id != info->table_desc->owner_id) {
return (AE_OK);
}
@ -107,33 +98,31 @@ acpi_ds_init_one_object (
/* And even then, we are only interested in a few object types */
type = acpi_ns_get_type (obj_handle);
type = acpi_ns_get_type(obj_handle);
switch (type) {
case ACPI_TYPE_REGION:
status = acpi_ds_initialize_region (obj_handle);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Region %p [%4.4s] - Init failure, %s\n",
obj_handle, acpi_ut_get_node_name (obj_handle),
acpi_format_exception (status)));
status = acpi_ds_initialize_region(obj_handle);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Region %p [%4.4s] - Init failure, %s\n",
obj_handle,
acpi_ut_get_node_name(obj_handle),
acpi_format_exception(status)));
}
info->op_region_count++;
break;
case ACPI_TYPE_METHOD:
info->method_count++;
/*
* Print a dot for each method unless we are going to print
* the entire pathname
*/
if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
}
/*
@ -143,41 +132,32 @@ acpi_ds_init_one_object (
* on a per-table basis. Currently, we just use a global for the width.
*/
if (info->table_desc->pointer->revision == 1) {
((struct acpi_namespace_node *) obj_handle)->flags |= ANOBJ_DATA_WIDTH_32;
node->flags |= ANOBJ_DATA_WIDTH_32;
}
/*
* Always parse methods to detect errors, we will delete
* the parse tree below
*/
status = acpi_ds_parse_method (obj_handle);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Method %p [%4.4s] - parse failure, %s\n",
obj_handle, acpi_ut_get_node_name (obj_handle),
acpi_format_exception (status)));
status = acpi_ds_parse_method(obj_handle);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"\n+Method %p [%4.4s] - parse failure, %s\n",
obj_handle,
acpi_ut_get_node_name(obj_handle),
acpi_format_exception(status)));
/* This parse failed, but we will continue parsing more methods */
break;
}
/*
* Delete the parse tree. We simply re-parse the method
* for every execution since there isn't much overhead
*/
acpi_ns_delete_namespace_subtree (obj_handle);
acpi_ns_delete_namespace_by_owner (
((struct acpi_namespace_node *) obj_handle)->object->method.owning_id);
info->method_count++;
break;
case ACPI_TYPE_DEVICE:
info->device_count++;
break;
default:
break;
}
@ -189,7 +169,6 @@ acpi_ds_init_one_object (
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_initialize_objects
@ -205,45 +184,43 @@ acpi_ds_init_one_object (
******************************************************************************/
acpi_status
acpi_ds_initialize_objects (
struct acpi_table_desc *table_desc,
struct acpi_namespace_node *start_node)
acpi_ds_initialize_objects(struct acpi_table_desc * table_desc,
struct acpi_namespace_node * start_node)
{
acpi_status status;
struct acpi_init_walk_info info;
acpi_status status;
struct acpi_init_walk_info info;
ACPI_FUNCTION_TRACE("ds_initialize_objects");
ACPI_FUNCTION_TRACE ("ds_initialize_objects");
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"**** Starting initialization of namespace objects ****\n"));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"**** Starting initialization of namespace objects ****\n"));
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:"));
info.method_count = 0;
info.method_count = 0;
info.op_region_count = 0;
info.object_count = 0;
info.device_count = 0;
info.table_desc = table_desc;
info.object_count = 0;
info.device_count = 0;
info.table_desc = table_desc;
/* Walk entire namespace from the supplied root */
status = acpi_walk_namespace (ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
acpi_ds_init_one_object, &info, NULL);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed, %s\n",
acpi_format_exception (status)));
status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
acpi_ds_init_one_object, &info, NULL);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed, %s\n",
acpi_format_exception(status)));
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
"\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
table_desc->pointer->signature, table_desc->table_id, info.object_count,
info.device_count, info.method_count, info.op_region_count));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
"\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
table_desc->pointer->signature,
table_desc->owner_id, info.object_count,
info.device_count, info.method_count,
info.op_region_count));
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"%hd Methods, %hd Regions\n", info.method_count, info.op_region_count));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"%hd Methods, %hd Regions\n", info.method_count,
info.op_region_count));
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}

View File

@ -41,7 +41,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acparser.h>
#include <acpi/amlcode.h>
@ -49,67 +48,57 @@
#include <acpi/acinterp.h>
#include <acpi/acnamesp.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsmethod")
ACPI_MODULE_NAME("dsmethod")
/*******************************************************************************
*
* FUNCTION: acpi_ds_parse_method
*
* PARAMETERS: obj_handle - Method node
* PARAMETERS: Node - Method node
*
* RETURN: Status
*
* DESCRIPTION: Call the parser and parse the AML that is associated with the
* method.
* DESCRIPTION: Parse the AML that is associated with the method.
*
* MUTEX: Assumes parser is locked
*
******************************************************************************/
acpi_status
acpi_ds_parse_method (
acpi_handle obj_handle)
acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
{
acpi_status status;
union acpi_operand_object *obj_desc;
union acpi_parse_object *op;
struct acpi_namespace_node *node;
acpi_owner_id owner_id;
struct acpi_walk_state *walk_state;
ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", obj_handle);
acpi_status status;
union acpi_operand_object *obj_desc;
union acpi_parse_object *op;
struct acpi_walk_state *walk_state;
ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node);
/* Parameter Validation */
if (!obj_handle) {
return_ACPI_STATUS (AE_NULL_ENTRY);
if (!node) {
return_ACPI_STATUS(AE_NULL_ENTRY);
}
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** named_obj=%p\n",
acpi_ut_get_node_name (obj_handle), obj_handle));
ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
"**** Parsing [%4.4s] **** named_obj=%p\n",
acpi_ut_get_node_name(node), node));
/* Extract the method object from the method Node */
node = (struct acpi_namespace_node *) obj_handle;
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
return_ACPI_STATUS (AE_NULL_OBJECT);
return_ACPI_STATUS(AE_NULL_OBJECT);
}
/* Create a mutex for the method if there is a concurrency limit */
if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&
(!obj_desc->method.semaphore)) {
status = acpi_os_create_semaphore (obj_desc->method.concurrency,
obj_desc->method.concurrency,
&obj_desc->method.semaphore);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
(!obj_desc->method.semaphore)) {
status = acpi_os_create_semaphore(obj_desc->method.concurrency,
obj_desc->method.concurrency,
&obj_desc->method.semaphore);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
@ -117,14 +106,14 @@ acpi_ds_parse_method (
* Allocate a new parser op to be the root of the parsed
* method tree
*/
op = acpi_ps_alloc_op (AML_METHOD_OP);
op = acpi_ps_alloc_op(AML_METHOD_OP);
if (!op) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Init new op with the method name and pointer back to the Node */
acpi_ps_set_name (op, node->name.integer);
acpi_ps_set_name(op, node->name.integer);
op->common.node = node;
/*
@ -132,22 +121,27 @@ acpi_ds_parse_method (
* objects (such as Operation Regions) can be created during the
* first pass parse.
*/
owner_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
obj_desc->method.owning_id = owner_id;
status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
/* Create and initialize a new walk state */
walk_state = acpi_ds_create_walk_state (owner_id, NULL, NULL, NULL);
walk_state =
acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
NULL);
if (!walk_state) {
return_ACPI_STATUS (AE_NO_MEMORY);
status = AE_NO_MEMORY;
goto cleanup2;
}
status = acpi_ds_init_aml_walk (walk_state, op, node,
obj_desc->method.aml_start,
obj_desc->method.aml_length, NULL, 1);
if (ACPI_FAILURE (status)) {
acpi_ds_delete_walk_state (walk_state);
return_ACPI_STATUS (status);
status = acpi_ds_init_aml_walk(walk_state, op, node,
obj_desc->method.aml_start,
obj_desc->method.aml_length, NULL, 1);
if (ACPI_FAILURE(status)) {
acpi_ds_delete_walk_state(walk_state);
goto cleanup2;
}
/*
@ -159,20 +153,31 @@ acpi_ds_parse_method (
* method so that operands to the named objects can take on dynamic
* run-time values.
*/
status = acpi_ps_parse_aml (walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ps_parse_aml(walk_state);
if (ACPI_FAILURE(status)) {
goto cleanup2;
}
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
acpi_ut_get_node_name (obj_handle), obj_handle, op));
ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
"**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
acpi_ut_get_node_name(node), node, op));
acpi_ps_delete_parse_tree (op);
return_ACPI_STATUS (status);
/*
* Delete the parse tree. We simply re-parse the method for every
* execution since there isn't much overhead (compared to keeping lots
* of parse trees around)
*/
acpi_ns_delete_namespace_subtree(node);
acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
cleanup2:
acpi_ut_release_owner_id(&obj_desc->method.owner_id);
cleanup:
acpi_ps_delete_parse_tree(op);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_begin_method_execution
@ -190,19 +195,23 @@ acpi_ds_parse_method (
******************************************************************************/
acpi_status
acpi_ds_begin_method_execution (
struct acpi_namespace_node *method_node,
union acpi_operand_object *obj_desc,
struct acpi_namespace_node *calling_method_node)
acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
union acpi_operand_object *obj_desc,
struct acpi_namespace_node *calling_method_node)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_PTR ("ds_begin_method_execution", method_node);
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_PTR("ds_begin_method_execution", method_node);
if (!method_node) {
return_ACPI_STATUS (AE_NULL_ENTRY);
return_ACPI_STATUS(AE_NULL_ENTRY);
}
/* Prevent wraparound of thread count */
if (obj_desc->method.thread_count == ACPI_UINT8_MAX) {
ACPI_REPORT_ERROR(("Method reached maximum reentrancy limit (255)\n"));
return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
}
/*
@ -219,8 +228,9 @@ acpi_ds_begin_method_execution (
* thread that is making recursive method calls.
*/
if (method_node == calling_method_node) {
if (obj_desc->method.thread_count >= obj_desc->method.concurrency) {
return_ACPI_STATUS (AE_AML_METHOD_LIMIT);
if (obj_desc->method.thread_count >=
obj_desc->method.concurrency) {
return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
}
}
@ -228,8 +238,21 @@ acpi_ds_begin_method_execution (
* Get a unit from the method semaphore. This releases the
* interpreter if we block
*/
status = acpi_ex_system_wait_semaphore (obj_desc->method.semaphore,
ACPI_WAIT_FOREVER);
status =
acpi_ex_system_wait_semaphore(obj_desc->method.semaphore,
ACPI_WAIT_FOREVER);
}
/*
* Allocate an Owner ID for this method, only if this is the first thread
* to begin concurrent execution. We only need one owner_id, even if the
* method is invoked recursively.
*/
if (!obj_desc->method.owner_id) {
status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
/*
@ -237,10 +260,9 @@ acpi_ds_begin_method_execution (
* reentered one more time (even if it is the same thread)
*/
obj_desc->method.thread_count++;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_call_control_method
@ -256,101 +278,99 @@ acpi_ds_begin_method_execution (
******************************************************************************/
acpi_status
acpi_ds_call_control_method (
struct acpi_thread_state *thread,
struct acpi_walk_state *this_walk_state,
union acpi_parse_object *op)
acpi_ds_call_control_method(struct acpi_thread_state *thread,
struct acpi_walk_state *this_walk_state,
union acpi_parse_object *op)
{
acpi_status status;
struct acpi_namespace_node *method_node;
struct acpi_walk_state *next_walk_state;
union acpi_operand_object *obj_desc;
struct acpi_parameter_info info;
u32 i;
acpi_status status;
struct acpi_namespace_node *method_node;
struct acpi_walk_state *next_walk_state = NULL;
union acpi_operand_object *obj_desc;
struct acpi_parameter_info info;
u32 i;
ACPI_FUNCTION_TRACE_PTR("ds_call_control_method", this_walk_state);
ACPI_FUNCTION_TRACE_PTR ("ds_call_control_method", this_walk_state);
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n",
this_walk_state->prev_op, this_walk_state));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Execute method %p, currentstate=%p\n",
this_walk_state->prev_op, this_walk_state));
/*
* Get the namespace entry for the control method we are about to call
*/
method_node = this_walk_state->method_call_node;
if (!method_node) {
return_ACPI_STATUS (AE_NULL_ENTRY);
return_ACPI_STATUS(AE_NULL_ENTRY);
}
obj_desc = acpi_ns_get_attached_object (method_node);
obj_desc = acpi_ns_get_attached_object(method_node);
if (!obj_desc) {
return_ACPI_STATUS (AE_NULL_OBJECT);
return_ACPI_STATUS(AE_NULL_OBJECT);
}
obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
/* Init for new method, wait on concurrency semaphore */
status = acpi_ds_begin_method_execution (method_node, obj_desc,
this_walk_state->method_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_begin_method_execution(method_node, obj_desc,
this_walk_state->method_node);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) {
/* 1) Parse: Create a new walk state for the preempting walk */
next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
op, obj_desc, NULL);
next_walk_state =
acpi_ds_create_walk_state(obj_desc->method.owner_id, op,
obj_desc, NULL);
if (!next_walk_state) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Create and init a Root Node */
op = acpi_ps_create_scope_op ();
op = acpi_ps_create_scope_op();
if (!op) {
status = AE_NO_MEMORY;
goto cleanup;
}
status = acpi_ds_init_aml_walk (next_walk_state, op, method_node,
obj_desc->method.aml_start, obj_desc->method.aml_length,
NULL, 1);
if (ACPI_FAILURE (status)) {
acpi_ds_delete_walk_state (next_walk_state);
status = acpi_ds_init_aml_walk(next_walk_state, op, method_node,
obj_desc->method.aml_start,
obj_desc->method.aml_length,
NULL, 1);
if (ACPI_FAILURE(status)) {
acpi_ds_delete_walk_state(next_walk_state);
goto cleanup;
}
/* Begin AML parse */
status = acpi_ps_parse_aml (next_walk_state);
acpi_ps_delete_parse_tree (op);
status = acpi_ps_parse_aml(next_walk_state);
acpi_ps_delete_parse_tree(op);
}
/* 2) Execute: Create a new state for the preempting walk */
next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
NULL, obj_desc, thread);
next_walk_state = acpi_ds_create_walk_state(obj_desc->method.owner_id,
NULL, obj_desc, thread);
if (!next_walk_state) {
status = AE_NO_MEMORY;
goto cleanup;
}
/*
* The resolved arguments were put on the previous walk state's operand
* stack. Operands on the previous walk state stack always
* start at index 0.
* Null terminate the list of arguments
* stack. Operands on the previous walk state stack always
* start at index 0. Also, null terminate the list of arguments
*/
this_walk_state->operands [this_walk_state->num_operands] = NULL;
this_walk_state->operands[this_walk_state->num_operands] = NULL;
info.parameters = &this_walk_state->operands[0];
info.parameter_type = ACPI_PARAM_ARGS;
status = acpi_ds_init_aml_walk (next_walk_state, NULL, method_node,
obj_desc->method.aml_start, obj_desc->method.aml_length,
&info, 3);
if (ACPI_FAILURE (status)) {
status = acpi_ds_init_aml_walk(next_walk_state, NULL, method_node,
obj_desc->method.aml_start,
obj_desc->method.aml_length, &info, 3);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
@ -359,39 +379,38 @@ acpi_ds_call_control_method (
* (they were copied to new objects)
*/
for (i = 0; i < obj_desc->method.param_count; i++) {
acpi_ut_remove_reference (this_walk_state->operands [i]);
this_walk_state->operands [i] = NULL;
acpi_ut_remove_reference(this_walk_state->operands[i]);
this_walk_state->operands[i] = NULL;
}
/* Clear the operand stack */
this_walk_state->num_operands = 0;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Starting nested execution, newstate=%p\n", next_walk_state));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Starting nested execution, newstate=%p\n",
next_walk_state));
if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
status = obj_desc->method.implementation (next_walk_state);
return_ACPI_STATUS (status);
status = obj_desc->method.implementation(next_walk_state);
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(status);
cleanup:
/* Decrement the thread count on the method parse tree */
if (next_walk_state && (next_walk_state->method_desc)) {
next_walk_state->method_desc->method.thread_count--;
}
/* On error, we must delete the new walk state */
cleanup:
if (next_walk_state && (next_walk_state->method_desc)) {
/* Decrement the thread count on the method parse tree */
next_walk_state->method_desc->method.thread_count--;
}
(void) acpi_ds_terminate_control_method (next_walk_state);
acpi_ds_delete_walk_state (next_walk_state);
return_ACPI_STATUS (status);
acpi_ds_terminate_control_method(next_walk_state);
acpi_ds_delete_walk_state(next_walk_state);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_restart_control_method
@ -407,25 +426,22 @@ cleanup:
******************************************************************************/
acpi_status
acpi_ds_restart_control_method (
struct acpi_walk_state *walk_state,
union acpi_operand_object *return_desc)
acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
union acpi_operand_object *return_desc)
{
acpi_status status;
acpi_status status;
ACPI_FUNCTION_TRACE_PTR("ds_restart_control_method", walk_state);
ACPI_FUNCTION_TRACE_PTR ("ds_restart_control_method", walk_state);
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"****Restart [%4.4s] Op %p return_value_from_callee %p\n",
(char *)&walk_state->method_node->name,
walk_state->method_call_op, return_desc));
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"****Restart [%4.4s] Op %p return_value_from_callee %p\n",
(char *) &walk_state->method_node->name, walk_state->method_call_op,
return_desc));
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
" return_from_this_method_used?=%X res_stack %p Walk %p\n",
walk_state->return_used,
walk_state->results, walk_state));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
" return_from_this_method_used?=%X res_stack %p Walk %p\n",
walk_state->return_used,
walk_state->results, walk_state));
/* Did the called method return a value? */
@ -435,10 +451,10 @@ acpi_ds_restart_control_method (
if (walk_state->return_used) {
/* Save the return value from the previous method */
status = acpi_ds_result_push (return_desc, walk_state);
if (ACPI_FAILURE (status)) {
acpi_ut_remove_reference (return_desc);
return_ACPI_STATUS (status);
status = acpi_ds_result_push(return_desc, walk_state);
if (ACPI_FAILURE(status)) {
acpi_ut_remove_reference(return_desc);
return_ACPI_STATUS(status);
}
/*
@ -456,26 +472,26 @@ acpi_ds_restart_control_method (
* NOTE: this is optional because the ASL language does not actually
* support this behavior.
*/
else if (!acpi_ds_do_implicit_return (return_desc, walk_state, FALSE)) {
else if (!acpi_ds_do_implicit_return
(return_desc, walk_state, FALSE)) {
/*
* Delete the return value if it will not be used by the
* calling method
*/
acpi_ut_remove_reference (return_desc);
acpi_ut_remove_reference(return_desc);
}
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_terminate_control_method
*
* PARAMETERS: walk_state - State of the method
*
* RETURN: Status
* RETURN: None
*
* DESCRIPTION: Terminate a control method. Delete everything that the method
* created, delete all locals and arguments, and delete the parse
@ -483,63 +499,59 @@ acpi_ds_restart_control_method (
*
******************************************************************************/
acpi_status
acpi_ds_terminate_control_method (
struct acpi_walk_state *walk_state)
void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
{
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *method_node;
acpi_status status;
ACPI_FUNCTION_TRACE_PTR ("ds_terminate_control_method", walk_state);
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *method_node;
acpi_status status;
ACPI_FUNCTION_TRACE_PTR("ds_terminate_control_method", walk_state);
if (!walk_state) {
return (AE_BAD_PARAMETER);
return_VOID;
}
/* The current method object was saved in the walk state */
obj_desc = walk_state->method_desc;
if (!obj_desc) {
return_ACPI_STATUS (AE_OK);
return_VOID;
}
/* Delete all arguments and locals */
acpi_ds_method_data_delete_all (walk_state);
acpi_ds_method_data_delete_all(walk_state);
/*
* Lock the parser while we terminate this method.
* If this is the last thread executing the method,
* we have additional cleanup to perform
*/
status = acpi_ut_acquire_mutex (ACPI_MTX_PARSER);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_PARSER);
if (ACPI_FAILURE(status)) {
return_VOID;
}
/* Signal completion of the execution of this method if necessary */
if (walk_state->method_desc->method.semaphore) {
status = acpi_os_signal_semaphore (
walk_state->method_desc->method.semaphore, 1);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("Could not signal method semaphore\n"));
status = AE_OK;
status =
acpi_os_signal_semaphore(walk_state->method_desc->method.
semaphore, 1);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Could not signal method semaphore\n"));
/* Ignore error and continue cleanup */
}
}
if (walk_state->method_desc->method.thread_count) {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"*** Not deleting method namespace, there are still %d threads\n",
walk_state->method_desc->method.thread_count));
}
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"*** Not deleting method namespace, there are still %d threads\n",
walk_state->method_desc->method.
thread_count));
} else { /* This is the last executing thread */
if (!walk_state->method_desc->method.thread_count) {
/*
* Support to dynamically change a method from not_serialized to
* Serialized if it appears that the method is written foolishly and
@ -551,10 +563,11 @@ acpi_ds_terminate_control_method (
* before creating the synchronization semaphore.
*/
if ((walk_state->method_desc->method.concurrency == 1) &&
(!walk_state->method_desc->method.semaphore)) {
status = acpi_os_create_semaphore (1,
1,
&walk_state->method_desc->method.semaphore);
(!walk_state->method_desc->method.semaphore)) {
status = acpi_os_create_semaphore(1, 1,
&walk_state->
method_desc->method.
semaphore);
}
/*
@ -569,28 +582,27 @@ acpi_ds_terminate_control_method (
* Delete any namespace entries created immediately underneath
* the method
*/
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
goto exit;
}
if (method_node->child) {
acpi_ns_delete_namespace_subtree (method_node);
acpi_ns_delete_namespace_subtree(method_node);
}
/*
* Delete any namespace entries created anywhere else within
* the namespace
*/
acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id);
status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
acpi_ns_delete_namespace_by_owner(walk_state->method_desc->
method.owner_id);
status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
acpi_ut_release_owner_id(&walk_state->method_desc->method.
owner_id);
}
status = acpi_ut_release_mutex (ACPI_MTX_PARSER);
return_ACPI_STATUS (status);
exit:
(void)acpi_ut_release_mutex(ACPI_MTX_PARSER);
return_VOID;
}

View File

@ -41,41 +41,32 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acdispat.h>
#include <acpi/amlcode.h>
#include <acpi/acnamesp.h>
#include <acpi/acinterp.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsmthdat")
ACPI_MODULE_NAME("dsmthdat")
/* Local prototypes */
static void
acpi_ds_method_data_delete_value (
u16 opcode,
u32 index,
struct acpi_walk_state *walk_state);
acpi_ds_method_data_delete_value(u16 opcode,
u32 index, struct acpi_walk_state *walk_state);
static acpi_status
acpi_ds_method_data_set_value (
u16 opcode,
u32 index,
union acpi_operand_object *object,
struct acpi_walk_state *walk_state);
acpi_ds_method_data_set_value(u16 opcode,
u32 index,
union acpi_operand_object *object,
struct acpi_walk_state *walk_state);
#ifdef ACPI_OBSOLETE_FUNCTIONS
acpi_object_type
acpi_ds_method_data_get_type (
u16 opcode,
u32 index,
struct acpi_walk_state *walk_state);
acpi_ds_method_data_get_type(u16 opcode,
u32 index, struct acpi_walk_state *walk_state);
#endif
/*******************************************************************************
*
* FUNCTION: acpi_ds_method_data_init
@ -97,45 +88,41 @@ acpi_ds_method_data_get_type (
*
******************************************************************************/
void
acpi_ds_method_data_init (
struct acpi_walk_state *walk_state)
void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
{
u32 i;
ACPI_FUNCTION_TRACE ("ds_method_data_init");
u32 i;
ACPI_FUNCTION_TRACE("ds_method_data_init");
/* Init the method arguments */
for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) {
ACPI_MOVE_32_TO_32 (&walk_state->arguments[i].name,
ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name,
NAMEOF_ARG_NTE);
walk_state->arguments[i].name.integer |= (i << 24);
walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
walk_state->arguments[i].type = ACPI_TYPE_ANY;
walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST |
ANOBJ_METHOD_ARG;
walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
walk_state->arguments[i].type = ACPI_TYPE_ANY;
walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST |
ANOBJ_METHOD_ARG;
}
/* Init the method locals */
for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) {
ACPI_MOVE_32_TO_32 (&walk_state->local_variables[i].name,
ACPI_MOVE_32_TO_32(&walk_state->local_variables[i].name,
NAMEOF_LOCAL_NTE);
walk_state->local_variables[i].name.integer |= (i << 24);
walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED;
walk_state->local_variables[i].type = ACPI_TYPE_ANY;
walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST |
ANOBJ_METHOD_LOCAL;
walk_state->local_variables[i].descriptor =
ACPI_DESC_TYPE_NAMED;
walk_state->local_variables[i].type = ACPI_TYPE_ANY;
walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST |
ANOBJ_METHOD_LOCAL;
}
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_method_data_delete_all
@ -149,26 +136,25 @@ acpi_ds_method_data_init (
*
******************************************************************************/
void
acpi_ds_method_data_delete_all (
struct acpi_walk_state *walk_state)
void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state)
{
u32 index;
ACPI_FUNCTION_TRACE ("ds_method_data_delete_all");
u32 index;
ACPI_FUNCTION_TRACE("ds_method_data_delete_all");
/* Detach the locals */
for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) {
if (walk_state->local_variables[index].object) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
index, walk_state->local_variables[index].object));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
index,
walk_state->local_variables[index].
object));
/* Detach object (if present) and remove a reference */
acpi_ns_detach_object (&walk_state->local_variables[index]);
acpi_ns_detach_object(&walk_state->
local_variables[index]);
}
}
@ -176,19 +162,19 @@ acpi_ds_method_data_delete_all (
for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) {
if (walk_state->arguments[index].object) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
index, walk_state->arguments[index].object));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
index,
walk_state->arguments[index].object));
/* Detach object (if present) and remove a reference */
acpi_ns_detach_object (&walk_state->arguments[index]);
acpi_ns_detach_object(&walk_state->arguments[index]);
}
}
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_method_data_init_args
@ -206,47 +192,44 @@ acpi_ds_method_data_delete_all (
******************************************************************************/
acpi_status
acpi_ds_method_data_init_args (
union acpi_operand_object **params,
u32 max_param_count,
struct acpi_walk_state *walk_state)
acpi_ds_method_data_init_args(union acpi_operand_object **params,
u32 max_param_count,
struct acpi_walk_state *walk_state)
{
acpi_status status;
u32 index = 0;
ACPI_FUNCTION_TRACE_PTR ("ds_method_data_init_args", params);
acpi_status status;
u32 index = 0;
ACPI_FUNCTION_TRACE_PTR("ds_method_data_init_args", params);
if (!params) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
return_ACPI_STATUS (AE_OK);
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"No param list passed to method\n"));
return_ACPI_STATUS(AE_OK);
}
/* Copy passed parameters into the new method stack frame */
while ((index < ACPI_METHOD_NUM_ARGS) &&
(index < max_param_count) &&
params[index]) {
(index < max_param_count) && params[index]) {
/*
* A valid parameter.
* Store the argument in the method/walk descriptor.
* Do not copy the arg in order to implement call by reference
*/
status = acpi_ds_method_data_set_value (AML_ARG_OP, index,
params[index], walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_method_data_set_value(AML_ARG_OP, index,
params[index],
walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
index++;
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", index));
return_ACPI_STATUS (AE_OK);
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%d args passed to method\n", index));
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_method_data_get_node
@ -263,14 +246,12 @@ acpi_ds_method_data_init_args (
******************************************************************************/
acpi_status
acpi_ds_method_data_get_node (
u16 opcode,
u32 index,
struct acpi_walk_state *walk_state,
struct acpi_namespace_node **node)
acpi_ds_method_data_get_node(u16 opcode,
u32 index,
struct acpi_walk_state *walk_state,
struct acpi_namespace_node **node)
{
ACPI_FUNCTION_TRACE ("ds_method_data_get_node");
ACPI_FUNCTION_TRACE("ds_method_data_get_node");
/*
* Method Locals and Arguments are supported
@ -279,10 +260,10 @@ acpi_ds_method_data_get_node (
case AML_LOCAL_OP:
if (index > ACPI_METHOD_MAX_LOCAL) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Local index %d is invalid (max %d)\n",
index, ACPI_METHOD_MAX_LOCAL));
return_ACPI_STATUS (AE_AML_INVALID_INDEX);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Local index %d is invalid (max %d)\n",
index, ACPI_METHOD_MAX_LOCAL));
return_ACPI_STATUS(AE_AML_INVALID_INDEX);
}
/* Return a pointer to the pseudo-node */
@ -293,10 +274,10 @@ acpi_ds_method_data_get_node (
case AML_ARG_OP:
if (index > ACPI_METHOD_MAX_ARG) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Arg index %d is invalid (max %d)\n",
index, ACPI_METHOD_MAX_ARG));
return_ACPI_STATUS (AE_AML_INVALID_INDEX);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Arg index %d is invalid (max %d)\n",
index, ACPI_METHOD_MAX_ARG));
return_ACPI_STATUS(AE_AML_INVALID_INDEX);
}
/* Return a pointer to the pseudo-node */
@ -305,14 +286,14 @@ acpi_ds_method_data_get_node (
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode));
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Opcode %d is invalid\n",
opcode));
return_ACPI_STATUS(AE_AML_BAD_OPCODE);
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_method_data_set_value
@ -330,29 +311,26 @@ acpi_ds_method_data_get_node (
******************************************************************************/
static acpi_status
acpi_ds_method_data_set_value (
u16 opcode,
u32 index,
union acpi_operand_object *object,
struct acpi_walk_state *walk_state)
acpi_ds_method_data_set_value(u16 opcode,
u32 index,
union acpi_operand_object *object,
struct acpi_walk_state *walk_state)
{
acpi_status status;
struct acpi_namespace_node *node;
acpi_status status;
struct acpi_namespace_node *node;
ACPI_FUNCTION_TRACE("ds_method_data_set_value");
ACPI_FUNCTION_TRACE ("ds_method_data_set_value");
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"new_obj %p Opcode %X, Refs=%d [%s]\n", object,
opcode, object->common.reference_count,
acpi_ut_get_type_name (object->common.type)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"new_obj %p Opcode %X, Refs=%d [%s]\n", object,
opcode, object->common.reference_count,
acpi_ut_get_type_name(object->common.type)));
/* Get the namespace node for the arg/local */
status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
@ -361,15 +339,14 @@ acpi_ds_method_data_set_value (
* reference semantics of ACPI Control Method invocation.
* (See ACPI specification 2.0_c)
*/
acpi_ut_add_reference (object);
acpi_ut_add_reference(object);
/* Install the object */
node->object = object;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_method_data_get_value
@ -387,32 +364,30 @@ acpi_ds_method_data_set_value (
******************************************************************************/
acpi_status
acpi_ds_method_data_get_value (
u16 opcode,
u32 index,
struct acpi_walk_state *walk_state,
union acpi_operand_object **dest_desc)
acpi_ds_method_data_get_value(u16 opcode,
u32 index,
struct acpi_walk_state *walk_state,
union acpi_operand_object **dest_desc)
{
acpi_status status;
struct acpi_namespace_node *node;
union acpi_operand_object *object;
ACPI_FUNCTION_TRACE ("ds_method_data_get_value");
acpi_status status;
struct acpi_namespace_node *node;
union acpi_operand_object *object;
ACPI_FUNCTION_TRACE("ds_method_data_get_value");
/* Validate the object descriptor */
if (!dest_desc) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n"));
return_ACPI_STATUS (AE_BAD_PARAMETER);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Null object descriptor pointer\n"));
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Get the namespace node for the arg/local */
status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Get the object from the node */
@ -433,9 +408,10 @@ acpi_ds_method_data_get_value (
/* If slack enabled, init the local_x/arg_x to an Integer of value zero */
if (acpi_gbl_enable_interpreter_slack) {
object = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
object =
acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!object) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
object->integer.value = 0;
@ -444,27 +420,29 @@ acpi_ds_method_data_get_value (
/* Otherwise, return the error */
else switch (opcode) {
case AML_ARG_OP:
else
switch (opcode) {
case AML_ARG_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Uninitialized Arg[%d] at node %p\n",
index, node));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Uninitialized Arg[%d] at node %p\n",
index, node));
return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
case AML_LOCAL_OP:
case AML_LOCAL_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Uninitialized Local[%d] at node %p\n",
index, node));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Uninitialized Local[%d] at node %p\n",
index, node));
return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
default:
ACPI_REPORT_ERROR (("Not Arg/Local opcode: %X\n", opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
default:
ACPI_REPORT_ERROR(("Not Arg/Local opcode: %X\n",
opcode));
return_ACPI_STATUS(AE_AML_INTERNAL);
}
}
/*
@ -472,12 +450,11 @@ acpi_ds_method_data_get_value (
* Return an additional reference to the object
*/
*dest_desc = object;
acpi_ut_add_reference (object);
acpi_ut_add_reference(object);
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_method_data_delete_value
@ -494,29 +471,25 @@ acpi_ds_method_data_get_value (
******************************************************************************/
static void
acpi_ds_method_data_delete_value (
u16 opcode,
u32 index,
struct acpi_walk_state *walk_state)
acpi_ds_method_data_delete_value(u16 opcode,
u32 index, struct acpi_walk_state *walk_state)
{
acpi_status status;
struct acpi_namespace_node *node;
union acpi_operand_object *object;
ACPI_FUNCTION_TRACE ("ds_method_data_delete_value");
acpi_status status;
struct acpi_namespace_node *node;
union acpi_operand_object *object;
ACPI_FUNCTION_TRACE("ds_method_data_delete_value");
/* Get the namespace node for the arg/local */
status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
if (ACPI_FAILURE (status)) {
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
if (ACPI_FAILURE(status)) {
return_VOID;
}
/* Get the associated object */
object = acpi_ns_get_attached_object (node);
object = acpi_ns_get_attached_object(node);
/*
* Undefine the Arg or Local by setting its descriptor
@ -526,19 +499,18 @@ acpi_ds_method_data_delete_value (
node->object = NULL;
if ((object) &&
(ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_OPERAND)) {
(ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_OPERAND)) {
/*
* There is a valid object.
* Decrement the reference count by one to balance the
* increment when the object was stored.
*/
acpi_ut_remove_reference (object);
acpi_ut_remove_reference(object);
}
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_store_object_to_local
@ -557,40 +529,38 @@ acpi_ds_method_data_delete_value (
******************************************************************************/
acpi_status
acpi_ds_store_object_to_local (
u16 opcode,
u32 index,
union acpi_operand_object *obj_desc,
struct acpi_walk_state *walk_state)
acpi_ds_store_object_to_local(u16 opcode,
u32 index,
union acpi_operand_object *obj_desc,
struct acpi_walk_state *walk_state)
{
acpi_status status;
struct acpi_namespace_node *node;
union acpi_operand_object *current_obj_desc;
union acpi_operand_object *new_obj_desc;
acpi_status status;
struct acpi_namespace_node *node;
union acpi_operand_object *current_obj_desc;
union acpi_operand_object *new_obj_desc;
ACPI_FUNCTION_TRACE ("ds_store_object_to_local");
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n",
opcode, index, obj_desc));
ACPI_FUNCTION_TRACE("ds_store_object_to_local");
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n",
opcode, index, obj_desc));
/* Parameter validation */
if (!obj_desc) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Get the namespace node for the arg/local */
status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
current_obj_desc = acpi_ns_get_attached_object (node);
current_obj_desc = acpi_ns_get_attached_object(node);
if (current_obj_desc == obj_desc) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
obj_desc));
return_ACPI_STATUS (status);
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n",
obj_desc));
return_ACPI_STATUS(status);
}
/*
@ -602,9 +572,11 @@ acpi_ds_store_object_to_local (
*/
new_obj_desc = obj_desc;
if (obj_desc->common.reference_count > 1) {
status = acpi_ut_copy_iobject_to_iobject (obj_desc, &new_obj_desc, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc,
walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
@ -632,43 +604,40 @@ acpi_ds_store_object_to_local (
* Weird, but true.
*/
if (opcode == AML_ARG_OP) {
/*
* Make sure that the object is the correct type. This may be
* overkill, butit is here because references were NS nodes in
* the past. Now they are operand objects of type Reference.
*/
if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) {
ACPI_REPORT_ERROR ((
"Invalid descriptor type while storing to method arg: [%s]\n",
acpi_ut_get_descriptor_name (current_obj_desc)));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
/*
* If we have a valid reference object that came from ref_of(),
* do the indirect store
*/
if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
(current_obj_desc->reference.opcode == AML_REF_OF_OP)) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Arg (%p) is an obj_ref(Node), storing in node %p\n",
new_obj_desc, current_obj_desc));
if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) ==
ACPI_DESC_TYPE_OPERAND)
&& (current_obj_desc->common.type ==
ACPI_TYPE_LOCAL_REFERENCE)
&& (current_obj_desc->reference.opcode ==
AML_REF_OF_OP)) {
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Arg (%p) is an obj_ref(Node), storing in node %p\n",
new_obj_desc,
current_obj_desc));
/*
* Store this object to the Node (perform the indirect store)
* NOTE: No implicit conversion is performed, as per the ACPI
* specification rules on storing to Locals/Args.
*/
status = acpi_ex_store_object_to_node (new_obj_desc,
current_obj_desc->reference.object, walk_state,
ACPI_NO_IMPLICIT_CONVERSION);
status =
acpi_ex_store_object_to_node(new_obj_desc,
current_obj_desc->
reference.
object,
walk_state,
ACPI_NO_IMPLICIT_CONVERSION);
/* Remove local reference if we copied the object above */
if (new_obj_desc != obj_desc) {
acpi_ut_remove_reference (new_obj_desc);
acpi_ut_remove_reference(new_obj_desc);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
}
@ -676,7 +645,7 @@ acpi_ds_store_object_to_local (
* Delete the existing object
* before storing the new one
*/
acpi_ds_method_data_delete_value (opcode, index, walk_state);
acpi_ds_method_data_delete_value(opcode, index, walk_state);
}
/*
@ -684,18 +653,19 @@ acpi_ds_store_object_to_local (
* the descriptor for the Arg or Local.
* (increments the object reference count by one)
*/
status = acpi_ds_method_data_set_value (opcode, index, new_obj_desc, walk_state);
status =
acpi_ds_method_data_set_value(opcode, index, new_obj_desc,
walk_state);
/* Remove local reference if we copied the object above */
if (new_obj_desc != obj_desc) {
acpi_ut_remove_reference (new_obj_desc);
acpi_ut_remove_reference(new_obj_desc);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
#ifdef ACPI_OBSOLETE_FUNCTIONS
/*******************************************************************************
*
@ -712,39 +682,33 @@ acpi_ds_store_object_to_local (
******************************************************************************/
acpi_object_type
acpi_ds_method_data_get_type (
u16 opcode,
u32 index,
struct acpi_walk_state *walk_state)
acpi_ds_method_data_get_type(u16 opcode,
u32 index, struct acpi_walk_state *walk_state)
{
acpi_status status;
struct acpi_namespace_node *node;
union acpi_operand_object *object;
ACPI_FUNCTION_TRACE ("ds_method_data_get_type");
acpi_status status;
struct acpi_namespace_node *node;
union acpi_operand_object *object;
ACPI_FUNCTION_TRACE("ds_method_data_get_type");
/* Get the namespace node for the arg/local */
status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
if (ACPI_FAILURE (status)) {
return_VALUE ((ACPI_TYPE_NOT_FOUND));
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
if (ACPI_FAILURE(status)) {
return_VALUE((ACPI_TYPE_NOT_FOUND));
}
/* Get the object */
object = acpi_ns_get_attached_object (node);
object = acpi_ns_get_attached_object(node);
if (!object) {
/* Uninitialized local/arg, return TYPE_ANY */
return_VALUE (ACPI_TYPE_ANY);
return_VALUE(ACPI_TYPE_ANY);
}
/* Get the object type */
return_VALUE (ACPI_GET_OBJECT_TYPE (object));
return_VALUE(ACPI_GET_OBJECT_TYPE(object));
}
#endif

View File

@ -41,7 +41,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acparser.h>
#include <acpi/amlcode.h>
@ -50,14 +49,12 @@
#include <acpi/acinterp.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsobject")
ACPI_MODULE_NAME("dsobject")
static acpi_status
acpi_ds_build_internal_object (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
union acpi_operand_object **obj_desc_ptr);
acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
union acpi_operand_object **obj_desc_ptr);
#ifndef ACPI_NO_METHOD_EXECUTION
/*******************************************************************************
@ -76,17 +73,14 @@ acpi_ds_build_internal_object (
******************************************************************************/
static acpi_status
acpi_ds_build_internal_object (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
union acpi_operand_object **obj_desc_ptr)
acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
union acpi_operand_object **obj_desc_ptr)
{
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE ("ds_build_internal_object");
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE("ds_build_internal_object");
*obj_desc_ptr = NULL;
if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
@ -96,40 +90,44 @@ acpi_ds_build_internal_object (
* Otherwise, go ahead and look it up now
*/
if (!op->common.node) {
status = acpi_ns_lookup (walk_state->scope_info,
op->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
NULL,
(struct acpi_namespace_node **) &(op->common.node));
status = acpi_ns_lookup(walk_state->scope_info,
op->common.value.string,
ACPI_TYPE_ANY,
ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT |
ACPI_NS_DONT_OPEN_SCOPE, NULL,
(struct acpi_namespace_node **)
&(op->common.node));
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (op->common.value.string, status);
return_ACPI_STATUS (status);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(op->common.value.string,
status);
return_ACPI_STATUS(status);
}
}
}
/* Create and init the internal ACPI object */
obj_desc = acpi_ut_create_internal_object (
(acpi_ps_get_opcode_info (op->common.aml_opcode))->object_type);
obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
(op->common.aml_opcode))->
object_type);
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
status = acpi_ds_init_object_from_op (walk_state, op, op->common.aml_opcode,
&obj_desc);
if (ACPI_FAILURE (status)) {
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
status =
acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode,
&obj_desc);
if (ACPI_FAILURE(status)) {
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
*obj_desc_ptr = obj_desc;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_build_internal_buffer_obj
@ -147,20 +145,17 @@ acpi_ds_build_internal_object (
******************************************************************************/
acpi_status
acpi_ds_build_internal_buffer_obj (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
u32 buffer_length,
union acpi_operand_object **obj_desc_ptr)
acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
u32 buffer_length,
union acpi_operand_object **obj_desc_ptr)
{
union acpi_parse_object *arg;
union acpi_operand_object *obj_desc;
union acpi_parse_object *byte_list;
u32 byte_list_length = 0;
ACPI_FUNCTION_TRACE ("ds_build_internal_buffer_obj");
union acpi_parse_object *arg;
union acpi_operand_object *obj_desc;
union acpi_parse_object *byte_list;
u32 byte_list_length = 0;
ACPI_FUNCTION_TRACE("ds_build_internal_buffer_obj");
obj_desc = *obj_desc_ptr;
if (obj_desc) {
@ -168,14 +163,13 @@ acpi_ds_build_internal_buffer_obj (
* We are evaluating a Named buffer object "Name (xxxx, Buffer)".
* The buffer object already exists (from the NS node)
*/
}
else {
} else {
/* Create a new buffer object */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
*obj_desc_ptr = obj_desc;
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
}
@ -184,16 +178,17 @@ acpi_ds_build_internal_buffer_obj (
* individual bytes or a string initializer. In either case, a
* byte_list appears in the AML.
*/
arg = op->common.value.arg; /* skip first arg */
arg = op->common.value.arg; /* skip first arg */
byte_list = arg->named.next;
if (byte_list) {
if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Expecting bytelist, got AML opcode %X in op %p\n",
byte_list->common.aml_opcode, byte_list));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Expecting bytelist, got AML opcode %X in op %p\n",
byte_list->common.aml_opcode,
byte_list));
acpi_ut_remove_reference (obj_desc);
acpi_ut_remove_reference(obj_desc);
return (AE_TYPE);
}
@ -214,31 +209,29 @@ acpi_ds_build_internal_buffer_obj (
if (obj_desc->buffer.length == 0) {
obj_desc->buffer.pointer = NULL;
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Buffer defined with zero length in AML, creating\n"));
}
else {
obj_desc->buffer.pointer = ACPI_MEM_CALLOCATE (
obj_desc->buffer.length);
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Buffer defined with zero length in AML, creating\n"));
} else {
obj_desc->buffer.pointer =
ACPI_MEM_CALLOCATE(obj_desc->buffer.length);
if (!obj_desc->buffer.pointer) {
acpi_ut_delete_object_desc (obj_desc);
return_ACPI_STATUS (AE_NO_MEMORY);
acpi_ut_delete_object_desc(obj_desc);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Initialize buffer from the byte_list (if present) */
if (byte_list) {
ACPI_MEMCPY (obj_desc->buffer.pointer, byte_list->named.data,
byte_list_length);
ACPI_MEMCPY(obj_desc->buffer.pointer,
byte_list->named.data, byte_list_length);
}
}
obj_desc->buffer.flags |= AOPOBJ_DATA_VALID;
op->common.node = (struct acpi_namespace_node *) obj_desc;
return_ACPI_STATUS (AE_OK);
op->common.node = (struct acpi_namespace_node *)obj_desc;
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_build_internal_package_obj
@ -256,28 +249,25 @@ acpi_ds_build_internal_buffer_obj (
******************************************************************************/
acpi_status
acpi_ds_build_internal_package_obj (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
u32 package_length,
union acpi_operand_object **obj_desc_ptr)
acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
u32 package_length,
union acpi_operand_object **obj_desc_ptr)
{
union acpi_parse_object *arg;
union acpi_parse_object *parent;
union acpi_operand_object *obj_desc = NULL;
u32 package_list_length;
acpi_status status = AE_OK;
u32 i;
ACPI_FUNCTION_TRACE ("ds_build_internal_package_obj");
union acpi_parse_object *arg;
union acpi_parse_object *parent;
union acpi_operand_object *obj_desc = NULL;
u32 package_list_length;
acpi_status status = AE_OK;
u32 i;
ACPI_FUNCTION_TRACE("ds_build_internal_package_obj");
/* Find the parent of a possibly nested package */
parent = op->common.parent;
while ((parent->common.aml_opcode == AML_PACKAGE_OP) ||
(parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
while ((parent->common.aml_opcode == AML_PACKAGE_OP) ||
(parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
parent = parent->common.parent;
}
@ -287,12 +277,11 @@ acpi_ds_build_internal_package_obj (
* We are evaluating a Named package object "Name (xxxx, Package)".
* Get the existing package object from the NS node
*/
}
else {
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE);
} else {
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
*obj_desc_ptr = obj_desc;
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
obj_desc->package.node = parent->common.node;
@ -323,12 +312,13 @@ acpi_ds_build_internal_package_obj (
* individual objects). Add an extra pointer slot so
* that the list is always null terminated.
*/
obj_desc->package.elements = ACPI_MEM_CALLOCATE (
((acpi_size) obj_desc->package.count + 1) * sizeof (void *));
obj_desc->package.elements = ACPI_MEM_CALLOCATE(((acpi_size) obj_desc->
package.count +
1) * sizeof(void *));
if (!obj_desc->package.elements) {
acpi_ut_delete_object_desc (obj_desc);
return_ACPI_STATUS (AE_NO_MEMORY);
acpi_ut_delete_object_desc(obj_desc);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/*
@ -342,11 +332,13 @@ acpi_ds_build_internal_package_obj (
/* Object (package or buffer) is already built */
obj_desc->package.elements[i] =
ACPI_CAST_PTR (union acpi_operand_object, arg->common.node);
}
else {
status = acpi_ds_build_internal_object (walk_state, arg,
&obj_desc->package.elements[i]);
ACPI_CAST_PTR(union acpi_operand_object,
arg->common.node);
} else {
status = acpi_ds_build_internal_object(walk_state, arg,
&obj_desc->
package.
elements[i]);
}
i++;
@ -354,11 +346,10 @@ acpi_ds_build_internal_package_obj (
}
obj_desc->package.flags |= AOPOBJ_DATA_VALID;
op->common.node = (struct acpi_namespace_node *) obj_desc;
return_ACPI_STATUS (status);
op->common.node = (struct acpi_namespace_node *)obj_desc;
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_create_node
@ -374,57 +365,53 @@ acpi_ds_build_internal_package_obj (
******************************************************************************/
acpi_status
acpi_ds_create_node (
struct acpi_walk_state *walk_state,
struct acpi_namespace_node *node,
union acpi_parse_object *op)
acpi_ds_create_node(struct acpi_walk_state *walk_state,
struct acpi_namespace_node *node,
union acpi_parse_object *op)
{
acpi_status status;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_TRACE_PTR ("ds_create_node", op);
acpi_status status;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_TRACE_PTR("ds_create_node", op);
/*
* Because of the execution pass through the non-control-method
* parts of the table, we can arrive here twice. Only init
* the named object node the first time through
*/
if (acpi_ns_get_attached_object (node)) {
return_ACPI_STATUS (AE_OK);
if (acpi_ns_get_attached_object(node)) {
return_ACPI_STATUS(AE_OK);
}
if (!op->common.value.arg) {
/* No arguments, there is nothing to do */
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/* Build an internal object for the argument(s) */
status = acpi_ds_build_internal_object (walk_state, op->common.value.arg,
&obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_build_internal_object(walk_state, op->common.value.arg,
&obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Re-type the object according to its argument */
node->type = ACPI_GET_OBJECT_TYPE (obj_desc);
node->type = ACPI_GET_OBJECT_TYPE(obj_desc);
/* Attach obj to node */
status = acpi_ns_attach_object (node, obj_desc, node->type);
status = acpi_ns_attach_object(node, obj_desc, node->type);
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
#endif /* ACPI_NO_METHOD_EXECUTION */
#endif /* ACPI_NO_METHOD_EXECUTION */
/*******************************************************************************
*
@ -444,55 +431,50 @@ acpi_ds_create_node (
******************************************************************************/
acpi_status
acpi_ds_init_object_from_op (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
u16 opcode,
union acpi_operand_object **ret_obj_desc)
acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
u16 opcode,
union acpi_operand_object **ret_obj_desc)
{
const struct acpi_opcode_info *op_info;
union acpi_operand_object *obj_desc;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("ds_init_object_from_op");
const struct acpi_opcode_info *op_info;
union acpi_operand_object *obj_desc;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ds_init_object_from_op");
obj_desc = *ret_obj_desc;
op_info = acpi_ps_get_opcode_info (opcode);
op_info = acpi_ps_get_opcode_info(opcode);
if (op_info->class == AML_CLASS_UNKNOWN) {
/* Unknown opcode */
return_ACPI_STATUS (AE_TYPE);
return_ACPI_STATUS(AE_TYPE);
}
/* Perform per-object initialization */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_BUFFER:
/*
* Defer evaluation of Buffer term_arg operand
*/
obj_desc->buffer.node = (struct acpi_namespace_node *)
walk_state->operands[0];
obj_desc->buffer.node = (struct acpi_namespace_node *)
walk_state->operands[0];
obj_desc->buffer.aml_start = op->named.data;
obj_desc->buffer.aml_length = op->named.length;
break;
case ACPI_TYPE_PACKAGE:
/*
* Defer evaluation of Package term_arg operand
*/
obj_desc->package.node = (struct acpi_namespace_node *)
walk_state->operands[0];
obj_desc->package.node = (struct acpi_namespace_node *)
walk_state->operands[0];
obj_desc->package.aml_start = op->named.data;
obj_desc->package.aml_length = op->named.length;
break;
case ACPI_TYPE_INTEGER:
switch (op_info->type) {
@ -525,7 +507,7 @@ acpi_ds_init_object_from_op (
/* Truncate value if we are executing from a 32-bit ACPI table */
#ifndef ACPI_NO_METHOD_EXECUTION
acpi_ex_truncate_for32bit_table (obj_desc);
acpi_ex_truncate_for32bit_table(obj_desc);
#endif
break;
@ -536,33 +518,36 @@ acpi_ds_init_object_from_op (
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unknown constant opcode %X\n", opcode));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unknown constant opcode %X\n",
opcode));
status = AE_AML_OPERAND_TYPE;
break;
}
break;
case AML_TYPE_LITERAL:
obj_desc->integer.value = op->common.value.integer;
#ifndef ACPI_NO_METHOD_EXECUTION
acpi_ex_truncate_for32bit_table(obj_desc);
#endif
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n",
op_info->type));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unknown Integer type %X\n",
op_info->type));
status = AE_AML_OPERAND_TYPE;
break;
}
break;
case ACPI_TYPE_STRING:
obj_desc->string.pointer = op->common.value.string;
obj_desc->string.length = (u32) ACPI_STRLEN (op->common.value.string);
obj_desc->string.length =
(u32) ACPI_STRLEN(op->common.value.string);
/*
* The string is contained in the ACPI table, don't ever try
@ -571,11 +556,9 @@ acpi_ds_init_object_from_op (
obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
break;
case ACPI_TYPE_METHOD:
break;
case ACPI_TYPE_LOCAL_REFERENCE:
switch (op_info->type) {
@ -587,14 +570,17 @@ acpi_ds_init_object_from_op (
obj_desc->reference.offset = opcode - AML_LOCAL_OP;
#ifndef ACPI_NO_METHOD_EXECUTION
status = acpi_ds_method_data_get_node (AML_LOCAL_OP,
obj_desc->reference.offset,
walk_state,
(struct acpi_namespace_node **) &obj_desc->reference.object);
status = acpi_ds_method_data_get_node(AML_LOCAL_OP,
obj_desc->
reference.offset,
walk_state,
(struct
acpi_namespace_node
**)&obj_desc->
reference.object);
#endif
break;
case AML_TYPE_METHOD_ARGUMENT:
/* Split the opcode into a base opcode + offset */
@ -603,14 +589,18 @@ acpi_ds_init_object_from_op (
obj_desc->reference.offset = opcode - AML_ARG_OP;
#ifndef ACPI_NO_METHOD_EXECUTION
status = acpi_ds_method_data_get_node (AML_ARG_OP,
obj_desc->reference.offset,
walk_state,
(struct acpi_namespace_node **) &obj_desc->reference.object);
status = acpi_ds_method_data_get_node(AML_ARG_OP,
obj_desc->
reference.offset,
walk_state,
(struct
acpi_namespace_node
**)&obj_desc->
reference.object);
#endif
break;
default: /* Other literals, etc.. */
default: /* Other literals, etc.. */
if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
/* Node was saved in Op */
@ -623,17 +613,15 @@ acpi_ds_init_object_from_op (
}
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %X\n",
ACPI_GET_OBJECT_TYPE (obj_desc)));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unimplemented data type: %X\n",
ACPI_GET_OBJECT_TYPE(obj_desc)));
status = AE_AML_OPERAND_TYPE;
break;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acparser.h>
#include <acpi/amlcode.h>
@ -51,8 +50,7 @@
#include <acpi/acdebug.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsutils")
ACPI_MODULE_NAME("dsutils")
/*******************************************************************************
*
@ -68,13 +66,9 @@
* parent method exits.)
*
******************************************************************************/
void
acpi_ds_clear_implicit_return (
struct acpi_walk_state *walk_state)
void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state)
{
ACPI_FUNCTION_NAME ("ds_clear_implicit_return");
ACPI_FUNCTION_NAME("ds_clear_implicit_return");
/*
* Slack must be enabled for this feature
@ -89,16 +83,15 @@ acpi_ds_clear_implicit_return (
* complex statements, the implicit return value can be
* bubbled up several levels.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Removing reference on stale implicit return obj %p\n",
walk_state->implicit_return_obj));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Removing reference on stale implicit return obj %p\n",
walk_state->implicit_return_obj));
acpi_ut_remove_reference (walk_state->implicit_return_obj);
acpi_ut_remove_reference(walk_state->implicit_return_obj);
walk_state->implicit_return_obj = NULL;
}
}
#ifndef ACPI_NO_METHOD_EXECUTION
/*******************************************************************************
*
@ -119,27 +112,22 @@ acpi_ds_clear_implicit_return (
******************************************************************************/
u8
acpi_ds_do_implicit_return (
union acpi_operand_object *return_desc,
struct acpi_walk_state *walk_state,
u8 add_reference)
acpi_ds_do_implicit_return(union acpi_operand_object *return_desc,
struct acpi_walk_state *walk_state, u8 add_reference)
{
ACPI_FUNCTION_NAME ("ds_do_implicit_return");
ACPI_FUNCTION_NAME("ds_do_implicit_return");
/*
* Slack must be enabled for this feature, and we must
* have a valid return object
*/
if ((!acpi_gbl_enable_interpreter_slack) ||
(!return_desc)) {
if ((!acpi_gbl_enable_interpreter_slack) || (!return_desc)) {
return (FALSE);
}
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Result %p will be implicitly returned; Prev=%p\n",
return_desc,
walk_state->implicit_return_obj));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Result %p will be implicitly returned; Prev=%p\n",
return_desc, walk_state->implicit_return_obj));
/*
* Delete any "stale" implicit return value first. However, in
@ -151,20 +139,19 @@ acpi_ds_do_implicit_return (
if (walk_state->implicit_return_obj == return_desc) {
return (TRUE);
}
acpi_ds_clear_implicit_return (walk_state);
acpi_ds_clear_implicit_return(walk_state);
}
/* Save the implicit return value, add a reference if requested */
walk_state->implicit_return_obj = return_desc;
if (add_reference) {
acpi_ut_add_reference (return_desc);
acpi_ut_add_reference(return_desc);
}
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_is_result_used
@ -179,20 +166,18 @@ acpi_ds_do_implicit_return (
******************************************************************************/
u8
acpi_ds_is_result_used (
union acpi_parse_object *op,
struct acpi_walk_state *walk_state)
acpi_ds_is_result_used(union acpi_parse_object * op,
struct acpi_walk_state * walk_state)
{
const struct acpi_opcode_info *parent_info;
ACPI_FUNCTION_TRACE_PTR ("ds_is_result_used", op);
const struct acpi_opcode_info *parent_info;
ACPI_FUNCTION_TRACE_PTR("ds_is_result_used", op);
/* Must have both an Op and a Result Object */
if (!op) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n"));
return_VALUE (TRUE);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n"));
return_VALUE(TRUE);
}
/*
@ -204,7 +189,8 @@ acpi_ds_is_result_used (
* NOTE: this is optional because the ASL language does not actually
* support this behavior.
*/
(void) acpi_ds_do_implicit_return (walk_state->result_obj, walk_state, TRUE);
(void)acpi_ds_do_implicit_return(walk_state->result_obj, walk_state,
TRUE);
/*
* Now determine if the parent will use the result
@ -215,22 +201,24 @@ acpi_ds_is_result_used (
* via execute_control_method has a scope_op as the parent.
*/
if ((!op->common.parent) ||
(op->common.parent->common.aml_opcode == AML_SCOPE_OP)) {
(op->common.parent->common.aml_opcode == AML_SCOPE_OP)) {
/* No parent, the return value cannot possibly be used */
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"At Method level, result of [%s] not used\n",
acpi_ps_get_opcode_name (op->common.aml_opcode)));
return_VALUE (FALSE);
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"At Method level, result of [%s] not used\n",
acpi_ps_get_opcode_name(op->common.
aml_opcode)));
return_VALUE(FALSE);
}
/* Get info on the parent. The root_op is AML_SCOPE */
parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode);
parent_info =
acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode);
if (parent_info->class == AML_CLASS_UNKNOWN) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unknown parent opcode. Op=%p\n", op));
return_VALUE (FALSE);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unknown parent opcode. Op=%p\n", op));
return_VALUE(FALSE);
}
/*
@ -256,8 +244,10 @@ acpi_ds_is_result_used (
* If we are executing the predicate AND this is the predicate op,
* we will use the return value
*/
if ((walk_state->control_state->common.state == ACPI_CONTROL_PREDICATE_EXECUTING) &&
(walk_state->control_state->control.predicate_op == op)) {
if ((walk_state->control_state->common.state ==
ACPI_CONTROL_PREDICATE_EXECUTING)
&& (walk_state->control_state->control.
predicate_op == op)) {
goto result_used;
}
break;
@ -271,7 +261,6 @@ acpi_ds_is_result_used (
goto result_not_used;
case AML_CLASS_CREATE:
/*
@ -280,15 +269,16 @@ acpi_ds_is_result_used (
*/
goto result_used;
case AML_CLASS_NAMED_OBJECT:
if ((op->common.parent->common.aml_opcode == AML_REGION_OP) ||
(op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) ||
(op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
(op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP) ||
(op->common.parent->common.aml_opcode == AML_BUFFER_OP) ||
(op->common.parent->common.aml_opcode == AML_INT_EVAL_SUBTREE_OP)) {
if ((op->common.parent->common.aml_opcode == AML_REGION_OP) ||
(op->common.parent->common.aml_opcode == AML_DATA_REGION_OP)
|| (op->common.parent->common.aml_opcode == AML_PACKAGE_OP)
|| (op->common.parent->common.aml_opcode ==
AML_VAR_PACKAGE_OP)
|| (op->common.parent->common.aml_opcode == AML_BUFFER_OP)
|| (op->common.parent->common.aml_opcode ==
AML_INT_EVAL_SUBTREE_OP)) {
/*
* These opcodes allow term_arg(s) as operands and therefore
* the operands can be method calls. The result is used.
@ -298,7 +288,6 @@ acpi_ds_is_result_used (
goto result_not_used;
default:
/*
@ -308,26 +297,25 @@ acpi_ds_is_result_used (
goto result_used;
}
result_used:
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Result of [%s] used by Parent [%s] Op=%p\n",
acpi_ps_get_opcode_name(op->common.aml_opcode),
acpi_ps_get_opcode_name(op->common.parent->common.
aml_opcode), op));
result_used:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Result of [%s] used by Parent [%s] Op=%p\n",
acpi_ps_get_opcode_name (op->common.aml_opcode),
acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
return_VALUE(TRUE);
return_VALUE (TRUE);
result_not_used:
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Result of [%s] not used by Parent [%s] Op=%p\n",
acpi_ps_get_opcode_name(op->common.aml_opcode),
acpi_ps_get_opcode_name(op->common.parent->common.
aml_opcode), op));
result_not_used:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Result of [%s] not used by Parent [%s] Op=%p\n",
acpi_ps_get_opcode_name (op->common.aml_opcode),
acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
return_VALUE (FALSE);
return_VALUE(FALSE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_delete_result_if_not_used
@ -346,20 +334,17 @@ result_not_used:
******************************************************************************/
void
acpi_ds_delete_result_if_not_used (
union acpi_parse_object *op,
union acpi_operand_object *result_obj,
struct acpi_walk_state *walk_state)
acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
union acpi_operand_object *result_obj,
struct acpi_walk_state *walk_state)
{
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE_PTR ("ds_delete_result_if_not_used", result_obj);
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE_PTR("ds_delete_result_if_not_used", result_obj);
if (!op) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n"));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n"));
return_VOID;
}
@ -367,19 +352,18 @@ acpi_ds_delete_result_if_not_used (
return_VOID;
}
if (!acpi_ds_is_result_used (op, walk_state)) {
if (!acpi_ds_is_result_used(op, walk_state)) {
/* Must pop the result stack (obj_desc should be equal to result_obj) */
status = acpi_ds_result_pop (&obj_desc, walk_state);
if (ACPI_SUCCESS (status)) {
acpi_ut_remove_reference (result_obj);
status = acpi_ds_result_pop(&obj_desc, walk_state);
if (ACPI_SUCCESS(status)) {
acpi_ut_remove_reference(result_obj);
}
}
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_resolve_operands
@ -394,16 +378,12 @@ acpi_ds_delete_result_if_not_used (
*
******************************************************************************/
acpi_status
acpi_ds_resolve_operands (
struct acpi_walk_state *walk_state)
acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state)
{
u32 i;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_PTR ("ds_resolve_operands", walk_state);
u32 i;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_PTR("ds_resolve_operands", walk_state);
/*
* Attempt to resolve each of the valid operands
@ -411,16 +391,17 @@ acpi_ds_resolve_operands (
* that the actual objects are passed, not copies of the objects.
*/
for (i = 0; i < walk_state->num_operands; i++) {
status = acpi_ex_resolve_to_value (&walk_state->operands[i], walk_state);
if (ACPI_FAILURE (status)) {
status =
acpi_ex_resolve_to_value(&walk_state->operands[i],
walk_state);
if (ACPI_FAILURE(status)) {
break;
}
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_clear_operands
@ -433,15 +414,11 @@ acpi_ds_resolve_operands (
*
******************************************************************************/
void
acpi_ds_clear_operands (
struct acpi_walk_state *walk_state)
void acpi_ds_clear_operands(struct acpi_walk_state *walk_state)
{
u32 i;
ACPI_FUNCTION_TRACE_PTR ("ds_clear_operands", walk_state);
u32 i;
ACPI_FUNCTION_TRACE_PTR("ds_clear_operands", walk_state);
/* Remove a reference on each operand on the stack */
@ -450,7 +427,7 @@ acpi_ds_clear_operands (
* Remove a reference to all operands, including both
* "Arguments" and "Targets".
*/
acpi_ut_remove_reference (walk_state->operands[i]);
acpi_ut_remove_reference(walk_state->operands[i]);
walk_state->operands[i] = NULL;
}
@ -459,7 +436,6 @@ acpi_ds_clear_operands (
}
#endif
/*******************************************************************************
*
* FUNCTION: acpi_ds_create_operand
@ -478,37 +454,36 @@ acpi_ds_clear_operands (
******************************************************************************/
acpi_status
acpi_ds_create_operand (
struct acpi_walk_state *walk_state,
union acpi_parse_object *arg,
u32 arg_index)
acpi_ds_create_operand(struct acpi_walk_state *walk_state,
union acpi_parse_object *arg, u32 arg_index)
{
acpi_status status = AE_OK;
char *name_string;
u32 name_length;
union acpi_operand_object *obj_desc;
union acpi_parse_object *parent_op;
u16 opcode;
acpi_interpreter_mode interpreter_mode;
const struct acpi_opcode_info *op_info;
ACPI_FUNCTION_TRACE_PTR ("ds_create_operand", arg);
acpi_status status = AE_OK;
char *name_string;
u32 name_length;
union acpi_operand_object *obj_desc;
union acpi_parse_object *parent_op;
u16 opcode;
acpi_interpreter_mode interpreter_mode;
const struct acpi_opcode_info *op_info;
ACPI_FUNCTION_TRACE_PTR("ds_create_operand", arg);
/* A valid name must be looked up in the namespace */
if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
(arg->common.value.string)) {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", arg));
(arg->common.value.string)) {
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n",
arg));
/* Get the entire name string from the AML stream */
status = acpi_ex_get_name_string (ACPI_TYPE_ANY, arg->common.value.buffer,
&name_string, &name_length);
status =
acpi_ex_get_name_string(ACPI_TYPE_ANY,
arg->common.value.buffer,
&name_string, &name_length);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* All prefixes have been handled, and the name is in name_string */
@ -523,13 +498,14 @@ acpi_ds_create_operand (
* actual opcode exists.
*/
if ((walk_state->deferred_node) &&
(walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) &&
(arg_index != 0)) {
obj_desc = ACPI_CAST_PTR (
union acpi_operand_object, walk_state->deferred_node);
(walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD)
&& (arg_index != 0)) {
obj_desc =
ACPI_CAST_PTR(union acpi_operand_object,
walk_state->deferred_node);
status = AE_OK;
}
else /* All other opcodes */ {
} else { /* All other opcodes */
/*
* Differentiate between a namespace "create" operation
* versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
@ -537,43 +513,51 @@ acpi_ds_create_operand (
* namespace objects during the execution of control methods.
*/
parent_op = arg->common.parent;
op_info = acpi_ps_get_opcode_info (parent_op->common.aml_opcode);
if ((op_info->flags & AML_NSNODE) &&
(parent_op->common.aml_opcode != AML_INT_METHODCALL_OP) &&
(parent_op->common.aml_opcode != AML_REGION_OP) &&
(parent_op->common.aml_opcode != AML_INT_NAMEPATH_OP)) {
op_info =
acpi_ps_get_opcode_info(parent_op->common.
aml_opcode);
if ((op_info->flags & AML_NSNODE)
&& (parent_op->common.aml_opcode !=
AML_INT_METHODCALL_OP)
&& (parent_op->common.aml_opcode != AML_REGION_OP)
&& (parent_op->common.aml_opcode !=
AML_INT_NAMEPATH_OP)) {
/* Enter name into namespace if not found */
interpreter_mode = ACPI_IMODE_LOAD_PASS2;
}
else {
} else {
/* Return a failure if name not found */
interpreter_mode = ACPI_IMODE_EXECUTE;
}
status = acpi_ns_lookup (walk_state->scope_info, name_string,
ACPI_TYPE_ANY, interpreter_mode,
ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
walk_state,
ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &obj_desc));
status =
acpi_ns_lookup(walk_state->scope_info, name_string,
ACPI_TYPE_ANY, interpreter_mode,
ACPI_NS_SEARCH_PARENT |
ACPI_NS_DONT_OPEN_SCOPE, walk_state,
ACPI_CAST_INDIRECT_PTR(struct
acpi_namespace_node,
&obj_desc));
/*
* The only case where we pass through (ignore) a NOT_FOUND
* error is for the cond_ref_of opcode.
*/
if (status == AE_NOT_FOUND) {
if (parent_op->common.aml_opcode == AML_COND_REF_OF_OP) {
if (parent_op->common.aml_opcode ==
AML_COND_REF_OF_OP) {
/*
* For the Conditional Reference op, it's OK if
* the name is not found; We just need a way to
* indicate this to the interpreter, set the
* object to the root
*/
obj_desc = ACPI_CAST_PTR (
union acpi_operand_object, acpi_gbl_root_node);
obj_desc =
ACPI_CAST_PTR(union
acpi_operand_object,
acpi_gbl_root_node);
status = AE_OK;
}
else {
} else {
/*
* We just plain didn't find it -- which is a
* very serious error at this point
@ -582,30 +566,30 @@ acpi_ds_create_operand (
}
}
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (name_string, status);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(name_string, status);
}
}
/* Free the namestring created above */
ACPI_MEM_FREE (name_string);
ACPI_MEM_FREE(name_string);
/* Check status from the lookup */
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Put the resulting object onto the current object stack */
status = acpi_ds_obj_stack_push (obj_desc, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_obj_stack_push(obj_desc, walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
}
else {
ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
(obj_desc, walk_state));
} else {
/* Check for null name case */
if (arg->common.aml_opcode == AML_INT_NAMEPATH_OP) {
@ -615,77 +599,83 @@ acpi_ds_create_operand (
* in the original ASL. Create a Zero Constant for a
* placeholder. (Store to a constant is a Noop.)
*/
opcode = AML_ZERO_OP; /* Has no arguments! */
opcode = AML_ZERO_OP; /* Has no arguments! */
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Null namepath: Arg=%p\n", arg));
}
else {
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Null namepath: Arg=%p\n", arg));
} else {
opcode = arg->common.aml_opcode;
}
/* Get the object type of the argument */
op_info = acpi_ps_get_opcode_info (opcode);
op_info = acpi_ps_get_opcode_info(opcode);
if (op_info->object_type == ACPI_TYPE_INVALID) {
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
}
if (op_info->flags & AML_HAS_RETVAL) {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Argument previously created, already stacked \n"));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Argument previously created, already stacked \n"));
ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (
walk_state->operands [walk_state->num_operands - 1], walk_state));
ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
(walk_state->
operands[walk_state->num_operands -
1], walk_state));
/*
* Use value that was already previously returned
* by the evaluation of this argument
*/
status = acpi_ds_result_pop_from_bottom (&obj_desc, walk_state);
if (ACPI_FAILURE (status)) {
status =
acpi_ds_result_pop_from_bottom(&obj_desc,
walk_state);
if (ACPI_FAILURE(status)) {
/*
* Only error is underflow, and this indicates
* a missing or null operand!
*/
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Missing or null operand, %s\n",
acpi_format_exception (status)));
return_ACPI_STATUS (status);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Missing or null operand, %s\n",
acpi_format_exception
(status)));
return_ACPI_STATUS(status);
}
}
else {
} else {
/* Create an ACPI_INTERNAL_OBJECT for the argument */
obj_desc = acpi_ut_create_internal_object (op_info->object_type);
obj_desc =
acpi_ut_create_internal_object(op_info->
object_type);
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Initialize the new object */
status = acpi_ds_init_object_from_op (
walk_state, arg, opcode, &obj_desc);
if (ACPI_FAILURE (status)) {
acpi_ut_delete_object_desc (obj_desc);
return_ACPI_STATUS (status);
status =
acpi_ds_init_object_from_op(walk_state, arg, opcode,
&obj_desc);
if (ACPI_FAILURE(status)) {
acpi_ut_delete_object_desc(obj_desc);
return_ACPI_STATUS(status);
}
}
/* Put the operand object on the object stack */
status = acpi_ds_obj_stack_push (obj_desc, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_obj_stack_push(obj_desc, walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
(obj_desc, walk_state));
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_create_operands
@ -702,29 +692,27 @@ acpi_ds_create_operand (
******************************************************************************/
acpi_status
acpi_ds_create_operands (
struct acpi_walk_state *walk_state,
union acpi_parse_object *first_arg)
acpi_ds_create_operands(struct acpi_walk_state *walk_state,
union acpi_parse_object *first_arg)
{
acpi_status status = AE_OK;
union acpi_parse_object *arg;
u32 arg_count = 0;
ACPI_FUNCTION_TRACE_PTR ("ds_create_operands", first_arg);
acpi_status status = AE_OK;
union acpi_parse_object *arg;
u32 arg_count = 0;
ACPI_FUNCTION_TRACE_PTR("ds_create_operands", first_arg);
/* For all arguments in the list... */
arg = first_arg;
while (arg) {
status = acpi_ds_create_operand (walk_state, arg, arg_count);
if (ACPI_FAILURE (status)) {
status = acpi_ds_create_operand(walk_state, arg, arg_count);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n",
arg_count, arg, first_arg));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Arg #%d (%p) done, Arg1=%p\n", arg_count,
arg, first_arg));
/* Move on to next argument, if any */
@ -732,20 +720,17 @@ acpi_ds_create_operands (
arg_count++;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
cleanup:
cleanup:
/*
* We must undo everything done above; meaning that we must
* pop everything off of the operand stack and delete those
* objects
*/
(void) acpi_ds_obj_stack_pop_and_delete (arg_count, walk_state);
(void)acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state);
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n",
(arg_count + 1), acpi_format_exception (status)));
return_ACPI_STATUS (status);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "While creating Arg %d - %s\n",
(arg_count + 1), acpi_format_exception(status)));
return_ACPI_STATUS(status);
}

View File

@ -42,7 +42,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acparser.h>
#include <acpi/amlcode.h>
@ -52,27 +51,26 @@
#include <acpi/acdebug.h>
#include <acpi/acdisasm.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dswexec")
ACPI_MODULE_NAME("dswexec")
/*
* Dispatch table for opcode classes
*/
static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch [] = {
acpi_ex_opcode_0A_0T_1R,
acpi_ex_opcode_1A_0T_0R,
acpi_ex_opcode_1A_0T_1R,
acpi_ex_opcode_1A_1T_0R,
acpi_ex_opcode_1A_1T_1R,
acpi_ex_opcode_2A_0T_0R,
acpi_ex_opcode_2A_0T_1R,
acpi_ex_opcode_2A_1T_1R,
acpi_ex_opcode_2A_2T_1R,
acpi_ex_opcode_3A_0T_0R,
acpi_ex_opcode_3A_1T_1R,
acpi_ex_opcode_6A_0T_1R};
static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch[] = {
acpi_ex_opcode_0A_0T_1R,
acpi_ex_opcode_1A_0T_0R,
acpi_ex_opcode_1A_0T_1R,
acpi_ex_opcode_1A_1T_0R,
acpi_ex_opcode_1A_1T_1R,
acpi_ex_opcode_2A_0T_0R,
acpi_ex_opcode_2A_0T_1R,
acpi_ex_opcode_2A_1T_1R,
acpi_ex_opcode_2A_2T_1R,
acpi_ex_opcode_3A_0T_0R,
acpi_ex_opcode_3A_1T_1R,
acpi_ex_opcode_6A_0T_1R
};
/*****************************************************************************
*
@ -88,64 +86,64 @@ static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch [] = {
****************************************************************************/
acpi_status
acpi_ds_get_predicate_value (
struct acpi_walk_state *walk_state,
union acpi_operand_object *result_obj) {
acpi_status status = AE_OK;
union acpi_operand_object *obj_desc;
union acpi_operand_object *local_obj_desc = NULL;
ACPI_FUNCTION_TRACE_PTR ("ds_get_predicate_value", walk_state);
acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
union acpi_operand_object *result_obj)
{
acpi_status status = AE_OK;
union acpi_operand_object *obj_desc;
union acpi_operand_object *local_obj_desc = NULL;
ACPI_FUNCTION_TRACE_PTR("ds_get_predicate_value", walk_state);
walk_state->control_state->common.state = 0;
if (result_obj) {
status = acpi_ds_result_pop (&obj_desc, walk_state);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not get result from predicate evaluation, %s\n",
acpi_format_exception (status)));
status = acpi_ds_result_pop(&obj_desc, walk_state);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Could not get result from predicate evaluation, %s\n",
acpi_format_exception(status)));
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
}
else {
status = acpi_ds_create_operand (walk_state, walk_state->op, 0);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
} else {
status = acpi_ds_create_operand(walk_state, walk_state->op, 0);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ex_resolve_to_value(&walk_state->operands[0],
walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
obj_desc = walk_state->operands [0];
obj_desc = walk_state->operands[0];
}
if (!obj_desc) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"No predicate obj_desc=%p State=%p\n",
obj_desc, walk_state));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"No predicate obj_desc=%p State=%p\n",
obj_desc, walk_state));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
/*
* Result of predicate evaluation must be an Integer
* object. Implicitly convert the argument if necessary.
*/
status = acpi_ex_convert_to_integer (obj_desc, &local_obj_desc, 16);
if (ACPI_FAILURE (status)) {
status = acpi_ex_convert_to_integer(obj_desc, &local_obj_desc, 16);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
if (ACPI_GET_OBJECT_TYPE (local_obj_desc) != ACPI_TYPE_INTEGER) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n",
obj_desc, walk_state, ACPI_GET_OBJECT_TYPE (obj_desc)));
if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n",
obj_desc, walk_state,
ACPI_GET_OBJECT_TYPE(obj_desc)));
status = AE_AML_OPERAND_TYPE;
goto cleanup;
@ -153,7 +151,7 @@ acpi_ds_get_predicate_value (
/* Truncate the predicate to 32-bits if necessary */
acpi_ex_truncate_for32bit_table (local_obj_desc);
acpi_ex_truncate_for32bit_table(local_obj_desc);
/*
* Save the result of the predicate evaluation on
@ -161,8 +159,7 @@ acpi_ds_get_predicate_value (
*/
if (local_obj_desc->integer.value) {
walk_state->control_state->common.value = TRUE;
}
else {
} else {
/*
* Predicate is FALSE, we will just toss the
* rest of the package
@ -171,30 +168,30 @@ acpi_ds_get_predicate_value (
status = AE_CTRL_FALSE;
}
cleanup:
cleanup:
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n",
walk_state->control_state->common.value,
walk_state->op));
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n",
walk_state->control_state->common.value, walk_state->op));
/* Break to debugger to display result */
/* Break to debugger to display result */
ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (local_obj_desc, walk_state));
ACPI_DEBUGGER_EXEC(acpi_db_display_result_object
(local_obj_desc, walk_state));
/*
* Delete the predicate result object (we know that
* we don't need it anymore)
*/
if (local_obj_desc != obj_desc) {
acpi_ut_remove_reference (local_obj_desc);
acpi_ut_remove_reference(local_obj_desc);
}
acpi_ut_remove_reference (obj_desc);
acpi_ut_remove_reference(obj_desc);
walk_state->control_state->common.state = ACPI_CONTROL_NORMAL;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*****************************************************************************
*
* FUNCTION: acpi_ds_exec_begin_op
@ -211,38 +208,39 @@ cleanup:
****************************************************************************/
acpi_status
acpi_ds_exec_begin_op (
struct acpi_walk_state *walk_state,
union acpi_parse_object **out_op)
acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
union acpi_parse_object **out_op)
{
union acpi_parse_object *op;
acpi_status status = AE_OK;
u32 opcode_class;
ACPI_FUNCTION_TRACE_PTR ("ds_exec_begin_op", walk_state);
union acpi_parse_object *op;
acpi_status status = AE_OK;
u32 opcode_class;
ACPI_FUNCTION_TRACE_PTR("ds_exec_begin_op", walk_state);
op = walk_state->op;
if (!op) {
status = acpi_ds_load2_begin_op (walk_state, out_op);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_load2_begin_op(walk_state, out_op);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
op = *out_op;
walk_state->op = op;
walk_state->opcode = op->common.aml_opcode;
walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
walk_state->op_info =
acpi_ps_get_opcode_info(op->common.aml_opcode);
if (acpi_ns_opens_scope (walk_state->op_info->object_type)) {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"(%s) Popping scope for Op %p\n",
acpi_ut_get_type_name (walk_state->op_info->object_type), op));
if (acpi_ns_opens_scope(walk_state->op_info->object_type)) {
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"(%s) Popping scope for Op %p\n",
acpi_ut_get_type_name(walk_state->
op_info->
object_type),
op));
status = acpi_ds_scope_stack_pop (walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_scope_stack_pop(walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
}
@ -252,7 +250,7 @@ acpi_ds_exec_begin_op (
*out_op = op;
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*
@ -261,19 +259,20 @@ acpi_ds_exec_begin_op (
* Save this knowledge in the current scope descriptor
*/
if ((walk_state->control_state) &&
(walk_state->control_state->common.state ==
ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n",
op, walk_state));
(walk_state->control_state->common.state ==
ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Exec predicate Op=%p State=%p\n", op,
walk_state));
walk_state->control_state->common.state = ACPI_CONTROL_PREDICATE_EXECUTING;
walk_state->control_state->common.state =
ACPI_CONTROL_PREDICATE_EXECUTING;
/* Save start of predicate */
walk_state->control_state->control.predicate_op = op;
}
opcode_class = walk_state->op_info->class;
/* We want to send namepaths to the load code */
@ -288,15 +287,14 @@ acpi_ds_exec_begin_op (
switch (opcode_class) {
case AML_CLASS_CONTROL:
status = acpi_ds_result_stack_push (walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_result_stack_push(walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
status = acpi_ds_exec_begin_control_op (walk_state, op);
status = acpi_ds_exec_begin_control_op(walk_state, op);
break;
case AML_CLASS_NAMED_OBJECT:
if (walk_state->walk_type == ACPI_WALK_METHOD) {
@ -306,15 +304,14 @@ acpi_ds_exec_begin_op (
* object is temporary and will be deleted upon completion of
* the execution of this method.
*/
status = acpi_ds_load2_begin_op (walk_state, NULL);
status = acpi_ds_load2_begin_op(walk_state, NULL);
}
if (op->common.aml_opcode == AML_REGION_OP) {
status = acpi_ds_result_stack_push (walk_state);
status = acpi_ds_result_stack_push(walk_state);
}
break;
case AML_CLASS_EXECUTE:
case AML_CLASS_CREATE:
@ -322,20 +319,18 @@ acpi_ds_exec_begin_op (
* Most operators with arguments.
* Start a new result/operand state
*/
status = acpi_ds_result_stack_push (walk_state);
status = acpi_ds_result_stack_push(walk_state);
break;
default:
break;
}
/* Nothing to do here during method execution */
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*****************************************************************************
*
* FUNCTION: acpi_ds_exec_end_op
@ -350,28 +345,25 @@ acpi_ds_exec_begin_op (
*
****************************************************************************/
acpi_status
acpi_ds_exec_end_op (
struct acpi_walk_state *walk_state)
acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
{
union acpi_parse_object *op;
acpi_status status = AE_OK;
u32 op_type;
u32 op_class;
union acpi_parse_object *next_op;
union acpi_parse_object *first_arg;
union acpi_parse_object *op;
acpi_status status = AE_OK;
u32 op_type;
u32 op_class;
union acpi_parse_object *next_op;
union acpi_parse_object *first_arg;
ACPI_FUNCTION_TRACE_PTR("ds_exec_end_op", walk_state);
ACPI_FUNCTION_TRACE_PTR ("ds_exec_end_op", walk_state);
op = walk_state->op;
op = walk_state->op;
op_type = walk_state->op_info->type;
op_class = walk_state->op_info->class;
if (op_class == AML_CLASS_UNKNOWN) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", op->common.aml_opcode));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown opcode %X\n",
op->common.aml_opcode));
return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
}
first_arg = op->common.value.arg;
@ -384,29 +376,31 @@ acpi_ds_exec_end_op (
/* Call debugger for single step support (DEBUG build only) */
ACPI_DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, op_class));
ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return_ACPI_STATUS (status);});
ACPI_DEBUGGER_EXEC(status =
acpi_db_single_step(walk_state, op, op_class));
ACPI_DEBUGGER_EXEC(if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);}
) ;
/* Decode the Opcode Class */
switch (op_class) {
case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */
case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */
break;
case AML_CLASS_EXECUTE: /* most operators with arguments */
case AML_CLASS_EXECUTE: /* most operators with arguments */
/* Build resolved operand stack */
status = acpi_ds_create_operands (walk_state, first_arg);
if (ACPI_FAILURE (status)) {
status = acpi_ds_create_operands(walk_state, first_arg);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
/* Done with this result state (Now that operand stack is built) */
status = acpi_ds_result_stack_pop (walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ds_result_stack_pop(walk_state);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
@ -417,86 +411,93 @@ acpi_ds_exec_end_op (
if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE)) {
/* Resolve all operands */
status = acpi_ex_resolve_operands (walk_state->opcode,
&(walk_state->operands [walk_state->num_operands -1]),
walk_state);
if (ACPI_SUCCESS (status)) {
ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
acpi_ps_get_opcode_name (walk_state->opcode),
walk_state->num_operands, "after ex_resolve_operands");
status = acpi_ex_resolve_operands(walk_state->opcode,
&(walk_state->
operands
[walk_state->
num_operands - 1]),
walk_state);
if (ACPI_SUCCESS(status)) {
ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS,
ACPI_IMODE_EXECUTE,
acpi_ps_get_opcode_name
(walk_state->opcode),
walk_state->num_operands,
"after ex_resolve_operands");
}
}
if (ACPI_SUCCESS (status)) {
if (ACPI_SUCCESS(status)) {
/*
* Dispatch the request to the appropriate interpreter handler
* routine. There is one routine per opcode "type" based upon the
* number of opcode arguments and return type.
*/
status = acpi_gbl_op_type_dispatch[op_type] (walk_state);
}
else {
status =
acpi_gbl_op_type_dispatch[op_type] (walk_state);
} else {
/*
* Treat constructs of the form "Store(local_x,local_x)" as noops when the
* Local is uninitialized.
*/
if ((status == AE_AML_UNINITIALIZED_LOCAL) &&
(walk_state->opcode == AML_STORE_OP) &&
(walk_state->operands[0]->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
(walk_state->operands[1]->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
(walk_state->operands[0]->reference.opcode ==
walk_state->operands[1]->reference.opcode) &&
(walk_state->operands[0]->reference.offset ==
walk_state->operands[1]->reference.offset)) {
if ((status == AE_AML_UNINITIALIZED_LOCAL) &&
(walk_state->opcode == AML_STORE_OP) &&
(walk_state->operands[0]->common.type ==
ACPI_TYPE_LOCAL_REFERENCE)
&& (walk_state->operands[1]->common.type ==
ACPI_TYPE_LOCAL_REFERENCE)
&& (walk_state->operands[0]->reference.opcode ==
walk_state->operands[1]->reference.opcode)
&& (walk_state->operands[0]->reference.offset ==
walk_state->operands[1]->reference.offset)) {
status = AE_OK;
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"[%s]: Could not resolve operands, %s\n",
acpi_ps_get_opcode_name (walk_state->opcode),
acpi_format_exception (status)));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"[%s]: Could not resolve operands, %s\n",
acpi_ps_get_opcode_name
(walk_state->opcode),
acpi_format_exception
(status)));
}
}
/* Always delete the argument objects and clear the operand stack */
acpi_ds_clear_operands (walk_state);
acpi_ds_clear_operands(walk_state);
/*
* If a result object was returned from above, push it on the
* current result stack
*/
if (ACPI_SUCCESS (status) &&
walk_state->result_obj) {
status = acpi_ds_result_push (walk_state->result_obj, walk_state);
if (ACPI_SUCCESS(status) && walk_state->result_obj) {
status =
acpi_ds_result_push(walk_state->result_obj,
walk_state);
}
break;
default:
switch (op_type) {
case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
/* 1 Operand, 0 external_result, 0 internal_result */
status = acpi_ds_exec_end_control_op (walk_state, op);
status = acpi_ds_exec_end_control_op(walk_state, op);
/* Make sure to properly pop the result stack */
if (ACPI_SUCCESS (status)) {
status = acpi_ds_result_stack_pop (walk_state);
}
else if (status == AE_CTRL_PENDING) {
status = acpi_ds_result_stack_pop (walk_state);
if (ACPI_SUCCESS (status)) {
if (ACPI_SUCCESS(status)) {
status = acpi_ds_result_stack_pop(walk_state);
} else if (status == AE_CTRL_PENDING) {
status = acpi_ds_result_stack_pop(walk_state);
if (ACPI_SUCCESS(status)) {
status = AE_CTRL_PENDING;
}
}
break;
case AML_TYPE_METHOD_CALL:
/*
@ -505,16 +506,22 @@ acpi_ds_exec_end_op (
* a reference to it.
*/
if ((op->asl.parent) &&
((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP) ||
(op->asl.parent->asl.aml_opcode == AML_VAR_PACKAGE_OP))) {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Method Reference in a Package, Op=%p\n", op));
op->common.node = (struct acpi_namespace_node *) op->asl.value.arg->asl.node->object;
acpi_ut_add_reference (op->asl.value.arg->asl.node->object);
return_ACPI_STATUS (AE_OK);
((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP)
|| (op->asl.parent->asl.aml_opcode ==
AML_VAR_PACKAGE_OP))) {
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Method Reference in a Package, Op=%p\n",
op));
op->common.node =
(struct acpi_namespace_node *)op->asl.value.
arg->asl.node->object;
acpi_ut_add_reference(op->asl.value.arg->asl.
node->object);
return_ACPI_STATUS(AE_OK);
}
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", op));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Method invocation, Op=%p\n", op));
/*
* (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains
@ -531,8 +538,8 @@ acpi_ds_exec_end_op (
/*
* Get the method's arguments and put them on the operand stack
*/
status = acpi_ds_create_operands (walk_state, next_op);
if (ACPI_FAILURE (status)) {
status = acpi_ds_create_operands(walk_state, next_op);
if (ACPI_FAILURE(status)) {
break;
}
@ -541,11 +548,11 @@ acpi_ds_exec_end_op (
* we must resolve all local references here (Local variables,
* arguments to *this* method, etc.)
*/
status = acpi_ds_resolve_operands (walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ds_resolve_operands(walk_state);
if (ACPI_FAILURE(status)) {
/* On error, clear all resolved operands */
acpi_ds_clear_operands (walk_state);
acpi_ds_clear_operands(walk_state);
break;
}
@ -559,27 +566,28 @@ acpi_ds_exec_end_op (
* Return now; we don't want to disturb anything,
* especially the operand count!
*/
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
case AML_TYPE_CREATE_FIELD:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Executing create_field Buffer/Index Op=%p\n", op));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Executing create_field Buffer/Index Op=%p\n",
op));
status = acpi_ds_load2_end_op (walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ds_load2_end_op(walk_state);
if (ACPI_FAILURE(status)) {
break;
}
status = acpi_ds_eval_buffer_field_operands (walk_state, op);
status =
acpi_ds_eval_buffer_field_operands(walk_state, op);
break;
case AML_TYPE_CREATE_OBJECT:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Executing create_object (Buffer/Package) Op=%p\n", op));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Executing create_object (Buffer/Package) Op=%p\n",
op));
switch (op->common.parent->common.aml_opcode) {
case AML_NAME_OP:
@ -588,13 +596,15 @@ acpi_ds_exec_end_op (
* Put the Node on the object stack (Contains the ACPI Name
* of this object)
*/
walk_state->operands[0] = (void *) op->common.parent->common.node;
walk_state->operands[0] =
(void *)op->common.parent->common.node;
walk_state->num_operands = 1;
status = acpi_ds_create_node (walk_state,
op->common.parent->common.node,
op->common.parent);
if (ACPI_FAILURE (status)) {
status = acpi_ds_create_node(walk_state,
op->common.parent->
common.node,
op->common.parent);
if (ACPI_FAILURE(status)) {
break;
}
@ -603,20 +613,26 @@ acpi_ds_exec_end_op (
case AML_INT_EVAL_SUBTREE_OP:
status = acpi_ds_eval_data_object_operands (walk_state, op,
acpi_ns_get_attached_object (op->common.parent->common.node));
status =
acpi_ds_eval_data_object_operands
(walk_state, op,
acpi_ns_get_attached_object(op->common.
parent->common.
node));
break;
default:
status = acpi_ds_eval_data_object_operands (walk_state, op, NULL);
status =
acpi_ds_eval_data_object_operands
(walk_state, op, NULL);
break;
}
/* Done with result state (Now that operand stack is built) */
status = acpi_ds_result_stack_pop (walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ds_result_stack_pop(walk_state);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
@ -625,56 +641,58 @@ acpi_ds_exec_end_op (
* current result stack
*/
if (walk_state->result_obj) {
status = acpi_ds_result_push (walk_state->result_obj, walk_state);
status =
acpi_ds_result_push(walk_state->result_obj,
walk_state);
}
break;
case AML_TYPE_NAMED_FIELD:
case AML_TYPE_NAMED_COMPLEX:
case AML_TYPE_NAMED_SIMPLE:
case AML_TYPE_NAMED_NO_OBJ:
status = acpi_ds_load2_end_op (walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ds_load2_end_op(walk_state);
if (ACPI_FAILURE(status)) {
break;
}
if (op->common.aml_opcode == AML_REGION_OP) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Executing op_region Address/Length Op=%p\n", op));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Executing op_region Address/Length Op=%p\n",
op));
status = acpi_ds_eval_region_operands (walk_state, op);
if (ACPI_FAILURE (status)) {
status =
acpi_ds_eval_region_operands(walk_state,
op);
if (ACPI_FAILURE(status)) {
break;
}
status = acpi_ds_result_stack_pop (walk_state);
status = acpi_ds_result_stack_pop(walk_state);
}
break;
case AML_TYPE_UNDEFINED:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Undefined opcode type Op=%p\n", op));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Undefined opcode type Op=%p\n", op));
return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
case AML_TYPE_BOGUS:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Internal opcode=%X type Op=%p\n",
walk_state->opcode, op));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Internal opcode=%X type Op=%p\n",
walk_state->opcode, op));
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n",
op_class, op_type, op->common.aml_opcode, op));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n",
op_class, op_type,
op->common.aml_opcode, op));
status = AE_NOT_IMPLEMENTED;
break;
@ -685,55 +703,58 @@ acpi_ds_exec_end_op (
* ACPI 2.0 support for 64-bit integers: Truncate numeric
* result value if we are executing from a 32-bit ACPI table
*/
acpi_ex_truncate_for32bit_table (walk_state->result_obj);
acpi_ex_truncate_for32bit_table(walk_state->result_obj);
/*
* Check if we just completed the evaluation of a
* conditional predicate
*/
if ((ACPI_SUCCESS (status)) &&
(walk_state->control_state) &&
(walk_state->control_state->common.state ==
ACPI_CONTROL_PREDICATE_EXECUTING) &&
(walk_state->control_state->control.predicate_op == op)) {
status = acpi_ds_get_predicate_value (walk_state, walk_state->result_obj);
if ((ACPI_SUCCESS(status)) &&
(walk_state->control_state) &&
(walk_state->control_state->common.state ==
ACPI_CONTROL_PREDICATE_EXECUTING) &&
(walk_state->control_state->control.predicate_op == op)) {
status =
acpi_ds_get_predicate_value(walk_state,
walk_state->result_obj);
walk_state->result_obj = NULL;
}
cleanup:
cleanup:
/* Invoke exception handler on error */
if (ACPI_FAILURE (status) &&
acpi_gbl_exception_handler &&
!(status & AE_CODE_CONTROL)) {
acpi_ex_exit_interpreter ();
status = acpi_gbl_exception_handler (status,
walk_state->method_node->name.integer, walk_state->opcode,
walk_state->aml_offset, NULL);
(void) acpi_ex_enter_interpreter ();
if (ACPI_FAILURE(status) &&
acpi_gbl_exception_handler && !(status & AE_CODE_CONTROL)) {
acpi_ex_exit_interpreter();
status = acpi_gbl_exception_handler(status,
walk_state->method_node->
name.integer,
walk_state->opcode,
walk_state->aml_offset,
NULL);
(void)acpi_ex_enter_interpreter();
}
if (walk_state->result_obj) {
/* Break to debugger to display result */
ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj,
walk_state));
ACPI_DEBUGGER_EXEC(acpi_db_display_result_object
(walk_state->result_obj, walk_state));
/*
* Delete the result op if and only if:
* Parent will not use the result -- such as any
* non-nested type2 op in a method (parent will be method)
*/
acpi_ds_delete_result_if_not_used (op, walk_state->result_obj, walk_state);
acpi_ds_delete_result_if_not_used(op, walk_state->result_obj,
walk_state);
}
#ifdef _UNDER_DEVELOPMENT
if (walk_state->parser_state.aml == walk_state->parser_state.aml_end) {
acpi_db_method_end (walk_state);
acpi_db_method_end(walk_state);
}
#endif
@ -745,12 +766,10 @@ cleanup:
/* On error, display method locals/args */
if (ACPI_FAILURE (status)) {
acpi_dm_dump_method_info (status, walk_state, op);
if (ACPI_FAILURE(status)) {
acpi_dm_dump_method_info(status, walk_state, op);
}
#endif
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -41,7 +41,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acparser.h>
#include <acpi/amlcode.h>
@ -50,13 +49,12 @@
#include <acpi/acnamesp.h>
#include <acpi/acevents.h>
#ifdef _ACPI_ASL_COMPILER
#ifdef ACPI_ASL_COMPILER
#include <acpi/acdisasm.h>
#endif
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dswload")
ACPI_MODULE_NAME("dswload")
/*******************************************************************************
*
@ -70,32 +68,29 @@
* DESCRIPTION: Init walk state callbacks
*
******************************************************************************/
acpi_status
acpi_ds_init_callbacks (
struct acpi_walk_state *walk_state,
u32 pass_number)
acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number)
{
switch (pass_number) {
case 1:
walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
ACPI_PARSE_DELETE_TREE;
walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
ACPI_PARSE_DELETE_TREE;
walk_state->descending_callback = acpi_ds_load1_begin_op;
walk_state->ascending_callback = acpi_ds_load1_end_op;
break;
case 2:
walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
ACPI_PARSE_DELETE_TREE;
walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
ACPI_PARSE_DELETE_TREE;
walk_state->descending_callback = acpi_ds_load2_begin_op;
walk_state->ascending_callback = acpi_ds_load2_end_op;
break;
case 3:
#ifndef ACPI_NO_METHOD_EXECUTION
walk_state->parse_flags |= ACPI_PARSE_EXECUTE |
ACPI_PARSE_DELETE_TREE;
walk_state->parse_flags |= ACPI_PARSE_EXECUTE |
ACPI_PARSE_DELETE_TREE;
walk_state->descending_callback = acpi_ds_exec_begin_op;
walk_state->ascending_callback = acpi_ds_exec_end_op;
#endif
@ -108,7 +103,6 @@ acpi_ds_init_callbacks (
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_load1_begin_op
@ -123,37 +117,26 @@ acpi_ds_init_callbacks (
******************************************************************************/
acpi_status
acpi_ds_load1_begin_op (
struct acpi_walk_state *walk_state,
union acpi_parse_object **out_op)
acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
union acpi_parse_object ** out_op)
{
union acpi_parse_object *op;
struct acpi_namespace_node *node;
acpi_status status;
acpi_object_type object_type;
char *path;
u32 flags;
ACPI_FUNCTION_NAME ("ds_load1_begin_op");
union acpi_parse_object *op;
struct acpi_namespace_node *node;
acpi_status status;
acpi_object_type object_type;
char *path;
u32 flags;
ACPI_FUNCTION_NAME("ds_load1_begin_op");
op = walk_state->op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
walk_state));
/* We are only interested in opcodes that have an associated name */
if (op) {
if (!(walk_state->op_info->flags & AML_NAMED)) {
#if 0
if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
(walk_state->op_info->class == AML_CLASS_CONTROL)) {
acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n",
walk_state->op_info->name);
*out_op = op;
return (AE_CTRL_SKIP);
}
#endif
*out_op = op;
return (AE_OK);
}
@ -166,14 +149,15 @@ acpi_ds_load1_begin_op (
}
}
path = acpi_ps_get_next_namestring (&walk_state->parser_state);
path = acpi_ps_get_next_namestring(&walk_state->parser_state);
/* Map the raw opcode into an internal object type */
object_type = walk_state->op_info->object_type;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"State=%p Op=%p [%s]\n", walk_state, op, acpi_ut_get_type_name (object_type)));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"State=%p Op=%p [%s]\n", walk_state, op,
acpi_ut_get_type_name(object_type)));
switch (walk_state->opcode) {
case AML_SCOPE_OP:
@ -183,23 +167,27 @@ acpi_ds_load1_begin_op (
* that we can actually open the scope to enter new names underneath it.
* Allow search-to-root for single namesegs.
*/
status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
#ifdef _ACPI_ASL_COMPILER
status =
acpi_ns_lookup(walk_state->scope_info, path, object_type,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
walk_state, &(node));
#ifdef ACPI_ASL_COMPILER
if (status == AE_NOT_FOUND) {
/*
* Table disassembly:
* Target of Scope() not found. Generate an External for it, and
* insert the name into the namespace.
*/
acpi_dm_add_to_external_list (path);
status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
walk_state, &(node));
acpi_dm_add_to_external_list(path);
status =
acpi_ns_lookup(walk_state->scope_info, path,
object_type, ACPI_IMODE_LOAD_PASS1,
ACPI_NS_SEARCH_PARENT, walk_state,
&(node));
}
#endif
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (path, status);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(path, status);
return (status);
}
@ -208,7 +196,7 @@ acpi_ds_load1_begin_op (
* one of the opcodes that actually opens a scope
*/
switch (node->type) {
case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_POWER:
case ACPI_TYPE_PROCESSOR:
@ -232,9 +220,10 @@ acpi_ds_load1_begin_op (
* a warning
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
path, acpi_ut_get_type_name (node->type)));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
path,
acpi_ut_get_type_name(node->type)));
node->type = ACPI_TYPE_ANY;
walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@ -244,15 +233,12 @@ acpi_ds_load1_begin_op (
/* All other types are an error */
ACPI_REPORT_ERROR ((
"Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
acpi_ut_get_type_name (node->type), path));
ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", acpi_ut_get_type_name(node->type), path));
return (AE_AML_OPERAND_TYPE);
}
break;
default:
/*
@ -281,15 +267,15 @@ acpi_ds_load1_begin_op (
flags = ACPI_NS_NO_UPSEARCH;
if ((walk_state->opcode != AML_SCOPE_OP) &&
(!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
(!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
flags |= ACPI_NS_ERROR_IF_FOUND;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
acpi_ut_get_type_name (object_type)));
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"[%s] Both Find or Create allowed\n",
acpi_ut_get_type_name (object_type)));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"[%s] Cannot already exist\n",
acpi_ut_get_type_name(object_type)));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"[%s] Both Find or Create allowed\n",
acpi_ut_get_type_name(object_type)));
}
/*
@ -298,22 +284,23 @@ acpi_ds_load1_begin_op (
* involve arguments to the opcode must be created as we go back up the
* parse tree later.
*/
status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node));
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (path, status);
status =
acpi_ns_lookup(walk_state->scope_info, path, object_type,
ACPI_IMODE_LOAD_PASS1, flags, walk_state,
&(node));
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(path, status);
return (status);
}
break;
}
/* Common exit */
if (!op) {
/* Create a new op */
op = acpi_ps_alloc_op (walk_state->opcode);
op = acpi_ps_alloc_op(walk_state->opcode);
if (!op) {
return (AE_NO_MEMORY);
}
@ -327,19 +314,18 @@ acpi_ds_load1_begin_op (
op->named.path = (u8 *) path;
#endif
/*
* Put the Node in the "op" object that the parser uses, so we
* can get it again quickly when this scope is closed
*/
op->common.node = node;
acpi_ps_append_arg (acpi_ps_get_parent_scope (&walk_state->parser_state), op);
acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state),
op);
*out_op = op;
return (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_load1_end_op
@ -353,20 +339,17 @@ acpi_ds_load1_begin_op (
*
******************************************************************************/
acpi_status
acpi_ds_load1_end_op (
struct acpi_walk_state *walk_state)
acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
{
union acpi_parse_object *op;
acpi_object_type object_type;
acpi_status status = AE_OK;
ACPI_FUNCTION_NAME ("ds_load1_end_op");
union acpi_parse_object *op;
acpi_object_type object_type;
acpi_status status = AE_OK;
ACPI_FUNCTION_NAME("ds_load1_end_op");
op = walk_state->op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
walk_state));
/* We are only interested in opcodes that have an associated name */
@ -380,21 +363,20 @@ acpi_ds_load1_end_op (
#ifndef ACPI_NO_METHOD_EXECUTION
if (walk_state->op_info->flags & AML_FIELD) {
if (walk_state->opcode == AML_FIELD_OP ||
walk_state->opcode == AML_BANK_FIELD_OP ||
walk_state->opcode == AML_INDEX_FIELD_OP) {
status = acpi_ds_init_field_objects (op, walk_state);
if (walk_state->opcode == AML_FIELD_OP ||
walk_state->opcode == AML_BANK_FIELD_OP ||
walk_state->opcode == AML_INDEX_FIELD_OP) {
status = acpi_ds_init_field_objects(op, walk_state);
}
return (status);
}
if (op->common.aml_opcode == AML_REGION_OP) {
status = acpi_ex_create_region (op->named.data, op->named.length,
(acpi_adr_space_type)
((op->common.value.arg)->common.value.integer),
walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ex_create_region(op->named.data, op->named.length,
(acpi_adr_space_type)
((op->common.value.arg)->common.
value.integer), walk_state);
if (ACPI_FAILURE(status)) {
return (status);
}
}
@ -404,8 +386,11 @@ acpi_ds_load1_end_op (
/* For Name opcode, get the object type from the argument */
if (op->common.value.arg) {
object_type = (acpi_ps_get_opcode_info (
(op->common.value.arg)->common.aml_opcode))->object_type;
object_type = (acpi_ps_get_opcode_info((op->common.
value.arg)->
common.
aml_opcode))->
object_type;
op->common.node->type = (u8) object_type;
}
}
@ -419,23 +404,26 @@ acpi_ds_load1_end_op (
* of invocations of the method (need to know the number of
* arguments.)
*/
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"LOADING-Method: State=%p Op=%p named_obj=%p\n",
walk_state, op, op->named.node));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"LOADING-Method: State=%p Op=%p named_obj=%p\n",
walk_state, op, op->named.node));
if (!acpi_ns_get_attached_object (op->named.node)) {
walk_state->operands[0] = (void *) op->named.node;
if (!acpi_ns_get_attached_object(op->named.node)) {
walk_state->operands[0] = (void *)op->named.node;
walk_state->num_operands = 1;
status = acpi_ds_create_operands (walk_state, op->common.value.arg);
if (ACPI_SUCCESS (status)) {
status = acpi_ex_create_method (op->named.data,
op->named.length, walk_state);
status =
acpi_ds_create_operands(walk_state,
op->common.value.arg);
if (ACPI_SUCCESS(status)) {
status = acpi_ex_create_method(op->named.data,
op->named.length,
walk_state);
}
walk_state->operands[0] = NULL;
walk_state->num_operands = 0;
if (ACPI_FAILURE (status)) {
if (ACPI_FAILURE(status)) {
return (status);
}
}
@ -443,17 +431,17 @@ acpi_ds_load1_end_op (
/* Pop the scope stack */
if (acpi_ns_opens_scope (object_type)) {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
acpi_ut_get_type_name (object_type), op));
if (acpi_ns_opens_scope(object_type)) {
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"(%s): Popping scope for Op %p\n",
acpi_ut_get_type_name(object_type), op));
status = acpi_ds_scope_stack_pop (walk_state);
status = acpi_ds_scope_stack_pop(walk_state);
}
return (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_load2_begin_op
@ -468,30 +456,53 @@ acpi_ds_load1_end_op (
******************************************************************************/
acpi_status
acpi_ds_load2_begin_op (
struct acpi_walk_state *walk_state,
union acpi_parse_object **out_op)
acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
union acpi_parse_object ** out_op)
{
union acpi_parse_object *op;
struct acpi_namespace_node *node;
acpi_status status;
acpi_object_type object_type;
char *buffer_ptr;
ACPI_FUNCTION_TRACE ("ds_load2_begin_op");
union acpi_parse_object *op;
struct acpi_namespace_node *node;
acpi_status status;
acpi_object_type object_type;
char *buffer_ptr;
ACPI_FUNCTION_TRACE("ds_load2_begin_op");
op = walk_state->op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
walk_state));
if (op) {
if ((walk_state->control_state) &&
(walk_state->control_state->common.state ==
ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
/* We are executing a while loop outside of a method */
status = acpi_ds_exec_begin_op(walk_state, out_op);
return_ACPI_STATUS(status);
}
/* We only care about Namespace opcodes here */
if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
(walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
(!(walk_state->op_info->flags & AML_NAMED))) {
return_ACPI_STATUS (AE_OK);
(walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
(!(walk_state->op_info->flags & AML_NAMED))) {
#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
(walk_state->op_info->class == AML_CLASS_CONTROL)) {
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Begin/EXEC: %s (fl %8.8X)\n",
walk_state->op_info->name,
walk_state->op_info->flags));
/* Executing a type1 or type2 opcode outside of a method */
status =
acpi_ds_exec_begin_op(walk_state, out_op);
return_ACPI_STATUS(status);
}
#endif
return_ACPI_STATUS(AE_OK);
}
/* Get the name we are going to enter or lookup in the namespace */
@ -503,28 +514,27 @@ acpi_ds_load2_begin_op (
if (!buffer_ptr) {
/* No name, just exit */
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
}
else {
} else {
/* Get name from the op */
buffer_ptr = (char *) &op->named.name;
buffer_ptr = (char *)&op->named.name;
}
}
else {
} else {
/* Get the namestring from the raw AML */
buffer_ptr = acpi_ps_get_next_namestring (&walk_state->parser_state);
buffer_ptr =
acpi_ps_get_next_namestring(&walk_state->parser_state);
}
/* Map the opcode into an internal object type */
object_type = walk_state->op_info->object_type;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"State=%p Op=%p Type=%X\n", walk_state, op, object_type));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"State=%p Op=%p Type=%X\n", walk_state, op,
object_type));
switch (walk_state->opcode) {
case AML_FIELD_OP:
@ -542,9 +552,10 @@ acpi_ds_load2_begin_op (
* Don't enter the name into the namespace, but look it up
* for use later.
*/
status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
walk_state, &(node));
status =
acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
object_type, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state, &(node));
break;
case AML_SCOPE_OP:
@ -554,28 +565,28 @@ acpi_ds_load2_begin_op (
* Don't enter the name into the namespace, but look it up
* for use later.
*/
status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
walk_state, &(node));
if (ACPI_FAILURE (status)) {
#ifdef _ACPI_ASL_COMPILER
status =
acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
object_type, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT, walk_state, &(node));
if (ACPI_FAILURE(status)) {
#ifdef ACPI_ASL_COMPILER
if (status == AE_NOT_FOUND) {
status = AE_OK;
}
else {
ACPI_REPORT_NSERROR (buffer_ptr, status);
} else {
ACPI_REPORT_NSERROR(buffer_ptr, status);
}
#else
ACPI_REPORT_NSERROR (buffer_ptr, status);
ACPI_REPORT_NSERROR(buffer_ptr, status);
#endif
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*
* We must check to make sure that the target is
* one of the opcodes that actually opens a scope
*/
switch (node->type) {
case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_POWER:
case ACPI_TYPE_PROCESSOR:
@ -596,9 +607,7 @@ acpi_ds_load2_begin_op (
* Scope (DEB) { ... }
*/
ACPI_REPORT_WARNING ((
"Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
buffer_ptr, acpi_ut_get_type_name (node->type)));
ACPI_REPORT_WARNING(("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", buffer_ptr, acpi_ut_get_type_name(node->type)));
node->type = ACPI_TYPE_ANY;
walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@ -608,9 +617,7 @@ acpi_ds_load2_begin_op (
/* All other types are an error */
ACPI_REPORT_ERROR ((
"Invalid type (%s) for target of Scope operator [%4.4s]\n",
acpi_ut_get_type_name (node->type), buffer_ptr));
ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s]\n", acpi_ut_get_type_name(node->type), buffer_ptr));
return (AE_AML_OPERAND_TYPE);
}
@ -625,14 +632,16 @@ acpi_ds_load2_begin_op (
node = op->common.node;
if (acpi_ns_opens_scope (object_type)) {
status = acpi_ds_scope_stack_push (node, object_type, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
if (acpi_ns_opens_scope(object_type)) {
status =
acpi_ds_scope_stack_push(node, object_type,
walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*
@ -651,24 +660,26 @@ acpi_ds_load2_begin_op (
break;
}
status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH,
walk_state, &(node));
/* Add new entry into namespace */
status =
acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
object_type, ACPI_IMODE_LOAD_PASS2,
ACPI_NS_NO_UPSEARCH, walk_state, &(node));
break;
}
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR (buffer_ptr, status);
return_ACPI_STATUS (status);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_NSERROR(buffer_ptr, status);
return_ACPI_STATUS(status);
}
if (!op) {
/* Create a new op */
op = acpi_ps_alloc_op (walk_state->opcode);
op = acpi_ps_alloc_op(walk_state->opcode);
if (!op) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Initialize the new op */
@ -676,9 +687,7 @@ acpi_ds_load2_begin_op (
if (node) {
op->named.name = node->name.integer;
}
if (out_op) {
*out_op = op;
}
*out_op = op;
}
/*
@ -687,10 +696,9 @@ acpi_ds_load2_begin_op (
*/
op->common.node = node;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ds_load2_end_op
@ -704,39 +712,54 @@ acpi_ds_load2_begin_op (
*
******************************************************************************/
acpi_status
acpi_ds_load2_end_op (
struct acpi_walk_state *walk_state)
acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
{
union acpi_parse_object *op;
acpi_status status = AE_OK;
acpi_object_type object_type;
struct acpi_namespace_node *node;
union acpi_parse_object *arg;
struct acpi_namespace_node *new_node;
union acpi_parse_object *op;
acpi_status status = AE_OK;
acpi_object_type object_type;
struct acpi_namespace_node *node;
union acpi_parse_object *arg;
struct acpi_namespace_node *new_node;
#ifndef ACPI_NO_METHOD_EXECUTION
u32 i;
u32 i;
#endif
ACPI_FUNCTION_TRACE ("ds_load2_end_op");
ACPI_FUNCTION_TRACE("ds_load2_end_op");
op = walk_state->op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
walk_state->op_info->name, op, walk_state));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
walk_state->op_info->name, op, walk_state));
/* Only interested in opcodes that have namespace objects */
/* Check if opcode had an associated namespace object */
if (!(walk_state->op_info->flags & AML_NSOBJECT)) {
return_ACPI_STATUS (AE_OK);
#ifndef ACPI_NO_METHOD_EXECUTION
#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
/* No namespace object. Executable opcode? */
if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
(walk_state->op_info->class == AML_CLASS_CONTROL)) {
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"End/EXEC: %s (fl %8.8X)\n",
walk_state->op_info->name,
walk_state->op_info->flags));
/* Executing a type1 or type2 opcode outside of a method */
status = acpi_ds_exec_end_op(walk_state);
return_ACPI_STATUS(status);
}
#endif
#endif
return_ACPI_STATUS(AE_OK);
}
if (op->common.aml_opcode == AML_SCOPE_OP) {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Ending scope Op=%p State=%p\n", op, walk_state));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Ending scope Op=%p State=%p\n", op,
walk_state));
}
object_type = walk_state->op_info->object_type;
/*
@ -749,18 +772,19 @@ acpi_ds_load2_end_op (
* Put the Node on the object stack (Contains the ACPI Name of
* this object)
*/
walk_state->operands[0] = (void *) node;
walk_state->operands[0] = (void *)node;
walk_state->num_operands = 1;
/* Pop the scope stack */
if (acpi_ns_opens_scope (object_type) &&
(op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
acpi_ut_get_type_name (object_type), op));
if (acpi_ns_opens_scope(object_type) &&
(op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"(%s) Popping scope for Op %p\n",
acpi_ut_get_type_name(object_type), op));
status = acpi_ds_scope_stack_pop (walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ds_scope_stack_pop(walk_state);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
}
@ -793,9 +817,10 @@ acpi_ds_load2_end_op (
* AML_THERMALZONE
*/
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Create-Load [%s] State=%p Op=%p named_obj=%p\n",
acpi_ps_get_opcode_name (op->common.aml_opcode), walk_state, op, node));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"Create-Load [%s] State=%p Op=%p named_obj=%p\n",
acpi_ps_get_opcode_name(op->common.aml_opcode),
walk_state, op, node));
/* Decode the opcode */
@ -810,27 +835,32 @@ acpi_ds_load2_end_op (
* Create the field object, but the field buffer and index must
* be evaluated later during the execution phase
*/
status = acpi_ds_create_buffer_field (op, walk_state);
status = acpi_ds_create_buffer_field(op, walk_state);
break;
case AML_TYPE_NAMED_FIELD:
case AML_TYPE_NAMED_FIELD:
switch (op->common.aml_opcode) {
case AML_INDEX_FIELD_OP:
status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node,
walk_state);
status =
acpi_ds_create_index_field(op,
(acpi_handle) arg->
common.node, walk_state);
break;
case AML_BANK_FIELD_OP:
status = acpi_ds_create_bank_field (op, arg->common.node, walk_state);
status =
acpi_ds_create_bank_field(op, arg->common.node,
walk_state);
break;
case AML_FIELD_OP:
status = acpi_ds_create_field (op, arg->common.node, walk_state);
status =
acpi_ds_create_field(op, arg->common.node,
walk_state);
break;
default:
@ -839,43 +869,42 @@ acpi_ds_load2_end_op (
}
break;
case AML_TYPE_NAMED_SIMPLE:
case AML_TYPE_NAMED_SIMPLE:
status = acpi_ds_create_operands (walk_state, arg);
if (ACPI_FAILURE (status)) {
status = acpi_ds_create_operands(walk_state, arg);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
switch (op->common.aml_opcode) {
case AML_PROCESSOR_OP:
status = acpi_ex_create_processor (walk_state);
status = acpi_ex_create_processor(walk_state);
break;
case AML_POWER_RES_OP:
status = acpi_ex_create_power_resource (walk_state);
status = acpi_ex_create_power_resource(walk_state);
break;
case AML_MUTEX_OP:
status = acpi_ex_create_mutex (walk_state);
status = acpi_ex_create_mutex(walk_state);
break;
case AML_EVENT_OP:
status = acpi_ex_create_event (walk_state);
status = acpi_ex_create_event(walk_state);
break;
case AML_DATA_REGION_OP:
status = acpi_ex_create_table_region (walk_state);
status = acpi_ex_create_table_region(walk_state);
break;
case AML_ALIAS_OP:
status = acpi_ex_create_alias (walk_state);
status = acpi_ex_create_alias(walk_state);
break;
default:
@ -888,12 +917,12 @@ acpi_ds_load2_end_op (
/* Delete operands */
for (i = 1; i < walk_state->num_operands; i++) {
acpi_ut_remove_reference (walk_state->operands[i]);
acpi_ut_remove_reference(walk_state->operands[i]);
walk_state->operands[i] = NULL;
}
break;
#endif /* ACPI_NO_METHOD_EXECUTION */
#endif /* ACPI_NO_METHOD_EXECUTION */
case AML_TYPE_NAMED_COMPLEX:
@ -909,9 +938,10 @@ acpi_ds_load2_end_op (
* If we have a valid region, initialize it
* Namespace is NOT locked at this point.
*/
status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node),
FALSE);
if (ACPI_FAILURE (status)) {
status =
acpi_ev_initialize_region
(acpi_ns_get_attached_object(node), FALSE);
if (ACPI_FAILURE(status)) {
/*
* If AE_NOT_EXIST is returned, it is not fatal
* because many regions get created before a handler
@ -923,13 +953,11 @@ acpi_ds_load2_end_op (
}
break;
case AML_NAME_OP:
status = acpi_ds_create_node (walk_state, node, op);
status = acpi_ds_create_node(walk_state, node, op);
break;
#endif /* ACPI_NO_METHOD_EXECUTION */
#endif /* ACPI_NO_METHOD_EXECUTION */
default:
/* All NAMED_COMPLEX opcodes must be handled above */
@ -938,27 +966,29 @@ acpi_ds_load2_end_op (
}
break;
case AML_CLASS_INTERNAL:
/* case AML_INT_NAMEPATH_OP: */
break;
case AML_CLASS_METHOD_CALL:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"RESOLVING-method_call: State=%p Op=%p named_obj=%p\n",
walk_state, op, node));
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"RESOLVING-method_call: State=%p Op=%p named_obj=%p\n",
walk_state, op, node));
/*
* Lookup the method name and save the Node
*/
status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
walk_state, &(new_node));
if (ACPI_SUCCESS (status)) {
status =
acpi_ns_lookup(walk_state->scope_info,
arg->common.value.string, ACPI_TYPE_ANY,
ACPI_IMODE_LOAD_PASS2,
ACPI_NS_SEARCH_PARENT |
ACPI_NS_DONT_OPEN_SCOPE, walk_state,
&(new_node));
if (ACPI_SUCCESS(status)) {
/*
* Make sure that what we found is indeed a method
* We didn't search for a method on purpose, to see if the name
@ -973,24 +1003,20 @@ acpi_ds_load2_end_op (
* parser uses, so we can get it again at the end of this scope
*/
op->common.node = new_node;
}
else {
ACPI_REPORT_NSERROR (arg->common.value.string, status);
} else {
ACPI_REPORT_NSERROR(arg->common.value.string, status);
}
break;
default:
break;
}
cleanup:
cleanup:
/* Remove the Node pushed at the very beginning */
walk_state->operands[0] = NULL;
walk_state->num_operands = 0;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -41,14 +41,11 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acdispat.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dswscope")
ACPI_MODULE_NAME("dswscope")
/****************************************************************************
*
@ -62,15 +59,11 @@
* root scope object (which remains at the stack top.)
*
***************************************************************************/
void
acpi_ds_scope_stack_clear (
struct acpi_walk_state *walk_state)
void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state)
{
union acpi_generic_state *scope_info;
ACPI_FUNCTION_NAME ("ds_scope_stack_clear");
union acpi_generic_state *scope_info;
ACPI_FUNCTION_NAME("ds_scope_stack_clear");
while (walk_state->scope_info) {
/* Pop a scope off the stack */
@ -78,14 +71,14 @@ acpi_ds_scope_stack_clear (
scope_info = walk_state->scope_info;
walk_state->scope_info = scope_info->scope.next;
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Popped object type (%s)\n",
acpi_ut_get_type_name (scope_info->common.value)));
acpi_ut_delete_generic_state (scope_info);
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Popped object type (%s)\n",
acpi_ut_get_type_name(scope_info->common.
value)));
acpi_ut_delete_generic_state(scope_info);
}
}
/****************************************************************************
*
* FUNCTION: acpi_ds_scope_stack_push
@ -102,74 +95,70 @@ acpi_ds_scope_stack_clear (
***************************************************************************/
acpi_status
acpi_ds_scope_stack_push (
struct acpi_namespace_node *node,
acpi_object_type type,
struct acpi_walk_state *walk_state)
acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
acpi_object_type type,
struct acpi_walk_state *walk_state)
{
union acpi_generic_state *scope_info;
union acpi_generic_state *old_scope_info;
ACPI_FUNCTION_TRACE ("ds_scope_stack_push");
union acpi_generic_state *scope_info;
union acpi_generic_state *old_scope_info;
ACPI_FUNCTION_TRACE("ds_scope_stack_push");
if (!node) {
/* Invalid scope */
ACPI_REPORT_ERROR (("ds_scope_stack_push: null scope passed\n"));
return_ACPI_STATUS (AE_BAD_PARAMETER);
ACPI_REPORT_ERROR(("ds_scope_stack_push: null scope passed\n"));
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Make sure object type is valid */
if (!acpi_ut_valid_object_type (type)) {
ACPI_REPORT_WARNING ((
"ds_scope_stack_push: Invalid object type: 0x%X\n", type));
if (!acpi_ut_valid_object_type(type)) {
ACPI_REPORT_WARNING(("ds_scope_stack_push: Invalid object type: 0x%X\n", type));
}
/* Allocate a new scope object */
scope_info = acpi_ut_create_generic_state ();
scope_info = acpi_ut_create_generic_state();
if (!scope_info) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Init new scope object */
scope_info->common.data_type = ACPI_DESC_TYPE_STATE_WSCOPE;
scope_info->scope.node = node;
scope_info->common.value = (u16) type;
scope_info->scope.node = node;
scope_info->common.value = (u16) type;
walk_state->scope_depth++;
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"[%.2d] Pushed scope ", (u32) walk_state->scope_depth));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"[%.2d] Pushed scope ",
(u32) walk_state->scope_depth));
old_scope_info = walk_state->scope_info;
if (old_scope_info) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
"[%4.4s] (%s)",
acpi_ut_get_node_name (old_scope_info->scope.node),
acpi_ut_get_type_name (old_scope_info->common.value)));
}
else {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
"[\\___] (%s)", "ROOT"));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
"[%4.4s] (%s)",
acpi_ut_get_node_name(old_scope_info->
scope.node),
acpi_ut_get_type_name(old_scope_info->
common.value)));
} else {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (%s)", "ROOT"));
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
", New scope -> [%4.4s] (%s)\n",
acpi_ut_get_node_name (scope_info->scope.node),
acpi_ut_get_type_name (scope_info->common.value)));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
", New scope -> [%4.4s] (%s)\n",
acpi_ut_get_node_name(scope_info->scope.node),
acpi_ut_get_type_name(scope_info->common.value)));
/* Push new scope object onto stack */
acpi_ut_push_generic_state (&walk_state->scope_info, scope_info);
return_ACPI_STATUS (AE_OK);
acpi_ut_push_generic_state(&walk_state->scope_info, scope_info);
return_ACPI_STATUS(AE_OK);
}
/****************************************************************************
*
* FUNCTION: acpi_ds_scope_stack_pop
@ -182,47 +171,41 @@ acpi_ds_scope_stack_push (
*
***************************************************************************/
acpi_status
acpi_ds_scope_stack_pop (
struct acpi_walk_state *walk_state)
acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state)
{
union acpi_generic_state *scope_info;
union acpi_generic_state *new_scope_info;
ACPI_FUNCTION_TRACE ("ds_scope_stack_pop");
union acpi_generic_state *scope_info;
union acpi_generic_state *new_scope_info;
ACPI_FUNCTION_TRACE("ds_scope_stack_pop");
/*
* Pop scope info object off the stack.
*/
scope_info = acpi_ut_pop_generic_state (&walk_state->scope_info);
scope_info = acpi_ut_pop_generic_state(&walk_state->scope_info);
if (!scope_info) {
return_ACPI_STATUS (AE_STACK_UNDERFLOW);
return_ACPI_STATUS(AE_STACK_UNDERFLOW);
}
walk_state->scope_depth--;
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
(u32) walk_state->scope_depth,
acpi_ut_get_node_name (scope_info->scope.node),
acpi_ut_get_type_name (scope_info->common.value)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
(u32) walk_state->scope_depth,
acpi_ut_get_node_name(scope_info->scope.node),
acpi_ut_get_type_name(scope_info->common.value)));
new_scope_info = walk_state->scope_info;
if (new_scope_info) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
"[%4.4s] (%s)\n",
acpi_ut_get_node_name (new_scope_info->scope.node),
acpi_ut_get_type_name (new_scope_info->common.value)));
}
else {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
"[\\___] (ROOT)\n"));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC,
"[%4.4s] (%s)\n",
acpi_ut_get_node_name(new_scope_info->
scope.node),
acpi_ut_get_type_name(new_scope_info->
common.value)));
} else {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (ROOT)\n"));
}
acpi_ut_delete_generic_state (scope_info);
return_ACPI_STATUS (AE_OK);
acpi_ut_delete_generic_state(scope_info);
return_ACPI_STATUS(AE_OK);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -13,45 +13,40 @@
#include <acpi/acpi_drivers.h>
#define _COMPONENT ACPI_SYSTEM_COMPONENT
ACPI_MODULE_NAME ("event")
ACPI_MODULE_NAME("event")
/* Global vars for handling event proc entry */
static DEFINE_SPINLOCK(acpi_system_event_lock);
int event_is_open = 0;
extern struct list_head acpi_bus_event_list;
extern wait_queue_head_t acpi_bus_event_queue;
int event_is_open = 0;
extern struct list_head acpi_bus_event_list;
extern wait_queue_head_t acpi_bus_event_queue;
static int
acpi_system_open_event(struct inode *inode, struct file *file)
static int acpi_system_open_event(struct inode *inode, struct file *file)
{
spin_lock_irq (&acpi_system_event_lock);
spin_lock_irq(&acpi_system_event_lock);
if(event_is_open)
if (event_is_open)
goto out_busy;
event_is_open = 1;
spin_unlock_irq (&acpi_system_event_lock);
spin_unlock_irq(&acpi_system_event_lock);
return 0;
out_busy:
spin_unlock_irq (&acpi_system_event_lock);
out_busy:
spin_unlock_irq(&acpi_system_event_lock);
return -EBUSY;
}
static ssize_t
acpi_system_read_event (
struct file *file,
char __user *buffer,
size_t count,
loff_t *ppos)
acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
loff_t * ppos)
{
int result = 0;
struct acpi_bus_event event;
static char str[ACPI_MAX_STRING];
static int chars_remaining = 0;
static char *ptr;
int result = 0;
struct acpi_bus_event event;
static char str[ACPI_MAX_STRING];
static int chars_remaining = 0;
static char *ptr;
ACPI_FUNCTION_TRACE("acpi_system_read_event");
@ -67,10 +62,12 @@ acpi_system_read_event (
return_VALUE(-EIO);
}
chars_remaining = sprintf(str, "%s %s %08x %08x\n",
event.device_class?event.device_class:"<unknown>",
event.bus_id?event.bus_id:"<unknown>",
event.type, event.data);
chars_remaining = sprintf(str, "%s %s %08x %08x\n",
event.device_class ? event.
device_class : "<unknown>",
event.bus_id ? event.
bus_id : "<unknown>", event.type,
event.data);
ptr = str;
}
@ -88,19 +85,15 @@ acpi_system_read_event (
return_VALUE(count);
}
static int
acpi_system_close_event(struct inode *inode, struct file *file)
static int acpi_system_close_event(struct inode *inode, struct file *file)
{
spin_lock_irq (&acpi_system_event_lock);
spin_lock_irq(&acpi_system_event_lock);
event_is_open = 0;
spin_unlock_irq (&acpi_system_event_lock);
spin_unlock_irq(&acpi_system_event_lock);
return 0;
}
static unsigned int
acpi_system_poll_event(
struct file *file,
poll_table *wait)
static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait)
{
poll_wait(file, &acpi_bus_event_queue, wait);
if (!list_empty(&acpi_bus_event_list))
@ -109,15 +102,15 @@ acpi_system_poll_event(
}
static struct file_operations acpi_system_event_ops = {
.open = acpi_system_open_event,
.read = acpi_system_read_event,
.release = acpi_system_close_event,
.poll = acpi_system_poll_event,
.open = acpi_system_open_event,
.read = acpi_system_read_event,
.release = acpi_system_close_event,
.poll = acpi_system_poll_event,
};
static int __init acpi_event_init(void)
{
struct proc_dir_entry *entry;
struct proc_dir_entry *entry;
int error = 0;
ACPI_FUNCTION_TRACE("acpi_event_init");
@ -130,8 +123,9 @@ static int __init acpi_event_init(void)
if (entry)
entry->proc_fops = &acpi_system_event_ops;
else {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' proc fs entry\n","event" ));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' proc fs entry\n",
"event"));
error = -EFAULT;
}
return_VALUE(error);

View File

@ -45,18 +45,12 @@
#include <acpi/acevents.h>
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evevent")
ACPI_MODULE_NAME("evevent")
/* Local prototypes */
static acpi_status acpi_ev_fixed_event_initialize(void);
static acpi_status
acpi_ev_fixed_event_initialize (
void);
static u32
acpi_ev_fixed_event_dispatch (
u32 event);
static u32 acpi_ev_fixed_event_dispatch(u32 event);
/*******************************************************************************
*
@ -70,21 +64,17 @@ acpi_ev_fixed_event_dispatch (
*
******************************************************************************/
acpi_status
acpi_ev_initialize_events (
void)
acpi_status acpi_ev_initialize_events(void)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_initialize_events");
acpi_status status;
ACPI_FUNCTION_TRACE("ev_initialize_events");
/* Make sure we have ACPI tables */
if (!acpi_gbl_DSDT) {
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No ACPI tables present!\n"));
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No ACPI tables present!\n"));
return_ACPI_STATUS(AE_NO_ACPI_TABLES);
}
/*
@ -92,26 +82,22 @@ acpi_ev_initialize_events (
* enabling SCIs to prevent interrupts from occurring before the handlers are
* installed.
*/
status = acpi_ev_fixed_event_initialize ();
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"Unable to initialize fixed events, %s\n",
acpi_format_exception (status)));
return_ACPI_STATUS (status);
status = acpi_ev_fixed_event_initialize();
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Unable to initialize fixed events, %s\n",
acpi_format_exception(status)));
return_ACPI_STATUS(status);
}
status = acpi_ev_gpe_initialize ();
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"Unable to initialize general purpose events, %s\n",
acpi_format_exception (status)));
return_ACPI_STATUS (status);
status = acpi_ev_gpe_initialize();
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Unable to initialize general purpose events, %s\n", acpi_format_exception(status)));
return_ACPI_STATUS(status);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_install_xrupt_handlers
@ -124,41 +110,32 @@ acpi_ev_initialize_events (
*
******************************************************************************/
acpi_status
acpi_ev_install_xrupt_handlers (
void)
acpi_status acpi_ev_install_xrupt_handlers(void)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_install_xrupt_handlers");
acpi_status status;
ACPI_FUNCTION_TRACE("ev_install_xrupt_handlers");
/* Install the SCI handler */
status = acpi_ev_install_sci_handler ();
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"Unable to install System Control Interrupt Handler, %s\n",
acpi_format_exception (status)));
return_ACPI_STATUS (status);
status = acpi_ev_install_sci_handler();
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Unable to install System Control Interrupt Handler, %s\n", acpi_format_exception(status)));
return_ACPI_STATUS(status);
}
/* Install the handler for the Global Lock */
status = acpi_ev_init_global_lock_handler ();
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"Unable to initialize Global Lock handler, %s\n",
acpi_format_exception (status)));
return_ACPI_STATUS (status);
status = acpi_ev_init_global_lock_handler();
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Unable to initialize Global Lock handler, %s\n", acpi_format_exception(status)));
return_ACPI_STATUS(status);
}
acpi_gbl_events_initialized = TRUE;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_fixed_event_initialize
@ -171,13 +148,10 @@ acpi_ev_install_xrupt_handlers (
*
******************************************************************************/
static acpi_status
acpi_ev_fixed_event_initialize (
void)
static acpi_status acpi_ev_fixed_event_initialize(void)
{
acpi_native_uint i;
acpi_status status;
acpi_native_uint i;
acpi_status status;
/*
* Initialize the structure that keeps track of fixed event handlers
@ -190,10 +164,11 @@ acpi_ev_fixed_event_initialize (
/* Enable the fixed event */
if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) {
status = acpi_set_register (
acpi_gbl_fixed_event_info[i].enable_register_id,
0, ACPI_MTX_LOCK);
if (ACPI_FAILURE (status)) {
status =
acpi_set_register(acpi_gbl_fixed_event_info[i].
enable_register_id, 0,
ACPI_MTX_LOCK);
if (ACPI_FAILURE(status)) {
return (status);
}
}
@ -202,7 +177,6 @@ acpi_ev_fixed_event_initialize (
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_fixed_event_detect
@ -215,31 +189,27 @@ acpi_ev_fixed_event_initialize (
*
******************************************************************************/
u32
acpi_ev_fixed_event_detect (
void)
u32 acpi_ev_fixed_event_detect(void)
{
u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
u32 fixed_status;
u32 fixed_enable;
acpi_native_uint i;
ACPI_FUNCTION_NAME ("ev_fixed_event_detect");
u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
u32 fixed_status;
u32 fixed_enable;
acpi_native_uint i;
ACPI_FUNCTION_NAME("ev_fixed_event_detect");
/*
* Read the fixed feature status and enable registers, as all the cases
* depend on their values. Ignore errors here.
*/
(void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
&fixed_status);
(void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE,
&fixed_enable);
(void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
ACPI_REGISTER_PM1_STATUS, &fixed_status);
(void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
"Fixed Event Block: Enable %08X Status %08X\n",
fixed_enable, fixed_status));
ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
"Fixed Event Block: Enable %08X Status %08X\n",
fixed_enable, fixed_status));
/*
* Check for all possible Fixed Events and dispatch those that are active
@ -247,18 +217,19 @@ acpi_ev_fixed_event_detect (
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
/* Both the status and enable bits must be on for this event */
if ((fixed_status & acpi_gbl_fixed_event_info[i].status_bit_mask) &&
(fixed_enable & acpi_gbl_fixed_event_info[i].enable_bit_mask)) {
if ((fixed_status & acpi_gbl_fixed_event_info[i].
status_bit_mask)
&& (fixed_enable & acpi_gbl_fixed_event_info[i].
enable_bit_mask)) {
/* Found an active (signalled) event */
int_status |= acpi_ev_fixed_event_dispatch ((u32) i);
int_status |= acpi_ev_fixed_event_dispatch((u32) i);
}
}
return (int_status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_fixed_event_dispatch
@ -272,39 +243,32 @@ acpi_ev_fixed_event_detect (
*
******************************************************************************/
static u32
acpi_ev_fixed_event_dispatch (
u32 event)
static u32 acpi_ev_fixed_event_dispatch(u32 event)
{
ACPI_FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY();
/* Clear the status bit */
(void) acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id,
1, ACPI_MTX_DO_NOT_LOCK);
(void)acpi_set_register(acpi_gbl_fixed_event_info[event].
status_register_id, 1, ACPI_MTX_DO_NOT_LOCK);
/*
* Make sure we've got a handler. If not, report an error.
* The event is disabled to prevent further interrupts.
*/
if (NULL == acpi_gbl_fixed_event_handlers[event].handler) {
(void) acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id,
0, ACPI_MTX_DO_NOT_LOCK);
(void)acpi_set_register(acpi_gbl_fixed_event_info[event].
enable_register_id, 0,
ACPI_MTX_DO_NOT_LOCK);
ACPI_REPORT_ERROR (
("No installed handler for fixed event [%08X]\n",
event));
ACPI_REPORT_ERROR(("No installed handler for fixed event [%08X]\n", event));
return (ACPI_INTERRUPT_NOT_HANDLED);
}
/* Invoke the Fixed Event handler */
return ((acpi_gbl_fixed_event_handlers[event].handler)(
acpi_gbl_fixed_event_handlers[event].context));
return ((acpi_gbl_fixed_event_handlers[event].
handler) (acpi_gbl_fixed_event_handlers[event].context));
}

View File

@ -46,14 +46,10 @@
#include <acpi/acnamesp.h>
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evgpe")
ACPI_MODULE_NAME("evgpe")
/* Local prototypes */
static void ACPI_SYSTEM_XFACE
acpi_ev_asynch_execute_gpe_method (
void *context);
static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
/*******************************************************************************
*
@ -69,15 +65,11 @@ acpi_ev_asynch_execute_gpe_method (
******************************************************************************/
acpi_status
acpi_ev_set_gpe_type (
struct acpi_gpe_event_info *gpe_event_info,
u8 type)
acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_set_gpe_type");
acpi_status status;
ACPI_FUNCTION_TRACE("ev_set_gpe_type");
/* Validate type and update register enable masks */
@ -88,21 +80,20 @@ acpi_ev_set_gpe_type (
break;
default:
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Disable the GPE if currently enabled */
status = acpi_ev_disable_gpe (gpe_event_info);
status = acpi_ev_disable_gpe(gpe_event_info);
/* Type was validated above */
gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */
gpe_event_info->flags |= type; /* Insert type */
return_ACPI_STATUS (status);
gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */
gpe_event_info->flags |= type; /* Insert type */
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_update_gpe_enable_masks
@ -118,57 +109,55 @@ acpi_ev_set_gpe_type (
******************************************************************************/
acpi_status
acpi_ev_update_gpe_enable_masks (
struct acpi_gpe_event_info *gpe_event_info,
u8 type)
acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
u8 type)
{
struct acpi_gpe_register_info *gpe_register_info;
u8 register_bit;
ACPI_FUNCTION_TRACE ("ev_update_gpe_enable_masks");
struct acpi_gpe_register_info *gpe_register_info;
u8 register_bit;
ACPI_FUNCTION_TRACE("ev_update_gpe_enable_masks");
gpe_register_info = gpe_event_info->register_info;
if (!gpe_register_info) {
return_ACPI_STATUS (AE_NOT_EXIST);
return_ACPI_STATUS(AE_NOT_EXIST);
}
register_bit = gpe_event_info->register_bit;
/* 1) Disable case. Simply clear all enable bits */
if (type == ACPI_GPE_DISABLE) {
ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit);
ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit);
return_ACPI_STATUS (AE_OK);
ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
register_bit);
ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
return_ACPI_STATUS(AE_OK);
}
/* 2) Enable case. Set/Clear the appropriate enable bits */
switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
case ACPI_GPE_TYPE_WAKE:
ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit);
ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit);
ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
break;
case ACPI_GPE_TYPE_RUNTIME:
ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit);
ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit);
ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
register_bit);
ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
break;
case ACPI_GPE_TYPE_WAKE_RUN:
ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit);
ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit);
ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
break;
default:
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_enable_gpe
@ -184,21 +173,19 @@ acpi_ev_update_gpe_enable_masks (
******************************************************************************/
acpi_status
acpi_ev_enable_gpe (
struct acpi_gpe_event_info *gpe_event_info,
u8 write_to_hardware)
acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
u8 write_to_hardware)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_enable_gpe");
acpi_status status;
ACPI_FUNCTION_TRACE("ev_enable_gpe");
/* Make sure HW enable masks are updated */
status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_ENABLE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_ENABLE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Mark wake-enabled or HW enable, or both */
@ -206,41 +193,40 @@ acpi_ev_enable_gpe (
switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
case ACPI_GPE_TYPE_WAKE:
ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
break;
case ACPI_GPE_TYPE_WAKE_RUN:
ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
/*lint -fallthrough */
case ACPI_GPE_TYPE_RUNTIME:
ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
if (write_to_hardware) {
/* Clear the GPE (of stale events), then enable it */
status = acpi_hw_clear_gpe (gpe_event_info);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_hw_clear_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Enable the requested runtime GPE */
status = acpi_hw_write_gpe_enable_reg (gpe_event_info);
status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
}
break;
default:
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_disable_gpe
@ -253,36 +239,33 @@ acpi_ev_enable_gpe (
*
******************************************************************************/
acpi_status
acpi_ev_disable_gpe (
struct acpi_gpe_event_info *gpe_event_info)
acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_disable_gpe");
acpi_status status;
ACPI_FUNCTION_TRACE("ev_disable_gpe");
if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) {
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/* Make sure HW enable masks are updated */
status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_DISABLE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Mark wake-disabled or HW disable, or both */
switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
case ACPI_GPE_TYPE_WAKE:
ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
break;
case ACPI_GPE_TYPE_WAKE_RUN:
ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
/*lint -fallthrough */
@ -290,18 +273,17 @@ acpi_ev_disable_gpe (
/* Disable the requested runtime GPE */
ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
status = acpi_hw_write_gpe_enable_reg (gpe_event_info);
ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
break;
default:
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_get_gpe_event_info
@ -319,18 +301,14 @@ acpi_ev_disable_gpe (
*
******************************************************************************/
struct acpi_gpe_event_info *
acpi_ev_get_gpe_event_info (
acpi_handle gpe_device,
u32 gpe_number)
struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
u32 gpe_number)
{
union acpi_operand_object *obj_desc;
struct acpi_gpe_block_info *gpe_block;
acpi_native_uint i;
ACPI_FUNCTION_ENTRY ();
union acpi_operand_object *obj_desc;
struct acpi_gpe_block_info *gpe_block;
acpi_native_uint i;
ACPI_FUNCTION_ENTRY();
/* A NULL gpe_block means use the FADT-defined GPE block(s) */
@ -340,11 +318,14 @@ acpi_ev_get_gpe_event_info (
for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
gpe_block = acpi_gbl_gpe_fadt_blocks[i];
if (gpe_block) {
if ((gpe_number >= gpe_block->block_base_number) &&
(gpe_number < gpe_block->block_base_number +
(gpe_block->register_count * 8))) {
return (&gpe_block->event_info[gpe_number -
gpe_block->block_base_number]);
if ((gpe_number >= gpe_block->block_base_number)
&& (gpe_number <
gpe_block->block_base_number +
(gpe_block->register_count * 8))) {
return (&gpe_block->
event_info[gpe_number -
gpe_block->
block_base_number]);
}
}
}
@ -356,23 +337,25 @@ acpi_ev_get_gpe_event_info (
/* A Non-NULL gpe_device means this is a GPE Block Device */
obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) gpe_device);
if (!obj_desc ||
!obj_desc->device.gpe_block) {
obj_desc =
acpi_ns_get_attached_object((struct acpi_namespace_node *)
gpe_device);
if (!obj_desc || !obj_desc->device.gpe_block) {
return (NULL);
}
gpe_block = obj_desc->device.gpe_block;
if ((gpe_number >= gpe_block->block_base_number) &&
(gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) {
return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]);
(gpe_number <
gpe_block->block_base_number + (gpe_block->register_count * 8))) {
return (&gpe_block->
event_info[gpe_number - gpe_block->block_base_number]);
}
return (NULL);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_gpe_detect
@ -387,22 +370,20 @@ acpi_ev_get_gpe_event_info (
*
******************************************************************************/
u32
acpi_ev_gpe_detect (
struct acpi_gpe_xrupt_info *gpe_xrupt_list)
u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
{
u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
u8 enabled_status_byte;
struct acpi_gpe_register_info *gpe_register_info;
u32 status_reg;
u32 enable_reg;
acpi_status status;
struct acpi_gpe_block_info *gpe_block;
acpi_native_uint i;
acpi_native_uint j;
u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
u8 enabled_status_byte;
struct acpi_gpe_register_info *gpe_register_info;
u32 status_reg;
u32 enable_reg;
u32 flags;
acpi_status status;
struct acpi_gpe_block_info *gpe_block;
acpi_native_uint i;
acpi_native_uint j;
ACPI_FUNCTION_NAME ("ev_gpe_detect");
ACPI_FUNCTION_NAME("ev_gpe_detect");
/* Check for the case where there are no GPEs */
@ -412,7 +393,7 @@ acpi_ev_gpe_detect (
/* Examine all GPE blocks attached to this interrupt level */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_ISR);
flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
gpe_block = gpe_xrupt_list->gpe_block_list_head;
while (gpe_block) {
/*
@ -427,23 +408,30 @@ acpi_ev_gpe_detect (
/* Read the Status Register */
status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &status_reg,
&gpe_register_info->status_address);
if (ACPI_FAILURE (status)) {
status =
acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
&status_reg,
&gpe_register_info->
status_address);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
/* Read the Enable Register */
status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &enable_reg,
&gpe_register_info->enable_address);
if (ACPI_FAILURE (status)) {
status =
acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
&enable_reg,
&gpe_register_info->
enable_address);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
"Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
gpe_register_info->base_gpe_number, status_reg, enable_reg));
ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
"Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
gpe_register_info->base_gpe_number,
status_reg, enable_reg));
/* Check if there is anything active at all in this register */
@ -459,14 +447,21 @@ acpi_ev_gpe_detect (
for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
/* Examine one GPE bit */
if (enabled_status_byte & acpi_gbl_decode_to8bit[j]) {
if (enabled_status_byte &
acpi_gbl_decode_to8bit[j]) {
/*
* Found an active GPE. Dispatch the event to a handler
* or method.
*/
int_status |= acpi_ev_gpe_dispatch (
&gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j],
(u32) j + gpe_register_info->base_gpe_number);
int_status |=
acpi_ev_gpe_dispatch(&gpe_block->
event_info[(i *
ACPI_GPE_REGISTER_WIDTH)
+
j],
(u32) j +
gpe_register_info->
base_gpe_number);
}
}
}
@ -474,13 +469,12 @@ acpi_ev_gpe_detect (
gpe_block = gpe_block->next;
}
unlock_and_exit:
unlock_and_exit:
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_ISR);
acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
return (int_status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_asynch_execute_gpe_method
@ -497,45 +491,41 @@ unlock_and_exit:
*
******************************************************************************/
static void ACPI_SYSTEM_XFACE
acpi_ev_asynch_execute_gpe_method (
void *context)
static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
{
struct acpi_gpe_event_info *gpe_event_info = (void *) context;
u32 gpe_number = 0;
acpi_status status;
struct acpi_gpe_event_info local_gpe_event_info;
struct acpi_parameter_info info;
struct acpi_gpe_event_info *gpe_event_info = (void *)context;
u32 gpe_number = 0;
acpi_status status;
struct acpi_gpe_event_info local_gpe_event_info;
struct acpi_parameter_info info;
ACPI_FUNCTION_TRACE("ev_asynch_execute_gpe_method");
ACPI_FUNCTION_TRACE ("ev_asynch_execute_gpe_method");
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_VOID;
}
/* Must revalidate the gpe_number/gpe_block */
if (!acpi_ev_valid_gpe_event (gpe_event_info)) {
status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
if (!acpi_ev_valid_gpe_event(gpe_event_info)) {
status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
return_VOID;
}
/* Set the GPE flags for return to enabled state */
(void) acpi_ev_enable_gpe (gpe_event_info, FALSE);
(void)acpi_ev_enable_gpe(gpe_event_info, FALSE);
/*
* Take a snapshot of the GPE info for this level - we copy the
* info to prevent a race condition with remove_handler/remove_block.
*/
ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info,
sizeof (struct acpi_gpe_event_info));
ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info,
sizeof(struct acpi_gpe_event_info));
status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_VOID;
}
@ -544,44 +534,40 @@ acpi_ev_asynch_execute_gpe_method (
* time to avoid race with ev_gpe_install_handler
*/
if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
ACPI_GPE_DISPATCH_METHOD) {
ACPI_GPE_DISPATCH_METHOD) {
/*
* Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
* control method that corresponds to this GPE
*/
info.node = local_gpe_event_info.dispatch.method_node;
info.parameters = ACPI_CAST_PTR (union acpi_operand_object *, gpe_event_info);
info.parameters =
ACPI_CAST_PTR(union acpi_operand_object *, gpe_event_info);
info.parameter_type = ACPI_PARAM_GPE;
status = acpi_ns_evaluate_by_handle (&info);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"%s while evaluating method [%4.4s] for GPE[%2X]\n",
acpi_format_exception (status),
acpi_ut_get_node_name (local_gpe_event_info.dispatch.method_node),
gpe_number));
status = acpi_ns_evaluate_by_handle(&info);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("%s while evaluating method [%4.4s] for GPE[%2X]\n", acpi_format_exception(status), acpi_ut_get_node_name(local_gpe_event_info.dispatch.method_node), gpe_number));
}
}
if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
ACPI_GPE_LEVEL_TRIGGERED) {
ACPI_GPE_LEVEL_TRIGGERED) {
/*
* GPE is level-triggered, we clear the GPE status bit after
* handling the event.
*/
status = acpi_hw_clear_gpe (&local_gpe_event_info);
if (ACPI_FAILURE (status)) {
status = acpi_hw_clear_gpe(&local_gpe_event_info);
if (ACPI_FAILURE(status)) {
return_VOID;
}
}
/* Enable this GPE */
(void) acpi_hw_write_gpe_enable_reg (&local_gpe_event_info);
(void)acpi_hw_write_gpe_enable_reg(&local_gpe_event_info);
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_gpe_dispatch
@ -599,38 +585,31 @@ acpi_ev_asynch_execute_gpe_method (
******************************************************************************/
u32
acpi_ev_gpe_dispatch (
struct acpi_gpe_event_info *gpe_event_info,
u32 gpe_number)
acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_gpe_dispatch");
acpi_status status;
ACPI_FUNCTION_TRACE("ev_gpe_dispatch");
/*
* If edge-triggered, clear the GPE status bit now. Note that
* level-triggered events are cleared after the GPE is serviced.
*/
if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
ACPI_GPE_EDGE_TRIGGERED) {
status = acpi_hw_clear_gpe (gpe_event_info);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n",
acpi_format_exception (status), gpe_number));
return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
ACPI_GPE_EDGE_TRIGGERED) {
status = acpi_hw_clear_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
}
}
/* Save current system state */
if (acpi_gbl_system_awake_and_running) {
ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
}
else {
ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
} else {
ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
}
/*
@ -647,19 +626,19 @@ acpi_ev_gpe_dispatch (
* Invoke the installed handler (at interrupt level)
* Ignore return status for now. TBD: leave GPE disabled on error?
*/
(void) gpe_event_info->dispatch.handler->address (
gpe_event_info->dispatch.handler->context);
(void)gpe_event_info->dispatch.handler->address(gpe_event_info->
dispatch.
handler->
context);
/* It is now safe to clear level-triggered events. */
if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
ACPI_GPE_LEVEL_TRIGGERED) {
status = acpi_hw_clear_gpe (gpe_event_info);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n",
acpi_format_exception (status), gpe_number));
return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
ACPI_GPE_LEVEL_TRIGGERED) {
status = acpi_hw_clear_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
}
}
break;
@ -670,24 +649,21 @@ acpi_ev_gpe_dispatch (
* Disable GPE, so it doesn't keep firing before the method has a
* chance to run.
*/
status = acpi_ev_disable_gpe (gpe_event_info);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n",
acpi_format_exception (status), gpe_number));
return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
status = acpi_ev_disable_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
}
/*
* Execute the method associated with the GPE
* NOTE: Level-triggered GPEs are cleared after the method completes.
*/
status = acpi_os_queue_for_execution (OSD_PRIORITY_GPE,
acpi_ev_asynch_execute_gpe_method, gpe_event_info);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n",
acpi_format_exception (status), gpe_number));
status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
acpi_ev_asynch_execute_gpe_method,
gpe_event_info);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number));
}
break;
@ -695,28 +671,23 @@ acpi_ev_gpe_dispatch (
/* No handler or method to run! */
ACPI_REPORT_ERROR ((
"acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n",
gpe_number));
ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", gpe_number));
/*
* Disable the GPE. The GPE will remain disabled until the ACPI
* Core Subsystem is restarted, or a handler is installed.
*/
status = acpi_ev_disable_gpe (gpe_event_info);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
"acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n",
acpi_format_exception (status), gpe_number));
return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
status = acpi_ev_disable_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
}
break;
}
return_VALUE (ACPI_INTERRUPT_HANDLED);
return_VALUE(ACPI_INTERRUPT_HANDLED);
}
#ifdef ACPI_GPE_NOTIFY_CHECK
/*******************************************************************************
* TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
@ -735,35 +706,29 @@ acpi_ev_gpe_dispatch (
******************************************************************************/
acpi_status
acpi_ev_check_for_wake_only_gpe (
struct acpi_gpe_event_info *gpe_event_info)
acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info)
{
acpi_status status;
acpi_status status;
ACPI_FUNCTION_TRACE("ev_check_for_wake_only_gpe");
ACPI_FUNCTION_TRACE ("ev_check_for_wake_only_gpe");
if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ {
if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) { /* System state at GPE time */
/* This must be a wake-only GPE, disable it */
status = acpi_ev_disable_gpe (gpe_event_info);
status = acpi_ev_disable_gpe(gpe_event_info);
/* Set GPE to wake-only. Do not change wake disabled/enabled status */
acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE);
acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n",
gpe_event_info));
ACPI_REPORT_INFO(("GPE %p was updated from wake/run to wake-only\n", gpe_event_info));
/* This was a wake-only GPE */
return_ACPI_STATUS (AE_WAKE_ONLY_GPE);
return_ACPI_STATUS(AE_WAKE_ONLY_GPE);
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -47,12 +47,10 @@
#include <acpi/acinterp.h>
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evmisc")
ACPI_MODULE_NAME("evmisc")
#ifdef ACPI_DEBUG_OUTPUT
static const char *acpi_notify_value_names[] =
{
static const char *acpi_notify_value_names[] = {
"Bus Check",
"Device Check",
"Device Wake",
@ -66,18 +64,11 @@ static const char *acpi_notify_value_names[] =
/* Local prototypes */
static void ACPI_SYSTEM_XFACE
acpi_ev_notify_dispatch (
void *context);
static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context);
static void ACPI_SYSTEM_XFACE
acpi_ev_global_lock_thread (
void *context);
static u32
acpi_ev_global_lock_handler (
void *context);
static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context);
static u32 acpi_ev_global_lock_handler(void *context);
/*******************************************************************************
*
@ -93,9 +84,7 @@ acpi_ev_global_lock_handler (
*
******************************************************************************/
u8
acpi_ev_is_notify_object (
struct acpi_namespace_node *node)
u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node)
{
switch (node->type) {
case ACPI_TYPE_DEVICE:
@ -112,7 +101,6 @@ acpi_ev_is_notify_object (
}
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_queue_notify_request
@ -128,18 +116,15 @@ acpi_ev_is_notify_object (
******************************************************************************/
acpi_status
acpi_ev_queue_notify_request (
struct acpi_namespace_node *node,
u32 notify_value)
acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
u32 notify_value)
{
union acpi_operand_object *obj_desc;
union acpi_operand_object *handler_obj = NULL;
union acpi_generic_state *notify_info;
acpi_status status = AE_OK;
ACPI_FUNCTION_NAME ("ev_queue_notify_request");
union acpi_operand_object *obj_desc;
union acpi_operand_object *handler_obj = NULL;
union acpi_generic_state *notify_info;
acpi_status status = AE_OK;
ACPI_FUNCTION_NAME("ev_queue_notify_request");
/*
* For value 3 (Ejection Request), some device method may need to be run.
@ -148,22 +133,22 @@ acpi_ev_queue_notify_request (
* For value 0x80 (Status Change) on the power button or sleep button,
* initiate soft-off or sleep operation?
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Dispatching Notify(%X) on node %p\n", notify_value, node));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Dispatching Notify(%X) on node %p\n", notify_value,
node));
if (notify_value <= 7) {
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: %s\n",
acpi_notify_value_names[notify_value]));
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Notify value: 0x%2.2X **Device Specific**\n",
notify_value));
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notify value: %s\n",
acpi_notify_value_names[notify_value]));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Notify value: 0x%2.2X **Device Specific**\n",
notify_value));
}
/* Get the notify object attached to the NS Node */
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
/* We have the notify object, Get the right handler */
@ -174,10 +159,11 @@ acpi_ev_queue_notify_request (
case ACPI_TYPE_POWER:
if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
handler_obj = obj_desc->common_notify.system_notify;
}
else {
handler_obj = obj_desc->common_notify.device_notify;
handler_obj =
obj_desc->common_notify.system_notify;
} else {
handler_obj =
obj_desc->common_notify.device_notify;
}
break;
@ -189,23 +175,25 @@ acpi_ev_queue_notify_request (
/* If there is any handler to run, schedule the dispatcher */
if ((acpi_gbl_system_notify.handler && (notify_value <= ACPI_MAX_SYS_NOTIFY)) ||
(acpi_gbl_device_notify.handler && (notify_value > ACPI_MAX_SYS_NOTIFY)) ||
handler_obj) {
notify_info = acpi_ut_create_generic_state ();
if ((acpi_gbl_system_notify.handler
&& (notify_value <= ACPI_MAX_SYS_NOTIFY))
|| (acpi_gbl_device_notify.handler
&& (notify_value > ACPI_MAX_SYS_NOTIFY)) || handler_obj) {
notify_info = acpi_ut_create_generic_state();
if (!notify_info) {
return (AE_NO_MEMORY);
}
notify_info->common.data_type = ACPI_DESC_TYPE_STATE_NOTIFY;
notify_info->notify.node = node;
notify_info->notify.value = (u16) notify_value;
notify_info->notify.node = node;
notify_info->notify.value = (u16) notify_value;
notify_info->notify.handler_obj = handler_obj;
status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH,
acpi_ev_notify_dispatch, notify_info);
if (ACPI_FAILURE (status)) {
acpi_ut_delete_generic_state (notify_info);
status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH,
acpi_ev_notify_dispatch,
notify_info);
if (ACPI_FAILURE(status)) {
acpi_ut_delete_generic_state(notify_info);
}
}
@ -214,15 +202,15 @@ acpi_ev_queue_notify_request (
* There is no per-device notify handler for this device.
* This may or may not be a problem.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"No notify handler for Notify(%4.4s, %X) node %p\n",
acpi_ut_get_node_name (node), notify_value, node));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"No notify handler for Notify(%4.4s, %X) node %p\n",
acpi_ut_get_node_name(node), notify_value,
node));
}
return (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_notify_dispatch
@ -236,18 +224,15 @@ acpi_ev_queue_notify_request (
*
******************************************************************************/
static void ACPI_SYSTEM_XFACE
acpi_ev_notify_dispatch (
void *context)
static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
{
union acpi_generic_state *notify_info = (union acpi_generic_state *) context;
acpi_notify_handler global_handler = NULL;
void *global_context = NULL;
union acpi_operand_object *handler_obj;
ACPI_FUNCTION_ENTRY ();
union acpi_generic_state *notify_info =
(union acpi_generic_state *)context;
acpi_notify_handler global_handler = NULL;
void *global_context = NULL;
union acpi_operand_object *handler_obj;
ACPI_FUNCTION_ENTRY();
/*
* We will invoke a global notify handler if installed.
@ -261,8 +246,7 @@ acpi_ev_notify_dispatch (
global_handler = acpi_gbl_system_notify.handler;
global_context = acpi_gbl_system_notify.context;
}
}
else {
} else {
/* Global driver notification handler */
if (acpi_gbl_device_notify.handler) {
@ -274,25 +258,24 @@ acpi_ev_notify_dispatch (
/* Invoke the system handler first, if present */
if (global_handler) {
global_handler (notify_info->notify.node, notify_info->notify.value,
global_context);
global_handler(notify_info->notify.node,
notify_info->notify.value, global_context);
}
/* Now invoke the per-device handler, if present */
handler_obj = notify_info->notify.handler_obj;
if (handler_obj) {
handler_obj->notify.handler (notify_info->notify.node,
notify_info->notify.value,
handler_obj->notify.context);
handler_obj->notify.handler(notify_info->notify.node,
notify_info->notify.value,
handler_obj->notify.context);
}
/* All done with the info object */
acpi_ut_delete_generic_state (notify_info);
acpi_ut_delete_generic_state(notify_info);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_global_lock_thread
@ -307,27 +290,24 @@ acpi_ev_notify_dispatch (
*
******************************************************************************/
static void ACPI_SYSTEM_XFACE
acpi_ev_global_lock_thread (
void *context)
static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context)
{
acpi_status status;
acpi_status status;
/* Signal threads that are waiting for the lock */
if (acpi_gbl_global_lock_thread_count) {
/* Send sufficient units to the semaphore */
status = acpi_os_signal_semaphore (acpi_gbl_global_lock_semaphore,
acpi_gbl_global_lock_thread_count);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("Could not signal Global Lock semaphore\n"));
status =
acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore,
acpi_gbl_global_lock_thread_count);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Could not signal Global Lock semaphore\n"));
}
}
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_global_lock_handler
@ -342,20 +322,17 @@ acpi_ev_global_lock_thread (
*
******************************************************************************/
static u32
acpi_ev_global_lock_handler (
void *context)
static u32 acpi_ev_global_lock_handler(void *context)
{
u8 acquired = FALSE;
acpi_status status;
u8 acquired = FALSE;
acpi_status status;
/*
* Attempt to get the lock
* If we don't get it now, it will be marked pending and we will
* take another interrupt when it becomes free.
*/
ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired);
ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired);
if (acquired) {
/* Got the lock, now wake all threads waiting for it */
@ -363,11 +340,11 @@ acpi_ev_global_lock_handler (
/* Run the Global Lock thread which will signal all waiting threads */
status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH,
acpi_ev_global_lock_thread, context);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("Could not queue Global Lock thread, %s\n",
acpi_format_exception (status)));
status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH,
acpi_ev_global_lock_thread,
context);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Could not queue Global Lock thread, %s\n", acpi_format_exception(status)));
return (ACPI_INTERRUPT_NOT_HANDLED);
}
@ -376,7 +353,6 @@ acpi_ev_global_lock_handler (
return (ACPI_INTERRUPT_HANDLED);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_init_global_lock_handler
@ -389,19 +365,16 @@ acpi_ev_global_lock_handler (
*
******************************************************************************/
acpi_status
acpi_ev_init_global_lock_handler (
void)
acpi_status acpi_ev_init_global_lock_handler(void)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_init_global_lock_handler");
acpi_status status;
ACPI_FUNCTION_TRACE("ev_init_global_lock_handler");
acpi_gbl_global_lock_present = TRUE;
status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL,
acpi_ev_global_lock_handler, NULL);
status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL,
acpi_ev_global_lock_handler,
NULL);
/*
* If the global lock does not exist on this platform, the attempt
@ -411,14 +384,15 @@ acpi_ev_init_global_lock_handler (
* with an error.
*/
if (status == AE_NO_HARDWARE_RESPONSE) {
ACPI_REPORT_ERROR(("No response from Global Lock hardware, disabling lock\n"));
acpi_gbl_global_lock_present = FALSE;
status = AE_OK;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/******************************************************************************
*
* FUNCTION: acpi_ev_acquire_global_lock
@ -431,22 +405,18 @@ acpi_ev_init_global_lock_handler (
*
*****************************************************************************/
acpi_status
acpi_ev_acquire_global_lock (
u16 timeout)
acpi_status acpi_ev_acquire_global_lock(u16 timeout)
{
acpi_status status = AE_OK;
u8 acquired = FALSE;
ACPI_FUNCTION_TRACE ("ev_acquire_global_lock");
acpi_status status = AE_OK;
u8 acquired = FALSE;
ACPI_FUNCTION_TRACE("ev_acquire_global_lock");
#ifndef ACPI_APPLICATION
/* Make sure that we actually have a global lock */
if (!acpi_gbl_global_lock_present) {
return_ACPI_STATUS (AE_NO_GLOBAL_LOCK);
return_ACPI_STATUS(AE_NO_GLOBAL_LOCK);
}
#endif
@ -459,37 +429,37 @@ acpi_ev_acquire_global_lock (
* we are done
*/
if (acpi_gbl_global_lock_acquired) {
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/* We must acquire the actual hardware lock */
ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired);
ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired);
if (acquired) {
/* We got the lock */
/* We got the lock */
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n"));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Acquired the HW Global Lock\n"));
acpi_gbl_global_lock_acquired = TRUE;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*
* Did not get the lock. The pending bit was set above, and we must now
* wait until we get the global lock released interrupt.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n"));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n"));
/*
* Acquire the global lock semaphore first.
* Since this wait will block, we must release the interpreter
*/
status = acpi_ex_system_wait_semaphore (acpi_gbl_global_lock_semaphore,
timeout);
return_ACPI_STATUS (status);
status = acpi_ex_system_wait_semaphore(acpi_gbl_global_lock_semaphore,
timeout);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_release_global_lock
@ -502,21 +472,16 @@ acpi_ev_acquire_global_lock (
*
******************************************************************************/
acpi_status
acpi_ev_release_global_lock (
void)
acpi_status acpi_ev_release_global_lock(void)
{
u8 pending = FALSE;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("ev_release_global_lock");
u8 pending = FALSE;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ev_release_global_lock");
if (!acpi_gbl_global_lock_thread_count) {
ACPI_REPORT_WARNING((
"Cannot release HW Global Lock, it has not been acquired\n"));
return_ACPI_STATUS (AE_NOT_ACQUIRED);
ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n"));
return_ACPI_STATUS(AE_NOT_ACQUIRED);
}
/* One fewer thread has the global lock */
@ -525,14 +490,14 @@ acpi_ev_release_global_lock (
if (acpi_gbl_global_lock_thread_count) {
/* There are still some threads holding the lock, cannot release */
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*
* No more threads holding lock, we can do the actual hardware
* release
*/
ACPI_RELEASE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, pending);
ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, pending);
acpi_gbl_global_lock_acquired = FALSE;
/*
@ -540,14 +505,13 @@ acpi_ev_release_global_lock (
* register
*/
if (pending) {
status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE,
1, ACPI_MTX_LOCK);
status = acpi_set_register(ACPI_BITREG_GLOBAL_LOCK_RELEASE,
1, ACPI_MTX_LOCK);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/******************************************************************************
*
* FUNCTION: acpi_ev_terminate
@ -560,16 +524,12 @@ acpi_ev_release_global_lock (
*
******************************************************************************/
void
acpi_ev_terminate (
void)
void acpi_ev_terminate(void)
{
acpi_native_uint i;
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_terminate");
acpi_native_uint i;
acpi_status status;
ACPI_FUNCTION_TRACE("ev_terminate");
if (acpi_gbl_events_initialized) {
/*
@ -580,38 +540,39 @@ acpi_ev_terminate (
/* Disable all fixed events */
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
status = acpi_disable_event ((u32) i, 0);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not disable fixed event %d\n", (u32) i));
status = acpi_disable_event((u32) i, 0);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Could not disable fixed event %d\n",
(u32) i));
}
}
/* Disable all GPEs in all GPE blocks */
status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, ACPI_NOT_ISR);
status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block);
/* Remove SCI handler */
status = acpi_ev_remove_sci_handler ();
status = acpi_ev_remove_sci_handler();
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not remove SCI handler\n"));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Could not remove SCI handler\n"));
}
}
/* Deallocate all handler objects installed within GPE info structs */
status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers, ACPI_NOT_ISR);
status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers);
/* Return to original mode if necessary */
if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) {
status = acpi_disable ();
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_disable failed\n"));
status = acpi_disable();
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"acpi_disable failed\n"));
}
}
return_VOID;
}

File diff suppressed because it is too large Load Diff

View File

@ -41,14 +41,12 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acevents.h>
#include <acpi/acnamesp.h>
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evrgnini")
ACPI_MODULE_NAME("evrgnini")
/*******************************************************************************
*
@ -64,34 +62,31 @@
* DESCRIPTION: Setup a system_memory operation region
*
******************************************************************************/
acpi_status
acpi_ev_system_memory_region_setup (
acpi_handle handle,
u32 function,
void *handler_context,
void **region_context)
acpi_ev_system_memory_region_setup(acpi_handle handle,
u32 function,
void *handler_context, void **region_context)
{
union acpi_operand_object *region_desc = (union acpi_operand_object *) handle;
struct acpi_mem_space_context *local_region_context;
ACPI_FUNCTION_TRACE ("ev_system_memory_region_setup");
union acpi_operand_object *region_desc =
(union acpi_operand_object *)handle;
struct acpi_mem_space_context *local_region_context;
ACPI_FUNCTION_TRACE("ev_system_memory_region_setup");
if (function == ACPI_REGION_DEACTIVATE) {
if (*region_context) {
ACPI_MEM_FREE (*region_context);
ACPI_MEM_FREE(*region_context);
*region_context = NULL;
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/* Create a new context */
local_region_context = ACPI_MEM_CALLOCATE (sizeof (struct acpi_mem_space_context));
local_region_context =
ACPI_MEM_CALLOCATE(sizeof(struct acpi_mem_space_context));
if (!(local_region_context)) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Save the region length and address for use in the handler */
@ -100,10 +95,9 @@ acpi_ev_system_memory_region_setup (
local_region_context->address = region_desc->region.address;
*region_context = local_region_context;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_io_space_region_setup
@ -120,26 +114,21 @@ acpi_ev_system_memory_region_setup (
******************************************************************************/
acpi_status
acpi_ev_io_space_region_setup (
acpi_handle handle,
u32 function,
void *handler_context,
void **region_context)
acpi_ev_io_space_region_setup(acpi_handle handle,
u32 function,
void *handler_context, void **region_context)
{
ACPI_FUNCTION_TRACE ("ev_io_space_region_setup");
ACPI_FUNCTION_TRACE("ev_io_space_region_setup");
if (function == ACPI_REGION_DEACTIVATE) {
*region_context = NULL;
}
else {
} else {
*region_context = handler_context;
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_pci_config_region_setup
@ -158,24 +147,21 @@ acpi_ev_io_space_region_setup (
******************************************************************************/
acpi_status
acpi_ev_pci_config_region_setup (
acpi_handle handle,
u32 function,
void *handler_context,
void **region_context)
acpi_ev_pci_config_region_setup(acpi_handle handle,
u32 function,
void *handler_context, void **region_context)
{
acpi_status status = AE_OK;
acpi_integer pci_value;
struct acpi_pci_id *pci_id = *region_context;
union acpi_operand_object *handler_obj;
struct acpi_namespace_node *parent_node;
struct acpi_namespace_node *pci_root_node;
union acpi_operand_object *region_obj = (union acpi_operand_object *) handle;
struct acpi_device_id object_hID;
ACPI_FUNCTION_TRACE ("ev_pci_config_region_setup");
acpi_status status = AE_OK;
acpi_integer pci_value;
struct acpi_pci_id *pci_id = *region_context;
union acpi_operand_object *handler_obj;
struct acpi_namespace_node *parent_node;
struct acpi_namespace_node *pci_root_node;
union acpi_operand_object *region_obj =
(union acpi_operand_object *)handle;
struct acpi_device_id object_hID;
ACPI_FUNCTION_TRACE("ev_pci_config_region_setup");
handler_obj = region_obj->region.handler;
if (!handler_obj) {
@ -183,20 +169,21 @@ acpi_ev_pci_config_region_setup (
* No installed handler. This shouldn't happen because the dispatch
* routine checks before we get here, but we check again just in case.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
"Attempting to init a region %p, with no handler\n", region_obj));
return_ACPI_STATUS (AE_NOT_EXIST);
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Attempting to init a region %p, with no handler\n",
region_obj));
return_ACPI_STATUS(AE_NOT_EXIST);
}
*region_context = NULL;
if (function == ACPI_REGION_DEACTIVATE) {
if (pci_id) {
ACPI_MEM_FREE (pci_id);
ACPI_MEM_FREE(pci_id);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
parent_node = acpi_ns_get_parent_node (region_obj->region.node);
parent_node = acpi_ns_get_parent_node(region_obj->region.node);
/*
* Get the _SEG and _BBN values from the device upon which the handler
@ -216,18 +203,28 @@ acpi_ev_pci_config_region_setup (
pci_root_node = parent_node;
while (pci_root_node != acpi_gbl_root_node) {
status = acpi_ut_execute_HID (pci_root_node, &object_hID);
if (ACPI_SUCCESS (status)) {
/* Got a valid _HID, check if this is a PCI root */
if (!(ACPI_STRNCMP (object_hID.value, PCI_ROOT_HID_STRING,
sizeof (PCI_ROOT_HID_STRING)))) {
status =
acpi_ut_execute_HID(pci_root_node, &object_hID);
if (ACPI_SUCCESS(status)) {
/*
* Got a valid _HID string, check if this is a PCI root.
* New for ACPI 3.0: check for a PCI Express root also.
*/
if (!
(ACPI_STRNCMP
(object_hID.value, PCI_ROOT_HID_STRING,
sizeof(PCI_ROOT_HID_STRING))
||
!(ACPI_STRNCMP
(object_hID.value,
PCI_EXPRESS_ROOT_HID_STRING,
sizeof(PCI_EXPRESS_ROOT_HID_STRING)))))
{
/* Install a handler for this PCI root bridge */
status = acpi_install_address_space_handler ((acpi_handle) pci_root_node,
ACPI_ADR_SPACE_PCI_CONFIG,
ACPI_DEFAULT_HANDLER, NULL, NULL);
if (ACPI_FAILURE (status)) {
status =
acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL);
if (ACPI_FAILURE(status)) {
if (status == AE_SAME_HANDLER) {
/*
* It is OK if the handler is already installed on the root
@ -235,23 +232,19 @@ acpi_ev_pci_config_region_setup (
* new PCI_Config operation region, however.
*/
status = AE_OK;
}
else {
ACPI_REPORT_ERROR ((
"Could not install pci_config handler for Root Bridge %4.4s, %s\n",
acpi_ut_get_node_name (pci_root_node), acpi_format_exception (status)));
} else {
ACPI_REPORT_ERROR(("Could not install pci_config handler for Root Bridge %4.4s, %s\n", acpi_ut_get_node_name(pci_root_node), acpi_format_exception(status)));
}
}
break;
}
}
pci_root_node = acpi_ns_get_parent_node (pci_root_node);
pci_root_node = acpi_ns_get_parent_node(pci_root_node);
}
/* PCI root bridge not found, use namespace root node */
}
else {
} else {
pci_root_node = handler_obj->address_space.node;
}
@ -260,14 +253,14 @@ acpi_ev_pci_config_region_setup (
* (install_address_space_handler could have initialized it)
*/
if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/* Region is still not initialized. Create a new context */
pci_id = ACPI_MEM_CALLOCATE (sizeof (struct acpi_pci_id));
pci_id = ACPI_MEM_CALLOCATE(sizeof(struct acpi_pci_id));
if (!pci_id) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/*
@ -279,40 +272,45 @@ acpi_ev_pci_config_region_setup (
* Get the PCI device and function numbers from the _ADR object
* contained in the parent's scope.
*/
status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, parent_node, &pci_value);
status =
acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, parent_node,
&pci_value);
/*
* The default is zero, and since the allocation above zeroed
* the data, just do nothing on failure.
*/
if (ACPI_SUCCESS (status)) {
pci_id->device = ACPI_HIWORD (ACPI_LODWORD (pci_value));
pci_id->function = ACPI_LOWORD (ACPI_LODWORD (pci_value));
if (ACPI_SUCCESS(status)) {
pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value));
pci_id->function = ACPI_LOWORD(ACPI_LODWORD(pci_value));
}
/* The PCI segment number comes from the _SEG method */
status = acpi_ut_evaluate_numeric_object (METHOD_NAME__SEG, pci_root_node, &pci_value);
if (ACPI_SUCCESS (status)) {
pci_id->segment = ACPI_LOWORD (pci_value);
status =
acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, pci_root_node,
&pci_value);
if (ACPI_SUCCESS(status)) {
pci_id->segment = ACPI_LOWORD(pci_value);
}
/* The PCI bus number comes from the _BBN method */
status = acpi_ut_evaluate_numeric_object (METHOD_NAME__BBN, pci_root_node, &pci_value);
if (ACPI_SUCCESS (status)) {
pci_id->bus = ACPI_LOWORD (pci_value);
status =
acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, pci_root_node,
&pci_value);
if (ACPI_SUCCESS(status)) {
pci_id->bus = ACPI_LOWORD(pci_value);
}
/* Complete this device's pci_id */
acpi_os_derive_pci_id (pci_root_node, region_obj->region.node, &pci_id);
acpi_os_derive_pci_id(pci_root_node, region_obj->region.node, &pci_id);
*region_context = pci_id;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_pci_bar_region_setup
@ -331,19 +329,15 @@ acpi_ev_pci_config_region_setup (
******************************************************************************/
acpi_status
acpi_ev_pci_bar_region_setup (
acpi_handle handle,
u32 function,
void *handler_context,
void **region_context)
acpi_ev_pci_bar_region_setup(acpi_handle handle,
u32 function,
void *handler_context, void **region_context)
{
ACPI_FUNCTION_TRACE ("ev_pci_bar_region_setup");
ACPI_FUNCTION_TRACE("ev_pci_bar_region_setup");
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_cmos_region_setup
@ -362,19 +356,15 @@ acpi_ev_pci_bar_region_setup (
******************************************************************************/
acpi_status
acpi_ev_cmos_region_setup (
acpi_handle handle,
u32 function,
void *handler_context,
void **region_context)
acpi_ev_cmos_region_setup(acpi_handle handle,
u32 function,
void *handler_context, void **region_context)
{
ACPI_FUNCTION_TRACE ("ev_cmos_region_setup");
ACPI_FUNCTION_TRACE("ev_cmos_region_setup");
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_default_region_setup
@ -391,26 +381,21 @@ acpi_ev_cmos_region_setup (
******************************************************************************/
acpi_status
acpi_ev_default_region_setup (
acpi_handle handle,
u32 function,
void *handler_context,
void **region_context)
acpi_ev_default_region_setup(acpi_handle handle,
u32 function,
void *handler_context, void **region_context)
{
ACPI_FUNCTION_TRACE ("ev_default_region_setup");
ACPI_FUNCTION_TRACE("ev_default_region_setup");
if (function == ACPI_REGION_DEACTIVATE) {
*region_context = NULL;
}
else {
} else {
*region_context = handler_context;
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_initialize_region
@ -434,37 +419,34 @@ acpi_ev_default_region_setup (
******************************************************************************/
acpi_status
acpi_ev_initialize_region (
union acpi_operand_object *region_obj,
u8 acpi_ns_locked)
acpi_ev_initialize_region(union acpi_operand_object *region_obj,
u8 acpi_ns_locked)
{
union acpi_operand_object *handler_obj;
union acpi_operand_object *obj_desc;
acpi_adr_space_type space_id;
struct acpi_namespace_node *node;
acpi_status status;
struct acpi_namespace_node *method_node;
acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
union acpi_operand_object *region_obj2;
ACPI_FUNCTION_TRACE_U32 ("ev_initialize_region", acpi_ns_locked);
union acpi_operand_object *handler_obj;
union acpi_operand_object *obj_desc;
acpi_adr_space_type space_id;
struct acpi_namespace_node *node;
acpi_status status;
struct acpi_namespace_node *method_node;
acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
union acpi_operand_object *region_obj2;
ACPI_FUNCTION_TRACE_U32("ev_initialize_region", acpi_ns_locked);
if (!region_obj) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) {
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
region_obj2 = acpi_ns_get_secondary_object (region_obj);
region_obj2 = acpi_ns_get_secondary_object(region_obj);
if (!region_obj2) {
return_ACPI_STATUS (AE_NOT_EXIST);
return_ACPI_STATUS(AE_NOT_EXIST);
}
node = acpi_ns_get_parent_node (region_obj->region.node);
node = acpi_ns_get_parent_node(region_obj->region.node);
space_id = region_obj->region.space_id;
/* Setup defaults */
@ -476,9 +458,9 @@ acpi_ev_initialize_region (
/* Find any "_REG" method associated with this region definition */
status = acpi_ns_search_node (*reg_name_ptr, node,
ACPI_TYPE_METHOD, &method_node);
if (ACPI_SUCCESS (status)) {
status = acpi_ns_search_node(*reg_name_ptr, node,
ACPI_TYPE_METHOD, &method_node);
if (ACPI_SUCCESS(status)) {
/*
* The _REG method is optional and there can be only one per region
* definition. This will be executed when the handler is attached
@ -495,7 +477,7 @@ acpi_ev_initialize_region (
/* Check to see if a handler exists */
handler_obj = NULL;
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
/* Can only be a handler if the object exists */
@ -523,37 +505,50 @@ acpi_ev_initialize_region (
while (handler_obj) {
/* Is this handler of the correct type? */
if (handler_obj->address_space.space_id == space_id) {
if (handler_obj->address_space.space_id ==
space_id) {
/* Found correct handler */
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
"Found handler %p for region %p in obj %p\n",
handler_obj, region_obj, obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Found handler %p for region %p in obj %p\n",
handler_obj,
region_obj,
obj_desc));
status = acpi_ev_attach_region (handler_obj, region_obj,
acpi_ns_locked);
status =
acpi_ev_attach_region(handler_obj,
region_obj,
acpi_ns_locked);
/*
* Tell all users that this region is usable by running the _REG
* method
*/
if (acpi_ns_locked) {
status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ut_release_mutex
(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS
(status);
}
}
status = acpi_ev_execute_reg_method (region_obj, 1);
status =
acpi_ev_execute_reg_method
(region_obj, 1);
if (acpi_ns_locked) {
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ut_acquire_mutex
(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS
(status);
}
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/* Try next handler in the list */
@ -566,15 +561,15 @@ acpi_ev_initialize_region (
* This node does not have the handler we need;
* Pop up one level
*/
node = acpi_ns_get_parent_node (node);
node = acpi_ns_get_parent_node(node);
}
/* If we get here, there is no handler for this region */
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
"No handler for region_type %s(%X) (region_obj %p)\n",
acpi_ut_get_region_name (space_id), space_id, region_obj));
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"No handler for region_type %s(%X) (region_obj %p)\n",
acpi_ut_get_region_name(space_id), space_id,
region_obj));
return_ACPI_STATUS (AE_NOT_EXIST);
return_ACPI_STATUS(AE_NOT_EXIST);
}

View File

@ -45,16 +45,11 @@
#include <acpi/acpi.h>
#include <acpi/acevents.h>
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evsci")
ACPI_MODULE_NAME("evsci")
/* Local prototypes */
static u32 ACPI_SYSTEM_XFACE
acpi_ev_sci_xrupt_handler (
void *context);
static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context);
/*******************************************************************************
*
@ -69,17 +64,13 @@ acpi_ev_sci_xrupt_handler (
*
******************************************************************************/
static u32 ACPI_SYSTEM_XFACE
acpi_ev_sci_xrupt_handler (
void *context)
static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
{
struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler");
/*
* We are guaranteed by the ACPI CA initialization/shutdown code that
* if this interrupt handler is installed, ACPI is enabled.
@ -89,18 +80,17 @@ acpi_ev_sci_xrupt_handler (
* Fixed Events:
* Check for and dispatch any Fixed Events that have occurred
*/
interrupt_handled |= acpi_ev_fixed_event_detect ();
interrupt_handled |= acpi_ev_fixed_event_detect();
/*
* General Purpose Events:
* Check for and dispatch any GPEs that have occurred
*/
interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
return_VALUE (interrupt_handled);
return_VALUE(interrupt_handled);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_gpe_xrupt_handler
@ -113,17 +103,13 @@ acpi_ev_sci_xrupt_handler (
*
******************************************************************************/
u32 ACPI_SYSTEM_XFACE
acpi_ev_gpe_xrupt_handler (
void *context)
u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
{
struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler");
/*
* We are guaranteed by the ACPI CA initialization/shutdown code that
* if this interrupt handler is installed, ACPI is enabled.
@ -133,12 +119,11 @@ acpi_ev_gpe_xrupt_handler (
* GPEs:
* Check for and dispatch any GPEs that have occurred
*/
interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
return_VALUE (interrupt_handled);
return_VALUE(interrupt_handled);
}
/******************************************************************************
*
* FUNCTION: acpi_ev_install_sci_handler
@ -151,22 +136,18 @@ acpi_ev_gpe_xrupt_handler (
*
******************************************************************************/
u32
acpi_ev_install_sci_handler (
void)
u32 acpi_ev_install_sci_handler(void)
{
u32 status = AE_OK;
u32 status = AE_OK;
ACPI_FUNCTION_TRACE("ev_install_sci_handler");
ACPI_FUNCTION_TRACE ("ev_install_sci_handler");
status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
acpi_ev_sci_xrupt_handler, acpi_gbl_gpe_xrupt_list_head);
return_ACPI_STATUS (status);
status = acpi_os_install_interrupt_handler((u32) acpi_gbl_FADT->sci_int,
acpi_ev_sci_xrupt_handler,
acpi_gbl_gpe_xrupt_list_head);
return_ACPI_STATUS(status);
}
/******************************************************************************
*
* FUNCTION: acpi_ev_remove_sci_handler
@ -186,22 +167,16 @@ acpi_ev_install_sci_handler (
*
******************************************************************************/
acpi_status
acpi_ev_remove_sci_handler (
void)
acpi_status acpi_ev_remove_sci_handler(void)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ev_remove_sci_handler");
acpi_status status;
ACPI_FUNCTION_TRACE("ev_remove_sci_handler");
/* Just let the OS remove the handler and disable the level */
status = acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
acpi_ev_sci_xrupt_handler);
status = acpi_os_remove_interrupt_handler((u32) acpi_gbl_FADT->sci_int,
acpi_ev_sci_xrupt_handler);
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -49,8 +49,7 @@
#include <acpi/acinterp.h>
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evxface")
ACPI_MODULE_NAME("evxface")
/*******************************************************************************
*
@ -64,21 +63,16 @@
* DESCRIPTION: Saves the pointer to the handler function
*
******************************************************************************/
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_install_exception_handler (
acpi_exception_handler handler)
acpi_status acpi_install_exception_handler(acpi_exception_handler handler)
{
acpi_status status;
acpi_status status;
ACPI_FUNCTION_TRACE("acpi_install_exception_handler");
ACPI_FUNCTION_TRACE ("acpi_install_exception_handler");
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Don't allow two handlers. */
@ -92,12 +86,11 @@ acpi_install_exception_handler (
acpi_gbl_exception_handler = handler;
cleanup:
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
return_ACPI_STATUS (status);
cleanup:
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
return_ACPI_STATUS(status);
}
#endif /* ACPI_FUTURE_USAGE */
#endif /* ACPI_FUTURE_USAGE */
/*******************************************************************************
*
@ -116,26 +109,22 @@ cleanup:
******************************************************************************/
acpi_status
acpi_install_fixed_event_handler (
u32 event,
acpi_event_handler handler,
void *context)
acpi_install_fixed_event_handler(u32 event,
acpi_event_handler handler, void *context)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("acpi_install_fixed_event_handler");
acpi_status status;
ACPI_FUNCTION_TRACE("acpi_install_fixed_event_handler");
/* Parameter validation */
if (event > ACPI_EVENT_MAX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Don't allow two handlers. */
@ -150,29 +139,29 @@ acpi_install_fixed_event_handler (
acpi_gbl_fixed_event_handlers[event].handler = handler;
acpi_gbl_fixed_event_handlers[event].context = context;
status = acpi_clear_event (event);
status = acpi_clear_event(event);
if (ACPI_SUCCESS(status))
status = acpi_enable_event (event, 0);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n"));
status = acpi_enable_event(event, 0);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"Could not enable fixed event.\n"));
/* Remove the handler */
acpi_gbl_fixed_event_handlers[event].handler = NULL;
acpi_gbl_fixed_event_handlers[event].context = NULL;
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Enabled fixed event %X, Handler=%p\n", event, handler));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Enabled fixed event %X, Handler=%p\n", event,
handler));
}
cleanup:
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
return_ACPI_STATUS (status);
cleanup:
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_install_fixed_event_handler);
EXPORT_SYMBOL(acpi_install_fixed_event_handler);
/*******************************************************************************
*
@ -188,49 +177,45 @@ EXPORT_SYMBOL(acpi_install_fixed_event_handler);
******************************************************************************/
acpi_status
acpi_remove_fixed_event_handler (
u32 event,
acpi_event_handler handler)
acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("acpi_remove_fixed_event_handler");
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("acpi_remove_fixed_event_handler");
/* Parameter validation */
if (event > ACPI_EVENT_MAX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Disable the event before removing the handler */
status = acpi_disable_event (event, 0);
status = acpi_disable_event(event, 0);
/* Always Remove the handler */
acpi_gbl_fixed_event_handlers[event].handler = NULL;
acpi_gbl_fixed_event_handlers[event].context = NULL;
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_WARN,
"Could not write to fixed event enable register.\n"));
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", event));
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"Could not write to fixed event enable register.\n"));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X.\n",
event));
}
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
return_ACPI_STATUS (status);
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
/*******************************************************************************
*
@ -251,37 +236,32 @@ EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
******************************************************************************/
acpi_status
acpi_install_notify_handler (
acpi_handle device,
u32 handler_type,
acpi_notify_handler handler,
void *context)
acpi_install_notify_handler(acpi_handle device,
u32 handler_type,
acpi_notify_handler handler, void *context)
{
union acpi_operand_object *obj_desc;
union acpi_operand_object *notify_obj;
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_TRACE ("acpi_install_notify_handler");
union acpi_operand_object *obj_desc;
union acpi_operand_object *notify_obj;
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_TRACE("acpi_install_notify_handler");
/* Parameter validation */
if ((!device) ||
(!handler) ||
(handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
if ((!device) ||
(!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Convert and validate the device handle */
node = acpi_ns_map_handle_to_node (device);
node = acpi_ns_map_handle_to_node(device);
if (!node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -297,21 +277,21 @@ acpi_install_notify_handler (
/* Make sure the handler is not already installed */
if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
acpi_gbl_system_notify.handler) ||
((handler_type & ACPI_DEVICE_NOTIFY) &&
acpi_gbl_device_notify.handler)) {
acpi_gbl_system_notify.handler) ||
((handler_type & ACPI_DEVICE_NOTIFY) &&
acpi_gbl_device_notify.handler)) {
status = AE_ALREADY_EXISTS;
goto unlock_and_exit;
}
if (handler_type & ACPI_SYSTEM_NOTIFY) {
acpi_gbl_system_notify.node = node;
acpi_gbl_system_notify.node = node;
acpi_gbl_system_notify.handler = handler;
acpi_gbl_system_notify.context = context;
}
if (handler_type & ACPI_DEVICE_NOTIFY) {
acpi_gbl_device_notify.node = node;
acpi_gbl_device_notify.node = node;
acpi_gbl_device_notify.handler = handler;
acpi_gbl_device_notify.context = context;
}
@ -327,29 +307,28 @@ acpi_install_notify_handler (
else {
/* Notifies allowed on this object? */
if (!acpi_ev_is_notify_object (node)) {
if (!acpi_ev_is_notify_object(node)) {
status = AE_TYPE;
goto unlock_and_exit;
}
/* Check for an existing internal object */
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
/* Object exists - make sure there's no handler */
if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
obj_desc->common_notify.system_notify) ||
((handler_type & ACPI_DEVICE_NOTIFY) &&
obj_desc->common_notify.device_notify)) {
obj_desc->common_notify.system_notify) ||
((handler_type & ACPI_DEVICE_NOTIFY) &&
obj_desc->common_notify.device_notify)) {
status = AE_ALREADY_EXISTS;
goto unlock_and_exit;
}
}
else {
} else {
/* Create a new object */
obj_desc = acpi_ut_create_internal_object (node->type);
obj_desc = acpi_ut_create_internal_object(node->type);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto unlock_and_exit;
@ -357,25 +336,27 @@ acpi_install_notify_handler (
/* Attach new object to the Node */
status = acpi_ns_attach_object (device, obj_desc, node->type);
status =
acpi_ns_attach_object(device, obj_desc, node->type);
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
if (ACPI_FAILURE (status)) {
acpi_ut_remove_reference(obj_desc);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
}
/* Install the handler */
notify_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_NOTIFY);
notify_obj =
acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_NOTIFY);
if (!notify_obj) {
status = AE_NO_MEMORY;
goto unlock_and_exit;
}
notify_obj->notify.node = node;
notify_obj->notify.node = node;
notify_obj->notify.handler = handler;
notify_obj->notify.context = context;
@ -390,17 +371,16 @@ acpi_install_notify_handler (
if (handler_type == ACPI_ALL_NOTIFY) {
/* Extra ref if installed in both */
acpi_ut_add_reference (notify_obj);
acpi_ut_add_reference(notify_obj);
}
}
unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (status);
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_install_notify_handler);
EXPORT_SYMBOL(acpi_install_notify_handler);
/*******************************************************************************
*
@ -420,36 +400,31 @@ EXPORT_SYMBOL(acpi_install_notify_handler);
******************************************************************************/
acpi_status
acpi_remove_notify_handler (
acpi_handle device,
u32 handler_type,
acpi_notify_handler handler)
acpi_remove_notify_handler(acpi_handle device,
u32 handler_type, acpi_notify_handler handler)
{
union acpi_operand_object *notify_obj;
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_TRACE ("acpi_remove_notify_handler");
union acpi_operand_object *notify_obj;
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_TRACE("acpi_remove_notify_handler");
/* Parameter validation */
if ((!device) ||
(!handler) ||
(handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
if ((!device) ||
(!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Convert and validate the device handle */
node = acpi_ns_map_handle_to_node (device);
node = acpi_ns_map_handle_to_node(device);
if (!node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -458,34 +433,34 @@ acpi_remove_notify_handler (
/* Root Object */
if (device == ACPI_ROOT_OBJECT) {
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Removing notify handler for ROOT object.\n"));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Removing notify handler for ROOT object.\n"));
if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
!acpi_gbl_system_notify.handler) ||
((handler_type & ACPI_DEVICE_NOTIFY) &&
!acpi_gbl_device_notify.handler)) {
!acpi_gbl_system_notify.handler) ||
((handler_type & ACPI_DEVICE_NOTIFY) &&
!acpi_gbl_device_notify.handler)) {
status = AE_NOT_EXIST;
goto unlock_and_exit;
}
/* Make sure all deferred tasks are completed */
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
acpi_os_wait_events_complete(NULL);
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
if (handler_type & ACPI_SYSTEM_NOTIFY) {
acpi_gbl_system_notify.node = NULL;
acpi_gbl_system_notify.node = NULL;
acpi_gbl_system_notify.handler = NULL;
acpi_gbl_system_notify.context = NULL;
}
if (handler_type & ACPI_DEVICE_NOTIFY) {
acpi_gbl_device_notify.node = NULL;
acpi_gbl_device_notify.node = NULL;
acpi_gbl_device_notify.handler = NULL;
acpi_gbl_device_notify.context = NULL;
}
@ -496,14 +471,14 @@ acpi_remove_notify_handler (
else {
/* Notifies allowed on this object? */
if (!acpi_ev_is_notify_object (node)) {
if (!acpi_ev_is_notify_object(node)) {
status = AE_TYPE;
goto unlock_and_exit;
}
/* Check for an existing internal object */
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
status = AE_NOT_EXIST;
goto unlock_and_exit;
@ -514,53 +489,52 @@ acpi_remove_notify_handler (
if (handler_type & ACPI_SYSTEM_NOTIFY) {
notify_obj = obj_desc->common_notify.system_notify;
if ((!notify_obj) ||
(notify_obj->notify.handler != handler)) {
(notify_obj->notify.handler != handler)) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
/* Make sure all deferred tasks are completed */
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
acpi_os_wait_events_complete(NULL);
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Remove the handler */
obj_desc->common_notify.system_notify = NULL;
acpi_ut_remove_reference (notify_obj);
acpi_ut_remove_reference(notify_obj);
}
if (handler_type & ACPI_DEVICE_NOTIFY) {
notify_obj = obj_desc->common_notify.device_notify;
if ((!notify_obj) ||
(notify_obj->notify.handler != handler)) {
(notify_obj->notify.handler != handler)) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
/* Make sure all deferred tasks are completed */
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
acpi_os_wait_events_complete(NULL);
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Remove the handler */
obj_desc->common_notify.device_notify = NULL;
acpi_ut_remove_reference (notify_obj);
acpi_ut_remove_reference(notify_obj);
}
}
unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (status);
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_remove_notify_handler);
EXPORT_SYMBOL(acpi_remove_notify_handler);
/*******************************************************************************
*
@ -581,35 +555,31 @@ EXPORT_SYMBOL(acpi_remove_notify_handler);
******************************************************************************/
acpi_status
acpi_install_gpe_handler (
acpi_handle gpe_device,
u32 gpe_number,
u32 type,
acpi_event_handler address,
void *context)
acpi_install_gpe_handler(acpi_handle gpe_device,
u32 gpe_number,
u32 type, acpi_event_handler address, void *context)
{
struct acpi_gpe_event_info *gpe_event_info;
struct acpi_handler_info *handler;
acpi_status status;
ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler");
struct acpi_gpe_event_info *gpe_event_info;
struct acpi_handler_info *handler;
acpi_status status;
u32 flags;
ACPI_FUNCTION_TRACE("acpi_install_gpe_handler");
/* Parameter validation */
if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Ensure that we have a valid GPE number */
gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (!gpe_event_info) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -617,49 +587,49 @@ acpi_install_gpe_handler (
/* Make sure that there isn't a handler there already */
if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) {
if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
ACPI_GPE_DISPATCH_HANDLER) {
status = AE_ALREADY_EXISTS;
goto unlock_and_exit;
}
/* Allocate and init handler object */
handler = ACPI_MEM_CALLOCATE (sizeof (struct acpi_handler_info));
handler = ACPI_MEM_CALLOCATE(sizeof(struct acpi_handler_info));
if (!handler) {
status = AE_NO_MEMORY;
goto unlock_and_exit;
}
handler->address = address;
handler->context = context;
handler->address = address;
handler->context = context;
handler->method_node = gpe_event_info->dispatch.method_node;
/* Disable the GPE before installing the handler */
status = acpi_ev_disable_gpe (gpe_event_info);
if (ACPI_FAILURE (status)) {
status = acpi_ev_disable_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
/* Install the handler */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
gpe_event_info->dispatch.handler = handler;
/* Setup up dispatch flags to indicate handler (vs. method) */
gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */
gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */
gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER);
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
return_ACPI_STATUS (status);
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_install_gpe_handler);
EXPORT_SYMBOL(acpi_install_gpe_handler);
/*******************************************************************************
*
@ -677,33 +647,30 @@ EXPORT_SYMBOL(acpi_install_gpe_handler);
******************************************************************************/
acpi_status
acpi_remove_gpe_handler (
acpi_handle gpe_device,
u32 gpe_number,
acpi_event_handler address)
acpi_remove_gpe_handler(acpi_handle gpe_device,
u32 gpe_number, acpi_event_handler address)
{
struct acpi_gpe_event_info *gpe_event_info;
struct acpi_handler_info *handler;
acpi_status status;
ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler");
struct acpi_gpe_event_info *gpe_event_info;
struct acpi_handler_info *handler;
acpi_status status;
u32 flags;
ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler");
/* Parameter validation */
if (!address) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Ensure that we have a valid GPE number */
gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (!gpe_event_info) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -711,7 +678,8 @@ acpi_remove_gpe_handler (
/* Make sure that a handler is indeed installed */
if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != ACPI_GPE_DISPATCH_HANDLER) {
if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) !=
ACPI_GPE_DISPATCH_HANDLER) {
status = AE_NOT_EXIST;
goto unlock_and_exit;
}
@ -725,45 +693,44 @@ acpi_remove_gpe_handler (
/* Disable the GPE before removing the handler */
status = acpi_ev_disable_gpe (gpe_event_info);
if (ACPI_FAILURE (status)) {
status = acpi_ev_disable_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
/* Make sure all deferred tasks are completed */
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
acpi_os_wait_events_complete(NULL);
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Remove the handler */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
handler = gpe_event_info->dispatch.handler;
/* Restore Method node (if any), set dispatch flags */
gpe_event_info->dispatch.method_node = handler->method_node;
gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */
gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */
if (handler->method_node) {
gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD;
}
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
/* Now we can free the handler object */
ACPI_MEM_FREE (handler);
ACPI_MEM_FREE(handler);
unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
return_ACPI_STATUS (status);
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_remove_gpe_handler);
EXPORT_SYMBOL(acpi_remove_gpe_handler);
/*******************************************************************************
*
@ -779,35 +746,31 @@ EXPORT_SYMBOL(acpi_remove_gpe_handler);
*
******************************************************************************/
acpi_status
acpi_acquire_global_lock (
u16 timeout,
u32 *handle)
acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle)
{
acpi_status status;
acpi_status status;
if (!handle) {
return (AE_BAD_PARAMETER);
}
status = acpi_ex_enter_interpreter ();
if (ACPI_FAILURE (status)) {
status = acpi_ex_enter_interpreter();
if (ACPI_FAILURE(status)) {
return (status);
}
status = acpi_ev_acquire_global_lock (timeout);
acpi_ex_exit_interpreter ();
status = acpi_ev_acquire_global_lock(timeout);
acpi_ex_exit_interpreter();
if (ACPI_SUCCESS (status)) {
if (ACPI_SUCCESS(status)) {
acpi_gbl_global_lock_handle++;
*handle = acpi_gbl_global_lock_handle;
}
return (status);
}
EXPORT_SYMBOL(acpi_acquire_global_lock);
EXPORT_SYMBOL(acpi_acquire_global_lock);
/*******************************************************************************
*
@ -821,19 +784,16 @@ EXPORT_SYMBOL(acpi_acquire_global_lock);
*
******************************************************************************/
acpi_status
acpi_release_global_lock (
u32 handle)
acpi_status acpi_release_global_lock(u32 handle)
{
acpi_status status;
acpi_status status;
if (handle != acpi_gbl_global_lock_handle) {
return (AE_NOT_ACQUIRED);
}
status = acpi_ev_release_global_lock ();
status = acpi_ev_release_global_lock();
return (status);
}
EXPORT_SYMBOL(acpi_release_global_lock);
EXPORT_SYMBOL(acpi_release_global_lock);

View File

@ -48,8 +48,7 @@
#include <acpi/acnamesp.h>
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evxfevnt")
ACPI_MODULE_NAME("evxfevnt")
/*******************************************************************************
*
@ -62,44 +61,39 @@
* DESCRIPTION: Transfers the system into ACPI mode.
*
******************************************************************************/
acpi_status
acpi_enable (
void)
acpi_status acpi_enable(void)
{
acpi_status status = AE_OK;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("acpi_enable");
ACPI_FUNCTION_TRACE ("acpi_enable");
/* Make sure we have the FADT*/
/* Make sure we have the FADT */
if (!acpi_gbl_FADT) {
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n"));
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"No FADT information present!\n"));
return_ACPI_STATUS(AE_NO_ACPI_TABLES);
}
if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
}
else {
ACPI_DEBUG_PRINT((ACPI_DB_INIT,
"System is already in ACPI mode\n"));
} else {
/* Transition to ACPI mode */
status = acpi_hw_set_mode (ACPI_SYS_MODE_ACPI);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("Could not transition to ACPI mode.\n"));
return_ACPI_STATUS (status);
status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Could not transition to ACPI mode.\n"));
return_ACPI_STATUS(status);
}
ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
"Transition to ACPI mode successful\n"));
ACPI_DEBUG_PRINT((ACPI_DB_INIT,
"Transition to ACPI mode successful\n"));
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_disable
@ -112,43 +106,38 @@ acpi_enable (
*
******************************************************************************/
acpi_status
acpi_disable (
void)
acpi_status acpi_disable(void)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("acpi_disable");
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("acpi_disable");
if (!acpi_gbl_FADT) {
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n"));
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"No FADT information present!\n"));
return_ACPI_STATUS(AE_NO_ACPI_TABLES);
}
if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
"System is already in legacy (non-ACPI) mode\n"));
}
else {
ACPI_DEBUG_PRINT((ACPI_DB_INIT,
"System is already in legacy (non-ACPI) mode\n"));
} else {
/* Transition to LEGACY mode */
status = acpi_hw_set_mode (ACPI_SYS_MODE_LEGACY);
status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not exit ACPI mode to legacy mode"));
return_ACPI_STATUS (status);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Could not exit ACPI mode to legacy mode"));
return_ACPI_STATUS(status);
}
ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_enable_event
@ -162,52 +151,50 @@ acpi_disable (
*
******************************************************************************/
acpi_status
acpi_enable_event (
u32 event,
u32 flags)
acpi_status acpi_enable_event(u32 event, u32 flags)
{
acpi_status status = AE_OK;
u32 value;
ACPI_FUNCTION_TRACE ("acpi_enable_event");
acpi_status status = AE_OK;
u32 value;
ACPI_FUNCTION_TRACE("acpi_enable_event");
/* Decode the Fixed Event */
if (event > ACPI_EVENT_MAX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/*
* Enable the requested fixed event (by writing a one to the
* enable register bit)
*/
status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id,
1, ACPI_MTX_LOCK);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_set_register(acpi_gbl_fixed_event_info[event].
enable_register_id, 1, ACPI_MTX_LOCK);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Make sure that the hardware responded */
status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id,
&value, ACPI_MTX_LOCK);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_get_register(acpi_gbl_fixed_event_info[event].
enable_register_id, &value, ACPI_MTX_LOCK);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
if (value != 1) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not enable %s event\n", acpi_ut_get_event_name (event)));
return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Could not enable %s event\n",
acpi_ut_get_event_name(event)));
return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_enable_event);
EXPORT_SYMBOL(acpi_enable_event);
/*******************************************************************************
*
@ -223,40 +210,34 @@ EXPORT_SYMBOL(acpi_enable_event);
*
******************************************************************************/
acpi_status
acpi_set_gpe_type (
acpi_handle gpe_device,
u32 gpe_number,
u8 type)
acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
{
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE ("acpi_set_gpe_type");
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE("acpi_set_gpe_type");
/* Ensure that we have a valid GPE number */
gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (!gpe_event_info) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/* Set the new type (will disable GPE if currently enabled) */
status = acpi_ev_set_gpe_type (gpe_event_info, type);
status = acpi_ev_set_gpe_type(gpe_event_info, type);
unlock_and_exit:
return_ACPI_STATUS (status);
unlock_and_exit:
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_set_gpe_type);
EXPORT_SYMBOL(acpi_set_gpe_type);
/*******************************************************************************
*
@ -273,31 +254,25 @@ EXPORT_SYMBOL(acpi_set_gpe_type);
*
******************************************************************************/
acpi_status
acpi_enable_gpe (
acpi_handle gpe_device,
u32 gpe_number,
u32 flags)
acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
{
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE ("acpi_enable_gpe");
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE("acpi_enable_gpe");
/* Use semaphore lock if not executing at interrupt level */
if (flags & ACPI_NOT_ISR) {
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
/* Ensure that we have a valid GPE number */
gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (!gpe_event_info) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -305,16 +280,16 @@ acpi_enable_gpe (
/* Perform the enable */
status = acpi_ev_enable_gpe (gpe_event_info, TRUE);
status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
unlock_and_exit:
unlock_and_exit:
if (flags & ACPI_NOT_ISR) {
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_enable_gpe);
EXPORT_SYMBOL(acpi_enable_gpe);
/*******************************************************************************
*
@ -331,46 +306,39 @@ EXPORT_SYMBOL(acpi_enable_gpe);
*
******************************************************************************/
acpi_status
acpi_disable_gpe (
acpi_handle gpe_device,
u32 gpe_number,
u32 flags)
acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
{
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE ("acpi_disable_gpe");
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE("acpi_disable_gpe");
/* Use semaphore lock if not executing at interrupt level */
if (flags & ACPI_NOT_ISR) {
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
/* Ensure that we have a valid GPE number */
gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (!gpe_event_info) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
status = acpi_ev_disable_gpe (gpe_event_info);
status = acpi_ev_disable_gpe(gpe_event_info);
unlock_and_exit:
unlock_and_exit:
if (flags & ACPI_NOT_ISR) {
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_disable_event
@ -384,50 +352,48 @@ unlock_and_exit:
*
******************************************************************************/
acpi_status
acpi_disable_event (
u32 event,
u32 flags)
acpi_status acpi_disable_event(u32 event, u32 flags)
{
acpi_status status = AE_OK;
u32 value;
ACPI_FUNCTION_TRACE ("acpi_disable_event");
acpi_status status = AE_OK;
u32 value;
ACPI_FUNCTION_TRACE("acpi_disable_event");
/* Decode the Fixed Event */
if (event > ACPI_EVENT_MAX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/*
* Disable the requested fixed event (by writing a zero to the
* enable register bit)
*/
status = acpi_set_register (acpi_gbl_fixed_event_info[event].enable_register_id,
0, ACPI_MTX_LOCK);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_set_register(acpi_gbl_fixed_event_info[event].
enable_register_id, 0, ACPI_MTX_LOCK);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
status = acpi_get_register (acpi_gbl_fixed_event_info[event].enable_register_id,
&value, ACPI_MTX_LOCK);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_get_register(acpi_gbl_fixed_event_info[event].
enable_register_id, &value, ACPI_MTX_LOCK);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
if (value != 0) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not disable %s events\n", acpi_ut_get_event_name (event)));
return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Could not disable %s events\n",
acpi_ut_get_event_name(event)));
return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_disable_event);
EXPORT_SYMBOL(acpi_disable_event);
/*******************************************************************************
*
@ -441,33 +407,30 @@ EXPORT_SYMBOL(acpi_disable_event);
*
******************************************************************************/
acpi_status
acpi_clear_event (
u32 event)
acpi_status acpi_clear_event(u32 event)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("acpi_clear_event");
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("acpi_clear_event");
/* Decode the Fixed Event */
if (event > ACPI_EVENT_MAX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/*
* Clear the requested fixed event (By writing a one to the
* status register bit)
*/
status = acpi_set_register (acpi_gbl_fixed_event_info[event].status_register_id,
1, ACPI_MTX_LOCK);
status =
acpi_set_register(acpi_gbl_fixed_event_info[event].
status_register_id, 1, ACPI_MTX_LOCK);
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_clear_event);
EXPORT_SYMBOL(acpi_clear_event);
/*******************************************************************************
*
@ -483,46 +446,39 @@ EXPORT_SYMBOL(acpi_clear_event);
*
******************************************************************************/
acpi_status
acpi_clear_gpe (
acpi_handle gpe_device,
u32 gpe_number,
u32 flags)
acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
{
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE ("acpi_clear_gpe");
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE("acpi_clear_gpe");
/* Use semaphore lock if not executing at interrupt level */
if (flags & ACPI_NOT_ISR) {
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
/* Ensure that we have a valid GPE number */
gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (!gpe_event_info) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
status = acpi_hw_clear_gpe (gpe_event_info);
status = acpi_hw_clear_gpe(gpe_event_info);
unlock_and_exit:
unlock_and_exit:
if (flags & ACPI_NOT_ISR) {
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
#ifdef ACPI_FUTURE_USAGE
/*******************************************************************************
*
@ -538,36 +494,31 @@ unlock_and_exit:
*
******************************************************************************/
acpi_status
acpi_get_event_status (
u32 event,
acpi_event_status *event_status)
acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("acpi_get_event_status");
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("acpi_get_event_status");
if (!event_status) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Decode the Fixed Event */
if (event > ACPI_EVENT_MAX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Get the status of the requested fixed event */
status = acpi_get_register (acpi_gbl_fixed_event_info[event].status_register_id,
event_status, ACPI_MTX_LOCK);
status =
acpi_get_register(acpi_gbl_fixed_event_info[event].
status_register_id, event_status, ACPI_MTX_LOCK);
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_get_gpe_status
@ -585,31 +536,26 @@ acpi_get_event_status (
******************************************************************************/
acpi_status
acpi_get_gpe_status (
acpi_handle gpe_device,
u32 gpe_number,
u32 flags,
acpi_event_status *event_status)
acpi_get_gpe_status(acpi_handle gpe_device,
u32 gpe_number, u32 flags, acpi_event_status * event_status)
{
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE ("acpi_get_gpe_status");
acpi_status status = AE_OK;
struct acpi_gpe_event_info *gpe_event_info;
ACPI_FUNCTION_TRACE("acpi_get_gpe_status");
/* Use semaphore lock if not executing at interrupt level */
if (flags & ACPI_NOT_ISR) {
status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
/* Ensure that we have a valid GPE number */
gpe_event_info = acpi_ev_get_gpe_event_info (gpe_device, gpe_number);
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (!gpe_event_info) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -617,16 +563,15 @@ acpi_get_gpe_status (
/* Obtain status on the requested GPE number */
status = acpi_hw_get_gpe_status (gpe_event_info, event_status);
status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
unlock_and_exit:
unlock_and_exit:
if (flags & ACPI_NOT_ISR) {
(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
#endif /* ACPI_FUTURE_USAGE */
#endif /* ACPI_FUTURE_USAGE */
/*******************************************************************************
*
@ -635,7 +580,7 @@ unlock_and_exit:
* PARAMETERS: gpe_device - Handle to the parent GPE Block Device
* gpe_block_address - Address and space_iD
* register_count - Number of GPE register pairs in the block
* interrupt_level - H/W interrupt for the block
* interrupt_number - H/W interrupt for the block
*
* RETURN: Status
*
@ -644,33 +589,27 @@ unlock_and_exit:
******************************************************************************/
acpi_status
acpi_install_gpe_block (
acpi_handle gpe_device,
struct acpi_generic_address *gpe_block_address,
u32 register_count,
u32 interrupt_level)
acpi_install_gpe_block(acpi_handle gpe_device,
struct acpi_generic_address *gpe_block_address,
u32 register_count, u32 interrupt_number)
{
acpi_status status;
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
struct acpi_gpe_block_info *gpe_block;
acpi_status status;
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
struct acpi_gpe_block_info *gpe_block;
ACPI_FUNCTION_TRACE("acpi_install_gpe_block");
ACPI_FUNCTION_TRACE ("acpi_install_gpe_block");
if ((!gpe_device) ||
(!gpe_block_address) ||
(!register_count)) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return (status);
}
node = acpi_ns_map_handle_to_node (gpe_device);
node = acpi_ns_map_handle_to_node(gpe_device);
if (!node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -680,31 +619,33 @@ acpi_install_gpe_block (
* For user-installed GPE Block Devices, the gpe_block_base_number
* is always zero
*/
status = acpi_ev_create_gpe_block (node, gpe_block_address, register_count,
0, interrupt_level, &gpe_block);
if (ACPI_FAILURE (status)) {
status =
acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
interrupt_number, &gpe_block);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
/* Get the device_object attached to the node */
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
/* No object, create a new one */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_DEVICE);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto unlock_and_exit;
}
status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_DEVICE);
status =
acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
acpi_ut_remove_reference(obj_desc);
if (ACPI_FAILURE (status)) {
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
}
@ -713,13 +654,12 @@ acpi_install_gpe_block (
obj_desc->device.gpe_block = gpe_block;
unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (status);
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_install_gpe_block);
EXPORT_SYMBOL(acpi_install_gpe_block);
/*******************************************************************************
*
@ -733,28 +673,24 @@ EXPORT_SYMBOL(acpi_install_gpe_block);
*
******************************************************************************/
acpi_status
acpi_remove_gpe_block (
acpi_handle gpe_device)
acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
{
union acpi_operand_object *obj_desc;
acpi_status status;
struct acpi_namespace_node *node;
ACPI_FUNCTION_TRACE ("acpi_remove_gpe_block");
union acpi_operand_object *obj_desc;
acpi_status status;
struct acpi_namespace_node *node;
ACPI_FUNCTION_TRACE("acpi_remove_gpe_block");
if (!gpe_device) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return (status);
}
node = acpi_ns_map_handle_to_node (gpe_device);
node = acpi_ns_map_handle_to_node(gpe_device);
if (!node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -762,22 +698,21 @@ acpi_remove_gpe_block (
/* Get the device_object attached to the node */
obj_desc = acpi_ns_get_attached_object (node);
if (!obj_desc ||
!obj_desc->device.gpe_block) {
return_ACPI_STATUS (AE_NULL_OBJECT);
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc || !obj_desc->device.gpe_block) {
return_ACPI_STATUS(AE_NULL_OBJECT);
}
/* Delete the GPE block (but not the device_object) */
status = acpi_ev_delete_gpe_block (obj_desc->device.gpe_block);
if (ACPI_SUCCESS (status)) {
status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
if (ACPI_SUCCESS(status)) {
obj_desc->device.gpe_block = NULL;
}
unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (status);
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_remove_gpe_block);

View File

@ -49,8 +49,7 @@
#include <acpi/acevents.h>
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evxfregn")
ACPI_MODULE_NAME("evxfregn")
/*******************************************************************************
*
@ -67,36 +66,31 @@
* DESCRIPTION: Install a handler for all op_regions of a given space_id.
*
******************************************************************************/
acpi_status
acpi_install_address_space_handler (
acpi_handle device,
acpi_adr_space_type space_id,
acpi_adr_space_handler handler,
acpi_adr_space_setup setup,
void *context)
acpi_install_address_space_handler(acpi_handle device,
acpi_adr_space_type space_id,
acpi_adr_space_handler handler,
acpi_adr_space_setup setup, void *context)
{
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_TRACE ("acpi_install_address_space_handler");
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_TRACE("acpi_install_address_space_handler");
/* Parameter validation */
if (!device) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Convert and validate the device handle */
node = acpi_ns_map_handle_to_node (device);
node = acpi_ns_map_handle_to_node(device);
if (!node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -104,21 +98,23 @@ acpi_install_address_space_handler (
/* Install the handler for all Regions for this Space ID */
status = acpi_ev_install_space_handler (node, space_id, handler, setup, context);
if (ACPI_FAILURE (status)) {
status =
acpi_ev_install_space_handler(node, space_id, handler, setup,
context);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
/* Run all _REG methods for this address space */
status = acpi_ev_execute_reg_methods (node, space_id);
status = acpi_ev_execute_reg_methods(node, space_id);
unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (status);
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_install_address_space_handler);
EXPORT_SYMBOL(acpi_install_address_space_handler);
/*******************************************************************************
*
@ -135,36 +131,33 @@ EXPORT_SYMBOL(acpi_install_address_space_handler);
******************************************************************************/
acpi_status
acpi_remove_address_space_handler (
acpi_handle device,
acpi_adr_space_type space_id,
acpi_adr_space_handler handler)
acpi_remove_address_space_handler(acpi_handle device,
acpi_adr_space_type space_id,
acpi_adr_space_handler handler)
{
union acpi_operand_object *obj_desc;
union acpi_operand_object *handler_obj;
union acpi_operand_object *region_obj;
union acpi_operand_object **last_obj_ptr;
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_TRACE ("acpi_remove_address_space_handler");
union acpi_operand_object *obj_desc;
union acpi_operand_object *handler_obj;
union acpi_operand_object *region_obj;
union acpi_operand_object **last_obj_ptr;
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_TRACE("acpi_remove_address_space_handler");
/* Parameter validation */
if (!device) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Convert and validate the device handle */
node = acpi_ns_map_handle_to_node (device);
node = acpi_ns_map_handle_to_node(device);
if (!node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
@ -172,7 +165,7 @@ acpi_remove_address_space_handler (
/* Make sure the internal object exists */
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
status = AE_NOT_EXIST;
goto unlock_and_exit;
@ -188,10 +181,11 @@ acpi_remove_address_space_handler (
if (handler_obj->address_space.space_id == space_id) {
/* Matched space_id, first dereference this in the Regions */
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
"Removing address handler %p(%p) for region %s on Device %p(%p)\n",
handler_obj, handler, acpi_ut_get_region_name (space_id),
node, obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Removing address handler %p(%p) for region %s on Device %p(%p)\n",
handler_obj, handler,
acpi_ut_get_region_name(space_id),
node, obj_desc));
region_obj = handler_obj->address_space.region_list;
@ -205,13 +199,14 @@ acpi_remove_address_space_handler (
* The region is just inaccessible as indicated to
* the _REG method
*/
acpi_ev_detach_region (region_obj, TRUE);
acpi_ev_detach_region(region_obj, TRUE);
/*
* Walk the list: Just grab the head because the
* detach_region removed the previous head.
*/
region_obj = handler_obj->address_space.region_list;
region_obj =
handler_obj->address_space.region_list;
}
@ -221,7 +216,7 @@ acpi_remove_address_space_handler (
/* Now we can delete the handler object */
acpi_ut_remove_reference (handler_obj);
acpi_ut_remove_reference(handler_obj);
goto unlock_and_exit;
}
@ -233,15 +228,16 @@ acpi_remove_address_space_handler (
/* The handler does not exist */
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
"Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n",
handler, acpi_ut_get_region_name (space_id), space_id, node, obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Unable to remove address handler %p for %s(%X), dev_node %p, obj %p\n",
handler, acpi_ut_get_region_name(space_id), space_id,
node, obj_desc));
status = AE_NOT_EXIST;
unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (status);
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(status);
}
EXPORT_SYMBOL(acpi_remove_address_space_handler);
EXPORT_SYMBOL(acpi_remove_address_space_handler);

View File

@ -41,7 +41,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/amlcode.h>
@ -50,18 +49,14 @@
#include <acpi/actables.h>
#include <acpi/acdispat.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exconfig")
ACPI_MODULE_NAME("exconfig")
/* Local prototypes */
static acpi_status
acpi_ex_add_table (
struct acpi_table_header *table,
struct acpi_namespace_node *parent_node,
union acpi_operand_object **ddb_handle);
acpi_ex_add_table(struct acpi_table_header *table,
struct acpi_namespace_node *parent_node,
union acpi_operand_object **ddb_handle);
/*******************************************************************************
*
@ -79,64 +74,67 @@ acpi_ex_add_table (
******************************************************************************/
static acpi_status
acpi_ex_add_table (
struct acpi_table_header *table,
struct acpi_namespace_node *parent_node,
union acpi_operand_object **ddb_handle)
acpi_ex_add_table(struct acpi_table_header *table,
struct acpi_namespace_node *parent_node,
union acpi_operand_object **ddb_handle)
{
acpi_status status;
struct acpi_table_desc table_info;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_TRACE ("ex_add_table");
acpi_status status;
struct acpi_table_desc table_info;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_TRACE("ex_add_table");
/* Create an object to be the table handle */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Install the new table into the local data structures */
ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc));
table_info.type = ACPI_TABLE_SSDT;
table_info.pointer = table;
table_info.length = (acpi_size) table->length;
table_info.allocation = ACPI_MEM_ALLOCATED;
status = acpi_tb_install_table (&table_info);
if (ACPI_FAILURE (status)) {
goto cleanup;
}
/* Add the table to the namespace */
status = acpi_ns_load_table (table_info.installed_desc, parent_node);
if (ACPI_FAILURE (status)) {
/* Uninstall table on error */
(void) acpi_tb_uninstall_table (table_info.installed_desc);
goto cleanup;
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Init the table handle */
obj_desc->reference.opcode = AML_LOAD_OP;
obj_desc->reference.object = table_info.installed_desc;
*ddb_handle = obj_desc;
return_ACPI_STATUS (AE_OK);
/* Install the new table into the local data structures */
cleanup:
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
ACPI_MEMSET(&table_info, 0, sizeof(struct acpi_table_desc));
table_info.type = ACPI_TABLE_SSDT;
table_info.pointer = table;
table_info.length = (acpi_size) table->length;
table_info.allocation = ACPI_MEM_ALLOCATED;
status = acpi_tb_install_table(&table_info);
obj_desc->reference.object = table_info.installed_desc;
if (ACPI_FAILURE(status)) {
if (status == AE_ALREADY_EXISTS) {
/* Table already exists, just return the handle */
return_ACPI_STATUS(AE_OK);
}
goto cleanup;
}
/* Add the table to the namespace */
status = acpi_ns_load_table(table_info.installed_desc, parent_node);
if (ACPI_FAILURE(status)) {
/* Uninstall table on error */
(void)acpi_tb_uninstall_table(table_info.installed_desc);
goto cleanup;
}
return_ACPI_STATUS(AE_OK);
cleanup:
acpi_ut_remove_reference(obj_desc);
*ddb_handle = NULL;
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_load_table_op
@ -151,56 +149,53 @@ cleanup:
******************************************************************************/
acpi_status
acpi_ex_load_table_op (
struct acpi_walk_state *walk_state,
union acpi_operand_object **return_desc)
acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
union acpi_operand_object **return_desc)
{
acpi_status status;
union acpi_operand_object **operand = &walk_state->operands[0];
struct acpi_table_header *table;
struct acpi_namespace_node *parent_node;
struct acpi_namespace_node *start_node;
struct acpi_namespace_node *parameter_node = NULL;
union acpi_operand_object *ddb_handle;
ACPI_FUNCTION_TRACE ("ex_load_table_op");
acpi_status status;
union acpi_operand_object **operand = &walk_state->operands[0];
struct acpi_table_header *table;
struct acpi_namespace_node *parent_node;
struct acpi_namespace_node *start_node;
struct acpi_namespace_node *parameter_node = NULL;
union acpi_operand_object *ddb_handle;
ACPI_FUNCTION_TRACE("ex_load_table_op");
#if 0
/*
* Make sure that the signature does not match one of the tables that
* is already loaded.
*/
status = acpi_tb_match_signature (operand[0]->string.pointer, NULL);
status = acpi_tb_match_signature(operand[0]->string.pointer, NULL);
if (status == AE_OK) {
/* Signature matched -- don't allow override */
return_ACPI_STATUS (AE_ALREADY_EXISTS);
return_ACPI_STATUS(AE_ALREADY_EXISTS);
}
#endif
/* Find the ACPI table */
status = acpi_tb_find_table (operand[0]->string.pointer,
operand[1]->string.pointer,
operand[2]->string.pointer, &table);
if (ACPI_FAILURE (status)) {
status = acpi_tb_find_table(operand[0]->string.pointer,
operand[1]->string.pointer,
operand[2]->string.pointer, &table);
if (ACPI_FAILURE(status)) {
if (status != AE_NOT_FOUND) {
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/* Table not found, return an Integer=0 and AE_OK */
ddb_handle = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
ddb_handle = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!ddb_handle) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
ddb_handle->integer.value = 0;
*return_desc = ddb_handle;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/* Default nodes */
@ -215,10 +210,12 @@ acpi_ex_load_table_op (
* Find the node referenced by the root_path_string. This is the
* location within the namespace where the table will be loaded.
*/
status = acpi_ns_get_node_by_path (operand[3]->string.pointer, start_node,
ACPI_NS_SEARCH_PARENT, &parent_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ns_get_node_by_path(operand[3]->string.pointer,
start_node, ACPI_NS_SEARCH_PARENT,
&parent_node);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
@ -226,7 +223,7 @@ acpi_ex_load_table_op (
if (operand[4]->string.length > 0) {
if ((operand[4]->string.pointer[0] != '\\') &&
(operand[4]->string.pointer[0] != '^')) {
(operand[4]->string.pointer[0] != '^')) {
/*
* Path is not absolute, so it will be relative to the node
* referenced by the root_path_string (or the NS root if omitted)
@ -236,18 +233,20 @@ acpi_ex_load_table_op (
/* Find the node referenced by the parameter_path_string */
status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node,
ACPI_NS_SEARCH_PARENT, &parameter_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ns_get_node_by_path(operand[4]->string.pointer,
start_node, ACPI_NS_SEARCH_PARENT,
&parameter_node);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
/* Load the table into the namespace */
status = acpi_ex_add_table (table, parent_node, &ddb_handle);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ex_add_table(table, parent_node, &ddb_handle);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Parameter Data (optional) */
@ -255,20 +254,20 @@ acpi_ex_load_table_op (
if (parameter_node) {
/* Store the parameter data into the optional parameter object */
status = acpi_ex_store (operand[5],
ACPI_CAST_PTR (union acpi_operand_object, parameter_node),
walk_state);
if (ACPI_FAILURE (status)) {
(void) acpi_ex_unload_table (ddb_handle);
return_ACPI_STATUS (status);
status = acpi_ex_store(operand[5],
ACPI_CAST_PTR(union acpi_operand_object,
parameter_node),
walk_state);
if (ACPI_FAILURE(status)) {
(void)acpi_ex_unload_table(ddb_handle);
return_ACPI_STATUS(status);
}
}
*return_desc = ddb_handle;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_load_op
@ -285,38 +284,37 @@ acpi_ex_load_table_op (
******************************************************************************/
acpi_status
acpi_ex_load_op (
union acpi_operand_object *obj_desc,
union acpi_operand_object *target,
struct acpi_walk_state *walk_state)
acpi_ex_load_op(union acpi_operand_object *obj_desc,
union acpi_operand_object *target,
struct acpi_walk_state *walk_state)
{
acpi_status status;
union acpi_operand_object *ddb_handle;
union acpi_operand_object *buffer_desc = NULL;
struct acpi_table_header *table_ptr = NULL;
acpi_physical_address address;
struct acpi_table_header table_header;
u32 i;
ACPI_FUNCTION_TRACE ("ex_load_op");
acpi_status status;
union acpi_operand_object *ddb_handle;
union acpi_operand_object *buffer_desc = NULL;
struct acpi_table_header *table_ptr = NULL;
acpi_physical_address address;
struct acpi_table_header table_header;
u32 i;
ACPI_FUNCTION_TRACE("ex_load_op");
/* Object can be either an op_region or a Field */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_REGION:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n",
obj_desc, acpi_ut_get_object_type_name (obj_desc)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Region %p %s\n",
obj_desc,
acpi_ut_get_object_type_name(obj_desc)));
/*
* If the Region Address and Length have not been previously evaluated,
* evaluate them now and save the results.
*/
if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
status = acpi_ds_get_region_arguments (obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_get_region_arguments(obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
@ -328,116 +326,127 @@ acpi_ex_load_op (
table_header.length = 0;
for (i = 0; i < 8; i++) {
status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ,
(acpi_physical_address) (i + address), 8,
((u8 *) &table_header) + i);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ev_address_space_dispatch(obj_desc, ACPI_READ,
(acpi_physical_address)
(i + address), 8,
((u8 *) &
table_header) + i);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
/* Sanity check the table length */
if (table_header.length < sizeof (struct acpi_table_header)) {
return_ACPI_STATUS (AE_BAD_HEADER);
if (table_header.length < sizeof(struct acpi_table_header)) {
return_ACPI_STATUS(AE_BAD_HEADER);
}
/* Allocate a buffer for the entire table */
table_ptr = ACPI_MEM_ALLOCATE (table_header.length);
table_ptr = ACPI_MEM_ALLOCATE(table_header.length);
if (!table_ptr) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Get the entire table from the op region */
for (i = 0; i < table_header.length; i++) {
status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ,
(acpi_physical_address) (i + address), 8,
((u8 *) table_ptr + i));
if (ACPI_FAILURE (status)) {
status =
acpi_ev_address_space_dispatch(obj_desc, ACPI_READ,
(acpi_physical_address)
(i + address), 8,
((u8 *) table_ptr +
i));
if (ACPI_FAILURE(status)) {
goto cleanup;
}
}
break;
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n",
obj_desc, acpi_ut_get_object_type_name (obj_desc)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Field %p %s\n",
obj_desc,
acpi_ut_get_object_type_name(obj_desc)));
/*
* The length of the field must be at least as large as the table.
* Read the entire field and thus the entire table. Buffer is
* allocated during the read.
*/
status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc);
if (ACPI_FAILURE (status)) {
goto cleanup;
status =
acpi_ex_read_data_from_field(walk_state, obj_desc,
&buffer_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
table_ptr = ACPI_CAST_PTR (struct acpi_table_header,
buffer_desc->buffer.pointer);
table_ptr = ACPI_CAST_PTR(struct acpi_table_header,
buffer_desc->buffer.pointer);
/* Sanity check the table length */
/* All done with the buffer_desc, delete it */
if (table_ptr->length < sizeof (struct acpi_table_header)) {
return_ACPI_STATUS (AE_BAD_HEADER);
buffer_desc->buffer.pointer = NULL;
acpi_ut_remove_reference(buffer_desc);
/* Sanity check the table length */
if (table_ptr->length < sizeof(struct acpi_table_header)) {
status = AE_BAD_HEADER;
goto cleanup;
}
break;
default:
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/* The table must be either an SSDT or a PSDT */
if ((!ACPI_STRNCMP (table_ptr->signature,
acpi_gbl_table_data[ACPI_TABLE_PSDT].signature,
acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) &&
(!ACPI_STRNCMP (table_ptr->signature,
acpi_gbl_table_data[ACPI_TABLE_SSDT].signature,
acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Table has invalid signature [%4.4s], must be SSDT or PSDT\n",
table_ptr->signature));
if ((!ACPI_STRNCMP(table_ptr->signature,
acpi_gbl_table_data[ACPI_TABLE_PSDT].signature,
acpi_gbl_table_data[ACPI_TABLE_PSDT].sig_length)) &&
(!ACPI_STRNCMP(table_ptr->signature,
acpi_gbl_table_data[ACPI_TABLE_SSDT].signature,
acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Table has invalid signature [%4.4s], must be SSDT or PSDT\n",
table_ptr->signature));
status = AE_BAD_SIGNATURE;
goto cleanup;
}
/* Install the new table into the local data structures */
status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle);
if (ACPI_FAILURE (status)) {
goto cleanup;
status = acpi_ex_add_table(table_ptr, acpi_gbl_root_node, &ddb_handle);
if (ACPI_FAILURE(status)) {
/* On error, table_ptr was deallocated above */
return_ACPI_STATUS(status);
}
/* Store the ddb_handle into the Target operand */
status = acpi_ex_store (ddb_handle, target, walk_state);
if (ACPI_FAILURE (status)) {
(void) acpi_ex_unload_table (ddb_handle);
status = acpi_ex_store(ddb_handle, target, walk_state);
if (ACPI_FAILURE(status)) {
(void)acpi_ex_unload_table(ddb_handle);
/* table_ptr was deallocated above */
return_ACPI_STATUS(status);
}
return_ACPI_STATUS (status);
cleanup:
if (buffer_desc) {
acpi_ut_remove_reference (buffer_desc);
cleanup:
if (ACPI_FAILURE(status)) {
ACPI_MEM_FREE(table_ptr);
}
else {
ACPI_MEM_FREE (table_ptr);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_unload_table
@ -450,17 +459,13 @@ cleanup:
*
******************************************************************************/
acpi_status
acpi_ex_unload_table (
union acpi_operand_object *ddb_handle)
acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
{
acpi_status status = AE_OK;
union acpi_operand_object *table_desc = ddb_handle;
struct acpi_table_desc *table_info;
ACPI_FUNCTION_TRACE ("ex_unload_table");
acpi_status status = AE_OK;
union acpi_operand_object *table_desc = ddb_handle;
struct acpi_table_desc *table_info;
ACPI_FUNCTION_TRACE("ex_unload_table");
/*
* Validate the handle
@ -469,28 +474,28 @@ acpi_ex_unload_table (
* validated here.
*/
if ((!ddb_handle) ||
(ACPI_GET_DESCRIPTOR_TYPE (ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
(ACPI_GET_OBJECT_TYPE (ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
(ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
(ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Get the actual table descriptor from the ddb_handle */
table_info = (struct acpi_table_desc *) table_desc->reference.object;
table_info = (struct acpi_table_desc *)table_desc->reference.object;
/*
* Delete the entire namespace under this table Node
* (Offset contains the table_id)
*/
acpi_ns_delete_namespace_by_owner (table_info->table_id);
acpi_ns_delete_namespace_by_owner(table_info->owner_id);
acpi_ut_release_owner_id(&table_info->owner_id);
/* Delete the table itself */
(void) acpi_tb_uninstall_table (table_info->installed_desc);
(void)acpi_tb_uninstall_table(table_info->installed_desc);
/* Delete the table descriptor (ddb_handle) */
acpi_ut_remove_reference (table_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(table_desc);
return_ACPI_STATUS(status);
}

View File

@ -41,24 +41,17 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/amlcode.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exconvrt")
ACPI_MODULE_NAME("exconvrt")
/* Local prototypes */
static u32
acpi_ex_convert_to_ascii (
acpi_integer integer,
u16 base,
u8 *string,
u8 max_length);
acpi_ex_convert_to_ascii(acpi_integer integer,
u16 base, u8 * string, u8 max_length);
/*******************************************************************************
*
@ -76,29 +69,25 @@ acpi_ex_convert_to_ascii (
******************************************************************************/
acpi_status
acpi_ex_convert_to_integer (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc,
u32 flags)
acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc, u32 flags)
{
union acpi_operand_object *return_desc;
u8 *pointer;
acpi_integer result;
u32 i;
u32 count;
acpi_status status;
union acpi_operand_object *return_desc;
u8 *pointer;
acpi_integer result;
u32 i;
u32 count;
acpi_status status;
ACPI_FUNCTION_TRACE_PTR("ex_convert_to_integer", obj_desc);
ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_integer", obj_desc);
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_INTEGER:
/* No conversion necessary */
*result_desc = obj_desc;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
case ACPI_TYPE_BUFFER:
case ACPI_TYPE_STRING:
@ -106,11 +95,11 @@ acpi_ex_convert_to_integer (
/* Note: Takes advantage of common buffer/string fields */
pointer = obj_desc->buffer.pointer;
count = obj_desc->buffer.length;
count = obj_desc->buffer.length;
break;
default:
return_ACPI_STATUS (AE_TYPE);
return_ACPI_STATUS(AE_TYPE);
}
/*
@ -126,7 +115,7 @@ acpi_ex_convert_to_integer (
/* String conversion is different than Buffer conversion */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_STRING:
/*
@ -135,19 +124,18 @@ acpi_ex_convert_to_integer (
* of ACPI 3.0) is that the to_integer() operator allows both decimal
* and hexadecimal strings (hex prefixed with "0x").
*/
status = acpi_ut_strtoul64 ((char *) pointer, flags, &result);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ut_strtoul64((char *)pointer, flags, &result);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
break;
case ACPI_TYPE_BUFFER:
/* Check for zero-length buffer */
if (!count) {
return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
}
/* Transfer no more than an integer's worth of data */
@ -170,7 +158,6 @@ acpi_ex_convert_to_integer (
}
break;
default:
/* No other types can get here */
break;
@ -178,20 +165,19 @@ acpi_ex_convert_to_integer (
/* Create a new integer */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Save the Result */
return_desc->integer.value = result;
acpi_ex_truncate_for32bit_table (return_desc);
acpi_ex_truncate_for32bit_table(return_desc);
*result_desc = return_desc;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_convert_to_buffer
@ -207,25 +193,21 @@ acpi_ex_convert_to_integer (
******************************************************************************/
acpi_status
acpi_ex_convert_to_buffer (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc)
acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc)
{
union acpi_operand_object *return_desc;
u8 *new_buf;
union acpi_operand_object *return_desc;
u8 *new_buf;
ACPI_FUNCTION_TRACE_PTR("ex_convert_to_buffer", obj_desc);
ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_buffer", obj_desc);
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_BUFFER:
/* No conversion necessary */
*result_desc = obj_desc;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
case ACPI_TYPE_INTEGER:
@ -233,20 +215,20 @@ acpi_ex_convert_to_buffer (
* Create a new Buffer object.
* Need enough space for one integer
*/
return_desc = acpi_ut_create_buffer_object (acpi_gbl_integer_byte_width);
return_desc =
acpi_ut_create_buffer_object(acpi_gbl_integer_byte_width);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Copy the integer to the buffer, LSB first */
new_buf = return_desc->buffer.pointer;
ACPI_MEMCPY (new_buf,
&obj_desc->integer.value,
acpi_gbl_integer_byte_width);
ACPI_MEMCPY(new_buf,
&obj_desc->integer.value,
acpi_gbl_integer_byte_width);
break;
case ACPI_TYPE_STRING:
/*
@ -258,32 +240,31 @@ acpi_ex_convert_to_buffer (
* ASL/AML code that depends on the null being transferred to the new
* buffer.
*/
return_desc = acpi_ut_create_buffer_object (
(acpi_size) obj_desc->string.length + 1);
return_desc = acpi_ut_create_buffer_object((acpi_size)
obj_desc->string.
length + 1);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Copy the string to the buffer */
new_buf = return_desc->buffer.pointer;
ACPI_STRNCPY ((char *) new_buf, (char *) obj_desc->string.pointer,
obj_desc->string.length);
ACPI_STRNCPY((char *)new_buf, (char *)obj_desc->string.pointer,
obj_desc->string.length);
break;
default:
return_ACPI_STATUS (AE_TYPE);
return_ACPI_STATUS(AE_TYPE);
}
/* Mark buffer initialized */
return_desc->common.flags |= AOPOBJ_DATA_VALID;
*result_desc = return_desc;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_convert_to_ascii
@ -300,24 +281,19 @@ acpi_ex_convert_to_buffer (
******************************************************************************/
static u32
acpi_ex_convert_to_ascii (
acpi_integer integer,
u16 base,
u8 *string,
u8 data_width)
acpi_ex_convert_to_ascii(acpi_integer integer,
u16 base, u8 * string, u8 data_width)
{
acpi_integer digit;
acpi_native_uint i;
acpi_native_uint j;
acpi_native_uint k = 0;
acpi_native_uint hex_length;
acpi_native_uint decimal_length;
u32 remainder;
u8 supress_zeros;
ACPI_FUNCTION_ENTRY ();
acpi_integer digit;
acpi_native_uint i;
acpi_native_uint j;
acpi_native_uint k = 0;
acpi_native_uint hex_length;
acpi_native_uint decimal_length;
u32 remainder;
u8 supress_zeros;
ACPI_FUNCTION_ENTRY();
switch (base) {
case 10:
@ -339,7 +315,7 @@ acpi_ex_convert_to_ascii (
break;
}
supress_zeros = TRUE; /* No leading zeros */
supress_zeros = TRUE; /* No leading zeros */
remainder = 0;
for (i = decimal_length; i > 0; i--) {
@ -347,7 +323,8 @@ acpi_ex_convert_to_ascii (
digit = integer;
for (j = 0; j < i; j++) {
(void) acpi_ut_short_divide (digit, 10, &digit, &remainder);
(void)acpi_ut_short_divide(digit, 10, &digit,
&remainder);
}
/* Handle leading zeros */
@ -367,11 +344,13 @@ acpi_ex_convert_to_ascii (
/* hex_length: 2 ascii hex chars per data byte */
hex_length = ACPI_MUL_2 (data_width);
for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) {
hex_length = (acpi_native_uint) ACPI_MUL_2(data_width);
for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) {
/* Get one hex digit, most significant digits first */
string[k] = (u8) acpi_ut_hex_to_ascii_char (integer, ACPI_MUL_4 (j));
string[k] =
(u8) acpi_ut_hex_to_ascii_char(integer,
ACPI_MUL_4(j));
k++;
}
break;
@ -387,15 +366,14 @@ acpi_ex_convert_to_ascii (
* Finally, null terminate the string and return the length
*/
if (!k) {
string [0] = ACPI_ASCII_ZERO;
string[0] = ACPI_ASCII_ZERO;
k = 1;
}
string [k] = 0;
string[k] = 0;
return ((u32) k);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_convert_to_string
@ -412,30 +390,25 @@ acpi_ex_convert_to_ascii (
******************************************************************************/
acpi_status
acpi_ex_convert_to_string (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc,
u32 type)
acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
union acpi_operand_object ** result_desc, u32 type)
{
union acpi_operand_object *return_desc;
u8 *new_buf;
u32 i;
u32 string_length = 0;
u16 base = 16;
u8 separator = ',';
union acpi_operand_object *return_desc;
u8 *new_buf;
u32 i;
u32 string_length = 0;
u16 base = 16;
u8 separator = ',';
ACPI_FUNCTION_TRACE_PTR("ex_convert_to_string", obj_desc);
ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_string", obj_desc);
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_STRING:
/* No conversion necessary */
*result_desc = obj_desc;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
case ACPI_TYPE_INTEGER:
@ -452,7 +425,7 @@ acpi_ex_convert_to_string (
/* Two hex string characters for each integer byte */
string_length = ACPI_MUL_2 (acpi_gbl_integer_byte_width);
string_length = ACPI_MUL_2(acpi_gbl_integer_byte_width);
break;
}
@ -460,31 +433,33 @@ acpi_ex_convert_to_string (
* Create a new String
* Need enough space for one ASCII integer (plus null terminator)
*/
return_desc = acpi_ut_create_string_object ((acpi_size) string_length);
return_desc =
acpi_ut_create_string_object((acpi_size) string_length);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
new_buf = return_desc->buffer.pointer;
/* Convert integer to string */
string_length = acpi_ex_convert_to_ascii (obj_desc->integer.value, base,
new_buf, acpi_gbl_integer_byte_width);
string_length =
acpi_ex_convert_to_ascii(obj_desc->integer.value, base,
new_buf,
acpi_gbl_integer_byte_width);
/* Null terminate at the correct place */
return_desc->string.length = string_length;
new_buf [string_length] = 0;
new_buf[string_length] = 0;
break;
case ACPI_TYPE_BUFFER:
/* Setup string length, base, and separator */
switch (type) {
case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */
case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */
/*
* From ACPI: "If Data is a buffer, it is converted to a string of
* decimal values separated by commas."
@ -498,11 +473,9 @@ acpi_ex_convert_to_string (
for (i = 0; i < obj_desc->buffer.length; i++) {
if (obj_desc->buffer.pointer[i] >= 100) {
string_length += 4;
}
else if (obj_desc->buffer.pointer[i] >= 10) {
} else if (obj_desc->buffer.pointer[i] >= 10) {
string_length += 3;
}
else {
} else {
string_length += 2;
}
}
@ -518,7 +491,7 @@ acpi_ex_convert_to_string (
string_length = (obj_desc->buffer.length * 3);
break;
case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */
case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */
/*
* From ACPI: "If Data is a buffer, it is converted to a string of
* hexadecimal values separated by commas."
@ -527,7 +500,7 @@ acpi_ex_convert_to_string (
break;
default:
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/*
@ -535,15 +508,16 @@ acpi_ex_convert_to_string (
* (-1 because of extra separator included in string_length from above)
*/
string_length--;
if (string_length > ACPI_MAX_STRING_CONVERSION) /* ACPI limit */ {
return_ACPI_STATUS (AE_AML_STRING_LIMIT);
if (string_length > ACPI_MAX_STRING_CONVERSION) { /* ACPI limit */
return_ACPI_STATUS(AE_AML_STRING_LIMIT);
}
/* Create a new string object and string buffer */
return_desc = acpi_ut_create_string_object ((acpi_size) string_length);
return_desc =
acpi_ut_create_string_object((acpi_size) string_length);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
new_buf = return_desc->buffer.pointer;
@ -553,10 +527,11 @@ acpi_ex_convert_to_string (
* (separated by commas or spaces)
*/
for (i = 0; i < obj_desc->buffer.length; i++) {
new_buf += acpi_ex_convert_to_ascii (
(acpi_integer) obj_desc->buffer.pointer[i], base,
new_buf, 1);
*new_buf++ = separator; /* each separated by a comma or space */
new_buf += acpi_ex_convert_to_ascii((acpi_integer)
obj_desc->buffer.
pointer[i], base,
new_buf, 1);
*new_buf++ = separator; /* each separated by a comma or space */
}
/*
@ -568,14 +543,13 @@ acpi_ex_convert_to_string (
break;
default:
return_ACPI_STATUS (AE_TYPE);
return_ACPI_STATUS(AE_TYPE);
}
*result_desc = return_desc;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_convert_to_target_type
@ -592,17 +566,14 @@ acpi_ex_convert_to_string (
******************************************************************************/
acpi_status
acpi_ex_convert_to_target_type (
acpi_object_type destination_type,
union acpi_operand_object *source_desc,
union acpi_operand_object **result_desc,
struct acpi_walk_state *walk_state)
acpi_ex_convert_to_target_type(acpi_object_type destination_type,
union acpi_operand_object *source_desc,
union acpi_operand_object **result_desc,
struct acpi_walk_state *walk_state)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("ex_convert_to_target_type");
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ex_convert_to_target_type");
/* Default behavior */
@ -612,10 +583,10 @@ acpi_ex_convert_to_target_type (
* If required by the target,
* perform implicit conversion on the source before we store it.
*/
switch (GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args)) {
switch (GET_CURRENT_ARG_TYPE(walk_state->op_info->runtime_args)) {
case ARGI_SIMPLE_TARGET:
case ARGI_FIXED_TARGET:
case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */
case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */
switch (destination_type) {
case ACPI_TYPE_LOCAL_REGION_FIELD:
@ -627,17 +598,19 @@ acpi_ex_convert_to_target_type (
default:
/* No conversion allowed for these types */
if (destination_type != ACPI_GET_OBJECT_TYPE (source_desc)) {
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Explicit operator, will store (%s) over existing type (%s)\n",
acpi_ut_get_object_type_name (source_desc),
acpi_ut_get_type_name (destination_type)));
if (destination_type !=
ACPI_GET_OBJECT_TYPE(source_desc)) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Explicit operator, will store (%s) over existing type (%s)\n",
acpi_ut_get_object_type_name
(source_desc),
acpi_ut_get_type_name
(destination_type)));
status = AE_TYPE;
}
}
break;
case ARGI_TARGETREF:
switch (destination_type) {
@ -649,55 +622,55 @@ acpi_ex_convert_to_target_type (
* These types require an Integer operand. We can convert
* a Buffer or a String to an Integer if necessary.
*/
status = acpi_ex_convert_to_integer (source_desc, result_desc,
16);
status =
acpi_ex_convert_to_integer(source_desc, result_desc,
16);
break;
case ACPI_TYPE_STRING:
/*
* The operand must be a String. We can convert an
* Integer or Buffer if necessary
*/
status = acpi_ex_convert_to_string (source_desc, result_desc,
ACPI_IMPLICIT_CONVERT_HEX);
status =
acpi_ex_convert_to_string(source_desc, result_desc,
ACPI_IMPLICIT_CONVERT_HEX);
break;
case ACPI_TYPE_BUFFER:
/*
* The operand must be a Buffer. We can convert an
* Integer or String if necessary
*/
status = acpi_ex_convert_to_buffer (source_desc, result_desc);
status =
acpi_ex_convert_to_buffer(source_desc, result_desc);
break;
default:
ACPI_REPORT_ERROR (("Bad destination type during conversion: %X\n",
destination_type));
ACPI_REPORT_ERROR(("Bad destination type during conversion: %X\n", destination_type));
status = AE_AML_INTERNAL;
break;
}
break;
case ARGI_REFERENCE:
/*
* create_xxxx_field cases - we are storing the field object into the name
*/
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unknown Target type ID 0x%X Op %s dest_type %s\n",
GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args),
walk_state->op_info->name, acpi_ut_get_type_name (destination_type)));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unknown Target type ID 0x%X Op %s dest_type %s\n",
GET_CURRENT_ARG_TYPE(walk_state->op_info->
runtime_args),
walk_state->op_info->name,
acpi_ut_get_type_name(destination_type)));
ACPI_REPORT_ERROR (("Bad Target Type (ARGI): %X\n",
GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args)))
status = AE_AML_INTERNAL;
ACPI_REPORT_ERROR(("Bad Target Type (ARGI): %X\n",
GET_CURRENT_ARG_TYPE(walk_state->op_info->
runtime_args)))
status = AE_AML_INTERNAL;
}
/*
@ -710,7 +683,5 @@ acpi_ex_convert_to_target_type (
status = AE_OK;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -41,7 +41,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/amlcode.h>
@ -49,10 +48,8 @@
#include <acpi/acevents.h>
#include <acpi/actables.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("excreate")
ACPI_MODULE_NAME("excreate")
#ifndef ACPI_NO_METHOD_EXECUTION
/*******************************************************************************
@ -66,33 +63,30 @@
* DESCRIPTION: Create a new named alias
*
******************************************************************************/
acpi_status
acpi_ex_create_alias (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
{
struct acpi_namespace_node *target_node;
struct acpi_namespace_node *alias_node;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("ex_create_alias");
struct acpi_namespace_node *target_node;
struct acpi_namespace_node *alias_node;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ex_create_alias");
/* Get the source/alias operands (both namespace nodes) */
alias_node = (struct acpi_namespace_node *) walk_state->operands[0];
target_node = (struct acpi_namespace_node *) walk_state->operands[1];
alias_node = (struct acpi_namespace_node *)walk_state->operands[0];
target_node = (struct acpi_namespace_node *)walk_state->operands[1];
if ((target_node->type == ACPI_TYPE_LOCAL_ALIAS) ||
(target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
(target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
/*
* Dereference an existing alias so that we don't create a chain
* of aliases. With this code, we guarantee that an alias is
* always exactly one level of indirection away from the
* actual aliased name.
*/
target_node = ACPI_CAST_PTR (struct acpi_namespace_node, target_node->object);
target_node =
ACPI_CAST_PTR(struct acpi_namespace_node,
target_node->object);
}
/*
@ -115,7 +109,8 @@ acpi_ex_create_alias (
* types, the object can change dynamically via a Store.
*/
alias_node->type = ACPI_TYPE_LOCAL_ALIAS;
alias_node->object = ACPI_CAST_PTR (union acpi_operand_object, target_node);
alias_node->object =
ACPI_CAST_PTR(union acpi_operand_object, target_node);
break;
case ACPI_TYPE_METHOD:
@ -126,7 +121,8 @@ acpi_ex_create_alias (
* types, the object can change dynamically via a Store.
*/
alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
alias_node->object = ACPI_CAST_PTR (union acpi_operand_object, target_node);
alias_node->object =
ACPI_CAST_PTR(union acpi_operand_object, target_node);
break;
default:
@ -139,17 +135,18 @@ acpi_ex_create_alias (
* additional reference to prevent deletion out from under either the
* target node or the alias Node
*/
status = acpi_ns_attach_object (alias_node,
acpi_ns_get_attached_object (target_node), target_node->type);
status = acpi_ns_attach_object(alias_node,
acpi_ns_get_attached_object
(target_node),
target_node->type);
break;
}
/* Since both operands are Nodes, we don't need to delete them */
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_create_event
@ -162,18 +159,14 @@ acpi_ex_create_alias (
*
******************************************************************************/
acpi_status
acpi_ex_create_event (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state)
{
acpi_status status;
union acpi_operand_object *obj_desc;
acpi_status status;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_TRACE("ex_create_event");
ACPI_FUNCTION_TRACE ("ex_create_event");
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_EVENT);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_EVENT);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -183,27 +176,27 @@ acpi_ex_create_event (
* Create the actual OS semaphore, with zero initial units -- meaning
* that the event is created in an unsignalled state
*/
status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0,
&obj_desc->event.semaphore);
if (ACPI_FAILURE (status)) {
status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
&obj_desc->event.semaphore);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
/* Attach object to the Node */
status = acpi_ns_attach_object ((struct acpi_namespace_node *) walk_state->operands[0],
obj_desc, ACPI_TYPE_EVENT);
status =
acpi_ns_attach_object((struct acpi_namespace_node *)walk_state->
operands[0], obj_desc, ACPI_TYPE_EVENT);
cleanup:
cleanup:
/*
* Remove local reference to the object (on error, will cause deletion
* of both object and semaphore if present.)
*/
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_create_mutex
@ -218,20 +211,16 @@ cleanup:
*
******************************************************************************/
acpi_status
acpi_ex_create_mutex (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
{
acpi_status status = AE_OK;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_TRACE_PTR ("ex_create_mutex", ACPI_WALK_OPERANDS);
acpi_status status = AE_OK;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_TRACE_PTR("ex_create_mutex", ACPI_WALK_OPERANDS);
/* Create the new mutex object */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_MUTEX);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -242,30 +231,30 @@ acpi_ex_create_mutex (
* One unit max to make it a mutex, with one initial unit to allow
* the mutex to be acquired.
*/
status = acpi_os_create_semaphore (1, 1, &obj_desc->mutex.semaphore);
if (ACPI_FAILURE (status)) {
status = acpi_os_create_semaphore(1, 1, &obj_desc->mutex.semaphore);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
/* Init object and attach to NS node */
obj_desc->mutex.sync_level = (u8) walk_state->operands[1]->integer.value;
obj_desc->mutex.node = (struct acpi_namespace_node *) walk_state->operands[0];
obj_desc->mutex.sync_level =
(u8) walk_state->operands[1]->integer.value;
obj_desc->mutex.node =
(struct acpi_namespace_node *)walk_state->operands[0];
status = acpi_ns_attach_object (obj_desc->mutex.node,
obj_desc, ACPI_TYPE_MUTEX);
status = acpi_ns_attach_object(obj_desc->mutex.node,
obj_desc, ACPI_TYPE_MUTEX);
cleanup:
cleanup:
/*
* Remove local reference to the object (on error, will cause deletion
* of both object and semaphore if present.)
*/
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_create_region
@ -282,20 +271,16 @@ cleanup:
******************************************************************************/
acpi_status
acpi_ex_create_region (
u8 *aml_start,
u32 aml_length,
u8 region_space,
struct acpi_walk_state *walk_state)
acpi_ex_create_region(u8 * aml_start,
u32 aml_length,
u8 region_space, struct acpi_walk_state *walk_state)
{
acpi_status status;
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
union acpi_operand_object *region_obj2;
ACPI_FUNCTION_TRACE ("ex_create_region");
acpi_status status;
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
union acpi_operand_object *region_obj2;
ACPI_FUNCTION_TRACE("ex_create_region");
/* Get the Namespace Node */
@ -305,8 +290,8 @@ acpi_ex_create_region (
* If the region object is already attached to this node,
* just return
*/
if (acpi_ns_get_attached_object (node)) {
return_ACPI_STATUS (AE_OK);
if (acpi_ns_get_attached_object(node)) {
return_ACPI_STATUS(AE_OK);
}
/*
@ -314,17 +299,18 @@ acpi_ex_create_region (
* range
*/
if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) &&
(region_space < ACPI_USER_REGION_BEGIN)) {
ACPI_REPORT_ERROR (("Invalid address_space type %X\n", region_space));
return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
(region_space < ACPI_USER_REGION_BEGIN)) {
ACPI_REPORT_ERROR(("Invalid address_space type %X\n",
region_space));
return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
}
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
acpi_ut_get_region_name (region_space), region_space));
ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
acpi_ut_get_region_name(region_space), region_space));
/* Create the region descriptor */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_REGION);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -334,7 +320,7 @@ acpi_ex_create_region (
* Remember location in AML stream of address & length
* operands since they need to be evaluated at run time.
*/
region_obj2 = obj_desc->common.next_object;
region_obj2 = obj_desc->common.next_object;
region_obj2->extra.aml_start = aml_start;
region_obj2->extra.aml_length = aml_length;
@ -343,22 +329,20 @@ acpi_ex_create_region (
obj_desc->region.space_id = region_space;
obj_desc->region.address = 0;
obj_desc->region.length = 0;
obj_desc->region.node = node;
obj_desc->region.node = node;
/* Install the new region object in the parent Node */
status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION);
status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_REGION);
cleanup:
cleanup:
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_create_table_region
@ -371,20 +355,16 @@ cleanup:
*
******************************************************************************/
acpi_status
acpi_ex_create_table_region (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_create_table_region(struct acpi_walk_state *walk_state)
{
acpi_status status;
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
struct acpi_table_header *table;
union acpi_operand_object *region_obj2;
ACPI_FUNCTION_TRACE ("ex_create_table_region");
acpi_status status;
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
struct acpi_table_header *table;
union acpi_operand_object *region_obj2;
ACPI_FUNCTION_TRACE("ex_create_table_region");
/* Get the Node from the object stack */
@ -394,66 +374,64 @@ acpi_ex_create_table_region (
* If the region object is already attached to this node,
* just return
*/
if (acpi_ns_get_attached_object (node)) {
return_ACPI_STATUS (AE_OK);
if (acpi_ns_get_attached_object(node)) {
return_ACPI_STATUS(AE_OK);
}
/* Find the ACPI table */
status = acpi_tb_find_table (operand[1]->string.pointer,
operand[2]->string.pointer,
operand[3]->string.pointer, &table);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_tb_find_table(operand[1]->string.pointer,
operand[2]->string.pointer,
operand[3]->string.pointer, &table);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Create the region descriptor */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_REGION);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION);
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
region_obj2 = obj_desc->common.next_object;
region_obj2 = obj_desc->common.next_object;
region_obj2->extra.region_context = NULL;
/* Init the region from the operands */
obj_desc->region.space_id = REGION_DATA_TABLE;
obj_desc->region.address = (acpi_physical_address) ACPI_TO_INTEGER (table);
obj_desc->region.address =
(acpi_physical_address) ACPI_TO_INTEGER(table);
obj_desc->region.length = table->length;
obj_desc->region.node = node;
obj_desc->region.flags = AOPOBJ_DATA_VALID;
obj_desc->region.node = node;
obj_desc->region.flags = AOPOBJ_DATA_VALID;
/* Install the new region object in the parent Node */
status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION);
if (ACPI_FAILURE (status)) {
status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_REGION);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
status = acpi_ev_initialize_region (obj_desc, FALSE);
if (ACPI_FAILURE (status)) {
status = acpi_ev_initialize_region(obj_desc, FALSE);
if (ACPI_FAILURE(status)) {
if (status == AE_NOT_EXIST) {
status = AE_OK;
}
else {
} else {
goto cleanup;
}
}
obj_desc->region.flags |= AOPOBJ_SETUP_COMPLETE;
cleanup:
cleanup:
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_create_processor
@ -468,43 +446,39 @@ cleanup:
*
******************************************************************************/
acpi_status
acpi_ex_create_processor (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE_PTR ("ex_create_processor", walk_state);
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE_PTR("ex_create_processor", walk_state);
/* Create the processor object */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PROCESSOR);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PROCESSOR);
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Initialize the processor object from the operands */
obj_desc->processor.proc_id = (u8) operand[1]->integer.value;
obj_desc->processor.address = (acpi_io_address) operand[2]->integer.value;
obj_desc->processor.length = (u8) operand[3]->integer.value;
obj_desc->processor.proc_id = (u8) operand[1]->integer.value;
obj_desc->processor.address =
(acpi_io_address) operand[2]->integer.value;
obj_desc->processor.length = (u8) operand[3]->integer.value;
/* Install the processor object in the parent Node */
status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0],
obj_desc, ACPI_TYPE_PROCESSOR);
status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0],
obj_desc, ACPI_TYPE_PROCESSOR);
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_create_power_resource
@ -519,43 +493,39 @@ acpi_ex_create_processor (
*
******************************************************************************/
acpi_status
acpi_ex_create_power_resource (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
acpi_status status;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_TRACE_PTR ("ex_create_power_resource", walk_state);
union acpi_operand_object **operand = &walk_state->operands[0];
acpi_status status;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_TRACE_PTR("ex_create_power_resource", walk_state);
/* Create the power resource object */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_POWER);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_POWER);
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Initialize the power object from the operands */
obj_desc->power_resource.system_level = (u8) operand[1]->integer.value;
obj_desc->power_resource.resource_order = (u16) operand[2]->integer.value;
obj_desc->power_resource.resource_order =
(u16) operand[2]->integer.value;
/* Install the power resource object in the parent Node */
status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0],
obj_desc, ACPI_TYPE_POWER);
status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0],
obj_desc, ACPI_TYPE_POWER);
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
#endif
/*******************************************************************************
*
* FUNCTION: acpi_ex_create_method
@ -571,25 +541,21 @@ acpi_ex_create_power_resource (
******************************************************************************/
acpi_status
acpi_ex_create_method (
u8 *aml_start,
u32 aml_length,
struct acpi_walk_state *walk_state)
acpi_ex_create_method(u8 * aml_start,
u32 aml_length, struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *obj_desc;
acpi_status status;
u8 method_flags;
ACPI_FUNCTION_TRACE_PTR ("ex_create_method", walk_state);
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *obj_desc;
acpi_status status;
u8 method_flags;
ACPI_FUNCTION_TRACE_PTR("ex_create_method", walk_state);
/* Create a new method object */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_METHOD);
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Save the method's AML pointer and length */
@ -603,8 +569,10 @@ acpi_ex_create_method (
*/
method_flags = (u8) operand[1]->integer.value;
obj_desc->method.method_flags = (u8) (method_flags & ~AML_METHOD_ARG_COUNT);
obj_desc->method.param_count = (u8) (method_flags & AML_METHOD_ARG_COUNT);
obj_desc->method.method_flags =
(u8) (method_flags & ~AML_METHOD_ARG_COUNT);
obj_desc->method.param_count =
(u8) (method_flags & AML_METHOD_ARG_COUNT);
/*
* Get the concurrency count. If required, a semaphore will be
@ -613,32 +581,28 @@ acpi_ex_create_method (
if (acpi_gbl_all_methods_serialized) {
obj_desc->method.concurrency = 1;
obj_desc->method.method_flags |= AML_METHOD_SERIALIZED;
}
else if (method_flags & AML_METHOD_SERIALIZED) {
} else if (method_flags & AML_METHOD_SERIALIZED) {
/*
* ACPI 1.0: Concurrency = 1
* ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1)
*/
obj_desc->method.concurrency = (u8)
(((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1);
}
else {
(((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1);
} else {
obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY;
}
/* Attach the new object to the method Node */
status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0],
obj_desc, ACPI_TYPE_METHOD);
status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0],
obj_desc, ACPI_TYPE_METHOD);
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
acpi_ut_remove_reference(obj_desc);
/* Remove a reference to the operand */
acpi_ut_remove_reference (operand[1]);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(operand[1]);
return_ACPI_STATUS(status);
}

File diff suppressed because it is too large Load Diff

View File

@ -41,15 +41,12 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acdispat.h>
#include <acpi/acinterp.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exfield")
ACPI_MODULE_NAME("exfield")
/*******************************************************************************
*
@ -65,64 +62,70 @@
* Buffer, depending on the size of the field.
*
******************************************************************************/
acpi_status
acpi_ex_read_data_from_field (
struct acpi_walk_state *walk_state,
union acpi_operand_object *obj_desc,
union acpi_operand_object **ret_buffer_desc)
acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
union acpi_operand_object *obj_desc,
union acpi_operand_object **ret_buffer_desc)
{
acpi_status status;
union acpi_operand_object *buffer_desc;
acpi_size length;
void *buffer;
u8 locked;
ACPI_FUNCTION_TRACE_PTR ("ex_read_data_from_field", obj_desc);
acpi_status status;
union acpi_operand_object *buffer_desc;
acpi_size length;
void *buffer;
u8 locked;
ACPI_FUNCTION_TRACE_PTR("ex_read_data_from_field", obj_desc);
/* Parameter validation */
if (!obj_desc) {
return_ACPI_STATUS (AE_AML_NO_OPERAND);
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
if (!ret_buffer_desc) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
/*
* If the buffer_field arguments have not been previously evaluated,
* evaluate them now and save the results.
*/
if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
status = acpi_ds_get_buffer_field_arguments (obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_get_buffer_field_arguments(obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
}
else if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) &&
(obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) {
} else
if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD)
&& (obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_SMBUS)) {
/*
* This is an SMBus read. We must create a buffer to hold the data
* and directly access the region handler.
*/
buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE);
buffer_desc =
acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
if (!buffer_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Lock entire transaction if requested */
locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
locked =
acpi_ex_acquire_global_lock(obj_desc->common_field.
field_flags);
/*
* Perform the read.
* Note: Smbus protocol value is passed in upper 16-bits of Function
*/
status = acpi_ex_access_region (obj_desc, 0,
ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer),
ACPI_READ | (obj_desc->field.attribute << 16));
acpi_ex_release_global_lock (locked);
status = acpi_ex_access_region(obj_desc, 0,
ACPI_CAST_PTR(acpi_integer,
buffer_desc->
buffer.pointer),
ACPI_READ | (obj_desc->field.
attribute << 16));
acpi_ex_release_global_lock(locked);
goto exit;
}
@ -136,22 +139,22 @@ acpi_ex_read_data_from_field (
*
* Note: Field.length is in bits.
*/
length = (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->field.bit_length);
length =
(acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length);
if (length > acpi_gbl_integer_byte_width) {
/* Field is too large for an Integer, create a Buffer instead */
buffer_desc = acpi_ut_create_buffer_object (length);
buffer_desc = acpi_ut_create_buffer_object(length);
if (!buffer_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
buffer = buffer_desc->buffer.pointer;
}
else {
} else {
/* Field will fit within an Integer (normal case) */
buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!buffer_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
length = acpi_gbl_integer_byte_width;
@ -159,37 +162,36 @@ acpi_ex_read_data_from_field (
buffer = &buffer_desc->integer.value;
}
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"field_read [TO]: Obj %p, Type %X, Buf %p, byte_len %X\n",
obj_desc, ACPI_GET_OBJECT_TYPE (obj_desc), buffer, (u32) length));
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"field_read [FROM]: bit_len %X, bit_off %X, byte_off %X\n",
obj_desc->common_field.bit_length,
obj_desc->common_field.start_field_bit_offset,
obj_desc->common_field.base_byte_offset));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"field_read [TO]: Obj %p, Type %X, Buf %p, byte_len %X\n",
obj_desc, ACPI_GET_OBJECT_TYPE(obj_desc), buffer,
(u32) length));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"field_read [FROM]: bit_len %X, bit_off %X, byte_off %X\n",
obj_desc->common_field.bit_length,
obj_desc->common_field.start_field_bit_offset,
obj_desc->common_field.base_byte_offset));
/* Lock entire transaction if requested */
locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
locked =
acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
/* Read from the field */
status = acpi_ex_extract_from_field (obj_desc, buffer, (u32) length);
acpi_ex_release_global_lock (locked);
status = acpi_ex_extract_from_field(obj_desc, buffer, (u32) length);
acpi_ex_release_global_lock(locked);
exit:
if (ACPI_FAILURE (status)) {
acpi_ut_remove_reference (buffer_desc);
}
else if (ret_buffer_desc) {
exit:
if (ACPI_FAILURE(status)) {
acpi_ut_remove_reference(buffer_desc);
} else {
*ret_buffer_desc = buffer_desc;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_write_data_to_field
@ -205,97 +207,96 @@ exit:
******************************************************************************/
acpi_status
acpi_ex_write_data_to_field (
union acpi_operand_object *source_desc,
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc)
acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc)
{
acpi_status status;
u32 length;
u32 required_length;
void *buffer;
void *new_buffer;
u8 locked;
union acpi_operand_object *buffer_desc;
ACPI_FUNCTION_TRACE_PTR ("ex_write_data_to_field", obj_desc);
acpi_status status;
u32 length;
u32 required_length;
void *buffer;
void *new_buffer;
u8 locked;
union acpi_operand_object *buffer_desc;
ACPI_FUNCTION_TRACE_PTR("ex_write_data_to_field", obj_desc);
/* Parameter validation */
if (!source_desc || !obj_desc) {
return_ACPI_STATUS (AE_AML_NO_OPERAND);
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
/*
* If the buffer_field arguments have not been previously evaluated,
* evaluate them now and save the results.
*/
if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
status = acpi_ds_get_buffer_field_arguments (obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_get_buffer_field_arguments(obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
}
else if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) &&
(obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS)) {
} else
if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD)
&& (obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_SMBUS)) {
/*
* This is an SMBus write. We will bypass the entire field mechanism
* and handoff the buffer directly to the handler.
*
* Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE).
*/
if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) {
ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n",
acpi_ut_get_object_type_name (source_desc)));
if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) {
ACPI_REPORT_ERROR(("SMBus write requires Buffer, found type %s\n", acpi_ut_get_object_type_name(source_desc)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) {
ACPI_REPORT_ERROR ((
"SMBus write requires Buffer of length %X, found length %X\n",
ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length));
ACPI_REPORT_ERROR(("SMBus write requires Buffer of length %X, found length %X\n", ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length));
return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
}
buffer_desc = acpi_ut_create_buffer_object (ACPI_SMBUS_BUFFER_SIZE);
buffer_desc =
acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
if (!buffer_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
buffer = buffer_desc->buffer.pointer;
ACPI_MEMCPY (buffer, source_desc->buffer.pointer,
ACPI_SMBUS_BUFFER_SIZE);
ACPI_MEMCPY(buffer, source_desc->buffer.pointer,
ACPI_SMBUS_BUFFER_SIZE);
/* Lock entire transaction if requested */
locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
locked =
acpi_ex_acquire_global_lock(obj_desc->common_field.
field_flags);
/*
* Perform the write (returns status and perhaps data in the
* same buffer)
* Note: SMBus protocol type is passed in upper 16-bits of Function.
*/
status = acpi_ex_access_region (obj_desc, 0,
(acpi_integer *) buffer,
ACPI_WRITE | (obj_desc->field.attribute << 16));
acpi_ex_release_global_lock (locked);
status = acpi_ex_access_region(obj_desc, 0,
(acpi_integer *) buffer,
ACPI_WRITE | (obj_desc->field.
attribute << 16));
acpi_ex_release_global_lock(locked);
*result_desc = buffer_desc;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/* Get a pointer to the data to be written */
switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
case ACPI_TYPE_INTEGER:
buffer = &source_desc->integer.value;
length = sizeof (source_desc->integer.value);
length = sizeof(source_desc->integer.value);
break;
case ACPI_TYPE_BUFFER:
@ -309,7 +310,7 @@ acpi_ex_write_data_to_field (
break;
default:
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/*
@ -319,15 +320,15 @@ acpi_ex_write_data_to_field (
* the ACPI specification.
*/
new_buffer = NULL;
required_length = ACPI_ROUND_BITS_UP_TO_BYTES (
obj_desc->common_field.bit_length);
required_length =
ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length);
if (length < required_length) {
/* We need to create a new buffer */
new_buffer = ACPI_MEM_CALLOCATE (required_length);
new_buffer = ACPI_MEM_CALLOCATE(required_length);
if (!new_buffer) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/*
@ -335,40 +336,42 @@ acpi_ex_write_data_to_field (
* at Byte zero. All unused (upper) bytes of the
* buffer will be 0.
*/
ACPI_MEMCPY ((char *) new_buffer, (char *) buffer, length);
ACPI_MEMCPY((char *)new_buffer, (char *)buffer, length);
buffer = new_buffer;
length = required_length;
}
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n",
source_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (source_desc)),
ACPI_GET_OBJECT_TYPE (source_desc), buffer, length));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n",
source_desc,
acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE
(source_desc)),
ACPI_GET_OBJECT_TYPE(source_desc), buffer, length));
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n",
obj_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)),
ACPI_GET_OBJECT_TYPE (obj_desc),
obj_desc->common_field.bit_length,
obj_desc->common_field.start_field_bit_offset,
obj_desc->common_field.base_byte_offset));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n",
obj_desc,
acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)),
ACPI_GET_OBJECT_TYPE(obj_desc),
obj_desc->common_field.bit_length,
obj_desc->common_field.start_field_bit_offset,
obj_desc->common_field.base_byte_offset));
/* Lock entire transaction if requested */
locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
locked =
acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
/* Write to the field */
status = acpi_ex_insert_into_field (obj_desc, buffer, length);
acpi_ex_release_global_lock (locked);
status = acpi_ex_insert_into_field(obj_desc, buffer, length);
acpi_ex_release_global_lock(locked);
/* Free temporary buffer if we used one */
if (new_buffer) {
ACPI_MEM_FREE (new_buffer);
ACPI_MEM_FREE(new_buffer);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

File diff suppressed because it is too large Load Diff

View File

@ -42,15 +42,12 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/amlcode.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exmisc")
ACPI_MODULE_NAME("exmisc")
/*******************************************************************************
*
@ -66,27 +63,23 @@
* Common code for the ref_of_op and the cond_ref_of_op.
*
******************************************************************************/
acpi_status
acpi_ex_get_object_reference (
union acpi_operand_object *obj_desc,
union acpi_operand_object **return_desc,
struct acpi_walk_state *walk_state)
acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
union acpi_operand_object **return_desc,
struct acpi_walk_state *walk_state)
{
union acpi_operand_object *reference_obj;
union acpi_operand_object *referenced_obj;
ACPI_FUNCTION_TRACE_PTR ("ex_get_object_reference", obj_desc);
union acpi_operand_object *reference_obj;
union acpi_operand_object *referenced_obj;
ACPI_FUNCTION_TRACE_PTR("ex_get_object_reference", obj_desc);
*return_desc = NULL;
switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
case ACPI_DESC_TYPE_OPERAND:
if (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) {
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) {
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/*
@ -104,13 +97,11 @@ acpi_ex_get_object_reference (
default:
ACPI_REPORT_ERROR (("Unknown Reference opcode in get_reference %X\n",
obj_desc->reference.opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
ACPI_REPORT_ERROR(("Unknown Reference opcode in get_reference %X\n", obj_desc->reference.opcode));
return_ACPI_STATUS(AE_AML_INTERNAL);
}
break;
case ACPI_DESC_TYPE_NAMED:
/*
@ -119,34 +110,32 @@ acpi_ex_get_object_reference (
referenced_obj = obj_desc;
break;
default:
ACPI_REPORT_ERROR (("Invalid descriptor type in get_reference: %X\n",
ACPI_GET_DESCRIPTOR_TYPE (obj_desc)));
return_ACPI_STATUS (AE_TYPE);
ACPI_REPORT_ERROR(("Invalid descriptor type in get_reference: %X\n", ACPI_GET_DESCRIPTOR_TYPE(obj_desc)));
return_ACPI_STATUS(AE_TYPE);
}
/* Create a new reference object */
reference_obj = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE);
reference_obj =
acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
if (!reference_obj) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
reference_obj->reference.opcode = AML_REF_OF_OP;
reference_obj->reference.object = referenced_obj;
*return_desc = reference_obj;
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Object %p Type [%s], returning Reference %p\n",
obj_desc, acpi_ut_get_object_type_name (obj_desc), *return_desc));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Object %p Type [%s], returning Reference %p\n",
obj_desc, acpi_ut_get_object_type_name(obj_desc),
*return_desc));
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_concat_template
@ -163,63 +152,58 @@ acpi_ex_get_object_reference (
******************************************************************************/
acpi_status
acpi_ex_concat_template (
union acpi_operand_object *operand0,
union acpi_operand_object *operand1,
union acpi_operand_object **actual_return_desc,
struct acpi_walk_state *walk_state)
acpi_ex_concat_template(union acpi_operand_object *operand0,
union acpi_operand_object *operand1,
union acpi_operand_object **actual_return_desc,
struct acpi_walk_state *walk_state)
{
union acpi_operand_object *return_desc;
u8 *new_buf;
u8 *end_tag1;
u8 *end_tag2;
acpi_size length1;
acpi_size length2;
ACPI_FUNCTION_TRACE ("ex_concat_template");
union acpi_operand_object *return_desc;
u8 *new_buf;
u8 *end_tag1;
u8 *end_tag2;
acpi_size length1;
acpi_size length2;
ACPI_FUNCTION_TRACE("ex_concat_template");
/* Find the end_tags in each resource template */
end_tag1 = acpi_ut_get_resource_end_tag (operand0);
end_tag2 = acpi_ut_get_resource_end_tag (operand1);
end_tag1 = acpi_ut_get_resource_end_tag(operand0);
end_tag2 = acpi_ut_get_resource_end_tag(operand1);
if (!end_tag1 || !end_tag2) {
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/* Compute the length of each part */
length1 = ACPI_PTR_DIFF (end_tag1, operand0->buffer.pointer);
length2 = ACPI_PTR_DIFF (end_tag2, operand1->buffer.pointer) +
2; /* Size of END_TAG */
length1 = ACPI_PTR_DIFF(end_tag1, operand0->buffer.pointer);
length2 = ACPI_PTR_DIFF(end_tag2, operand1->buffer.pointer) + 2; /* Size of END_TAG */
/* Create a new buffer object for the result */
return_desc = acpi_ut_create_buffer_object (length1 + length2);
return_desc = acpi_ut_create_buffer_object(length1 + length2);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Copy the templates to the new descriptor */
new_buf = return_desc->buffer.pointer;
ACPI_MEMCPY (new_buf, operand0->buffer.pointer, length1);
ACPI_MEMCPY (new_buf + length1, operand1->buffer.pointer, length2);
ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length1);
ACPI_MEMCPY(new_buf + length1, operand1->buffer.pointer, length2);
/* Compute the new checksum */
new_buf[return_desc->buffer.length - 1] =
acpi_ut_generate_checksum (return_desc->buffer.pointer,
(return_desc->buffer.length - 1));
acpi_ut_generate_checksum(return_desc->buffer.pointer,
(return_desc->buffer.length - 1));
/* Return the completed template descriptor */
*actual_return_desc = return_desc;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_do_concatenate
@ -236,21 +220,18 @@ acpi_ex_concat_template (
******************************************************************************/
acpi_status
acpi_ex_do_concatenate (
union acpi_operand_object *operand0,
union acpi_operand_object *operand1,
union acpi_operand_object **actual_return_desc,
struct acpi_walk_state *walk_state)
acpi_ex_do_concatenate(union acpi_operand_object *operand0,
union acpi_operand_object *operand1,
union acpi_operand_object **actual_return_desc,
struct acpi_walk_state *walk_state)
{
union acpi_operand_object *local_operand1 = operand1;
union acpi_operand_object *return_desc;
char *new_buf;
acpi_status status;
acpi_size new_length;
ACPI_FUNCTION_TRACE ("ex_do_concatenate");
union acpi_operand_object *local_operand1 = operand1;
union acpi_operand_object *return_desc;
char *new_buf;
acpi_status status;
acpi_size new_length;
ACPI_FUNCTION_TRACE("ex_do_concatenate");
/*
* Convert the second operand if necessary. The first operand
@ -259,27 +240,28 @@ acpi_ex_do_concatenate (
* guaranteed to be either Integer/String/Buffer by the operand
* resolution mechanism.
*/
switch (ACPI_GET_OBJECT_TYPE (operand0)) {
switch (ACPI_GET_OBJECT_TYPE(operand0)) {
case ACPI_TYPE_INTEGER:
status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16);
status =
acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
break;
case ACPI_TYPE_STRING:
status = acpi_ex_convert_to_string (operand1, &local_operand1,
ACPI_IMPLICIT_CONVERT_HEX);
status = acpi_ex_convert_to_string(operand1, &local_operand1,
ACPI_IMPLICIT_CONVERT_HEX);
break;
case ACPI_TYPE_BUFFER:
status = acpi_ex_convert_to_buffer (operand1, &local_operand1);
status = acpi_ex_convert_to_buffer(operand1, &local_operand1);
break;
default:
ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n",
ACPI_GET_OBJECT_TYPE (operand0)));
ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n",
ACPI_GET_OBJECT_TYPE(operand0)));
status = AE_AML_INTERNAL;
}
if (ACPI_FAILURE (status)) {
if (ACPI_FAILURE(status)) {
goto cleanup;
}
@ -296,32 +278,33 @@ acpi_ex_do_concatenate (
* 2) Two Strings concatenated to produce a new String
* 3) Two Buffers concatenated to produce a new Buffer
*/
switch (ACPI_GET_OBJECT_TYPE (operand0)) {
switch (ACPI_GET_OBJECT_TYPE(operand0)) {
case ACPI_TYPE_INTEGER:
/* Result of two Integers is a Buffer */
/* Need enough buffer space for two integers */
return_desc = acpi_ut_create_buffer_object (
ACPI_MUL_2 (acpi_gbl_integer_byte_width));
return_desc = acpi_ut_create_buffer_object((acpi_size)
ACPI_MUL_2
(acpi_gbl_integer_byte_width));
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
}
new_buf = (char *) return_desc->buffer.pointer;
new_buf = (char *)return_desc->buffer.pointer;
/* Copy the first integer, LSB first */
ACPI_MEMCPY (new_buf,
&operand0->integer.value,
acpi_gbl_integer_byte_width);
ACPI_MEMCPY(new_buf,
&operand0->integer.value,
acpi_gbl_integer_byte_width);
/* Copy the second integer (LSB first) after the first */
ACPI_MEMCPY (new_buf + acpi_gbl_integer_byte_width,
&local_operand1->integer.value,
acpi_gbl_integer_byte_width);
ACPI_MEMCPY(new_buf + acpi_gbl_integer_byte_width,
&local_operand1->integer.value,
acpi_gbl_integer_byte_width);
break;
case ACPI_TYPE_STRING:
@ -329,13 +312,13 @@ acpi_ex_do_concatenate (
/* Result of two Strings is a String */
new_length = (acpi_size) operand0->string.length +
(acpi_size) local_operand1->string.length;
(acpi_size) local_operand1->string.length;
if (new_length > ACPI_MAX_STRING_CONVERSION) {
status = AE_AML_STRING_LIMIT;
goto cleanup;
}
return_desc = acpi_ut_create_string_object (new_length);
return_desc = acpi_ut_create_string_object(new_length);
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -345,56 +328,56 @@ acpi_ex_do_concatenate (
/* Concatenate the strings */
ACPI_STRCPY (new_buf,
operand0->string.pointer);
ACPI_STRCPY (new_buf + operand0->string.length,
local_operand1->string.pointer);
ACPI_STRCPY(new_buf, operand0->string.pointer);
ACPI_STRCPY(new_buf + operand0->string.length,
local_operand1->string.pointer);
break;
case ACPI_TYPE_BUFFER:
/* Result of two Buffers is a Buffer */
return_desc = acpi_ut_create_buffer_object (
(acpi_size) operand0->buffer.length +
(acpi_size) local_operand1->buffer.length);
return_desc = acpi_ut_create_buffer_object((acpi_size)
operand0->buffer.
length +
(acpi_size)
local_operand1->
buffer.length);
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
}
new_buf = (char *) return_desc->buffer.pointer;
new_buf = (char *)return_desc->buffer.pointer;
/* Concatenate the buffers */
ACPI_MEMCPY (new_buf,
operand0->buffer.pointer,
operand0->buffer.length);
ACPI_MEMCPY (new_buf + operand0->buffer.length,
local_operand1->buffer.pointer,
local_operand1->buffer.length);
ACPI_MEMCPY(new_buf,
operand0->buffer.pointer, operand0->buffer.length);
ACPI_MEMCPY(new_buf + operand0->buffer.length,
local_operand1->buffer.pointer,
local_operand1->buffer.length);
break;
default:
/* Invalid object type, should not happen here */
ACPI_REPORT_ERROR (("Concatenate - Invalid object type: %X\n",
ACPI_GET_OBJECT_TYPE (operand0)));
status =AE_AML_INTERNAL;
ACPI_REPORT_ERROR(("Concatenate - Invalid object type: %X\n",
ACPI_GET_OBJECT_TYPE(operand0)));
status = AE_AML_INTERNAL;
goto cleanup;
}
*actual_return_desc = return_desc;
cleanup:
cleanup:
if (local_operand1 != operand1) {
acpi_ut_remove_reference (local_operand1);
acpi_ut_remove_reference(local_operand1);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_do_math_op
@ -412,62 +395,49 @@ cleanup:
******************************************************************************/
acpi_integer
acpi_ex_do_math_op (
u16 opcode,
acpi_integer integer0,
acpi_integer integer1)
acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1)
{
ACPI_FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY();
switch (opcode) {
case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */
case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */
return (integer0 + integer1);
case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
return (integer0 & integer1);
case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
return (~(integer0 & integer1));
case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
return (integer0 | integer1);
case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
return (~(integer0 | integer1));
case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
return (integer0 ^ integer1);
case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
return (integer0 * integer1);
case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result)*/
case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result) */
return (integer0 << integer1);
case AML_SHIFT_RIGHT_OP: /* shift_right (Operand, shift_count, Result) */
case AML_SHIFT_RIGHT_OP: /* shift_right (Operand, shift_count, Result) */
return (integer0 >> integer1);
case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
return (integer0 - integer1);
@ -477,7 +447,6 @@ acpi_ex_do_math_op (
}
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_do_logical_numeric_op
@ -499,28 +468,24 @@ acpi_ex_do_math_op (
******************************************************************************/
acpi_status
acpi_ex_do_logical_numeric_op (
u16 opcode,
acpi_integer integer0,
acpi_integer integer1,
u8 *logical_result)
acpi_ex_do_logical_numeric_op(u16 opcode,
acpi_integer integer0,
acpi_integer integer1, u8 * logical_result)
{
acpi_status status = AE_OK;
u8 local_result = FALSE;
ACPI_FUNCTION_TRACE ("ex_do_logical_numeric_op");
acpi_status status = AE_OK;
u8 local_result = FALSE;
ACPI_FUNCTION_TRACE("ex_do_logical_numeric_op");
switch (opcode) {
case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
if (integer0 && integer1) {
local_result = TRUE;
}
break;
case AML_LOR_OP: /* LOr (Integer0, Integer1) */
case AML_LOR_OP: /* LOr (Integer0, Integer1) */
if (integer0 || integer1) {
local_result = TRUE;
@ -535,10 +500,9 @@ acpi_ex_do_logical_numeric_op (
/* Return the logical result and status */
*logical_result = local_result;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_do_logical_op
@ -566,24 +530,20 @@ acpi_ex_do_logical_numeric_op (
******************************************************************************/
acpi_status
acpi_ex_do_logical_op (
u16 opcode,
union acpi_operand_object *operand0,
union acpi_operand_object *operand1,
u8 *logical_result)
acpi_ex_do_logical_op(u16 opcode,
union acpi_operand_object *operand0,
union acpi_operand_object *operand1, u8 * logical_result)
{
union acpi_operand_object *local_operand1 = operand1;
acpi_integer integer0;
acpi_integer integer1;
u32 length0;
u32 length1;
acpi_status status = AE_OK;
u8 local_result = FALSE;
int compare;
ACPI_FUNCTION_TRACE ("ex_do_logical_op");
union acpi_operand_object *local_operand1 = operand1;
acpi_integer integer0;
acpi_integer integer1;
u32 length0;
u32 length1;
acpi_status status = AE_OK;
u8 local_result = FALSE;
int compare;
ACPI_FUNCTION_TRACE("ex_do_logical_op");
/*
* Convert the second operand if necessary. The first operand
@ -592,18 +552,19 @@ acpi_ex_do_logical_op (
* guaranteed to be either Integer/String/Buffer by the operand
* resolution mechanism.
*/
switch (ACPI_GET_OBJECT_TYPE (operand0)) {
switch (ACPI_GET_OBJECT_TYPE(operand0)) {
case ACPI_TYPE_INTEGER:
status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16);
status =
acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
break;
case ACPI_TYPE_STRING:
status = acpi_ex_convert_to_string (operand1, &local_operand1,
ACPI_IMPLICIT_CONVERT_HEX);
status = acpi_ex_convert_to_string(operand1, &local_operand1,
ACPI_IMPLICIT_CONVERT_HEX);
break;
case ACPI_TYPE_BUFFER:
status = acpi_ex_convert_to_buffer (operand1, &local_operand1);
status = acpi_ex_convert_to_buffer(operand1, &local_operand1);
break;
default:
@ -611,14 +572,14 @@ acpi_ex_do_logical_op (
break;
}
if (ACPI_FAILURE (status)) {
if (ACPI_FAILURE(status)) {
goto cleanup;
}
/*
* Two cases: 1) Both Integers, 2) Both Strings or Buffers
*/
if (ACPI_GET_OBJECT_TYPE (operand0) == ACPI_TYPE_INTEGER) {
if (ACPI_GET_OBJECT_TYPE(operand0) == ACPI_TYPE_INTEGER) {
/*
* 1) Both operands are of type integer
* Note: local_operand1 may have changed above
@ -627,21 +588,21 @@ acpi_ex_do_logical_op (
integer1 = local_operand1->integer.value;
switch (opcode) {
case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
if (integer0 == integer1) {
local_result = TRUE;
}
break;
case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
if (integer0 > integer1) {
local_result = TRUE;
}
break;
case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
if (integer0 < integer1) {
local_result = TRUE;
@ -652,8 +613,7 @@ acpi_ex_do_logical_op (
status = AE_AML_INTERNAL;
break;
}
}
else {
} else {
/*
* 2) Both operands are Strings or both are Buffers
* Note: Code below takes advantage of common Buffer/String
@ -665,31 +625,31 @@ acpi_ex_do_logical_op (
/* Lexicographic compare: compare the data bytes */
compare = ACPI_MEMCMP ((const char * ) operand0->buffer.pointer,
(const char * ) local_operand1->buffer.pointer,
(length0 > length1) ? length1 : length0);
compare = ACPI_MEMCMP((const char *)operand0->buffer.pointer,
(const char *)local_operand1->buffer.
pointer,
(length0 > length1) ? length1 : length0);
switch (opcode) {
case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
/* Length and all bytes must be equal */
if ((length0 == length1) &&
(compare == 0)) {
if ((length0 == length1) && (compare == 0)) {
/* Length and all bytes match ==> TRUE */
local_result = TRUE;
}
break;
case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
if (compare > 0) {
local_result = TRUE;
goto cleanup; /* TRUE */
goto cleanup; /* TRUE */
}
if (compare < 0) {
goto cleanup; /* FALSE */
goto cleanup; /* FALSE */
}
/* Bytes match (to shortest length), compare lengths */
@ -699,14 +659,14 @@ acpi_ex_do_logical_op (
}
break;
case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
if (compare > 0) {
goto cleanup; /* FALSE */
goto cleanup; /* FALSE */
}
if (compare < 0) {
local_result = TRUE;
goto cleanup; /* TRUE */
goto cleanup; /* TRUE */
}
/* Bytes match (to shortest length), compare lengths */
@ -722,18 +682,16 @@ acpi_ex_do_logical_op (
}
}
cleanup:
cleanup:
/* New object was created if implicit conversion performed - delete */
if (local_operand1 != operand1) {
acpi_ut_remove_reference (local_operand1);
acpi_ut_remove_reference(local_operand1);
}
/* Return the logical result and status */
*logical_result = local_result;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -42,20 +42,16 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exmutex")
ACPI_MODULE_NAME("exmutex")
/* Local prototypes */
static void
acpi_ex_link_mutex (
union acpi_operand_object *obj_desc,
struct acpi_thread_state *thread);
acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
struct acpi_thread_state *thread);
/*******************************************************************************
*
@ -69,12 +65,9 @@ acpi_ex_link_mutex (
*
******************************************************************************/
void
acpi_ex_unlink_mutex (
union acpi_operand_object *obj_desc)
void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc)
{
struct acpi_thread_state *thread = obj_desc->mutex.owner_thread;
struct acpi_thread_state *thread = obj_desc->mutex.owner_thread;
if (!thread) {
return;
@ -88,13 +81,11 @@ acpi_ex_unlink_mutex (
if (obj_desc->mutex.prev) {
(obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next;
}
else {
} else {
thread->acquired_mutex_list = obj_desc->mutex.next;
}
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_link_mutex
@ -109,12 +100,10 @@ acpi_ex_unlink_mutex (
******************************************************************************/
static void
acpi_ex_link_mutex (
union acpi_operand_object *obj_desc,
struct acpi_thread_state *thread)
acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
struct acpi_thread_state *thread)
{
union acpi_operand_object *list_head;
union acpi_operand_object *list_head;
list_head = thread->acquired_mutex_list;
@ -134,7 +123,6 @@ acpi_ex_link_mutex (
thread->acquired_mutex_list = obj_desc;
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_acquire_mutex
@ -150,27 +138,23 @@ acpi_ex_link_mutex (
******************************************************************************/
acpi_status
acpi_ex_acquire_mutex (
union acpi_operand_object *time_desc,
union acpi_operand_object *obj_desc,
struct acpi_walk_state *walk_state)
acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
union acpi_operand_object *obj_desc,
struct acpi_walk_state *walk_state)
{
acpi_status status;
ACPI_FUNCTION_TRACE_PTR ("ex_acquire_mutex", obj_desc);
acpi_status status;
ACPI_FUNCTION_TRACE_PTR("ex_acquire_mutex", obj_desc);
if (!obj_desc) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Sanity check -- we must have a valid thread ID */
if (!walk_state->thread) {
ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n",
acpi_ut_get_node_name (obj_desc->mutex.node)));
return_ACPI_STATUS (AE_AML_INTERNAL);
ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
return_ACPI_STATUS(AE_AML_INTERNAL);
}
/*
@ -178,10 +162,8 @@ acpi_ex_acquire_mutex (
* mutex. This mechanism provides some deadlock prevention
*/
if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
ACPI_REPORT_ERROR ((
"Cannot acquire Mutex [%4.4s], incorrect sync_level\n",
acpi_ut_get_node_name (obj_desc->mutex.node)));
return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
}
/* Support for multiple acquires by the owning thread */
@ -190,43 +172,43 @@ acpi_ex_acquire_mutex (
/* Special case for Global Lock, allow all threads */
if ((obj_desc->mutex.owner_thread->thread_id ==
walk_state->thread->thread_id) ||
(obj_desc->mutex.semaphore ==
acpi_gbl_global_lock_semaphore)) {
walk_state->thread->thread_id) ||
(obj_desc->mutex.semaphore ==
acpi_gbl_global_lock_semaphore)) {
/*
* The mutex is already owned by this thread,
* just increment the acquisition depth
*/
obj_desc->mutex.acquisition_depth++;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
}
/* Acquire the mutex, wait if necessary */
status = acpi_ex_system_acquire_mutex (time_desc, obj_desc);
if (ACPI_FAILURE (status)) {
status = acpi_ex_system_acquire_mutex(time_desc, obj_desc);
if (ACPI_FAILURE(status)) {
/* Includes failure from a timeout on time_desc */
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/* Have the mutex: update mutex and walk info and save the sync_level */
obj_desc->mutex.owner_thread = walk_state->thread;
obj_desc->mutex.owner_thread = walk_state->thread;
obj_desc->mutex.acquisition_depth = 1;
obj_desc->mutex.original_sync_level = walk_state->thread->current_sync_level;
obj_desc->mutex.original_sync_level =
walk_state->thread->current_sync_level;
walk_state->thread->current_sync_level = obj_desc->mutex.sync_level;
/* Link the mutex to the current thread for force-unlock at method exit */
acpi_ex_link_mutex (obj_desc, walk_state->thread);
acpi_ex_link_mutex(obj_desc, walk_state->thread);
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_release_mutex
@ -241,48 +223,40 @@ acpi_ex_acquire_mutex (
******************************************************************************/
acpi_status
acpi_ex_release_mutex (
union acpi_operand_object *obj_desc,
struct acpi_walk_state *walk_state)
acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
struct acpi_walk_state *walk_state)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ex_release_mutex");
acpi_status status;
ACPI_FUNCTION_TRACE("ex_release_mutex");
if (!obj_desc) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* The mutex must have been previously acquired in order to release it */
if (!obj_desc->mutex.owner_thread) {
ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], not acquired\n",
acpi_ut_get_node_name (obj_desc->mutex.node)));
return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED);
ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], not acquired\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
}
/* Sanity check -- we must have a valid thread ID */
if (!walk_state->thread) {
ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], null thread info\n",
acpi_ut_get_node_name (obj_desc->mutex.node)));
return_ACPI_STATUS (AE_AML_INTERNAL);
ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
return_ACPI_STATUS(AE_AML_INTERNAL);
}
/*
* The Mutex is owned, but this thread must be the owner.
* Special case for Global Lock, any thread can release
*/
if ((obj_desc->mutex.owner_thread->thread_id != walk_state->thread->thread_id) &&
(obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) {
ACPI_REPORT_ERROR ((
"Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n",
walk_state->thread->thread_id,
acpi_ut_get_node_name (obj_desc->mutex.node),
obj_desc->mutex.owner_thread->thread_id));
return_ACPI_STATUS (AE_AML_NOT_OWNER);
if ((obj_desc->mutex.owner_thread->thread_id !=
walk_state->thread->thread_id)
&& (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) {
ACPI_REPORT_ERROR(("Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", walk_state->thread->thread_id, acpi_ut_get_node_name(obj_desc->mutex.node), obj_desc->mutex.owner_thread->thread_id));
return_ACPI_STATUS(AE_AML_NOT_OWNER);
}
/*
@ -290,10 +264,8 @@ acpi_ex_release_mutex (
* equal to the current sync level
*/
if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) {
ACPI_REPORT_ERROR ((
"Cannot release Mutex [%4.4s], incorrect sync_level\n",
acpi_ut_get_node_name (obj_desc->mutex.node)));
return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node)));
return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
}
/* Match multiple Acquires with multiple Releases */
@ -302,26 +274,26 @@ acpi_ex_release_mutex (
if (obj_desc->mutex.acquisition_depth != 0) {
/* Just decrement the depth and return */
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/* Unlink the mutex from the owner's list */
acpi_ex_unlink_mutex (obj_desc);
acpi_ex_unlink_mutex(obj_desc);
/* Release the mutex */
status = acpi_ex_system_release_mutex (obj_desc);
status = acpi_ex_system_release_mutex(obj_desc);
/* Update the mutex and walk state, restore sync_level before acquire */
obj_desc->mutex.owner_thread = NULL;
walk_state->thread->current_sync_level = obj_desc->mutex.original_sync_level;
walk_state->thread->current_sync_level =
obj_desc->mutex.original_sync_level;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_release_all_mutexes
@ -334,17 +306,13 @@ acpi_ex_release_mutex (
*
******************************************************************************/
void
acpi_ex_release_all_mutexes (
struct acpi_thread_state *thread)
void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
{
union acpi_operand_object *next = thread->acquired_mutex_list;
union acpi_operand_object *this;
acpi_status status;
ACPI_FUNCTION_ENTRY ();
union acpi_operand_object *next = thread->acquired_mutex_list;
union acpi_operand_object *this;
acpi_status status;
ACPI_FUNCTION_ENTRY();
/* Traverse the list of owned mutexes, releasing each one */
@ -353,13 +321,13 @@ acpi_ex_release_all_mutexes (
next = this->mutex.next;
this->mutex.acquisition_depth = 1;
this->mutex.prev = NULL;
this->mutex.next = NULL;
this->mutex.prev = NULL;
this->mutex.next = NULL;
/* Release the mutex */
/* Release the mutex */
status = acpi_ex_system_release_mutex (this);
if (ACPI_FAILURE (status)) {
status = acpi_ex_system_release_mutex(this);
if (ACPI_FAILURE(status)) {
continue;
}
@ -372,5 +340,3 @@ acpi_ex_release_all_mutexes (
thread->current_sync_level = this->mutex.original_sync_level;
}
}

View File

@ -42,26 +42,18 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/amlcode.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exnames")
ACPI_MODULE_NAME("exnames")
/* Local prototypes */
static char *
acpi_ex_allocate_name_string (
u32 prefix_count,
u32 num_name_segs);
static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs);
static acpi_status
acpi_ex_name_segment (
u8 **in_aml_address,
char *name_string);
acpi_ex_name_segment(u8 ** in_aml_address, char *name_string);
/*******************************************************************************
*
@ -79,17 +71,13 @@ acpi_ex_name_segment (
*
******************************************************************************/
static char *
acpi_ex_allocate_name_string (
u32 prefix_count,
u32 num_name_segs)
static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs)
{
char *temp_ptr;
char *name_string;
u32 size_needed;
ACPI_FUNCTION_TRACE ("ex_allocate_name_string");
char *temp_ptr;
char *name_string;
u32 size_needed;
ACPI_FUNCTION_TRACE("ex_allocate_name_string");
/*
* Allow room for all \ and ^ prefixes, all segments and a multi_name_prefix.
@ -100,20 +88,19 @@ acpi_ex_allocate_name_string (
/* Special case for root */
size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
}
else {
size_needed = prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
} else {
size_needed =
prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
}
/*
* Allocate a buffer for the name.
* This buffer must be deleted by the caller!
*/
name_string = ACPI_MEM_ALLOCATE (size_needed);
name_string = ACPI_MEM_ALLOCATE(size_needed);
if (!name_string) {
ACPI_REPORT_ERROR ((
"ex_allocate_name_string: Could not allocate size %d\n", size_needed));
return_PTR (NULL);
ACPI_REPORT_ERROR(("ex_allocate_name_string: Could not allocate size %d\n", size_needed));
return_PTR(NULL);
}
temp_ptr = name_string;
@ -122,23 +109,20 @@ acpi_ex_allocate_name_string (
if (prefix_count == ACPI_UINT32_MAX) {
*temp_ptr++ = AML_ROOT_PREFIX;
}
else {
} else {
while (prefix_count--) {
*temp_ptr++ = AML_PARENT_PREFIX;
}
}
/* Set up Dual or Multi prefixes if needed */
if (num_name_segs > 2) {
/* Set up multi prefixes */
*temp_ptr++ = AML_MULTI_NAME_PREFIX_OP;
*temp_ptr++ = (char) num_name_segs;
}
else if (2 == num_name_segs) {
*temp_ptr++ = (char)num_name_segs;
} else if (2 == num_name_segs) {
/* Set up dual prefixes */
*temp_ptr++ = AML_DUAL_NAME_PREFIX;
@ -150,7 +134,7 @@ acpi_ex_allocate_name_string (
*/
*temp_ptr = 0;
return_PTR (name_string);
return_PTR(name_string);
}
/*******************************************************************************
@ -167,19 +151,14 @@ acpi_ex_allocate_name_string (
*
******************************************************************************/
static acpi_status
acpi_ex_name_segment (
u8 **in_aml_address,
char *name_string)
static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
{
char *aml_address = (void *) *in_aml_address;
acpi_status status = AE_OK;
u32 index;
char char_buf[5];
ACPI_FUNCTION_TRACE ("ex_name_segment");
char *aml_address = (void *)*in_aml_address;
acpi_status status = AE_OK;
u32 index;
char char_buf[5];
ACPI_FUNCTION_TRACE("ex_name_segment");
/*
* If first character is a digit, then we know that we aren't looking at a
@ -188,20 +167,20 @@ acpi_ex_name_segment (
char_buf[0] = *aml_address;
if ('0' <= char_buf[0] && char_buf[0] <= '9') {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "leading digit: %c\n", char_buf[0]));
return_ACPI_STATUS (AE_CTRL_PENDING);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "leading digit: %c\n",
char_buf[0]));
return_ACPI_STATUS(AE_CTRL_PENDING);
}
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n"));
ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n"));
for (index = 0;
(index < ACPI_NAME_SIZE) && (acpi_ut_valid_acpi_character (*aml_address));
index++) {
(index < ACPI_NAME_SIZE)
&& (acpi_ut_valid_acpi_character(*aml_address)); index++) {
char_buf[index] = *aml_address++;
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", char_buf[index]));
ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index]));
}
/* Valid name segment */
if (index == 4) {
@ -210,41 +189,37 @@ acpi_ex_name_segment (
char_buf[4] = '\0';
if (name_string) {
ACPI_STRCAT (name_string, char_buf);
ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
"Appended to - %s \n", name_string));
ACPI_STRCAT(name_string, char_buf);
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
"Appended to - %s \n", name_string));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
"No Name string - %s \n", char_buf));
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
"No Name string - %s \n", char_buf));
}
}
else if (index == 0) {
} else if (index == 0) {
/*
* First character was not a valid name character,
* so we are looking at something other than a name.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Leading character is not alpha: %02Xh (not a name)\n",
char_buf[0]));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Leading character is not alpha: %02Xh (not a name)\n",
char_buf[0]));
status = AE_CTRL_PENDING;
}
else {
} else {
/*
* Segment started with one or more valid characters, but fewer than
* the required 4
*/
status = AE_AML_BAD_NAME;
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Bad character %02x in name, at %p\n",
*aml_address, aml_address));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Bad character %02x in name, at %p\n",
*aml_address, aml_address));
}
*in_aml_address = (u8 *) aml_address;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_get_name_string
@ -263,37 +238,32 @@ acpi_ex_name_segment (
******************************************************************************/
acpi_status
acpi_ex_get_name_string (
acpi_object_type data_type,
u8 *in_aml_address,
char **out_name_string,
u32 *out_name_length)
acpi_ex_get_name_string(acpi_object_type data_type,
u8 * in_aml_address,
char **out_name_string, u32 * out_name_length)
{
acpi_status status = AE_OK;
u8 *aml_address = in_aml_address;
char *name_string = NULL;
u32 num_segments;
u32 prefix_count = 0;
u8 has_prefix = FALSE;
acpi_status status = AE_OK;
u8 *aml_address = in_aml_address;
char *name_string = NULL;
u32 num_segments;
u32 prefix_count = 0;
u8 has_prefix = FALSE;
ACPI_FUNCTION_TRACE_PTR("ex_get_name_string", aml_address);
ACPI_FUNCTION_TRACE_PTR ("ex_get_name_string", aml_address);
if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type ||
ACPI_TYPE_LOCAL_BANK_FIELD == data_type ||
ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) {
if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type ||
ACPI_TYPE_LOCAL_BANK_FIELD == data_type ||
ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) {
/* Disallow prefixes for types associated with field_unit names */
name_string = acpi_ex_allocate_name_string (0, 1);
name_string = acpi_ex_allocate_name_string(0, 1);
if (!name_string) {
status = AE_NO_MEMORY;
} else {
status =
acpi_ex_name_segment(&aml_address, name_string);
}
else {
status = acpi_ex_name_segment (&aml_address, name_string);
}
}
else {
} else {
/*
* data_type is not a field name.
* Examine first character of name for root or parent prefix operators
@ -301,8 +271,9 @@ acpi_ex_get_name_string (
switch (*aml_address) {
case AML_ROOT_PREFIX:
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "root_prefix(\\) at %p\n",
aml_address));
ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
"root_prefix(\\) at %p\n",
aml_address));
/*
* Remember that we have a root_prefix --
@ -313,14 +284,14 @@ acpi_ex_get_name_string (
has_prefix = TRUE;
break;
case AML_PARENT_PREFIX:
/* Increment past possibly multiple parent prefixes */
do {
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "parent_prefix (^) at %p\n",
aml_address));
ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
"parent_prefix (^) at %p\n",
aml_address));
aml_address++;
prefix_count++;
@ -330,7 +301,6 @@ acpi_ex_get_name_string (
has_prefix = TRUE;
break;
default:
/* Not a prefix character */
@ -343,11 +313,13 @@ acpi_ex_get_name_string (
switch (*aml_address) {
case AML_DUAL_NAME_PREFIX:
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "dual_name_prefix at %p\n",
aml_address));
ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
"dual_name_prefix at %p\n",
aml_address));
aml_address++;
name_string = acpi_ex_allocate_name_string (prefix_count, 2);
name_string =
acpi_ex_allocate_name_string(prefix_count, 2);
if (!name_string) {
status = AE_NO_MEMORY;
break;
@ -357,24 +329,29 @@ acpi_ex_get_name_string (
has_prefix = TRUE;
status = acpi_ex_name_segment (&aml_address, name_string);
if (ACPI_SUCCESS (status)) {
status = acpi_ex_name_segment (&aml_address, name_string);
status =
acpi_ex_name_segment(&aml_address, name_string);
if (ACPI_SUCCESS(status)) {
status =
acpi_ex_name_segment(&aml_address,
name_string);
}
break;
case AML_MULTI_NAME_PREFIX_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "multi_name_prefix at %p\n",
aml_address));
ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
"multi_name_prefix at %p\n",
aml_address));
/* Fetch count of segments remaining in name path */
aml_address++;
num_segments = *aml_address;
name_string = acpi_ex_allocate_name_string (prefix_count, num_segments);
name_string =
acpi_ex_allocate_name_string(prefix_count,
num_segments);
if (!name_string) {
status = AE_NO_MEMORY;
break;
@ -386,27 +363,28 @@ acpi_ex_get_name_string (
has_prefix = TRUE;
while (num_segments &&
(status = acpi_ex_name_segment (&aml_address, name_string)) ==
AE_OK) {
(status =
acpi_ex_name_segment(&aml_address,
name_string)) == AE_OK) {
num_segments--;
}
break;
case 0:
/* null_name valid as of 8-12-98 ASL/AML Grammar Update */
if (prefix_count == ACPI_UINT32_MAX) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"name_seg is \"\\\" followed by NULL\n"));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"name_seg is \"\\\" followed by NULL\n"));
}
/* Consume the NULL byte */
aml_address++;
name_string = acpi_ex_allocate_name_string (prefix_count, 0);
name_string =
acpi_ex_allocate_name_string(prefix_count, 0);
if (!name_string) {
status = AE_NO_MEMORY;
break;
@ -414,18 +392,19 @@ acpi_ex_get_name_string (
break;
default:
/* Name segment string */
name_string = acpi_ex_allocate_name_string (prefix_count, 1);
name_string =
acpi_ex_allocate_name_string(prefix_count, 1);
if (!name_string) {
status = AE_NO_MEMORY;
break;
}
status = acpi_ex_name_segment (&aml_address, name_string);
status =
acpi_ex_name_segment(&aml_address, name_string);
break;
}
}
@ -433,15 +412,20 @@ acpi_ex_get_name_string (
if (AE_CTRL_PENDING == status && has_prefix) {
/* Ran out of segments after processing a prefix */
ACPI_REPORT_ERROR (
("ex_do_name: Malformed Name at %p\n", name_string));
ACPI_REPORT_ERROR(("ex_do_name: Malformed Name at %p\n",
name_string));
status = AE_AML_BAD_NAME;
}
if (ACPI_FAILURE(status)) {
if (name_string) {
ACPI_MEM_FREE(name_string);
}
return_ACPI_STATUS(status);
}
*out_name_string = name_string;
*out_name_length = (u32) (aml_address - in_aml_address);
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

File diff suppressed because it is too large Load Diff

View File

@ -41,17 +41,14 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acparser.h>
#include <acpi/acinterp.h>
#include <acpi/acevents.h>
#include <acpi/amlcode.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exoparg2")
ACPI_MODULE_NAME("exoparg2")
/*!
* Naming convention for AML interpreter execution routines.
@ -74,8 +71,6 @@
* The AcpiExOpcode* functions are called via the Dispatcher component with
* fully resolved operands.
!*/
/*******************************************************************************
*
* FUNCTION: acpi_ex_opcode_2A_0T_0R
@ -90,29 +85,24 @@
* ALLOCATION: Deletes both operands
*
******************************************************************************/
acpi_status
acpi_ex_opcode_2A_0T_0R (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
struct acpi_namespace_node *node;
u32 value;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_0R",
acpi_ps_get_opcode_name (walk_state->opcode));
union acpi_operand_object **operand = &walk_state->operands[0];
struct acpi_namespace_node *node;
u32 value;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_0T_0R",
acpi_ps_get_opcode_name(walk_state->opcode));
/* Examine the opcode */
switch (walk_state->opcode) {
case AML_NOTIFY_OP: /* Notify (notify_object, notify_value) */
case AML_NOTIFY_OP: /* Notify (notify_object, notify_value) */
/* The first operand is a namespace node */
node = (struct acpi_namespace_node *) operand[0];
node = (struct acpi_namespace_node *)operand[0];
/* Second value is the notify value */
@ -120,15 +110,14 @@ acpi_ex_opcode_2A_0T_0R (
/* Are notifies allowed on this object? */
if (!acpi_ev_is_notify_object (node)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unexpected notify object type [%s]\n",
acpi_ut_get_type_name (node->type)));
if (!acpi_ev_is_notify_object(node)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unexpected notify object type [%s]\n",
acpi_ut_get_type_name(node->type)));
status = AE_AML_OPERAND_TYPE;
break;
}
#ifdef ACPI_GPE_NOTIFY_CHECK
/*
* GPE method wake/notify check. Here, we want to ensure that we
@ -144,12 +133,14 @@ acpi_ex_opcode_2A_0T_0R (
* If all three cases are true, this is a wake-only GPE that should
* be disabled at runtime.
*/
if (value == 2) /* device_wake */ {
status = acpi_ev_check_for_wake_only_gpe (walk_state->gpe_event_info);
if (ACPI_FAILURE (status)) {
if (value == 2) { /* device_wake */
status =
acpi_ev_check_for_wake_only_gpe(walk_state->
gpe_event_info);
if (ACPI_FAILURE(status)) {
/* AE_WAKE_ONLY_GPE only error, means ignore this notify */
return_ACPI_STATUS (AE_OK)
return_ACPI_STATUS(AE_OK)
}
}
#endif
@ -161,21 +152,18 @@ acpi_ex_opcode_2A_0T_0R (
* from this thread -- because handlers may in turn run other
* control methods.
*/
status = acpi_ev_queue_notify_request (node, value);
status = acpi_ev_queue_notify_request(node, value);
break;
default:
ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n",
walk_state->opcode));
ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
status = AE_AML_BAD_OPCODE;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_opcode_2A_2T_1R
@ -189,19 +177,15 @@ acpi_ex_opcode_2A_0T_0R (
*
******************************************************************************/
acpi_status
acpi_ex_opcode_2A_2T_1R (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc1 = NULL;
union acpi_operand_object *return_desc2 = NULL;
acpi_status status;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_2T_1R",
acpi_ps_get_opcode_name (walk_state->opcode));
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc1 = NULL;
union acpi_operand_object *return_desc2 = NULL;
acpi_status status;
ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_2T_1R",
acpi_ps_get_opcode_name(walk_state->opcode));
/* Execute the opcode */
@ -210,13 +194,15 @@ acpi_ex_opcode_2A_2T_1R (
/* Divide (Dividend, Divisor, remainder_result quotient_result) */
return_desc1 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
return_desc1 =
acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!return_desc1) {
status = AE_NO_MEMORY;
goto cleanup;
}
return_desc2 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
return_desc2 =
acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!return_desc2) {
status = AE_NO_MEMORY;
goto cleanup;
@ -224,33 +210,31 @@ acpi_ex_opcode_2A_2T_1R (
/* Quotient to return_desc1, remainder to return_desc2 */
status = acpi_ut_divide (operand[0]->integer.value,
operand[1]->integer.value,
&return_desc1->integer.value,
&return_desc2->integer.value);
if (ACPI_FAILURE (status)) {
status = acpi_ut_divide(operand[0]->integer.value,
operand[1]->integer.value,
&return_desc1->integer.value,
&return_desc2->integer.value);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
break;
default:
ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n",
walk_state->opcode));
ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n", walk_state->opcode));
status = AE_AML_BAD_OPCODE;
goto cleanup;
}
/* Store the results to the target reference operands */
status = acpi_ex_store (return_desc2, operand[2], walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ex_store(return_desc2, operand[2], walk_state);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
status = acpi_ex_store (return_desc1, operand[3], walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ex_store(return_desc1, operand[3], walk_state);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
@ -258,24 +242,22 @@ acpi_ex_opcode_2A_2T_1R (
walk_state->result_obj = return_desc1;
cleanup:
cleanup:
/*
* Since the remainder is not returned indirectly, remove a reference to
* it. Only the quotient is returned indirectly.
*/
acpi_ut_remove_reference (return_desc2);
acpi_ut_remove_reference(return_desc2);
if (ACPI_FAILURE (status)) {
if (ACPI_FAILURE(status)) {
/* Delete the return object */
acpi_ut_remove_reference (return_desc1);
acpi_ut_remove_reference(return_desc1);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_opcode_2A_1T_1R
@ -289,42 +271,39 @@ cleanup:
*
******************************************************************************/
acpi_status
acpi_ex_opcode_2A_1T_1R (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
acpi_integer index;
acpi_status status = AE_OK;
acpi_size length;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_1T_1R",
acpi_ps_get_opcode_name (walk_state->opcode));
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
acpi_integer index;
acpi_status status = AE_OK;
acpi_size length;
ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_1T_1R",
acpi_ps_get_opcode_name(walk_state->opcode));
/* Execute the opcode */
if (walk_state->op_info->flags & AML_MATH) {
/* All simple math opcodes (add, etc.) */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
}
return_desc->integer.value = acpi_ex_do_math_op (walk_state->opcode,
operand[0]->integer.value,
operand[1]->integer.value);
return_desc->integer.value =
acpi_ex_do_math_op(walk_state->opcode,
operand[0]->integer.value,
operand[1]->integer.value);
goto store_result_to_target;
}
switch (walk_state->opcode) {
case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */
case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -332,21 +311,18 @@ acpi_ex_opcode_2A_1T_1R (
/* return_desc will contain the remainder */
status = acpi_ut_divide (operand[0]->integer.value,
operand[1]->integer.value,
NULL,
&return_desc->integer.value);
status = acpi_ut_divide(operand[0]->integer.value,
operand[1]->integer.value,
NULL, &return_desc->integer.value);
break;
case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
status = acpi_ex_do_concatenate (operand[0], operand[1],
&return_desc, walk_state);
status = acpi_ex_do_concatenate(operand[0], operand[1],
&return_desc, walk_state);
break;
case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */
case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */
/*
* Input object is guaranteed to be a buffer at this point (it may have
@ -365,8 +341,8 @@ acpi_ex_opcode_2A_1T_1R (
*/
length = 0;
while ((length < operand[0]->buffer.length) &&
(length < operand[1]->integer.value) &&
(operand[0]->buffer.pointer[length])) {
(length < operand[1]->integer.value) &&
(operand[0]->buffer.pointer[length])) {
length++;
if (length > ACPI_MAX_STRING_CONVERSION) {
status = AE_AML_STRING_LIMIT;
@ -376,33 +352,32 @@ acpi_ex_opcode_2A_1T_1R (
/* Allocate a new string object */
return_desc = acpi_ut_create_string_object (length);
return_desc = acpi_ut_create_string_object(length);
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
}
/* Copy the raw buffer data with no transform. NULL terminated already*/
/* Copy the raw buffer data with no transform. NULL terminated already */
ACPI_MEMCPY (return_desc->string.pointer,
operand[0]->buffer.pointer, length);
ACPI_MEMCPY(return_desc->string.pointer,
operand[0]->buffer.pointer, length);
break;
case AML_CONCAT_RES_OP:
/* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
status = acpi_ex_concat_template (operand[0], operand[1],
&return_desc, walk_state);
status = acpi_ex_concat_template(operand[0], operand[1],
&return_desc, walk_state);
break;
case AML_INDEX_OP: /* Index (Source Index Result) */
case AML_INDEX_OP: /* Index (Source Index Result) */
/* Create the internal return object */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_REFERENCE);
return_desc =
acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -412,76 +387,75 @@ acpi_ex_opcode_2A_1T_1R (
/* At this point, the Source operand is a Package, Buffer, or String */
if (ACPI_GET_OBJECT_TYPE (operand[0]) == ACPI_TYPE_PACKAGE) {
if (ACPI_GET_OBJECT_TYPE(operand[0]) == ACPI_TYPE_PACKAGE) {
/* Object to be indexed is a Package */
if (index >= operand[0]->package.count) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Index value (%X%8.8X) beyond package end (%X)\n",
ACPI_FORMAT_UINT64 (index), operand[0]->package.count));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Index value (%X%8.8X) beyond package end (%X)\n",
ACPI_FORMAT_UINT64(index),
operand[0]->package.count));
status = AE_AML_PACKAGE_LIMIT;
goto cleanup;
}
return_desc->reference.target_type = ACPI_TYPE_PACKAGE;
return_desc->reference.object = operand[0];
return_desc->reference.where = &operand[0]->package.elements [
index];
}
else {
return_desc->reference.object = operand[0];
return_desc->reference.where =
&operand[0]->package.elements[index];
} else {
/* Object to be indexed is a Buffer/String */
if (index >= operand[0]->buffer.length) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Index value (%X%8.8X) beyond end of buffer (%X)\n",
ACPI_FORMAT_UINT64 (index), operand[0]->buffer.length));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Index value (%X%8.8X) beyond end of buffer (%X)\n",
ACPI_FORMAT_UINT64(index),
operand[0]->buffer.length));
status = AE_AML_BUFFER_LIMIT;
goto cleanup;
}
return_desc->reference.target_type = ACPI_TYPE_BUFFER_FIELD;
return_desc->reference.object = operand[0];
return_desc->reference.target_type =
ACPI_TYPE_BUFFER_FIELD;
return_desc->reference.object = operand[0];
}
/*
* Add a reference to the target package/buffer/string for the life
* of the index.
*/
acpi_ut_add_reference (operand[0]);
acpi_ut_add_reference(operand[0]);
/* Complete the Index reference object */
return_desc->reference.opcode = AML_INDEX_OP;
return_desc->reference.offset = (u32) index;
return_desc->reference.opcode = AML_INDEX_OP;
return_desc->reference.offset = (u32) index;
/* Store the reference to the Target */
status = acpi_ex_store (return_desc, operand[2], walk_state);
status = acpi_ex_store(return_desc, operand[2], walk_state);
/* Return the reference */
walk_state->result_obj = return_desc;
goto cleanup;
default:
ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n",
walk_state->opcode));
ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n", walk_state->opcode));
status = AE_AML_BAD_OPCODE;
break;
}
store_result_to_target:
store_result_to_target:
if (ACPI_SUCCESS (status)) {
if (ACPI_SUCCESS(status)) {
/*
* Store the result of the operation (which is now in return_desc) into
* the Target descriptor.
*/
status = acpi_ex_store (return_desc, operand[2], walk_state);
if (ACPI_FAILURE (status)) {
status = acpi_ex_store(return_desc, operand[2], walk_state);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
@ -490,19 +464,17 @@ store_result_to_target:
}
}
cleanup:
cleanup:
/* Delete return object on error */
if (ACPI_FAILURE (status)) {
acpi_ut_remove_reference (return_desc);
if (ACPI_FAILURE(status)) {
acpi_ut_remove_reference(return_desc);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_opcode_2A_0T_1R
@ -515,23 +487,19 @@ cleanup:
*
******************************************************************************/
acpi_status
acpi_ex_opcode_2A_0T_1R (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
acpi_status status = AE_OK;
u8 logical_result = FALSE;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_1R",
acpi_ps_get_opcode_name (walk_state->opcode));
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
acpi_status status = AE_OK;
u8 logical_result = FALSE;
ACPI_FUNCTION_TRACE_STR("ex_opcode_2A_0T_1R",
acpi_ps_get_opcode_name(walk_state->opcode));
/* Create the internal return object */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -542,50 +510,48 @@ acpi_ex_opcode_2A_0T_1R (
if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) {
/* logical_op (Operand0, Operand1) */
status = acpi_ex_do_logical_numeric_op (walk_state->opcode,
operand[0]->integer.value, operand[1]->integer.value,
&logical_result);
status = acpi_ex_do_logical_numeric_op(walk_state->opcode,
operand[0]->integer.
value,
operand[1]->integer.
value, &logical_result);
goto store_logical_result;
}
else if (walk_state->op_info->flags & AML_LOGICAL) {
} else if (walk_state->op_info->flags & AML_LOGICAL) {
/* logical_op (Operand0, Operand1) */
status = acpi_ex_do_logical_op (walk_state->opcode, operand[0],
operand[1], &logical_result);
status = acpi_ex_do_logical_op(walk_state->opcode, operand[0],
operand[1], &logical_result);
goto store_logical_result;
}
switch (walk_state->opcode) {
case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */
case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */
status = acpi_ex_acquire_mutex (operand[1], operand[0], walk_state);
status =
acpi_ex_acquire_mutex(operand[1], operand[0], walk_state);
if (status == AE_TIME) {
logical_result = TRUE; /* TRUE = Acquire timed out */
logical_result = TRUE; /* TRUE = Acquire timed out */
status = AE_OK;
}
break;
case AML_WAIT_OP: /* Wait (event_object, Timeout) */
case AML_WAIT_OP: /* Wait (event_object, Timeout) */
status = acpi_ex_system_wait_event (operand[1], operand[0]);
status = acpi_ex_system_wait_event(operand[1], operand[0]);
if (status == AE_TIME) {
logical_result = TRUE; /* TRUE, Wait timed out */
logical_result = TRUE; /* TRUE, Wait timed out */
status = AE_OK;
}
break;
default:
ACPI_REPORT_ERROR (("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n",
walk_state->opcode));
ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
status = AE_AML_BAD_OPCODE;
goto cleanup;
}
store_logical_result:
store_logical_result:
/*
* Set return value to according to logical_result. logical TRUE (all ones)
* Default is FALSE (zero)
@ -596,16 +562,13 @@ store_logical_result:
walk_state->result_obj = return_desc;
cleanup:
cleanup:
/* Delete return object on error */
if (ACPI_FAILURE (status)) {
acpi_ut_remove_reference (return_desc);
if (ACPI_FAILURE(status)) {
acpi_ut_remove_reference(return_desc);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -42,16 +42,13 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/acparser.h>
#include <acpi/amlcode.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exoparg3")
ACPI_MODULE_NAME("exoparg3")
/*!
* Naming convention for AML interpreter execution routines.
@ -74,8 +71,6 @@
* The AcpiExOpcode* functions are called via the Dispatcher component with
* fully resolved operands.
!*/
/*******************************************************************************
*
* FUNCTION: acpi_ex_opcode_3A_0T_0R
@ -87,61 +82,53 @@
* DESCRIPTION: Execute Triadic operator (3 operands)
*
******************************************************************************/
acpi_status
acpi_ex_opcode_3A_0T_0R (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
struct acpi_signal_fatal_info *fatal;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_0T_0R",
acpi_ps_get_opcode_name (walk_state->opcode));
union acpi_operand_object **operand = &walk_state->operands[0];
struct acpi_signal_fatal_info *fatal;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_STR("ex_opcode_3A_0T_0R",
acpi_ps_get_opcode_name(walk_state->opcode));
switch (walk_state->opcode) {
case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */
case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
(u32) operand[0]->integer.value,
(u32) operand[1]->integer.value,
(u32) operand[2]->integer.value));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
(u32) operand[0]->integer.value,
(u32) operand[1]->integer.value,
(u32) operand[2]->integer.value));
fatal = ACPI_MEM_ALLOCATE (sizeof (struct acpi_signal_fatal_info));
fatal =
ACPI_MEM_ALLOCATE(sizeof(struct acpi_signal_fatal_info));
if (fatal) {
fatal->type = (u32) operand[0]->integer.value;
fatal->code = (u32) operand[1]->integer.value;
fatal->type = (u32) operand[0]->integer.value;
fatal->code = (u32) operand[1]->integer.value;
fatal->argument = (u32) operand[2]->integer.value;
}
/* Always signal the OS! */
status = acpi_os_signal (ACPI_SIGNAL_FATAL, fatal);
status = acpi_os_signal(ACPI_SIGNAL_FATAL, fatal);
/* Might return while OS is shutting down, just continue */
ACPI_MEM_FREE (fatal);
ACPI_MEM_FREE(fatal);
break;
default:
ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
walk_state->opcode));
ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
status = AE_AML_BAD_OPCODE;
goto cleanup;
}
cleanup:
cleanup:
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_opcode_3A_1T_1R
@ -154,31 +141,28 @@ cleanup:
*
******************************************************************************/
acpi_status
acpi_ex_opcode_3A_1T_1R (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
char *buffer;
acpi_status status = AE_OK;
acpi_integer index;
acpi_size length;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_1T_1R",
acpi_ps_get_opcode_name (walk_state->opcode));
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
char *buffer = NULL;
acpi_status status = AE_OK;
acpi_integer index;
acpi_size length;
ACPI_FUNCTION_TRACE_STR("ex_opcode_3A_1T_1R",
acpi_ps_get_opcode_name(walk_state->opcode));
switch (walk_state->opcode) {
case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
/*
* Create the return object. The Source operand is guaranteed to be
* either a String or a Buffer, so just use its type.
*/
return_desc = acpi_ut_create_internal_object (
ACPI_GET_OBJECT_TYPE (operand[0]));
return_desc =
acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
(operand[0]));
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -193,67 +177,92 @@ acpi_ex_opcode_3A_1T_1R (
* If the index is beyond the length of the String/Buffer, or if the
* requested length is zero, return a zero-length String/Buffer
*/
if ((index < operand[0]->string.length) &&
(length > 0)) {
/* Truncate request if larger than the actual String/Buffer */
if (index >= operand[0]->string.length) {
length = 0;
}
if ((index + length) >
operand[0]->string.length) {
length = (acpi_size) operand[0]->string.length -
(acpi_size) index;
}
/* Truncate request if larger than the actual String/Buffer */
/* Allocate a new buffer for the String/Buffer */
else if ((index + length) > operand[0]->string.length) {
length = (acpi_size) operand[0]->string.length -
(acpi_size) index;
}
buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1);
/* Strings always have a sub-pointer, not so for buffers */
switch (ACPI_GET_OBJECT_TYPE(operand[0])) {
case ACPI_TYPE_STRING:
/* Always allocate a new buffer for the String */
buffer = ACPI_MEM_CALLOCATE((acpi_size) length + 1);
if (!buffer) {
status = AE_NO_MEMORY;
goto cleanup;
}
break;
case ACPI_TYPE_BUFFER:
/* If the requested length is zero, don't allocate a buffer */
if (length > 0) {
/* Allocate a new buffer for the Buffer */
buffer = ACPI_MEM_CALLOCATE(length);
if (!buffer) {
status = AE_NO_MEMORY;
goto cleanup;
}
}
break;
default: /* Should not happen */
status = AE_AML_OPERAND_TYPE;
goto cleanup;
}
if (length > 0) {
/* Copy the portion requested */
ACPI_MEMCPY (buffer, operand[0]->string.pointer + index,
length);
/* Set the length of the new String/Buffer */
return_desc->string.pointer = buffer;
return_desc->string.length = (u32) length;
ACPI_MEMCPY(buffer, operand[0]->string.pointer + index,
length);
}
/* Set the length of the new String/Buffer */
return_desc->string.pointer = buffer;
return_desc->string.length = (u32) length;
/* Mark buffer initialized */
return_desc->buffer.flags |= AOPOBJ_DATA_VALID;
break;
default:
ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
walk_state->opcode));
ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
status = AE_AML_BAD_OPCODE;
goto cleanup;
}
/* Store the result in the target */
status = acpi_ex_store (return_desc, operand[3], walk_state);
status = acpi_ex_store(return_desc, operand[3], walk_state);
cleanup:
cleanup:
/* Delete return object on error */
if (ACPI_FAILURE (status)) {
acpi_ut_remove_reference (return_desc);
if (ACPI_FAILURE(status) || walk_state->result_obj) {
acpi_ut_remove_reference(return_desc);
}
/* Set the return object and exit */
if (!walk_state->result_obj) {
else {
walk_state->result_obj = return_desc;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -42,16 +42,13 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/acparser.h>
#include <acpi/amlcode.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exoparg6")
ACPI_MODULE_NAME("exoparg6")
/*!
* Naming convention for AML interpreter execution routines.
@ -74,15 +71,11 @@
* The AcpiExOpcode* functions are called via the Dispatcher component with
* fully resolved operands.
!*/
/* Local prototypes */
static u8
acpi_ex_do_match (
u32 match_op,
union acpi_operand_object *package_obj,
union acpi_operand_object *match_obj);
acpi_ex_do_match(u32 match_op,
union acpi_operand_object *package_obj,
union acpi_operand_object *match_obj);
/*******************************************************************************
*
@ -101,14 +94,12 @@ acpi_ex_do_match (
******************************************************************************/
static u8
acpi_ex_do_match (
u32 match_op,
union acpi_operand_object *package_obj,
union acpi_operand_object *match_obj)
acpi_ex_do_match(u32 match_op,
union acpi_operand_object *package_obj,
union acpi_operand_object *match_obj)
{
u8 logical_result = TRUE;
acpi_status status;
u8 logical_result = TRUE;
acpi_status status;
/*
* Note: Since the package_obj/match_obj ordering is opposite to that of
@ -133,9 +124,10 @@ acpi_ex_do_match (
* True if equal: (P[i] == M)
* Change to: (M == P[i])
*/
status = acpi_ex_do_logical_op (AML_LEQUAL_OP, match_obj, package_obj,
&logical_result);
if (ACPI_FAILURE (status)) {
status =
acpi_ex_do_logical_op(AML_LEQUAL_OP, match_obj, package_obj,
&logical_result);
if (ACPI_FAILURE(status)) {
return (FALSE);
}
break;
@ -146,12 +138,13 @@ acpi_ex_do_match (
* True if less than or equal: (P[i] <= M) (P[i] not_greater than M)
* Change to: (M >= P[i]) (M not_less than P[i])
*/
status = acpi_ex_do_logical_op (AML_LLESS_OP, match_obj, package_obj,
&logical_result);
if (ACPI_FAILURE (status)) {
status =
acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj,
&logical_result);
if (ACPI_FAILURE(status)) {
return (FALSE);
}
logical_result = (u8) !logical_result;
logical_result = (u8) ! logical_result;
break;
case MATCH_MLT:
@ -160,9 +153,10 @@ acpi_ex_do_match (
* True if less than: (P[i] < M)
* Change to: (M > P[i])
*/
status = acpi_ex_do_logical_op (AML_LGREATER_OP, match_obj, package_obj,
&logical_result);
if (ACPI_FAILURE (status)) {
status =
acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj,
package_obj, &logical_result);
if (ACPI_FAILURE(status)) {
return (FALSE);
}
break;
@ -173,12 +167,13 @@ acpi_ex_do_match (
* True if greater than or equal: (P[i] >= M) (P[i] not_less than M)
* Change to: (M <= P[i]) (M not_greater than P[i])
*/
status = acpi_ex_do_logical_op (AML_LGREATER_OP, match_obj, package_obj,
&logical_result);
if (ACPI_FAILURE (status)) {
status =
acpi_ex_do_logical_op(AML_LGREATER_OP, match_obj,
package_obj, &logical_result);
if (ACPI_FAILURE(status)) {
return (FALSE);
}
logical_result = (u8)!logical_result;
logical_result = (u8) ! logical_result;
break;
case MATCH_MGT:
@ -187,9 +182,10 @@ acpi_ex_do_match (
* True if greater than: (P[i] > M)
* Change to: (M < P[i])
*/
status = acpi_ex_do_logical_op (AML_LLESS_OP, match_obj, package_obj,
&logical_result);
if (ACPI_FAILURE (status)) {
status =
acpi_ex_do_logical_op(AML_LLESS_OP, match_obj, package_obj,
&logical_result);
if (ACPI_FAILURE(status)) {
return (FALSE);
}
break;
@ -204,7 +200,6 @@ acpi_ex_do_match (
return logical_result;
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_opcode_6A_0T_1R
@ -217,20 +212,16 @@ acpi_ex_do_match (
*
******************************************************************************/
acpi_status
acpi_ex_opcode_6A_0T_1R (
struct acpi_walk_state *walk_state)
acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
acpi_status status = AE_OK;
acpi_integer index;
union acpi_operand_object *this_element;
ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R",
acpi_ps_get_opcode_name (walk_state->opcode));
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
acpi_status status = AE_OK;
acpi_integer index;
union acpi_operand_object *this_element;
ACPI_FUNCTION_TRACE_STR("ex_opcode_6A_0T_1R",
acpi_ps_get_opcode_name(walk_state->opcode));
switch (walk_state->opcode) {
case AML_MATCH_OP:
@ -242,8 +233,9 @@ acpi_ex_opcode_6A_0T_1R (
/* Validate both Match Term Operators (MTR, MEQ, etc.) */
if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) ||
(operand[3]->integer.value > MAX_MATCH_OPERATOR)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Match operator out of range\n"));
(operand[3]->integer.value > MAX_MATCH_OPERATOR)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Match operator out of range\n"));
status = AE_AML_OPERAND_VALUE;
goto cleanup;
}
@ -252,16 +244,17 @@ acpi_ex_opcode_6A_0T_1R (
index = operand[5]->integer.value;
if (index >= operand[0]->package.count) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Index (%X%8.8X) beyond package end (%X)\n",
ACPI_FORMAT_UINT64 (index), operand[0]->package.count));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Index (%X%8.8X) beyond package end (%X)\n",
ACPI_FORMAT_UINT64(index),
operand[0]->package.count));
status = AE_AML_PACKAGE_LIMIT;
goto cleanup;
}
/* Create an integer for the return value */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@ -283,7 +276,7 @@ acpi_ex_opcode_6A_0T_1R (
* ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no
* match was found.
*/
for ( ; index < operand[0]->package.count; index++) {
for (; index < operand[0]->package.count; index++) {
/* Get the current package element */
this_element = operand[0]->package.elements[index];
@ -299,13 +292,13 @@ acpi_ex_opcode_6A_0T_1R (
* (proceed to next iteration of enclosing for loop) signifies a
* non-match.
*/
if (!acpi_ex_do_match ((u32) operand[1]->integer.value,
this_element, operand[2])) {
if (!acpi_ex_do_match((u32) operand[1]->integer.value,
this_element, operand[2])) {
continue;
}
if (!acpi_ex_do_match ((u32) operand[3]->integer.value,
this_element, operand[4])) {
if (!acpi_ex_do_match((u32) operand[3]->integer.value,
this_element, operand[4])) {
continue;
}
@ -316,31 +309,27 @@ acpi_ex_opcode_6A_0T_1R (
}
break;
case AML_LOAD_TABLE_OP:
status = acpi_ex_load_table_op (walk_state, &return_desc);
status = acpi_ex_load_table_op(walk_state, &return_desc);
break;
default:
ACPI_REPORT_ERROR (("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n",
walk_state->opcode));
ACPI_REPORT_ERROR(("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
status = AE_AML_BAD_OPCODE;
goto cleanup;
}
walk_state->result_obj = return_desc;
cleanup:
cleanup:
/* Delete return object on error */
if (ACPI_FAILURE (status)) {
acpi_ut_remove_reference (return_desc);
if (ACPI_FAILURE(status)) {
acpi_ut_remove_reference(return_desc);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -42,32 +42,24 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/amlcode.h>
#include <acpi/acnamesp.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exprep")
ACPI_MODULE_NAME("exprep")
/* Local prototypes */
static u32
acpi_ex_decode_field_access (
union acpi_operand_object *obj_desc,
u8 field_flags,
u32 *return_byte_alignment);
acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
u8 field_flags, u32 * return_byte_alignment);
#ifdef ACPI_UNDER_DEVELOPMENT
static u32
acpi_ex_generate_access (
u32 field_bit_offset,
u32 field_bit_length,
u32 region_length);
acpi_ex_generate_access(u32 field_bit_offset,
u32 field_bit_length, u32 region_length);
/*******************************************************************************
*
@ -92,39 +84,36 @@ acpi_ex_generate_access (
******************************************************************************/
static u32
acpi_ex_generate_access (
u32 field_bit_offset,
u32 field_bit_length,
u32 region_length)
acpi_ex_generate_access(u32 field_bit_offset,
u32 field_bit_length, u32 region_length)
{
u32 field_byte_length;
u32 field_byte_offset;
u32 field_byte_end_offset;
u32 access_byte_width;
u32 field_start_offset;
u32 field_end_offset;
u32 minimum_access_width = 0xFFFFFFFF;
u32 minimum_accesses = 0xFFFFFFFF;
u32 accesses;
ACPI_FUNCTION_TRACE ("ex_generate_access");
u32 field_byte_length;
u32 field_byte_offset;
u32 field_byte_end_offset;
u32 access_byte_width;
u32 field_start_offset;
u32 field_end_offset;
u32 minimum_access_width = 0xFFFFFFFF;
u32 minimum_accesses = 0xFFFFFFFF;
u32 accesses;
ACPI_FUNCTION_TRACE("ex_generate_access");
/* Round Field start offset and length to "minimal" byte boundaries */
field_byte_offset = ACPI_DIV_8 (ACPI_ROUND_DOWN (field_bit_offset, 8));
field_byte_end_offset = ACPI_DIV_8 (ACPI_ROUND_UP (field_bit_length +
field_bit_offset, 8));
field_byte_length = field_byte_end_offset - field_byte_offset;
field_byte_offset = ACPI_DIV_8(ACPI_ROUND_DOWN(field_bit_offset, 8));
field_byte_end_offset = ACPI_DIV_8(ACPI_ROUND_UP(field_bit_length +
field_bit_offset, 8));
field_byte_length = field_byte_end_offset - field_byte_offset;
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Bit length %d, Bit offset %d\n",
field_bit_length, field_bit_offset));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"Bit length %d, Bit offset %d\n",
field_bit_length, field_bit_offset));
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Byte Length %d, Byte Offset %d, End Offset %d\n",
field_byte_length, field_byte_offset, field_byte_end_offset));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"Byte Length %d, Byte Offset %d, End Offset %d\n",
field_byte_length, field_byte_offset,
field_byte_end_offset));
/*
* Iterative search for the maximum access width that is both aligned
@ -132,7 +121,8 @@ acpi_ex_generate_access (
*
* Start at byte_acc and work upwards to qword_acc max. (1,2,4,8 bytes)
*/
for (access_byte_width = 1; access_byte_width <= 8; access_byte_width <<= 1) {
for (access_byte_width = 1; access_byte_width <= 8;
access_byte_width <<= 1) {
/*
* 1) Round end offset up to next access boundary and make sure that
* this does not go beyond the end of the parent region.
@ -140,31 +130,37 @@ acpi_ex_generate_access (
* are done. (This does not optimize for the perfectly aligned
* case yet).
*/
if (ACPI_ROUND_UP (field_byte_end_offset, access_byte_width) <= region_length) {
if (ACPI_ROUND_UP(field_byte_end_offset, access_byte_width) <=
region_length) {
field_start_offset =
ACPI_ROUND_DOWN (field_byte_offset, access_byte_width) /
access_byte_width;
ACPI_ROUND_DOWN(field_byte_offset,
access_byte_width) /
access_byte_width;
field_end_offset =
ACPI_ROUND_UP ((field_byte_length + field_byte_offset),
access_byte_width) / access_byte_width;
ACPI_ROUND_UP((field_byte_length +
field_byte_offset),
access_byte_width) /
access_byte_width;
accesses = field_end_offset - field_start_offset;
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"access_width %d end is within region\n", access_byte_width));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"access_width %d end is within region\n",
access_byte_width));
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Field Start %d, Field End %d -- requires %d accesses\n",
field_start_offset, field_end_offset, accesses));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"Field Start %d, Field End %d -- requires %d accesses\n",
field_start_offset, field_end_offset,
accesses));
/* Single access is optimal */
if (accesses <= 1) {
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Entire field can be accessed with one operation of size %d\n",
access_byte_width));
return_VALUE (access_byte_width);
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"Entire field can be accessed with one operation of size %d\n",
access_byte_width));
return_VALUE(access_byte_width);
}
/*
@ -172,30 +168,30 @@ acpi_ex_generate_access (
* try the next wider access on next iteration
*/
if (accesses < minimum_accesses) {
minimum_accesses = accesses;
minimum_accesses = accesses;
minimum_access_width = access_byte_width;
}
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"access_width %d end is NOT within region\n", access_byte_width));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"access_width %d end is NOT within region\n",
access_byte_width));
if (access_byte_width == 1) {
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Field goes beyond end-of-region!\n"));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"Field goes beyond end-of-region!\n"));
/* Field does not fit in the region at all */
return_VALUE (0);
return_VALUE(0);
}
/*
* This width goes beyond the end-of-region, back off to
* previous access
*/
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Backing off to previous optimal access width of %d\n",
minimum_access_width));
return_VALUE (minimum_access_width);
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"Backing off to previous optimal access width of %d\n",
minimum_access_width));
return_VALUE(minimum_access_width);
}
}
@ -203,12 +199,11 @@ acpi_ex_generate_access (
* Could not read/write field with one operation,
* just use max access width
*/
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Cannot access field in one operation, using width 8\n"));
return_VALUE (8);
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"Cannot access field in one operation, using width 8\n"));
return_VALUE(8);
}
#endif /* ACPI_UNDER_DEVELOPMENT */
#endif /* ACPI_UNDER_DEVELOPMENT */
/*******************************************************************************
*
@ -226,18 +221,14 @@ acpi_ex_generate_access (
******************************************************************************/
static u32
acpi_ex_decode_field_access (
union acpi_operand_object *obj_desc,
u8 field_flags,
u32 *return_byte_alignment)
acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
u8 field_flags, u32 * return_byte_alignment)
{
u32 access;
u32 byte_alignment;
u32 bit_length;
ACPI_FUNCTION_TRACE ("ex_decode_field_access");
u32 access;
u32 byte_alignment;
u32 bit_length;
ACPI_FUNCTION_TRACE("ex_decode_field_access");
access = (field_flags & AML_FIELD_ACCESS_TYPE_MASK);
@ -246,9 +237,12 @@ acpi_ex_decode_field_access (
#ifdef ACPI_UNDER_DEVELOPMENT
byte_alignment =
acpi_ex_generate_access (obj_desc->common_field.start_field_bit_offset,
obj_desc->common_field.bit_length,
0xFFFFFFFF /* Temp until we pass region_length as parameter */);
acpi_ex_generate_access(obj_desc->common_field.
start_field_bit_offset,
obj_desc->common_field.bit_length,
0xFFFFFFFF
/* Temp until we pass region_length as parameter */
);
bit_length = byte_alignment * 8;
#endif
@ -257,36 +251,35 @@ acpi_ex_decode_field_access (
break;
case AML_FIELD_ACCESS_BYTE:
case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */
case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */
byte_alignment = 1;
bit_length = 8;
bit_length = 8;
break;
case AML_FIELD_ACCESS_WORD:
byte_alignment = 2;
bit_length = 16;
bit_length = 16;
break;
case AML_FIELD_ACCESS_DWORD:
byte_alignment = 4;
bit_length = 32;
bit_length = 32;
break;
case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */
case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */
byte_alignment = 8;
bit_length = 64;
bit_length = 64;
break;
default:
/* Invalid field access type */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unknown field access type %X\n",
access));
return_VALUE (0);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unknown field access type %X\n", access));
return_VALUE(0);
}
if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
/*
* buffer_field access can be on any byte boundary, so the
* byte_alignment is always 1 byte -- regardless of any byte_alignment
@ -296,10 +289,9 @@ acpi_ex_decode_field_access (
}
*return_byte_alignment = byte_alignment;
return_VALUE (bit_length);
return_VALUE(bit_length);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_prep_common_field_object
@ -322,20 +314,16 @@ acpi_ex_decode_field_access (
******************************************************************************/
acpi_status
acpi_ex_prep_common_field_object (
union acpi_operand_object *obj_desc,
u8 field_flags,
u8 field_attribute,
u32 field_bit_position,
u32 field_bit_length)
acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
u8 field_flags,
u8 field_attribute,
u32 field_bit_position, u32 field_bit_length)
{
u32 access_bit_width;
u32 byte_alignment;
u32 nearest_byte_address;
ACPI_FUNCTION_TRACE ("ex_prep_common_field_object");
u32 access_bit_width;
u32 byte_alignment;
u32 nearest_byte_address;
ACPI_FUNCTION_TRACE("ex_prep_common_field_object");
/*
* Note: the structure being initialized is the
@ -361,16 +349,16 @@ acpi_ex_prep_common_field_object (
* For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
* the same (equivalent) as the byte_alignment.
*/
access_bit_width = acpi_ex_decode_field_access (obj_desc, field_flags,
&byte_alignment);
access_bit_width = acpi_ex_decode_field_access(obj_desc, field_flags,
&byte_alignment);
if (!access_bit_width) {
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
}
/* Setup width (access granularity) fields */
obj_desc->common_field.access_byte_width = (u8)
ACPI_DIV_8 (access_bit_width); /* 1, 2, 4, 8 */
ACPI_DIV_8(access_bit_width); /* 1, 2, 4, 8 */
obj_desc->common_field.access_bit_width = (u8) access_bit_width;
@ -385,30 +373,30 @@ acpi_ex_prep_common_field_object (
* region or buffer.
*/
nearest_byte_address =
ACPI_ROUND_BITS_DOWN_TO_BYTES (field_bit_position);
ACPI_ROUND_BITS_DOWN_TO_BYTES(field_bit_position);
obj_desc->common_field.base_byte_offset = (u32)
ACPI_ROUND_DOWN (nearest_byte_address, byte_alignment);
ACPI_ROUND_DOWN(nearest_byte_address, byte_alignment);
/*
* start_field_bit_offset is the offset of the first bit of the field within
* a field datum.
*/
obj_desc->common_field.start_field_bit_offset = (u8)
(field_bit_position - ACPI_MUL_8 (obj_desc->common_field.base_byte_offset));
(field_bit_position -
ACPI_MUL_8(obj_desc->common_field.base_byte_offset));
/*
* Does the entire field fit within a single field access element? (datum)
* (i.e., without crossing a datum boundary)
*/
if ((obj_desc->common_field.start_field_bit_offset + field_bit_length) <=
(u16) access_bit_width) {
if ((obj_desc->common_field.start_field_bit_offset +
field_bit_length) <= (u16) access_bit_width) {
obj_desc->common.flags |= AOPOBJ_SINGLE_DATUM;
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_prep_field_value
@ -422,51 +410,49 @@ acpi_ex_prep_common_field_object (
*
******************************************************************************/
acpi_status
acpi_ex_prep_field_value (
struct acpi_create_field_info *info)
acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
{
union acpi_operand_object *obj_desc;
u32 type;
acpi_status status;
ACPI_FUNCTION_TRACE ("ex_prep_field_value");
union acpi_operand_object *obj_desc;
u32 type;
acpi_status status;
ACPI_FUNCTION_TRACE("ex_prep_field_value");
/* Parameter validation */
if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) {
if (!info->region_node) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null region_node\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null region_node\n"));
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
type = acpi_ns_get_type (info->region_node);
type = acpi_ns_get_type(info->region_node);
if (type != ACPI_TYPE_REGION) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed Region, found type %X (%s)\n",
type, acpi_ut_get_type_name (type)));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed Region, found type %X (%s)\n",
type, acpi_ut_get_type_name(type)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
}
/* Allocate a new field object */
obj_desc = acpi_ut_create_internal_object (info->field_type);
obj_desc = acpi_ut_create_internal_object(info->field_type);
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Initialize areas of the object that are common to all fields */
obj_desc->common_field.node = info->field_node;
status = acpi_ex_prep_common_field_object (obj_desc, info->field_flags,
info->attribute, info->field_bit_position, info->field_bit_length);
if (ACPI_FAILURE (status)) {
acpi_ut_delete_object_desc (obj_desc);
return_ACPI_STATUS (status);
status = acpi_ex_prep_common_field_object(obj_desc, info->field_flags,
info->attribute,
info->field_bit_position,
info->field_bit_length);
if (ACPI_FAILURE(status)) {
acpi_ut_delete_object_desc(obj_desc);
return_ACPI_STATUS(status);
}
/* Initialize areas of the object that are specific to the field type */
@ -474,71 +460,73 @@ acpi_ex_prep_field_value (
switch (info->field_type) {
case ACPI_TYPE_LOCAL_REGION_FIELD:
obj_desc->field.region_obj = acpi_ns_get_attached_object (info->region_node);
obj_desc->field.region_obj =
acpi_ns_get_attached_object(info->region_node);
/* An additional reference for the container */
acpi_ut_add_reference (obj_desc->field.region_obj);
acpi_ut_add_reference(obj_desc->field.region_obj);
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"region_field: bit_off %X, Off %X, Gran %X, Region %p\n",
obj_desc->field.start_field_bit_offset, obj_desc->field.base_byte_offset,
obj_desc->field.access_byte_width, obj_desc->field.region_obj));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"region_field: bit_off %X, Off %X, Gran %X, Region %p\n",
obj_desc->field.start_field_bit_offset,
obj_desc->field.base_byte_offset,
obj_desc->field.access_byte_width,
obj_desc->field.region_obj));
break;
case ACPI_TYPE_LOCAL_BANK_FIELD:
obj_desc->bank_field.value = info->bank_value;
obj_desc->bank_field.region_obj = acpi_ns_get_attached_object (
info->region_node);
obj_desc->bank_field.bank_obj = acpi_ns_get_attached_object (
info->register_node);
obj_desc->bank_field.value = info->bank_value;
obj_desc->bank_field.region_obj =
acpi_ns_get_attached_object(info->region_node);
obj_desc->bank_field.bank_obj =
acpi_ns_get_attached_object(info->register_node);
/* An additional reference for the attached objects */
acpi_ut_add_reference (obj_desc->bank_field.region_obj);
acpi_ut_add_reference (obj_desc->bank_field.bank_obj);
acpi_ut_add_reference(obj_desc->bank_field.region_obj);
acpi_ut_add_reference(obj_desc->bank_field.bank_obj);
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Bank Field: bit_off %X, Off %X, Gran %X, Region %p, bank_reg %p\n",
obj_desc->bank_field.start_field_bit_offset,
obj_desc->bank_field.base_byte_offset,
obj_desc->field.access_byte_width,
obj_desc->bank_field.region_obj,
obj_desc->bank_field.bank_obj));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"Bank Field: bit_off %X, Off %X, Gran %X, Region %p, bank_reg %p\n",
obj_desc->bank_field.start_field_bit_offset,
obj_desc->bank_field.base_byte_offset,
obj_desc->field.access_byte_width,
obj_desc->bank_field.region_obj,
obj_desc->bank_field.bank_obj));
break;
case ACPI_TYPE_LOCAL_INDEX_FIELD:
obj_desc->index_field.index_obj = acpi_ns_get_attached_object (
info->register_node);
obj_desc->index_field.data_obj = acpi_ns_get_attached_object (
info->data_register_node);
obj_desc->index_field.value = (u32)
(info->field_bit_position / ACPI_MUL_8 (
obj_desc->field.access_byte_width));
obj_desc->index_field.index_obj =
acpi_ns_get_attached_object(info->register_node);
obj_desc->index_field.data_obj =
acpi_ns_get_attached_object(info->data_register_node);
obj_desc->index_field.value = (u32)
(info->field_bit_position /
ACPI_MUL_8(obj_desc->field.access_byte_width));
if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) {
ACPI_REPORT_ERROR (("Null Index Object during field prep\n"));
acpi_ut_delete_object_desc (obj_desc);
return_ACPI_STATUS (AE_AML_INTERNAL);
if (!obj_desc->index_field.data_obj
|| !obj_desc->index_field.index_obj) {
ACPI_REPORT_ERROR(("Null Index Object during field prep\n"));
acpi_ut_delete_object_desc(obj_desc);
return_ACPI_STATUS(AE_AML_INTERNAL);
}
/* An additional reference for the attached objects */
acpi_ut_add_reference (obj_desc->index_field.data_obj);
acpi_ut_add_reference (obj_desc->index_field.index_obj);
acpi_ut_add_reference(obj_desc->index_field.data_obj);
acpi_ut_add_reference(obj_desc->index_field.index_obj);
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
obj_desc->index_field.start_field_bit_offset,
obj_desc->index_field.base_byte_offset,
obj_desc->index_field.value,
obj_desc->field.access_byte_width,
obj_desc->index_field.index_obj,
obj_desc->index_field.data_obj));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
obj_desc->index_field.start_field_bit_offset,
obj_desc->index_field.base_byte_offset,
obj_desc->index_field.value,
obj_desc->field.access_byte_width,
obj_desc->index_field.index_obj,
obj_desc->index_field.data_obj));
break;
default:
@ -550,15 +538,16 @@ acpi_ex_prep_field_value (
* Store the constructed descriptor (obj_desc) into the parent Node,
* preserving the current type of that named_obj.
*/
status = acpi_ns_attach_object (info->field_node, obj_desc,
acpi_ns_get_type (info->field_node));
status = acpi_ns_attach_object(info->field_node, obj_desc,
acpi_ns_get_type(info->field_node));
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set named_obj %p [%4.4s], obj_desc %p\n",
info->field_node, acpi_ut_get_node_name (info->field_node), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"Set named_obj %p [%4.4s], obj_desc %p\n",
info->field_node,
acpi_ut_get_node_name(info->field_node), obj_desc));
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}

View File

@ -42,14 +42,11 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exregion")
ACPI_MODULE_NAME("exregion")
/*******************************************************************************
*
@ -68,27 +65,23 @@
* DESCRIPTION: Handler for the System Memory address space (Op Region)
*
******************************************************************************/
acpi_status
acpi_ex_system_memory_space_handler (
u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer *value,
void *handler_context,
void *region_context)
acpi_ex_system_memory_space_handler(u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer * value,
void *handler_context, void *region_context)
{
acpi_status status = AE_OK;
void *logical_addr_ptr = NULL;
struct acpi_mem_space_context *mem_info = region_context;
u32 length;
acpi_size window_size;
acpi_status status = AE_OK;
void *logical_addr_ptr = NULL;
struct acpi_mem_space_context *mem_info = region_context;
u32 length;
acpi_size window_size;
#ifndef ACPI_MISALIGNED_TRANSFERS
u32 remainder;
u32 remainder;
#endif
ACPI_FUNCTION_TRACE ("ex_system_memory_space_handler");
ACPI_FUNCTION_TRACE("ex_system_memory_space_handler");
/* Validate and translate the bit width */
@ -110,9 +103,10 @@ acpi_ex_system_memory_space_handler (
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid system_memory width %d\n",
bit_width));
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Invalid system_memory width %d\n",
bit_width));
return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
}
#ifndef ACPI_MISALIGNED_TRANSFERS
@ -120,9 +114,10 @@ acpi_ex_system_memory_space_handler (
* Hardware does not support non-aligned data transfers, we must verify
* the request.
*/
(void) acpi_ut_short_divide ((acpi_integer) address, length, NULL, &remainder);
(void)acpi_ut_short_divide((acpi_integer) address, length, NULL,
&remainder);
if (remainder != 0) {
return_ACPI_STATUS (AE_AML_ALIGNMENT);
return_ACPI_STATUS(AE_AML_ALIGNMENT);
}
#endif
@ -132,9 +127,10 @@ acpi_ex_system_memory_space_handler (
* 2) Address beyond the current mapping?
*/
if ((address < mem_info->mapped_physical_address) ||
(((acpi_integer) address + length) >
((acpi_integer)
mem_info->mapped_physical_address + mem_info->mapped_length))) {
(((acpi_integer) address + length) > ((acpi_integer)
mem_info->
mapped_physical_address +
mem_info->mapped_length))) {
/*
* The request cannot be resolved by the current memory mapping;
* Delete the existing mapping and create a new one.
@ -142,8 +138,8 @@ acpi_ex_system_memory_space_handler (
if (mem_info->mapped_length) {
/* Valid mapping, delete it */
acpi_os_unmap_memory (mem_info->mapped_logical_address,
mem_info->mapped_length);
acpi_os_unmap_memory(mem_info->mapped_logical_address,
mem_info->mapped_length);
}
/*
@ -151,7 +147,7 @@ acpi_ex_system_memory_space_handler (
* constrain the maximum mapping size to something reasonable.
*/
window_size = (acpi_size)
((mem_info->address + mem_info->length) - address);
((mem_info->address + mem_info->length) - address);
if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) {
window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE;
@ -159,14 +155,16 @@ acpi_ex_system_memory_space_handler (
/* Create a new mapping starting at the address given */
status = acpi_os_map_memory (address, window_size,
(void **) &mem_info->mapped_logical_address);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not map memory at %8.8X%8.8X, size %X\n",
ACPI_FORMAT_UINT64 (address), (u32) window_size));
status = acpi_os_map_memory(address, window_size,
(void **)&mem_info->
mapped_logical_address);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Could not map memory at %8.8X%8.8X, size %X\n",
ACPI_FORMAT_UINT64(address),
(u32) window_size));
mem_info->mapped_length = 0;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/* Save the physical address and mapping size */
@ -180,42 +178,41 @@ acpi_ex_system_memory_space_handler (
* access
*/
logical_addr_ptr = mem_info->mapped_logical_address +
((acpi_integer) address -
(acpi_integer) mem_info->mapped_physical_address);
((acpi_integer) address -
(acpi_integer) mem_info->mapped_physical_address);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"system_memory %d (%d width) Address=%8.8X%8.8X\n",
function, bit_width,
ACPI_FORMAT_UINT64 (address)));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"system_memory %d (%d width) Address=%8.8X%8.8X\n",
function, bit_width, ACPI_FORMAT_UINT64(address)));
/*
* Perform the memory read or write
*
* Note: For machines that do not support non-aligned transfers, the target
* address was checked for alignment above. We do not attempt to break the
* transfer up into smaller (byte-size) chunks because the AML specifically
* asked for a transfer width that the hardware may require.
*/
/*
* Perform the memory read or write
*
* Note: For machines that do not support non-aligned transfers, the target
* address was checked for alignment above. We do not attempt to break the
* transfer up into smaller (byte-size) chunks because the AML specifically
* asked for a transfer width that the hardware may require.
*/
switch (function) {
case ACPI_READ:
*value = 0;
switch (bit_width) {
case 8:
*value = (acpi_integer) *((u8 *) logical_addr_ptr);
*value = (acpi_integer) * ((u8 *) logical_addr_ptr);
break;
case 16:
*value = (acpi_integer) *((u16 *) logical_addr_ptr);
*value = (acpi_integer) * ((u16 *) logical_addr_ptr);
break;
case 32:
*value = (acpi_integer) *((u32 *) logical_addr_ptr);
*value = (acpi_integer) * ((u32 *) logical_addr_ptr);
break;
#if ACPI_MACHINE_WIDTH != 16
case 64:
*value = (acpi_integer) *((u64 *) logical_addr_ptr);
*value = (acpi_integer) * ((u64 *) logical_addr_ptr);
break;
#endif
default:
@ -228,20 +225,20 @@ acpi_ex_system_memory_space_handler (
switch (bit_width) {
case 8:
*(u8 *) logical_addr_ptr = (u8) *value;
*(u8 *) logical_addr_ptr = (u8) * value;
break;
case 16:
*(u16 *) logical_addr_ptr = (u16) *value;
*(u16 *) logical_addr_ptr = (u16) * value;
break;
case 32:
*(u32 *) logical_addr_ptr = (u32) *value;
*(u32 *) logical_addr_ptr = (u32) * value;
break;
#if ACPI_MACHINE_WIDTH != 16
case 64:
*(u64 *) logical_addr_ptr = (u64) *value;
*(u64 *) logical_addr_ptr = (u64) * value;
break;
#endif
@ -256,10 +253,9 @@ acpi_ex_system_memory_space_handler (
break;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_system_io_space_handler
@ -279,39 +275,35 @@ acpi_ex_system_memory_space_handler (
******************************************************************************/
acpi_status
acpi_ex_system_io_space_handler (
u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer *value,
void *handler_context,
void *region_context)
acpi_ex_system_io_space_handler(u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer * value,
void *handler_context, void *region_context)
{
acpi_status status = AE_OK;
u32 value32;
acpi_status status = AE_OK;
u32 value32;
ACPI_FUNCTION_TRACE("ex_system_io_space_handler");
ACPI_FUNCTION_TRACE ("ex_system_io_space_handler");
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"system_iO %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
ACPI_FORMAT_UINT64 (address)));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"system_iO %d (%d width) Address=%8.8X%8.8X\n",
function, bit_width, ACPI_FORMAT_UINT64(address)));
/* Decode the function parameter */
switch (function) {
case ACPI_READ:
status = acpi_os_read_port ((acpi_io_address) address,
&value32, bit_width);
status = acpi_os_read_port((acpi_io_address) address,
&value32, bit_width);
*value = value32;
break;
case ACPI_WRITE:
status = acpi_os_write_port ((acpi_io_address) address,
(u32) *value, bit_width);
status = acpi_os_write_port((acpi_io_address) address,
(u32) * value, bit_width);
break;
default:
@ -319,10 +311,9 @@ acpi_ex_system_io_space_handler (
break;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_pci_config_space_handler
@ -342,21 +333,17 @@ acpi_ex_system_io_space_handler (
******************************************************************************/
acpi_status
acpi_ex_pci_config_space_handler (
u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer *value,
void *handler_context,
void *region_context)
acpi_ex_pci_config_space_handler(u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer * value,
void *handler_context, void *region_context)
{
acpi_status status = AE_OK;
struct acpi_pci_id *pci_id;
u16 pci_register;
ACPI_FUNCTION_TRACE ("ex_pci_config_space_handler");
acpi_status status = AE_OK;
struct acpi_pci_id *pci_id;
u16 pci_register;
ACPI_FUNCTION_TRACE("ex_pci_config_space_handler");
/*
* The arguments to acpi_os(Read|Write)pci_configuration are:
@ -370,26 +357,26 @@ acpi_ex_pci_config_space_handler (
* Value - input value for write, output address for read
*
*/
pci_id = (struct acpi_pci_id *) region_context;
pci_id = (struct acpi_pci_id *)region_context;
pci_register = (u16) (u32) address;
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
function, bit_width, pci_id->segment, pci_id->bus, pci_id->device,
pci_id->function, pci_register));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
function, bit_width, pci_id->segment, pci_id->bus,
pci_id->device, pci_id->function, pci_register));
switch (function) {
case ACPI_READ:
*value = 0;
status = acpi_os_read_pci_configuration (pci_id, pci_register,
value, bit_width);
status = acpi_os_read_pci_configuration(pci_id, pci_register,
value, bit_width);
break;
case ACPI_WRITE:
status = acpi_os_write_pci_configuration (pci_id, pci_register,
*value, bit_width);
status = acpi_os_write_pci_configuration(pci_id, pci_register,
*value, bit_width);
break;
default:
@ -398,10 +385,9 @@ acpi_ex_pci_config_space_handler (
break;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_cmos_space_handler
@ -421,24 +407,19 @@ acpi_ex_pci_config_space_handler (
******************************************************************************/
acpi_status
acpi_ex_cmos_space_handler (
u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer *value,
void *handler_context,
void *region_context)
acpi_ex_cmos_space_handler(u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer * value,
void *handler_context, void *region_context)
{
acpi_status status = AE_OK;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ex_cmos_space_handler");
ACPI_FUNCTION_TRACE ("ex_cmos_space_handler");
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_pci_bar_space_handler
@ -458,24 +439,19 @@ acpi_ex_cmos_space_handler (
******************************************************************************/
acpi_status
acpi_ex_pci_bar_space_handler (
u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer *value,
void *handler_context,
void *region_context)
acpi_ex_pci_bar_space_handler(u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer * value,
void *handler_context, void *region_context)
{
acpi_status status = AE_OK;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ex_pci_bar_space_handler");
ACPI_FUNCTION_TRACE ("ex_pci_bar_space_handler");
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_data_table_space_handler
@ -495,24 +471,20 @@ acpi_ex_pci_bar_space_handler (
******************************************************************************/
acpi_status
acpi_ex_data_table_space_handler (
u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer *value,
void *handler_context,
void *region_context)
acpi_ex_data_table_space_handler(u32 function,
acpi_physical_address address,
u32 bit_width,
acpi_integer * value,
void *handler_context, void *region_context)
{
acpi_status status = AE_OK;
u32 byte_width = ACPI_DIV_8 (bit_width);
u32 i;
char *logical_addr_ptr;
acpi_status status = AE_OK;
u32 byte_width = ACPI_DIV_8(bit_width);
u32 i;
char *logical_addr_ptr;
ACPI_FUNCTION_TRACE("ex_data_table_space_handler");
ACPI_FUNCTION_TRACE ("ex_data_table_space_handler");
logical_addr_ptr = ACPI_PHYSADDR_TO_PTR (address);
logical_addr_ptr = ACPI_PHYSADDR_TO_PTR(address);
/* Perform the memory read or write */
@ -520,17 +492,15 @@ acpi_ex_data_table_space_handler (
case ACPI_READ:
for (i = 0; i < byte_width; i++) {
((char *) value) [i] = logical_addr_ptr[i];
((char *)value)[i] = logical_addr_ptr[i];
}
break;
case ACPI_WRITE:
default:
return_ACPI_STATUS (AE_SUPPORT);
return_ACPI_STATUS(AE_SUPPORT);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -42,7 +42,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acdispat.h>
#include <acpi/acinterp.h>
@ -50,10 +49,8 @@
#include <acpi/acparser.h>
#include <acpi/amlcode.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exresnte")
ACPI_MODULE_NAME("exresnte")
/*******************************************************************************
*
@ -80,41 +77,37 @@
* ACPI_TYPE_PACKAGE
*
******************************************************************************/
acpi_status
acpi_ex_resolve_node_to_value (
struct acpi_namespace_node **object_ptr,
struct acpi_walk_state *walk_state)
acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
struct acpi_walk_state *walk_state)
{
acpi_status status = AE_OK;
union acpi_operand_object *source_desc;
union acpi_operand_object *obj_desc = NULL;
struct acpi_namespace_node *node;
acpi_object_type entry_type;
ACPI_FUNCTION_TRACE ("ex_resolve_node_to_value");
acpi_status status = AE_OK;
union acpi_operand_object *source_desc;
union acpi_operand_object *obj_desc = NULL;
struct acpi_namespace_node *node;
acpi_object_type entry_type;
ACPI_FUNCTION_TRACE("ex_resolve_node_to_value");
/*
* The stack pointer points to a struct acpi_namespace_node (Node). Get the
* object that is attached to the Node.
*/
node = *object_ptr;
source_desc = acpi_ns_get_attached_object (node);
entry_type = acpi_ns_get_type ((acpi_handle) node);
node = *object_ptr;
source_desc = acpi_ns_get_attached_object(node);
entry_type = acpi_ns_get_type((acpi_handle) node);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p source_desc=%p [%s]\n",
node, source_desc, acpi_ut_get_type_name (entry_type)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Entry=%p source_desc=%p [%s]\n",
node, source_desc,
acpi_ut_get_type_name(entry_type)));
if ((entry_type == ACPI_TYPE_LOCAL_ALIAS) ||
(entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
(entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
/* There is always exactly one level of indirection */
node = ACPI_CAST_PTR (struct acpi_namespace_node, node->object);
source_desc = acpi_ns_get_attached_object (node);
entry_type = acpi_ns_get_type ((acpi_handle) node);
node = ACPI_CAST_PTR(struct acpi_namespace_node, node->object);
source_desc = acpi_ns_get_attached_object(node);
entry_type = acpi_ns_get_type((acpi_handle) node);
*object_ptr = node;
}
@ -124,14 +117,14 @@ acpi_ex_resolve_node_to_value (
* 2) Method locals and arguments have a pseudo-Node
*/
if (entry_type == ACPI_TYPE_DEVICE ||
(node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) {
return_ACPI_STATUS (AE_OK);
(node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) {
return_ACPI_STATUS(AE_OK);
}
if (!source_desc) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object attached to node %p\n",
node));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"No object attached to node %p\n", node));
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
/*
@ -141,83 +134,89 @@ acpi_ex_resolve_node_to_value (
switch (entry_type) {
case ACPI_TYPE_PACKAGE:
if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_PACKAGE) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Package, type %s\n",
acpi_ut_get_object_type_name (source_desc)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Object not a Package, type %s\n",
acpi_ut_get_object_type_name
(source_desc)));
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
status = acpi_ds_get_package_arguments (source_desc);
if (ACPI_SUCCESS (status)) {
status = acpi_ds_get_package_arguments(source_desc);
if (ACPI_SUCCESS(status)) {
/* Return an additional reference to the object */
obj_desc = source_desc;
acpi_ut_add_reference (obj_desc);
acpi_ut_add_reference(obj_desc);
}
break;
case ACPI_TYPE_BUFFER:
if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Buffer, type %s\n",
acpi_ut_get_object_type_name (source_desc)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Object not a Buffer, type %s\n",
acpi_ut_get_object_type_name
(source_desc)));
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
status = acpi_ds_get_buffer_arguments (source_desc);
if (ACPI_SUCCESS (status)) {
status = acpi_ds_get_buffer_arguments(source_desc);
if (ACPI_SUCCESS(status)) {
/* Return an additional reference to the object */
obj_desc = source_desc;
acpi_ut_add_reference (obj_desc);
acpi_ut_add_reference(obj_desc);
}
break;
case ACPI_TYPE_STRING:
if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a String, type %s\n",
acpi_ut_get_object_type_name (source_desc)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Object not a String, type %s\n",
acpi_ut_get_object_type_name
(source_desc)));
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/* Return an additional reference to the object */
obj_desc = source_desc;
acpi_ut_add_reference (obj_desc);
acpi_ut_add_reference(obj_desc);
break;
case ACPI_TYPE_INTEGER:
if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Integer, type %s\n",
acpi_ut_get_object_type_name (source_desc)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Object not a Integer, type %s\n",
acpi_ut_get_object_type_name
(source_desc)));
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/* Return an additional reference to the object */
obj_desc = source_desc;
acpi_ut_add_reference (obj_desc);
acpi_ut_add_reference(obj_desc);
break;
case ACPI_TYPE_BUFFER_FIELD:
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"field_read Node=%p source_desc=%p Type=%X\n",
node, source_desc, entry_type));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"field_read Node=%p source_desc=%p Type=%X\n",
node, source_desc, entry_type));
status = acpi_ex_read_data_from_field (walk_state, source_desc, &obj_desc);
status =
acpi_ex_read_data_from_field(walk_state, source_desc,
&obj_desc);
break;
/* For these objects, just return the object attached to the Node */
/* For these objects, just return the object attached to the Node */
case ACPI_TYPE_MUTEX:
case ACPI_TYPE_METHOD:
@ -230,19 +229,18 @@ acpi_ex_resolve_node_to_value (
/* Return an additional reference to the object */
obj_desc = source_desc;
acpi_ut_add_reference (obj_desc);
acpi_ut_add_reference(obj_desc);
break;
/* TYPE_ANY is untyped, and thus there is no object associated with it */
/* TYPE_ANY is untyped, and thus there is no object associated with it */
case ACPI_TYPE_ANY:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Untyped entry %p, no attached object!\n",
node));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Untyped entry %p, no attached object!\n",
node));
return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
case ACPI_TYPE_LOCAL_REFERENCE:
@ -253,39 +251,37 @@ acpi_ex_resolve_node_to_value (
/* Return an additional reference to the object */
obj_desc = source_desc;
acpi_ut_add_reference (obj_desc);
acpi_ut_add_reference(obj_desc);
break;
default:
/* No named references are allowed here */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unsupported Reference opcode %X (%s)\n",
source_desc->reference.opcode,
acpi_ps_get_opcode_name (source_desc->reference.opcode)));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unsupported Reference opcode %X (%s)\n",
source_desc->reference.opcode,
acpi_ps_get_opcode_name(source_desc->
reference.
opcode)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
break;
default:
/* Default case is for unknown types */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Node %p - Unknown object type %X\n",
node, entry_type));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Node %p - Unknown object type %X\n",
node, entry_type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
} /* switch (entry_type) */
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
} /* switch (entry_type) */
/* Return the object descriptor */
*object_ptr = (void *) obj_desc;
return_ACPI_STATUS (status);
*object_ptr = (void *)obj_desc;
return_ACPI_STATUS(status);
}

View File

@ -42,7 +42,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/amlcode.h>
#include <acpi/acdispat.h>
@ -50,17 +49,13 @@
#include <acpi/acnamesp.h>
#include <acpi/acparser.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exresolv")
ACPI_MODULE_NAME("exresolv")
/* Local prototypes */
static acpi_status
acpi_ex_resolve_object_to_value (
union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state);
acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state);
/*******************************************************************************
*
@ -78,19 +73,16 @@ acpi_ex_resolve_object_to_value (
******************************************************************************/
acpi_status
acpi_ex_resolve_to_value (
union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state)
acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state)
{
acpi_status status;
ACPI_FUNCTION_TRACE_PTR ("ex_resolve_to_value", stack_ptr);
acpi_status status;
ACPI_FUNCTION_TRACE_PTR("ex_resolve_to_value", stack_ptr);
if (!stack_ptr || !*stack_ptr) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Internal - null pointer\n"));
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
/*
@ -98,15 +90,16 @@ acpi_ex_resolve_to_value (
* 1) A valid union acpi_operand_object, or
* 2) A struct acpi_namespace_node (named_obj)
*/
if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_OPERAND) {
status = acpi_ex_resolve_object_to_value (stack_ptr, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
if (ACPI_GET_DESCRIPTOR_TYPE(*stack_ptr) == ACPI_DESC_TYPE_OPERAND) {
status = acpi_ex_resolve_object_to_value(stack_ptr, walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
if (!*stack_ptr) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Internal - null pointer\n"));
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
}
@ -114,20 +107,20 @@ acpi_ex_resolve_to_value (
* Object on the stack may have changed if acpi_ex_resolve_object_to_value()
* was called (i.e., we can't use an _else_ here.)
*/
if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_NAMED) {
status = acpi_ex_resolve_node_to_value (
ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, stack_ptr),
walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
if (ACPI_GET_DESCRIPTOR_TYPE(*stack_ptr) == ACPI_DESC_TYPE_NAMED) {
status =
acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR
(struct acpi_namespace_node,
stack_ptr), walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *stack_ptr));
return_ACPI_STATUS (AE_OK);
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Resolved object %p\n", *stack_ptr));
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_resolve_object_to_value
@ -143,25 +136,22 @@ acpi_ex_resolve_to_value (
******************************************************************************/
static acpi_status
acpi_ex_resolve_object_to_value (
union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state)
acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state)
{
acpi_status status = AE_OK;
union acpi_operand_object *stack_desc;
void *temp_node;
union acpi_operand_object *obj_desc;
u16 opcode;
ACPI_FUNCTION_TRACE ("ex_resolve_object_to_value");
acpi_status status = AE_OK;
union acpi_operand_object *stack_desc;
void *temp_node;
union acpi_operand_object *obj_desc;
u16 opcode;
ACPI_FUNCTION_TRACE("ex_resolve_object_to_value");
stack_desc = *stack_ptr;
/* This is an union acpi_operand_object */
switch (ACPI_GET_OBJECT_TYPE (stack_desc)) {
switch (ACPI_GET_OBJECT_TYPE(stack_desc)) {
case ACPI_TYPE_LOCAL_REFERENCE:
opcode = stack_desc->reference.opcode;
@ -177,14 +167,13 @@ acpi_ex_resolve_object_to_value (
/* Delete the Reference Object */
acpi_ut_remove_reference (stack_desc);
acpi_ut_remove_reference(stack_desc);
/* Return the namespace node */
(*stack_ptr) = temp_node;
break;
case AML_LOCAL_OP:
case AML_ARG_OP:
@ -192,24 +181,28 @@ acpi_ex_resolve_object_to_value (
* Get the local from the method's state info
* Note: this increments the local's object reference count
*/
status = acpi_ds_method_data_get_value (opcode,
stack_desc->reference.offset, walk_state, &obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ds_method_data_get_value(opcode,
stack_desc->
reference.offset,
walk_state,
&obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] value_obj is %p\n",
stack_desc->reference.offset, obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"[Arg/Local %X] value_obj is %p\n",
stack_desc->reference.offset,
obj_desc));
/*
* Now we can delete the original Reference Object and
* replace it with the resolved value
*/
acpi_ut_remove_reference (stack_desc);
acpi_ut_remove_reference(stack_desc);
*stack_ptr = obj_desc;
break;
case AML_INDEX_OP:
switch (stack_desc->reference.target_type) {
@ -218,7 +211,6 @@ acpi_ex_resolve_object_to_value (
/* Just return - leave the Reference on the stack */
break;
case ACPI_TYPE_PACKAGE:
obj_desc = *stack_desc->reference.where;
@ -228,36 +220,31 @@ acpi_ex_resolve_object_to_value (
* (i.e., dereference the package index)
* Delete the ref object, increment the returned object
*/
acpi_ut_remove_reference (stack_desc);
acpi_ut_add_reference (obj_desc);
acpi_ut_remove_reference(stack_desc);
acpi_ut_add_reference(obj_desc);
*stack_ptr = obj_desc;
}
else {
} else {
/*
* A NULL object descriptor means an unitialized element of
* the package, can't dereference it
*/
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Attempt to deref an Index to NULL pkg element Idx=%p\n",
stack_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Attempt to deref an Index to NULL pkg element Idx=%p\n",
stack_desc));
status = AE_AML_UNINITIALIZED_ELEMENT;
}
break;
default:
/* Invalid reference object */
ACPI_REPORT_ERROR ((
"During resolve, Unknown target_type %X in Index/Reference obj %p\n",
stack_desc->reference.target_type, stack_desc));
ACPI_REPORT_ERROR(("During resolve, Unknown target_type %X in Index/Reference obj %p\n", stack_desc->reference.target_type, stack_desc));
status = AE_AML_INTERNAL;
break;
}
break;
case AML_REF_OF_OP:
case AML_DEBUG_OP:
case AML_LOAD_OP:
@ -266,60 +253,58 @@ acpi_ex_resolve_object_to_value (
break;
case AML_INT_NAMEPATH_OP: /* Reference to a named object */
case AML_INT_NAMEPATH_OP: /* Reference to a named object */
/* Get the object pointed to by the namespace node */
*stack_ptr = (stack_desc->reference.node)->object;
acpi_ut_add_reference (*stack_ptr);
acpi_ut_remove_reference (stack_desc);
acpi_ut_add_reference(*stack_ptr);
acpi_ut_remove_reference(stack_desc);
break;
default:
ACPI_REPORT_ERROR ((
"During resolve, Unknown Reference opcode %X (%s) in %p\n",
opcode, acpi_ps_get_opcode_name (opcode), stack_desc));
ACPI_REPORT_ERROR(("During resolve, Unknown Reference opcode %X (%s) in %p\n", opcode, acpi_ps_get_opcode_name(opcode), stack_desc));
status = AE_AML_INTERNAL;
break;
}
break;
case ACPI_TYPE_BUFFER:
status = acpi_ds_get_buffer_arguments (stack_desc);
status = acpi_ds_get_buffer_arguments(stack_desc);
break;
case ACPI_TYPE_PACKAGE:
status = acpi_ds_get_package_arguments (stack_desc);
status = acpi_ds_get_package_arguments(stack_desc);
break;
/* These cases may never happen here, but just in case.. */
/* These cases may never happen here, but just in case.. */
case ACPI_TYPE_BUFFER_FIELD:
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "field_read source_desc=%p Type=%X\n",
stack_desc, ACPI_GET_OBJECT_TYPE (stack_desc)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"field_read source_desc=%p Type=%X\n",
stack_desc,
ACPI_GET_OBJECT_TYPE(stack_desc)));
status = acpi_ex_read_data_from_field (walk_state, stack_desc, &obj_desc);
*stack_ptr = (void *) obj_desc;
status =
acpi_ex_read_data_from_field(walk_state, stack_desc,
&obj_desc);
*stack_ptr = (void *)obj_desc;
break;
default:
break;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_resolve_multiple
@ -337,42 +322,44 @@ acpi_ex_resolve_object_to_value (
******************************************************************************/
acpi_status
acpi_ex_resolve_multiple (
struct acpi_walk_state *walk_state,
union acpi_operand_object *operand,
acpi_object_type *return_type,
union acpi_operand_object **return_desc)
acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
union acpi_operand_object *operand,
acpi_object_type * return_type,
union acpi_operand_object **return_desc)
{
union acpi_operand_object *obj_desc = (void *) operand;
struct acpi_namespace_node *node;
acpi_object_type type;
acpi_status status;
ACPI_FUNCTION_TRACE ("acpi_ex_resolve_multiple");
union acpi_operand_object *obj_desc = (void *)operand;
struct acpi_namespace_node *node;
acpi_object_type type;
acpi_status status;
ACPI_FUNCTION_TRACE("acpi_ex_resolve_multiple");
/* Operand can be either a namespace node or an operand descriptor */
switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
case ACPI_DESC_TYPE_OPERAND:
type = obj_desc->common.type;
break;
case ACPI_DESC_TYPE_NAMED:
type = ((struct acpi_namespace_node *) obj_desc)->type;
obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc);
type = ((struct acpi_namespace_node *)obj_desc)->type;
obj_desc =
acpi_ns_get_attached_object((struct acpi_namespace_node *)
obj_desc);
/* If we had an Alias node, use the attached object for type info */
if (type == ACPI_TYPE_LOCAL_ALIAS) {
type = ((struct acpi_namespace_node *) obj_desc)->type;
obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc);
type = ((struct acpi_namespace_node *)obj_desc)->type;
obj_desc =
acpi_ns_get_attached_object((struct
acpi_namespace_node *)
obj_desc);
}
break;
default:
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/* If type is anything other than a reference, we are done */
@ -387,7 +374,7 @@ acpi_ex_resolve_multiple (
* of the object_type and size_of operators). This means traversing
* the list of possibly many nested references.
*/
while (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) {
while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) {
switch (obj_desc->reference.opcode) {
case AML_REF_OF_OP:
@ -397,31 +384,29 @@ acpi_ex_resolve_multiple (
/* All "References" point to a NS node */
if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
ACPI_REPORT_ERROR ((
"acpi_ex_resolve_multiple: Not a NS node %p [%s]\n",
node, acpi_ut_get_descriptor_name (node)));
return_ACPI_STATUS (AE_AML_INTERNAL);
if (ACPI_GET_DESCRIPTOR_TYPE(node) !=
ACPI_DESC_TYPE_NAMED) {
ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node)));
return_ACPI_STATUS(AE_AML_INTERNAL);
}
/* Get the attached object */
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
/* No object, use the NS node type */
type = acpi_ns_get_type (node);
type = acpi_ns_get_type(node);
goto exit;
}
/* Check for circular references */
if (obj_desc == operand) {
return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
return_ACPI_STATUS(AE_AML_CIRCULAR_REFERENCE);
}
break;
case AML_INDEX_OP:
/* Get the type of this reference (index into another object) */
@ -442,12 +427,11 @@ acpi_ex_resolve_multiple (
if (!obj_desc) {
/* NULL package elements are allowed */
type = 0; /* Uninitialized */
type = 0; /* Uninitialized */
goto exit;
}
break;
case AML_INT_NAMEPATH_OP:
/* Dereference the reference pointer */
@ -456,50 +440,61 @@ acpi_ex_resolve_multiple (
/* All "References" point to a NS node */
if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
ACPI_REPORT_ERROR ((
"acpi_ex_resolve_multiple: Not a NS node %p [%s]\n",
node, acpi_ut_get_descriptor_name (node)));
return_ACPI_STATUS (AE_AML_INTERNAL);
if (ACPI_GET_DESCRIPTOR_TYPE(node) !=
ACPI_DESC_TYPE_NAMED) {
ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node)));
return_ACPI_STATUS(AE_AML_INTERNAL);
}
/* Get the attached object */
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
/* No object, use the NS node type */
type = acpi_ns_get_type (node);
type = acpi_ns_get_type(node);
goto exit;
}
/* Check for circular references */
if (obj_desc == operand) {
return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
return_ACPI_STATUS(AE_AML_CIRCULAR_REFERENCE);
}
break;
case AML_LOCAL_OP:
case AML_ARG_OP:
if (return_desc) {
status = acpi_ds_method_data_get_value (obj_desc->reference.opcode,
obj_desc->reference.offset, walk_state, &obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ds_method_data_get_value(obj_desc->
reference.
opcode,
obj_desc->
reference.
offset,
walk_state,
&obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
acpi_ut_remove_reference (obj_desc);
}
else {
status = acpi_ds_method_data_get_node (obj_desc->reference.opcode,
obj_desc->reference.offset, walk_state, &node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
acpi_ut_remove_reference(obj_desc);
} else {
status =
acpi_ds_method_data_get_node(obj_desc->
reference.
opcode,
obj_desc->
reference.
offset,
walk_state,
&node);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
obj_desc = acpi_ns_get_attached_object (node);
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
type = ACPI_TYPE_ANY;
goto exit;
@ -507,7 +502,6 @@ acpi_ex_resolve_multiple (
}
break;
case AML_DEBUG_OP:
/* The Debug Object is of type "debug_object" */
@ -515,13 +509,10 @@ acpi_ex_resolve_multiple (
type = ACPI_TYPE_DEBUG_OBJECT;
goto exit;
default:
ACPI_REPORT_ERROR ((
"acpi_ex_resolve_multiple: Unknown Reference subtype %X\n",
obj_desc->reference.opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", obj_desc->reference.opcode));
return_ACPI_STATUS(AE_AML_INTERNAL);
}
}
@ -529,10 +520,9 @@ acpi_ex_resolve_multiple (
* Now we are guaranteed to have an object that has not been created
* via the ref_of or Index operators.
*/
type = ACPI_GET_OBJECT_TYPE (obj_desc);
type = ACPI_GET_OBJECT_TYPE(obj_desc);
exit:
exit:
/* Convert internal types to external types */
switch (type) {
@ -559,7 +549,5 @@ exit:
if (return_desc) {
*return_desc = obj_desc;
}
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}

View File

@ -42,24 +42,18 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/amlcode.h>
#include <acpi/acparser.h>
#include <acpi/acinterp.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exresop")
ACPI_MODULE_NAME("exresop")
/* Local prototypes */
static acpi_status
acpi_ex_check_object_type (
acpi_object_type type_needed,
acpi_object_type this_type,
void *object);
acpi_ex_check_object_type(acpi_object_type type_needed,
acpi_object_type this_type, void *object);
/*******************************************************************************
*
@ -76,13 +70,10 @@ acpi_ex_check_object_type (
******************************************************************************/
static acpi_status
acpi_ex_check_object_type (
acpi_object_type type_needed,
acpi_object_type this_type,
void *object)
acpi_ex_check_object_type(acpi_object_type type_needed,
acpi_object_type this_type, void *object)
{
ACPI_FUNCTION_NAME ("ex_check_object_type");
ACPI_FUNCTION_NAME("ex_check_object_type");
if (type_needed == ACPI_TYPE_ANY) {
/* All types OK, so we don't perform any typechecks */
@ -97,16 +88,17 @@ acpi_ex_check_object_type (
* specification, a store to a constant is a noop.)
*/
if ((this_type == ACPI_TYPE_INTEGER) &&
(((union acpi_operand_object *) object)->common.flags & AOPOBJ_AML_CONSTANT)) {
(((union acpi_operand_object *)object)->common.
flags & AOPOBJ_AML_CONSTANT)) {
return (AE_OK);
}
}
if (type_needed != this_type) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [%s], found [%s] %p\n",
acpi_ut_get_type_name (type_needed),
acpi_ut_get_type_name (this_type), object));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed [%s], found [%s] %p\n",
acpi_ut_get_type_name(type_needed),
acpi_ut_get_type_name(this_type), object));
return (AE_AML_OPERAND_TYPE);
}
@ -114,7 +106,6 @@ acpi_ex_check_object_type (
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_resolve_operands
@ -137,41 +128,37 @@ acpi_ex_check_object_type (
******************************************************************************/
acpi_status
acpi_ex_resolve_operands (
u16 opcode,
union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state)
acpi_ex_resolve_operands(u16 opcode,
union acpi_operand_object ** stack_ptr,
struct acpi_walk_state * walk_state)
{
union acpi_operand_object *obj_desc;
acpi_status status = AE_OK;
u8 object_type;
void *temp_node;
u32 arg_types;
const struct acpi_opcode_info *op_info;
u32 this_arg_type;
acpi_object_type type_needed;
u16 target_op = 0;
union acpi_operand_object *obj_desc;
acpi_status status = AE_OK;
u8 object_type;
void *temp_node;
u32 arg_types;
const struct acpi_opcode_info *op_info;
u32 this_arg_type;
acpi_object_type type_needed;
u16 target_op = 0;
ACPI_FUNCTION_TRACE_U32("ex_resolve_operands", opcode);
ACPI_FUNCTION_TRACE_U32 ("ex_resolve_operands", opcode);
op_info = acpi_ps_get_opcode_info (opcode);
op_info = acpi_ps_get_opcode_info(opcode);
if (op_info->class == AML_CLASS_UNKNOWN) {
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
return_ACPI_STATUS(AE_AML_BAD_OPCODE);
}
arg_types = op_info->runtime_args;
if (arg_types == ARGI_INVALID_OPCODE) {
ACPI_REPORT_ERROR (("resolve_operands: %X is not a valid AML opcode\n",
opcode));
ACPI_REPORT_ERROR(("resolve_operands: %X is not a valid AML opcode\n", opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
return_ACPI_STATUS(AE_AML_INTERNAL);
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Opcode %X [%s] required_operand_types=%8.8X \n",
opcode, op_info->name, arg_types));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Opcode %X [%s] required_operand_types=%8.8X \n",
opcode, op_info->name, arg_types));
/*
* Normal exit is with (arg_types == 0) at end of argument list.
@ -180,12 +167,11 @@ acpi_ex_resolve_operands (
* to) the required type; if stack underflows; or upon
* finding a NULL stack entry (which should not happen).
*/
while (GET_CURRENT_ARG_TYPE (arg_types)) {
while (GET_CURRENT_ARG_TYPE(arg_types)) {
if (!stack_ptr || !*stack_ptr) {
ACPI_REPORT_ERROR (("resolve_operands: Null stack entry at %p\n",
stack_ptr));
ACPI_REPORT_ERROR(("resolve_operands: Null stack entry at %p\n", stack_ptr));
return_ACPI_STATUS (AE_AML_INTERNAL);
return_ACPI_STATUS(AE_AML_INTERNAL);
}
/* Extract useful items */
@ -194,37 +180,37 @@ acpi_ex_resolve_operands (
/* Decode the descriptor type */
switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
case ACPI_DESC_TYPE_NAMED:
/* Namespace Node */
object_type = ((struct acpi_namespace_node *) obj_desc)->type;
object_type =
((struct acpi_namespace_node *)obj_desc)->type;
break;
case ACPI_DESC_TYPE_OPERAND:
/* ACPI internal object */
object_type = ACPI_GET_OBJECT_TYPE (obj_desc);
object_type = ACPI_GET_OBJECT_TYPE(obj_desc);
/* Check for bad acpi_object_type */
if (!acpi_ut_valid_object_type (object_type)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Bad operand object type [%X]\n",
object_type));
if (!acpi_ut_valid_object_type(object_type)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Bad operand object type [%X]\n",
object_type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) {
/* Decode the Reference */
op_info = acpi_ps_get_opcode_info (opcode);
op_info = acpi_ps_get_opcode_info(opcode);
if (op_info->class == AML_CLASS_UNKNOWN) {
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
return_ACPI_STATUS(AE_AML_BAD_OPCODE);
}
switch (obj_desc->reference.opcode) {
@ -238,51 +224,62 @@ acpi_ex_resolve_operands (
case AML_REF_OF_OP:
case AML_ARG_OP:
case AML_LOCAL_OP:
case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
case AML_INT_NAMEPATH_OP: /* Reference to a named object */
case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
case AML_INT_NAMEPATH_OP: /* Reference to a named object */
ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Operand is a Reference, ref_opcode [%s]\n",
(acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name)));
ACPI_DEBUG_ONLY_MEMBERS(ACPI_DEBUG_PRINT
((ACPI_DB_EXEC,
"Operand is a Reference, ref_opcode [%s]\n",
(acpi_ps_get_opcode_info
(obj_desc->
reference.
opcode))->
name)));
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Operand is a Reference, Unknown Reference Opcode %X [%s]\n",
obj_desc->reference.opcode,
(acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Operand is a Reference, Unknown Reference Opcode %X [%s]\n",
obj_desc->reference.
opcode,
(acpi_ps_get_opcode_info
(obj_desc->reference.
opcode))->name));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
}
break;
default:
/* Invalid descriptor */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Invalid descriptor %p [%s]\n",
obj_desc, acpi_ut_get_descriptor_name (obj_desc)));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Invalid descriptor %p [%s]\n",
obj_desc,
acpi_ut_get_descriptor_name
(obj_desc)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/* Get one argument type, point to the next */
this_arg_type = GET_CURRENT_ARG_TYPE (arg_types);
INCREMENT_ARG_LIST (arg_types);
this_arg_type = GET_CURRENT_ARG_TYPE(arg_types);
INCREMENT_ARG_LIST(arg_types);
/*
* Handle cases where the object does not need to be
* resolved to a value
*/
switch (this_arg_type) {
case ARGI_REF_OR_STRING: /* Can be a String or Reference */
case ARGI_REF_OR_STRING: /* Can be a String or Reference */
if ((ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) &&
(ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_STRING)) {
if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
ACPI_DESC_TYPE_OPERAND)
&& (ACPI_GET_OBJECT_TYPE(obj_desc) ==
ACPI_TYPE_STRING)) {
/*
* String found - the string references a named object and
* must be resolved to a node
@ -296,39 +293,40 @@ acpi_ex_resolve_operands (
*/
/*lint -fallthrough */
case ARGI_REFERENCE: /* References: */
case ARGI_REFERENCE: /* References: */
case ARGI_INTEGER_REF:
case ARGI_OBJECT_REF:
case ARGI_DEVICE_REF:
case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
/*
* Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
* A Namespace Node is OK as-is
*/
if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
ACPI_DESC_TYPE_NAMED) {
goto next_operand;
}
status = acpi_ex_check_object_type (ACPI_TYPE_LOCAL_REFERENCE,
object_type, obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ex_check_object_type(ACPI_TYPE_LOCAL_REFERENCE,
object_type, obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
if (obj_desc->reference.opcode == AML_NAME_OP) {
/* Convert a named reference to the actual named object */
temp_node = obj_desc->reference.object;
acpi_ut_remove_reference (obj_desc);
acpi_ut_remove_reference(obj_desc);
(*stack_ptr) = temp_node;
}
goto next_operand;
case ARGI_DATAREFOBJ: /* Store operator only */
case ARGI_DATAREFOBJ: /* Store operator only */
/*
* We don't want to resolve index_op reference objects during
@ -337,8 +335,10 @@ acpi_ex_resolve_operands (
* -- All others must be resolved below.
*/
if ((opcode == AML_STORE_OP) &&
(ACPI_GET_OBJECT_TYPE (*stack_ptr) == ACPI_TYPE_LOCAL_REFERENCE) &&
((*stack_ptr)->reference.opcode == AML_INDEX_OP)) {
(ACPI_GET_OBJECT_TYPE(*stack_ptr) ==
ACPI_TYPE_LOCAL_REFERENCE)
&& ((*stack_ptr)->reference.opcode ==
AML_INDEX_OP)) {
goto next_operand;
}
break;
@ -351,9 +351,9 @@ acpi_ex_resolve_operands (
/*
* Resolve this object to a value
*/
status = acpi_ex_resolve_to_value (stack_ptr, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ex_resolve_to_value(stack_ptr, walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Get the resolved object */
@ -364,10 +364,10 @@ acpi_ex_resolve_operands (
* Check the resulting object (value) type
*/
switch (this_arg_type) {
/*
* For the simple cases, only one type of resolved object
* is allowed
*/
/*
* For the simple cases, only one type of resolved object
* is allowed
*/
case ARGI_MUTEX:
/* Need an operand of type ACPI_TYPE_MUTEX */
@ -382,7 +382,7 @@ acpi_ex_resolve_operands (
type_needed = ACPI_TYPE_EVENT;
break;
case ARGI_PACKAGE: /* Package */
case ARGI_PACKAGE: /* Package */
/* Need an operand of type ACPI_TYPE_PACKAGE */
@ -403,10 +403,9 @@ acpi_ex_resolve_operands (
type_needed = ACPI_TYPE_LOCAL_REFERENCE;
break;
/*
* The more complex cases allow multiple resolved object types
*/
/*
* The more complex cases allow multiple resolved object types
*/
case ARGI_INTEGER:
/*
@ -414,21 +413,27 @@ acpi_ex_resolve_operands (
* But we can implicitly convert from a STRING or BUFFER
* Aka - "Implicit Source Operand Conversion"
*/
status = acpi_ex_convert_to_integer (obj_desc, stack_ptr, 16);
if (ACPI_FAILURE (status)) {
status =
acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16);
if (ACPI_FAILURE(status)) {
if (status == AE_TYPE) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name
(obj_desc),
obj_desc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
if (obj_desc != *stack_ptr) {
acpi_ut_remove_reference(obj_desc);
}
goto next_operand;
case ARGI_BUFFER:
/*
@ -436,21 +441,26 @@ acpi_ex_resolve_operands (
* But we can implicitly convert from a STRING or INTEGER
* Aka - "Implicit Source Operand Conversion"
*/
status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr);
if (ACPI_FAILURE (status)) {
status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr);
if (ACPI_FAILURE(status)) {
if (status == AE_TYPE) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name
(obj_desc),
obj_desc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
if (obj_desc != *stack_ptr) {
acpi_ut_remove_reference(obj_desc);
}
goto next_operand;
case ARGI_STRING:
/*
@ -458,75 +468,86 @@ acpi_ex_resolve_operands (
* But we can implicitly convert from a BUFFER or INTEGER
* Aka - "Implicit Source Operand Conversion"
*/
status = acpi_ex_convert_to_string (obj_desc, stack_ptr,
ACPI_IMPLICIT_CONVERT_HEX);
if (ACPI_FAILURE (status)) {
status = acpi_ex_convert_to_string(obj_desc, stack_ptr,
ACPI_IMPLICIT_CONVERT_HEX);
if (ACPI_FAILURE(status)) {
if (status == AE_TYPE) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name
(obj_desc),
obj_desc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
if (obj_desc != *stack_ptr) {
acpi_ut_remove_reference(obj_desc);
}
goto next_operand;
case ARGI_COMPUTEDATA:
/* Need an operand of type INTEGER, STRING or BUFFER */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/* Valid operand */
break;
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name
(obj_desc), obj_desc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
goto next_operand;
case ARGI_BUFFER_OR_STRING:
/* Need an operand of type STRING or BUFFER */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/* Valid operand */
break;
break;
case ACPI_TYPE_INTEGER:
/* Highest priority conversion is to type Buffer */
status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ex_convert_to_buffer(obj_desc,
stack_ptr);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
if (obj_desc != *stack_ptr) {
acpi_ut_remove_reference(obj_desc);
}
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
acpi_ut_get_object_type_name
(obj_desc), obj_desc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
goto next_operand;
case ARGI_DATAOBJECT:
/*
* ARGI_DATAOBJECT is only used by the size_of operator.
@ -535,7 +556,7 @@ acpi_ex_resolve_operands (
* The only reference allowed here is a direct reference to
* a namespace node.
*/
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_PACKAGE:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
@ -545,20 +566,20 @@ acpi_ex_resolve_operands (
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Buffer/String/Package/Reference], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed [Buffer/String/Package/Reference], found [%s] %p\n",
acpi_ut_get_object_type_name
(obj_desc), obj_desc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
goto next_operand;
case ARGI_COMPLEXOBJ:
/* Need a buffer or package or (ACPI 2.0) String */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_PACKAGE:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
@ -567,20 +588,20 @@ acpi_ex_resolve_operands (
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Buffer/String/Package], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed [Buffer/String/Package], found [%s] %p\n",
acpi_ut_get_object_type_name
(obj_desc), obj_desc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
goto next_operand;
case ARGI_REGION_OR_FIELD:
/* Need an operand of type REGION or a FIELD in a region */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_REGION:
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
@ -590,20 +611,20 @@ acpi_ex_resolve_operands (
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Region/region_field], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed [Region/region_field], found [%s] %p\n",
acpi_ut_get_object_type_name
(obj_desc), obj_desc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
goto next_operand;
case ARGI_DATAREFOBJ:
/* Used by the Store() operator only */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_PACKAGE:
case ACPI_TYPE_STRING:
@ -635,47 +656,46 @@ acpi_ex_resolve_operands (
break;
}
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n",
acpi_ut_get_object_type_name
(obj_desc), obj_desc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
goto next_operand;
default:
/* Unknown type */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Internal - Unknown ARGI (required operand) type %X\n",
this_arg_type));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Internal - Unknown ARGI (required operand) type %X\n",
this_arg_type));
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/*
* Make sure that the original object was resolved to the
* required object type (Simple cases only).
*/
status = acpi_ex_check_object_type (type_needed,
ACPI_GET_OBJECT_TYPE (*stack_ptr), *stack_ptr);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ex_check_object_type(type_needed,
ACPI_GET_OBJECT_TYPE
(*stack_ptr), *stack_ptr);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
next_operand:
next_operand:
/*
* If more operands needed, decrement stack_ptr to point
* to next operand on stack
*/
if (GET_CURRENT_ARG_TYPE (arg_types)) {
if (GET_CURRENT_ARG_TYPE(arg_types)) {
stack_ptr--;
}
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -42,7 +42,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acdispat.h>
#include <acpi/acinterp.h>
@ -50,24 +49,18 @@
#include <acpi/acnamesp.h>
#include <acpi/acparser.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exstore")
ACPI_MODULE_NAME("exstore")
/* Local prototypes */
static void
acpi_ex_do_debug_object (
union acpi_operand_object *source_desc,
u32 level,
u32 index);
acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
u32 level, u32 index);
static acpi_status
acpi_ex_store_object_to_index (
union acpi_operand_object *val_desc,
union acpi_operand_object *dest_desc,
struct acpi_walk_state *walk_state);
acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
union acpi_operand_object *dest_desc,
struct acpi_walk_state *walk_state);
/*******************************************************************************
*
@ -84,136 +77,146 @@ acpi_ex_store_object_to_index (
******************************************************************************/
static void
acpi_ex_do_debug_object (
union acpi_operand_object *source_desc,
u32 level,
u32 index)
acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
u32 level, u32 index)
{
u32 i;
u32 i;
ACPI_FUNCTION_TRACE_PTR("ex_do_debug_object", source_desc);
ACPI_FUNCTION_TRACE_PTR ("ex_do_debug_object", source_desc);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s",
level, " "));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s",
level, " "));
/* Display index for package output only */
if (index > 0) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
"(%.2u) ", index -1));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
"(%.2u) ", index - 1));
}
if (!source_desc) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "<Null Object>\n"));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "<Null Object>\n"));
return_VOID;
}
if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_OPERAND) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: ",
acpi_ut_get_object_type_name (source_desc)));
if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s: ",
acpi_ut_get_object_type_name
(source_desc)));
if (!acpi_ut_valid_internal_object (source_desc)) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
"%p, Invalid Internal Object!\n", source_desc));
return_VOID;
if (!acpi_ut_valid_internal_object(source_desc)) {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
"%p, Invalid Internal Object!\n",
source_desc));
return_VOID;
}
}
else if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_NAMED) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n",
acpi_ut_get_type_name (((struct acpi_namespace_node *) source_desc)->type),
source_desc));
} else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
ACPI_DESC_TYPE_NAMED) {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s: %p\n",
acpi_ut_get_type_name(((struct
acpi_namespace_node
*)source_desc)->
type),
source_desc));
return_VOID;
}
else {
} else {
return_VOID;
}
switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
case ACPI_TYPE_INTEGER:
/* Output correct integer width */
if (acpi_gbl_integer_byte_width == 4) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
(u32) source_desc->integer.value));
}
else {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n",
ACPI_FORMAT_UINT64 (source_desc->integer.value)));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
(u32) source_desc->integer.
value));
} else {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
"0x%8.8X%8.8X\n",
ACPI_FORMAT_UINT64(source_desc->
integer.
value)));
}
break;
case ACPI_TYPE_BUFFER:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]",
(u32) source_desc->buffer.length));
ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
(source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n",
(u32) source_desc->buffer.length));
ACPI_DUMP_BUFFER(source_desc->buffer.pointer,
(source_desc->buffer.length <
32) ? source_desc->buffer.length : 32);
break;
case ACPI_TYPE_STRING:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
source_desc->string.length, source_desc->string.pointer));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
source_desc->string.length,
source_desc->string.pointer));
break;
case ACPI_TYPE_PACKAGE:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X Elements]\n",
source_desc->package.count));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
"[0x%.2X Elements]\n",
source_desc->package.count));
/* Output the entire contents of the package */
for (i = 0; i < source_desc->package.count; i++) {
acpi_ex_do_debug_object (source_desc->package.elements[i],
level+4, i+1);
acpi_ex_do_debug_object(source_desc->package.
elements[i], level + 4, i + 1);
}
break;
case ACPI_TYPE_LOCAL_REFERENCE:
if (source_desc->reference.opcode == AML_INDEX_OP) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s, 0x%X]\n",
acpi_ps_get_opcode_name (source_desc->reference.opcode),
source_desc->reference.offset));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
"[%s, 0x%X]\n",
acpi_ps_get_opcode_name
(source_desc->reference.opcode),
source_desc->reference.offset));
} else {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s]\n",
acpi_ps_get_opcode_name
(source_desc->reference.opcode)));
}
else {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s]\n",
acpi_ps_get_opcode_name (source_desc->reference.opcode)));
}
if (source_desc->reference.object) {
if (ACPI_GET_DESCRIPTOR_TYPE (source_desc->reference.object) ==
ACPI_DESC_TYPE_NAMED) {
acpi_ex_do_debug_object (((struct acpi_namespace_node *)
source_desc->reference.object)->object,
level+4, 0);
if (ACPI_GET_DESCRIPTOR_TYPE
(source_desc->reference.object) ==
ACPI_DESC_TYPE_NAMED) {
acpi_ex_do_debug_object(((struct
acpi_namespace_node *)
source_desc->reference.
object)->object,
level + 4, 0);
} else {
acpi_ex_do_debug_object(source_desc->reference.
object, level + 4, 0);
}
else {
acpi_ex_do_debug_object (source_desc->reference.object, level+4, 0);
}
}
else if (source_desc->reference.node) {
acpi_ex_do_debug_object ((source_desc->reference.node)->object,
level+4, 0);
} else if (source_desc->reference.node) {
acpi_ex_do_debug_object((source_desc->reference.node)->
object, level + 4, 0);
}
break;
default:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p %s\n",
source_desc, acpi_ut_get_object_type_name (source_desc)));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%p %s\n",
source_desc,
acpi_ut_get_object_type_name
(source_desc)));
break;
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_store
@ -235,42 +238,41 @@ acpi_ex_do_debug_object (
******************************************************************************/
acpi_status
acpi_ex_store (
union acpi_operand_object *source_desc,
union acpi_operand_object *dest_desc,
struct acpi_walk_state *walk_state)
acpi_ex_store(union acpi_operand_object *source_desc,
union acpi_operand_object *dest_desc,
struct acpi_walk_state *walk_state)
{
acpi_status status = AE_OK;
union acpi_operand_object *ref_desc = dest_desc;
ACPI_FUNCTION_TRACE_PTR ("ex_store", dest_desc);
acpi_status status = AE_OK;
union acpi_operand_object *ref_desc = dest_desc;
ACPI_FUNCTION_TRACE_PTR("ex_store", dest_desc);
/* Validate parameters */
if (!source_desc || !dest_desc) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null parameter\n"));
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
/* dest_desc can be either a namespace node or an ACPI object */
if (ACPI_GET_DESCRIPTOR_TYPE (dest_desc) == ACPI_DESC_TYPE_NAMED) {
if (ACPI_GET_DESCRIPTOR_TYPE(dest_desc) == ACPI_DESC_TYPE_NAMED) {
/*
* Dest is a namespace node,
* Storing an object into a Named node.
*/
status = acpi_ex_store_object_to_node (source_desc,
(struct acpi_namespace_node *) dest_desc, walk_state,
ACPI_IMPLICIT_CONVERSION);
status = acpi_ex_store_object_to_node(source_desc,
(struct
acpi_namespace_node *)
dest_desc, walk_state,
ACPI_IMPLICIT_CONVERSION);
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/* Destination object must be a Reference or a Constant object */
switch (ACPI_GET_OBJECT_TYPE (dest_desc)) {
switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
case ACPI_TYPE_LOCAL_REFERENCE:
break;
@ -279,7 +281,7 @@ acpi_ex_store (
/* Allow stores to Constants -- a Noop as per ACPI spec */
if (dest_desc->common.flags & AOPOBJ_AML_CONSTANT) {
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*lint -fallthrough */
@ -288,16 +290,18 @@ acpi_ex_store (
/* Destination is not a Reference object */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Target is not a Reference or Constant object - %s [%p]\n",
acpi_ut_get_object_type_name (dest_desc), dest_desc));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Target is not a Reference or Constant object - %s [%p]\n",
acpi_ut_get_object_type_name(dest_desc),
dest_desc));
ACPI_DUMP_STACK_ENTRY (source_desc);
ACPI_DUMP_STACK_ENTRY (dest_desc);
ACPI_DUMP_OPERANDS (&dest_desc, ACPI_IMODE_EXECUTE, "ex_store",
2, "Target is not a Reference or Constant object");
ACPI_DUMP_STACK_ENTRY(source_desc);
ACPI_DUMP_STACK_ENTRY(dest_desc);
ACPI_DUMP_OPERANDS(&dest_desc, ACPI_IMODE_EXECUTE, "ex_store",
2,
"Target is not a Reference or Constant object");
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/*
@ -314,58 +318,59 @@ acpi_ex_store (
/* Storing an object into a Name "container" */
status = acpi_ex_store_object_to_node (source_desc,
ref_desc->reference.object,
walk_state, ACPI_IMPLICIT_CONVERSION);
status = acpi_ex_store_object_to_node(source_desc,
ref_desc->reference.
object, walk_state,
ACPI_IMPLICIT_CONVERSION);
break;
case AML_INDEX_OP:
/* Storing to an Index (pointer into a packager or buffer) */
status = acpi_ex_store_object_to_index (source_desc, ref_desc, walk_state);
status =
acpi_ex_store_object_to_index(source_desc, ref_desc,
walk_state);
break;
case AML_LOCAL_OP:
case AML_ARG_OP:
/* Store to a method local/arg */
status = acpi_ds_store_object_to_local (ref_desc->reference.opcode,
ref_desc->reference.offset, source_desc, walk_state);
status =
acpi_ds_store_object_to_local(ref_desc->reference.opcode,
ref_desc->reference.offset,
source_desc, walk_state);
break;
case AML_DEBUG_OP:
/*
* Storing to the Debug object causes the value stored to be
* displayed and otherwise has no effect -- see ACPI Specification
*/
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"**** Write to Debug Object: Object %p %s ****:\n\n",
source_desc, acpi_ut_get_object_type_name (source_desc)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"**** Write to Debug Object: Object %p %s ****:\n\n",
source_desc,
acpi_ut_get_object_type_name(source_desc)));
acpi_ex_do_debug_object (source_desc, 0, 0);
acpi_ex_do_debug_object(source_desc, 0, 0);
break;
default:
ACPI_REPORT_ERROR (("ex_store: Unknown Reference opcode %X\n",
ref_desc->reference.opcode));
ACPI_DUMP_ENTRY (ref_desc, ACPI_LV_ERROR);
ACPI_REPORT_ERROR(("ex_store: Unknown Reference opcode %X\n",
ref_desc->reference.opcode));
ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR);
status = AE_AML_INTERNAL;
break;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_store_object_to_index
@ -381,20 +386,17 @@ acpi_ex_store (
******************************************************************************/
static acpi_status
acpi_ex_store_object_to_index (
union acpi_operand_object *source_desc,
union acpi_operand_object *index_desc,
struct acpi_walk_state *walk_state)
acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
union acpi_operand_object *index_desc,
struct acpi_walk_state *walk_state)
{
acpi_status status = AE_OK;
union acpi_operand_object *obj_desc;
union acpi_operand_object *new_desc;
u8 value = 0;
u32 i;
ACPI_FUNCTION_TRACE ("ex_store_object_to_index");
acpi_status status = AE_OK;
union acpi_operand_object *obj_desc;
union acpi_operand_object *new_desc;
u8 value = 0;
u32 i;
ACPI_FUNCTION_TRACE("ex_store_object_to_index");
/*
* Destination must be a reference pointer, and
@ -413,19 +415,20 @@ acpi_ex_store_object_to_index (
*/
obj_desc = *(index_desc->reference.where);
status = acpi_ut_copy_iobject_to_iobject (source_desc, &new_desc, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc,
walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
if (obj_desc) {
/* Decrement reference count by the ref count of the parent package */
for (i = 0;
i < ((union acpi_operand_object *)
index_desc->reference.object)->common.reference_count;
i++) {
acpi_ut_remove_reference (obj_desc);
for (i = 0; i < ((union acpi_operand_object *)
index_desc->reference.object)->common.
reference_count; i++) {
acpi_ut_remove_reference(obj_desc);
}
}
@ -433,16 +436,14 @@ acpi_ex_store_object_to_index (
/* Increment ref count by the ref count of the parent package-1 */
for (i = 1;
i < ((union acpi_operand_object *)
index_desc->reference.object)->common.reference_count;
i++) {
acpi_ut_add_reference (new_desc);
for (i = 1; i < ((union acpi_operand_object *)
index_desc->reference.object)->common.
reference_count; i++) {
acpi_ut_add_reference(new_desc);
}
break;
case ACPI_TYPE_BUFFER_FIELD:
/*
@ -460,16 +461,16 @@ acpi_ex_store_object_to_index (
* by the INDEX_OP code.
*/
obj_desc = index_desc->reference.object;
if ((ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_BUFFER) &&
(ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_STRING)) {
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
if ((ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_BUFFER) &&
(ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_STRING)) {
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/*
* The assignment of the individual elements will be slightly
* different for each source type.
*/
switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
case ACPI_TYPE_INTEGER:
/* Use the least-significant byte of the integer */
@ -489,10 +490,11 @@ acpi_ex_store_object_to_index (
/* All other types are invalid */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Source must be Integer/Buffer/String type, not %s\n",
acpi_ut_get_object_type_name (source_desc)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Source must be Integer/Buffer/String type, not %s\n",
acpi_ut_get_object_type_name
(source_desc)));
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
/* Store the source value into the target buffer byte */
@ -500,18 +502,16 @@ acpi_ex_store_object_to_index (
obj_desc->buffer.pointer[index_desc->reference.offset] = value;
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Target is not a Package or buffer_field\n"));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Target is not a Package or buffer_field\n"));
status = AE_AML_OPERAND_TYPE;
break;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_store_object_to_node
@ -539,42 +539,40 @@ acpi_ex_store_object_to_index (
******************************************************************************/
acpi_status
acpi_ex_store_object_to_node (
union acpi_operand_object *source_desc,
struct acpi_namespace_node *node,
struct acpi_walk_state *walk_state,
u8 implicit_conversion)
acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
struct acpi_namespace_node *node,
struct acpi_walk_state *walk_state,
u8 implicit_conversion)
{
acpi_status status = AE_OK;
union acpi_operand_object *target_desc;
union acpi_operand_object *new_desc;
acpi_object_type target_type;
ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_node", source_desc);
acpi_status status = AE_OK;
union acpi_operand_object *target_desc;
union acpi_operand_object *new_desc;
acpi_object_type target_type;
ACPI_FUNCTION_TRACE_PTR("ex_store_object_to_node", source_desc);
/* Get current type of the node, and object attached to Node */
target_type = acpi_ns_get_type (node);
target_desc = acpi_ns_get_attached_object (node);
target_type = acpi_ns_get_type(node);
target_desc = acpi_ns_get_attached_object(node);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
source_desc, acpi_ut_get_object_type_name (source_desc),
node, acpi_ut_get_type_name (target_type)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
source_desc,
acpi_ut_get_object_type_name(source_desc), node,
acpi_ut_get_type_name(target_type)));
/*
* Resolve the source object to an actual value
* (If it is a reference object)
*/
status = acpi_ex_resolve_object (&source_desc, target_type, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status = acpi_ex_resolve_object(&source_desc, target_type, walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* If no implicit conversion, drop into the default case below */
if (!implicit_conversion) {
if ((!implicit_conversion) || (walk_state->opcode == AML_COPY_OP)) {
/* Force execution of default (no implicit conversion) */
target_type = ACPI_TYPE_ANY;
@ -590,11 +588,10 @@ acpi_ex_store_object_to_node (
/* For fields, copy the source data to the target field. */
status = acpi_ex_write_data_to_field (source_desc, target_desc,
&walk_state->result_obj);
status = acpi_ex_write_data_to_field(source_desc, target_desc,
&walk_state->result_obj);
break;
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
@ -605,10 +602,11 @@ acpi_ex_store_object_to_node (
*
* Copy and/or convert the source object to a new target object
*/
status = acpi_ex_store_object_to_object (source_desc, target_desc,
&new_desc, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ex_store_object_to_object(source_desc, target_desc,
&new_desc, walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
if (new_desc != target_desc) {
@ -621,30 +619,33 @@ acpi_ex_store_object_to_node (
* has been performed such that the node/object type has been
* changed.
*/
status = acpi_ns_attach_object (node, new_desc, new_desc->common.type);
status =
acpi_ns_attach_object(node, new_desc,
new_desc->common.type);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Store %s into %s via Convert/Attach\n",
acpi_ut_get_object_type_name (source_desc),
acpi_ut_get_object_type_name (new_desc)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Store %s into %s via Convert/Attach\n",
acpi_ut_get_object_type_name
(source_desc),
acpi_ut_get_object_type_name
(new_desc)));
}
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Storing %s (%p) directly into node (%p), no implicit conversion\n",
acpi_ut_get_object_type_name (source_desc), source_desc, node));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Storing %s (%p) directly into node (%p) with no implicit conversion\n",
acpi_ut_get_object_type_name(source_desc),
source_desc, node));
/* No conversions for all other types. Just attach the source object */
status = acpi_ns_attach_object (node, source_desc,
ACPI_GET_OBJECT_TYPE (source_desc));
status = acpi_ns_attach_object(node, source_desc,
ACPI_GET_OBJECT_TYPE
(source_desc));
break;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -43,15 +43,12 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/amlcode.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exstoren")
ACPI_MODULE_NAME("exstoren")
/*******************************************************************************
*
@ -67,19 +64,15 @@
* it and return the actual object in the source_desc_ptr.
*
******************************************************************************/
acpi_status
acpi_ex_resolve_object (
union acpi_operand_object **source_desc_ptr,
acpi_object_type target_type,
struct acpi_walk_state *walk_state)
acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
acpi_object_type target_type,
struct acpi_walk_state *walk_state)
{
union acpi_operand_object *source_desc = *source_desc_ptr;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("ex_resolve_object");
union acpi_operand_object *source_desc = *source_desc_ptr;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ex_resolve_object");
/* Ensure we have a Target that can be stored to */
@ -102,11 +95,14 @@ acpi_ex_resolve_object (
* are all essentially the same. This case handles the
* "interchangeable" types Integer, String, and Buffer.
*/
if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) {
if (ACPI_GET_OBJECT_TYPE(source_desc) ==
ACPI_TYPE_LOCAL_REFERENCE) {
/* Resolve a reference object first */
status = acpi_ex_resolve_to_value (source_desc_ptr, walk_state);
if (ACPI_FAILURE (status)) {
status =
acpi_ex_resolve_to_value(source_desc_ptr,
walk_state);
if (ACPI_FAILURE(status)) {
break;
}
}
@ -119,31 +115,32 @@ acpi_ex_resolve_object (
/* Must have a Integer, Buffer, or String */
if ((ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) &&
(ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) &&
(ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) &&
!((ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) && (source_desc->reference.opcode == AML_LOAD_OP))) {
if ((ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) &&
(ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) &&
(ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) &&
!((ACPI_GET_OBJECT_TYPE(source_desc) ==
ACPI_TYPE_LOCAL_REFERENCE)
&& (source_desc->reference.opcode == AML_LOAD_OP))) {
/* Conversion successful but still not a valid type */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
acpi_ut_get_object_type_name (source_desc),
acpi_ut_get_type_name (target_type)));
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
acpi_ut_get_object_type_name
(source_desc),
acpi_ut_get_type_name(target_type)));
status = AE_AML_OPERAND_TYPE;
}
break;
case ACPI_TYPE_LOCAL_ALIAS:
case ACPI_TYPE_LOCAL_METHOD_ALIAS:
/* Aliases are resolved by acpi_ex_prep_operands */
ACPI_REPORT_ERROR (("Store into Alias - should never happen\n"));
ACPI_REPORT_ERROR(("Store into Alias - should never happen\n"));
status = AE_AML_INTERNAL;
break;
case ACPI_TYPE_PACKAGE:
default:
@ -154,10 +151,9 @@ acpi_ex_resolve_object (
break;
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_store_object_to_object
@ -194,18 +190,15 @@ acpi_ex_resolve_object (
******************************************************************************/
acpi_status
acpi_ex_store_object_to_object (
union acpi_operand_object *source_desc,
union acpi_operand_object *dest_desc,
union acpi_operand_object **new_desc,
struct acpi_walk_state *walk_state)
acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
union acpi_operand_object *dest_desc,
union acpi_operand_object **new_desc,
struct acpi_walk_state *walk_state)
{
union acpi_operand_object *actual_src_desc;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_object", source_desc);
union acpi_operand_object *actual_src_desc;
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_PTR("ex_store_object_to_object", source_desc);
actual_src_desc = source_desc;
if (!dest_desc) {
@ -214,11 +207,14 @@ acpi_ex_store_object_to_object (
* package element), so we can simply copy the source object
* creating a new destination object
*/
status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, new_desc, walk_state);
return_ACPI_STATUS (status);
status =
acpi_ut_copy_iobject_to_iobject(actual_src_desc, new_desc,
walk_state);
return_ACPI_STATUS(status);
}
if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_GET_OBJECT_TYPE (dest_desc)) {
if (ACPI_GET_OBJECT_TYPE(source_desc) !=
ACPI_GET_OBJECT_TYPE(dest_desc)) {
/*
* The source type does not match the type of the destination.
* Perform the "implicit conversion" of the source to the current type
@ -228,10 +224,13 @@ acpi_ex_store_object_to_object (
* Otherwise, actual_src_desc is a temporary object to hold the
* converted object.
*/
status = acpi_ex_convert_to_target_type (ACPI_GET_OBJECT_TYPE (dest_desc),
source_desc, &actual_src_desc, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
status =
acpi_ex_convert_to_target_type(ACPI_GET_OBJECT_TYPE
(dest_desc), source_desc,
&actual_src_desc,
walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
if (source_desc == actual_src_desc) {
@ -240,7 +239,7 @@ acpi_ex_store_object_to_object (
* new object.
*/
*new_desc = source_desc;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
}
@ -248,42 +247,42 @@ acpi_ex_store_object_to_object (
* We now have two objects of identical types, and we can perform a
* copy of the *value* of the source object.
*/
switch (ACPI_GET_OBJECT_TYPE (dest_desc)) {
switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
case ACPI_TYPE_INTEGER:
dest_desc->integer.value = actual_src_desc->integer.value;
/* Truncate value if we are executing from a 32-bit ACPI table */
acpi_ex_truncate_for32bit_table (dest_desc);
acpi_ex_truncate_for32bit_table(dest_desc);
break;
case ACPI_TYPE_STRING:
status = acpi_ex_store_string_to_string (actual_src_desc, dest_desc);
status =
acpi_ex_store_string_to_string(actual_src_desc, dest_desc);
break;
case ACPI_TYPE_BUFFER:
/*
* Note: There is different store behavior depending on the original
* source type
*/
status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc);
status =
acpi_ex_store_buffer_to_buffer(actual_src_desc, dest_desc);
break;
case ACPI_TYPE_PACKAGE:
status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, &dest_desc,
walk_state);
status =
acpi_ut_copy_iobject_to_iobject(actual_src_desc, &dest_desc,
walk_state);
break;
default:
/*
* All other types come here.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n",
acpi_ut_get_object_type_name (dest_desc)));
ACPI_DEBUG_PRINT((ACPI_DB_WARN,
"Store into type %s not implemented\n",
acpi_ut_get_object_type_name(dest_desc)));
status = AE_NOT_IMPLEMENTED;
break;
@ -292,11 +291,9 @@ acpi_ex_store_object_to_object (
if (actual_src_desc != source_desc) {
/* Delete the intermediate (temporary) source object */
acpi_ut_remove_reference (actual_src_desc);
acpi_ut_remove_reference(actual_src_desc);
}
*new_desc = dest_desc;
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}

View File

@ -42,14 +42,11 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exstorob")
ACPI_MODULE_NAME("exstorob")
/*******************************************************************************
*
@ -63,18 +60,14 @@
* DESCRIPTION: Copy a buffer object to another buffer object.
*
******************************************************************************/
acpi_status
acpi_ex_store_buffer_to_buffer (
union acpi_operand_object *source_desc,
union acpi_operand_object *target_desc)
acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
union acpi_operand_object *target_desc)
{
u32 length;
u8 *buffer;
ACPI_FUNCTION_TRACE_PTR ("ex_store_buffer_to_buffer", source_desc);
u32 length;
u8 *buffer;
ACPI_FUNCTION_TRACE_PTR("ex_store_buffer_to_buffer", source_desc);
/* We know that source_desc is a buffer by now */
@ -86,10 +79,10 @@ acpi_ex_store_buffer_to_buffer (
* allocate a new buffer of the proper length
*/
if ((target_desc->buffer.length == 0) ||
(target_desc->common.flags & AOPOBJ_STATIC_POINTER)) {
target_desc->buffer.pointer = ACPI_MEM_ALLOCATE (length);
(target_desc->common.flags & AOPOBJ_STATIC_POINTER)) {
target_desc->buffer.pointer = ACPI_MEM_ALLOCATE(length);
if (!target_desc->buffer.pointer) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
target_desc->buffer.length = length;
@ -100,8 +93,9 @@ acpi_ex_store_buffer_to_buffer (
if (length <= target_desc->buffer.length) {
/* Clear existing buffer and copy in the new one */
ACPI_MEMSET (target_desc->buffer.pointer, 0, target_desc->buffer.length);
ACPI_MEMCPY (target_desc->buffer.pointer, buffer, length);
ACPI_MEMSET(target_desc->buffer.pointer, 0,
target_desc->buffer.length);
ACPI_MEMCPY(target_desc->buffer.pointer, buffer, length);
#ifdef ACPI_OBSOLETE_BEHAVIOR
/*
@ -124,26 +118,24 @@ acpi_ex_store_buffer_to_buffer (
target_desc->buffer.length = length;
}
#endif
}
else {
} else {
/* Truncate the source, copy only what will fit */
ACPI_MEMCPY (target_desc->buffer.pointer, buffer,
target_desc->buffer.length);
ACPI_MEMCPY(target_desc->buffer.pointer, buffer,
target_desc->buffer.length);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Truncating source buffer from %X to %X\n",
length, target_desc->buffer.length));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Truncating source buffer from %X to %X\n",
length, target_desc->buffer.length));
}
/* Copy flags */
target_desc->buffer.flags = source_desc->buffer.flags;
target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_store_string_to_string
@ -158,16 +150,13 @@ acpi_ex_store_buffer_to_buffer (
******************************************************************************/
acpi_status
acpi_ex_store_string_to_string (
union acpi_operand_object *source_desc,
union acpi_operand_object *target_desc)
acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
union acpi_operand_object *target_desc)
{
u32 length;
u8 *buffer;
ACPI_FUNCTION_TRACE_PTR ("ex_store_string_to_string", source_desc);
u32 length;
u8 *buffer;
ACPI_FUNCTION_TRACE_PTR("ex_store_string_to_string", source_desc);
/* We know that source_desc is a string by now */
@ -179,41 +168,38 @@ acpi_ex_store_string_to_string (
* pointer is not a static pointer (part of an ACPI table)
*/
if ((length < target_desc->string.length) &&
(!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
(!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
/*
* String will fit in existing non-static buffer.
* Clear old string and copy in the new one
*/
ACPI_MEMSET (target_desc->string.pointer, 0,
(acpi_size) target_desc->string.length + 1);
ACPI_MEMCPY (target_desc->string.pointer, buffer, length);
}
else {
ACPI_MEMSET(target_desc->string.pointer, 0,
(acpi_size) target_desc->string.length + 1);
ACPI_MEMCPY(target_desc->string.pointer, buffer, length);
} else {
/*
* Free the current buffer, then allocate a new buffer
* large enough to hold the value
*/
if (target_desc->string.pointer &&
(!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
(!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
/* Only free if not a pointer into the DSDT */
ACPI_MEM_FREE (target_desc->string.pointer);
ACPI_MEM_FREE(target_desc->string.pointer);
}
target_desc->string.pointer = ACPI_MEM_CALLOCATE (
(acpi_size) length + 1);
target_desc->string.pointer = ACPI_MEM_CALLOCATE((acpi_size)
length + 1);
if (!target_desc->string.pointer) {
return_ACPI_STATUS (AE_NO_MEMORY);
return_ACPI_STATUS(AE_NO_MEMORY);
}
target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
ACPI_MEMCPY (target_desc->string.pointer, buffer, length);
ACPI_MEMCPY(target_desc->string.pointer, buffer, length);
}
/* Set the new target length */
target_desc->string.length = length;
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS(AE_OK);
}

View File

@ -42,14 +42,12 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include <acpi/acinterp.h>
#include <acpi/acevents.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exsystem")
ACPI_MODULE_NAME("exsystem")
/*******************************************************************************
*
@ -65,49 +63,42 @@
* interpreter is released.
*
******************************************************************************/
acpi_status
acpi_ex_system_wait_semaphore (
acpi_handle semaphore,
u16 timeout)
acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout)
{
acpi_status status;
acpi_status status2;
acpi_status status;
acpi_status status2;
ACPI_FUNCTION_TRACE("ex_system_wait_semaphore");
ACPI_FUNCTION_TRACE ("ex_system_wait_semaphore");
status = acpi_os_wait_semaphore (semaphore, 1, 0);
if (ACPI_SUCCESS (status)) {
return_ACPI_STATUS (status);
status = acpi_os_wait_semaphore(semaphore, 1, 0);
if (ACPI_SUCCESS(status)) {
return_ACPI_STATUS(status);
}
if (status == AE_TIME) {
/* We must wait, so unlock the interpreter */
acpi_ex_exit_interpreter ();
acpi_ex_exit_interpreter();
status = acpi_os_wait_semaphore (semaphore, 1, timeout);
status = acpi_os_wait_semaphore(semaphore, 1, timeout);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"*** Thread awake after blocking, %s\n",
acpi_format_exception (status)));
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"*** Thread awake after blocking, %s\n",
acpi_format_exception(status)));
/* Reacquire the interpreter */
status2 = acpi_ex_enter_interpreter ();
if (ACPI_FAILURE (status2)) {
status2 = acpi_ex_enter_interpreter();
if (ACPI_FAILURE(status2)) {
/* Report fatal error, could not acquire interpreter */
return_ACPI_STATUS (status2);
return_ACPI_STATUS(status2);
}
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_system_do_stall
@ -125,35 +116,29 @@ acpi_ex_system_wait_semaphore (
*
******************************************************************************/
acpi_status
acpi_ex_system_do_stall (
u32 how_long)
acpi_status acpi_ex_system_do_stall(u32 how_long)
{
acpi_status status = AE_OK;
acpi_status status = AE_OK;
ACPI_FUNCTION_ENTRY();
ACPI_FUNCTION_ENTRY ();
if (how_long > 255) /* 255 microseconds */ {
if (how_long > 255) { /* 255 microseconds */
/*
* Longer than 255 usec, this is an error
*
* (ACPI specifies 100 usec as max, but this gives some slack in
* order to support existing BIOSs)
*/
ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n",
how_long));
ACPI_REPORT_ERROR(("Stall: Time parameter is too large (%d)\n",
how_long));
status = AE_AML_OPERAND_VALUE;
}
else {
acpi_os_stall (how_long);
} else {
acpi_os_stall(how_long);
}
return (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_system_do_suspend
@ -167,29 +152,24 @@ acpi_ex_system_do_stall (
*
******************************************************************************/
acpi_status
acpi_ex_system_do_suspend (
acpi_integer how_long)
acpi_status acpi_ex_system_do_suspend(acpi_integer how_long)
{
acpi_status status;
ACPI_FUNCTION_ENTRY ();
acpi_status status;
ACPI_FUNCTION_ENTRY();
/* Since this thread will sleep, we must release the interpreter */
acpi_ex_exit_interpreter ();
acpi_ex_exit_interpreter();
acpi_os_sleep (how_long);
acpi_os_sleep(how_long);
/* And now we must get the interpreter again */
status = acpi_ex_enter_interpreter ();
status = acpi_ex_enter_interpreter();
return (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_system_acquire_mutex
@ -206,33 +186,30 @@ acpi_ex_system_do_suspend (
******************************************************************************/
acpi_status
acpi_ex_system_acquire_mutex (
union acpi_operand_object *time_desc,
union acpi_operand_object *obj_desc)
acpi_ex_system_acquire_mutex(union acpi_operand_object * time_desc,
union acpi_operand_object * obj_desc)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_PTR ("ex_system_acquire_mutex", obj_desc);
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_PTR("ex_system_acquire_mutex", obj_desc);
if (!obj_desc) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Support for the _GL_ Mutex object -- go get the global lock */
if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
status = acpi_ev_acquire_global_lock ((u16) time_desc->integer.value);
return_ACPI_STATUS (status);
status =
acpi_ev_acquire_global_lock((u16) time_desc->integer.value);
return_ACPI_STATUS(status);
}
status = acpi_ex_system_wait_semaphore (obj_desc->mutex.semaphore,
(u16) time_desc->integer.value);
return_ACPI_STATUS (status);
status = acpi_ex_system_wait_semaphore(obj_desc->mutex.semaphore,
(u16) time_desc->integer.value);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_system_release_mutex
@ -248,32 +225,27 @@ acpi_ex_system_acquire_mutex (
*
******************************************************************************/
acpi_status
acpi_ex_system_release_mutex (
union acpi_operand_object *obj_desc)
acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("ex_system_release_mutex");
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ex_system_release_mutex");
if (!obj_desc) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Support for the _GL_ Mutex object -- release the global lock */
if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
status = acpi_ev_release_global_lock ();
return_ACPI_STATUS (status);
status = acpi_ev_release_global_lock();
return_ACPI_STATUS(status);
}
status = acpi_os_signal_semaphore (obj_desc->mutex.semaphore, 1);
return_ACPI_STATUS (status);
status = acpi_os_signal_semaphore(obj_desc->mutex.semaphore, 1);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_system_signal_event
@ -287,24 +259,19 @@ acpi_ex_system_release_mutex (
*
******************************************************************************/
acpi_status
acpi_ex_system_signal_event (
union acpi_operand_object *obj_desc)
acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("ex_system_signal_event");
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ex_system_signal_event");
if (obj_desc) {
status = acpi_os_signal_semaphore (obj_desc->event.semaphore, 1);
status = acpi_os_signal_semaphore(obj_desc->event.semaphore, 1);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_system_wait_event
@ -321,25 +288,23 @@ acpi_ex_system_signal_event (
******************************************************************************/
acpi_status
acpi_ex_system_wait_event (
union acpi_operand_object *time_desc,
union acpi_operand_object *obj_desc)
acpi_ex_system_wait_event(union acpi_operand_object *time_desc,
union acpi_operand_object *obj_desc)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE ("ex_system_wait_event");
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE("ex_system_wait_event");
if (obj_desc) {
status = acpi_ex_system_wait_semaphore (obj_desc->event.semaphore,
(u16) time_desc->integer.value);
status =
acpi_ex_system_wait_semaphore(obj_desc->event.semaphore,
(u16) time_desc->integer.
value);
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_system_reset_event
@ -352,27 +317,23 @@ acpi_ex_system_wait_event (
*
******************************************************************************/
acpi_status
acpi_ex_system_reset_event (
union acpi_operand_object *obj_desc)
acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)
{
acpi_status status = AE_OK;
void *temp_semaphore;
ACPI_FUNCTION_ENTRY ();
acpi_status status = AE_OK;
void *temp_semaphore;
ACPI_FUNCTION_ENTRY();
/*
* We are going to simply delete the existing semaphore and
* create a new one!
*/
status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore);
if (ACPI_SUCCESS (status)) {
(void) acpi_os_delete_semaphore (obj_desc->event.semaphore);
status =
acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore);
if (ACPI_SUCCESS(status)) {
(void)acpi_os_delete_semaphore(obj_desc->event.semaphore);
obj_desc->event.semaphore = temp_semaphore;
}
return (status);
}

View File

@ -42,7 +42,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
/*
* DEFINE_AML_GLOBALS is tested in amlcode.h
* to determine whether certain global names should be "defined" or only
@ -65,15 +64,10 @@
#include <acpi/acevents.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exutils")
ACPI_MODULE_NAME("exutils")
/* Local prototypes */
static u32
acpi_ex_digits_needed (
acpi_integer value,
u32 base);
static u32 acpi_ex_digits_needed(acpi_integer value, u32 base);
#ifndef ACPI_NO_METHOD_EXECUTION
/*******************************************************************************
@ -89,24 +83,20 @@ acpi_ex_digits_needed (
*
******************************************************************************/
acpi_status
acpi_ex_enter_interpreter (
void)
acpi_status acpi_ex_enter_interpreter(void)
{
acpi_status status;
acpi_status status;
ACPI_FUNCTION_TRACE ("ex_enter_interpreter");
ACPI_FUNCTION_TRACE("ex_enter_interpreter");
status = acpi_ut_acquire_mutex (ACPI_MTX_EXECUTE);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("Could not acquire interpreter mutex\n"));
status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Could not acquire interpreter mutex\n"));
}
return_ACPI_STATUS (status);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_exit_interpreter
@ -129,25 +119,20 @@ acpi_ex_enter_interpreter (
*
******************************************************************************/
void
acpi_ex_exit_interpreter (
void)
void acpi_ex_exit_interpreter(void)
{
acpi_status status;
acpi_status status;
ACPI_FUNCTION_TRACE("ex_exit_interpreter");
ACPI_FUNCTION_TRACE ("ex_exit_interpreter");
status = acpi_ut_release_mutex (ACPI_MTX_EXECUTE);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("Could not release interpreter mutex\n"));
status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE);
if (ACPI_FAILURE(status)) {
ACPI_REPORT_ERROR(("Could not release interpreter mutex\n"));
}
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_truncate_for32bit_table
@ -161,20 +146,17 @@ acpi_ex_exit_interpreter (
*
******************************************************************************/
void
acpi_ex_truncate_for32bit_table (
union acpi_operand_object *obj_desc)
void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
{
ACPI_FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY();
/*
* Object must be a valid number and we must be executing
* a control method
*/
if ((!obj_desc) ||
(ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_INTEGER)) {
(ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) {
return;
}
@ -187,7 +169,6 @@ acpi_ex_truncate_for32bit_table (
}
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_acquire_global_lock
@ -203,37 +184,31 @@ acpi_ex_truncate_for32bit_table (
*
******************************************************************************/
u8
acpi_ex_acquire_global_lock (
u32 field_flags)
u8 acpi_ex_acquire_global_lock(u32 field_flags)
{
u8 locked = FALSE;
acpi_status status;
ACPI_FUNCTION_TRACE ("ex_acquire_global_lock");
u8 locked = FALSE;
acpi_status status;
ACPI_FUNCTION_TRACE("ex_acquire_global_lock");
/* Only attempt lock if the always_lock bit is set */
if (field_flags & AML_FIELD_LOCK_RULE_MASK) {
/* We should attempt to get the lock, wait forever */
status = acpi_ev_acquire_global_lock (ACPI_WAIT_FOREVER);
if (ACPI_SUCCESS (status)) {
status = acpi_ev_acquire_global_lock(ACPI_WAIT_FOREVER);
if (ACPI_SUCCESS(status)) {
locked = TRUE;
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not acquire Global Lock, %s\n",
acpi_format_exception (status)));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Could not acquire Global Lock, %s\n",
acpi_format_exception(status)));
}
}
return_VALUE (locked);
return_VALUE(locked);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_release_global_lock
@ -247,34 +222,28 @@ acpi_ex_acquire_global_lock (
*
******************************************************************************/
void
acpi_ex_release_global_lock (
u8 locked_by_me)
void acpi_ex_release_global_lock(u8 locked_by_me)
{
acpi_status status;
ACPI_FUNCTION_TRACE ("ex_release_global_lock");
acpi_status status;
ACPI_FUNCTION_TRACE("ex_release_global_lock");
/* Only attempt unlock if the caller locked it */
if (locked_by_me) {
/* OK, now release the lock */
status = acpi_ev_release_global_lock ();
if (ACPI_FAILURE (status)) {
status = acpi_ev_release_global_lock();
if (ACPI_FAILURE(status)) {
/* Report the error, but there isn't much else we can do */
ACPI_REPORT_ERROR (("Could not release ACPI Global Lock, %s\n",
acpi_format_exception (status)));
ACPI_REPORT_ERROR(("Could not release ACPI Global Lock, %s\n", acpi_format_exception(status)));
}
}
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_digits_needed
@ -289,22 +258,17 @@ acpi_ex_release_global_lock (
*
******************************************************************************/
static u32
acpi_ex_digits_needed (
acpi_integer value,
u32 base)
static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
{
u32 num_digits;
acpi_integer current_value;
ACPI_FUNCTION_TRACE ("ex_digits_needed");
u32 num_digits;
acpi_integer current_value;
ACPI_FUNCTION_TRACE("ex_digits_needed");
/* acpi_integer is unsigned, so we don't worry about a '-' prefix */
if (value == 0) {
return_VALUE (1);
return_VALUE(1);
}
current_value = value;
@ -313,14 +277,14 @@ acpi_ex_digits_needed (
/* Count the digits in the requested base */
while (current_value) {
(void) acpi_ut_short_divide (current_value, base, &current_value, NULL);
(void)acpi_ut_short_divide(current_value, base, &current_value,
NULL);
num_digits++;
}
return_VALUE (num_digits);
return_VALUE(num_digits);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_eisa_id_to_string
@ -334,32 +298,26 @@ acpi_ex_digits_needed (
*
******************************************************************************/
void
acpi_ex_eisa_id_to_string (
u32 numeric_id,
char *out_string)
void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string)
{
u32 eisa_id;
ACPI_FUNCTION_ENTRY ();
u32 eisa_id;
ACPI_FUNCTION_ENTRY();
/* Swap ID to big-endian to get contiguous bits */
eisa_id = acpi_ut_dword_byte_swap (numeric_id);
eisa_id = acpi_ut_dword_byte_swap(numeric_id);
out_string[0] = (char) ('@' + (((unsigned long) eisa_id >> 26) & 0x1f));
out_string[1] = (char) ('@' + ((eisa_id >> 21) & 0x1f));
out_string[2] = (char) ('@' + ((eisa_id >> 16) & 0x1f));
out_string[3] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 12);
out_string[4] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 8);
out_string[5] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 4);
out_string[6] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 0);
out_string[0] = (char)('@' + (((unsigned long)eisa_id >> 26) & 0x1f));
out_string[1] = (char)('@' + ((eisa_id >> 21) & 0x1f));
out_string[2] = (char)('@' + ((eisa_id >> 16) & 0x1f));
out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 12);
out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 8);
out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 4);
out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 0);
out_string[7] = 0;
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_unsigned_integer_to_string
@ -369,30 +327,25 @@ acpi_ex_eisa_id_to_string (
*
* RETURN: None, string
*
* DESCRIPTOIN: Convert a number to string representation. Assumes string
* DESCRIPTION: Convert a number to string representation. Assumes string
* buffer is large enough to hold the string.
*
******************************************************************************/
void
acpi_ex_unsigned_integer_to_string (
acpi_integer value,
char *out_string)
void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string)
{
u32 count;
u32 digits_needed;
u32 remainder;
u32 count;
u32 digits_needed;
u32 remainder;
ACPI_FUNCTION_ENTRY();
ACPI_FUNCTION_ENTRY ();
digits_needed = acpi_ex_digits_needed (value, 10);
digits_needed = acpi_ex_digits_needed(value, 10);
out_string[digits_needed] = 0;
for (count = digits_needed; count > 0; count--) {
(void) acpi_ut_short_divide (value, 10, &value, &remainder);
out_string[count-1] = (char) ('0' + remainder);\
(void)acpi_ut_short_divide(value, 10, &value, &remainder);
out_string[count - 1] = (char)('0' + remainder);
}
}

View File

@ -34,52 +34,45 @@
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#define ACPI_FAN_COMPONENT 0x00200000
#define ACPI_FAN_CLASS "fan"
#define ACPI_FAN_HID "PNP0C0B"
#define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver"
#define ACPI_FAN_DEVICE_NAME "Fan"
#define ACPI_FAN_FILE_STATE "state"
#define ACPI_FAN_NOTIFY_STATUS 0x80
#define _COMPONENT ACPI_FAN_COMPONENT
ACPI_MODULE_NAME ("acpi_fan")
ACPI_MODULE_NAME("acpi_fan")
MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME);
MODULE_LICENSE("GPL");
static int acpi_fan_add (struct acpi_device *device);
static int acpi_fan_remove (struct acpi_device *device, int type);
static int acpi_fan_add(struct acpi_device *device);
static int acpi_fan_remove(struct acpi_device *device, int type);
static struct acpi_driver acpi_fan_driver = {
.name = ACPI_FAN_DRIVER_NAME,
.class = ACPI_FAN_CLASS,
.ids = ACPI_FAN_HID,
.ops = {
.add = acpi_fan_add,
.remove = acpi_fan_remove,
},
.name = ACPI_FAN_DRIVER_NAME,
.class = ACPI_FAN_CLASS,
.ids = "PNP0C0B",
.ops = {
.add = acpi_fan_add,
.remove = acpi_fan_remove,
},
};
struct acpi_fan {
acpi_handle handle;
acpi_handle handle;
};
/* --------------------------------------------------------------------------
FS Interface (/proc)
-------------------------------------------------------------------------- */
static struct proc_dir_entry *acpi_fan_dir;
static struct proc_dir_entry *acpi_fan_dir;
static int
acpi_fan_read_state (struct seq_file *seq, void *offset)
static int acpi_fan_read_state(struct seq_file *seq, void *offset)
{
struct acpi_fan *fan = seq->private;
int state = 0;
struct acpi_fan *fan = seq->private;
int state = 0;
ACPI_FUNCTION_TRACE("acpi_fan_read_state");
@ -88,7 +81,7 @@ acpi_fan_read_state (struct seq_file *seq, void *offset)
seq_printf(seq, "status: ERROR\n");
else
seq_printf(seq, "status: %s\n",
!state?"on":"off");
!state ? "on" : "off");
}
return_VALUE(0);
}
@ -99,29 +92,26 @@ static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
}
static ssize_t
acpi_fan_write_state (
struct file *file,
const char __user *buffer,
size_t count,
loff_t *ppos)
acpi_fan_write_state(struct file *file, const char __user * buffer,
size_t count, loff_t * ppos)
{
int result = 0;
struct seq_file *m = (struct seq_file *)file->private_data;
struct acpi_fan *fan = (struct acpi_fan *) m->private;
char state_string[12] = {'\0'};
int result = 0;
struct seq_file *m = (struct seq_file *)file->private_data;
struct acpi_fan *fan = (struct acpi_fan *)m->private;
char state_string[12] = { '\0' };
ACPI_FUNCTION_TRACE("acpi_fan_write_state");
if (!fan || (count > sizeof(state_string) - 1))
return_VALUE(-EINVAL);
if (copy_from_user(state_string, buffer, count))
return_VALUE(-EFAULT);
state_string[count] = '\0';
result = acpi_bus_set_power(fan->handle,
simple_strtoul(state_string, NULL, 0));
result = acpi_bus_set_power(fan->handle,
simple_strtoul(state_string, NULL, 0));
if (result)
return_VALUE(result);
@ -129,19 +119,17 @@ acpi_fan_write_state (
}
static struct file_operations acpi_fan_state_ops = {
.open = acpi_fan_state_open_fs,
.read = seq_read,
.write = acpi_fan_write_state,
.llseek = seq_lseek,
.release = single_release,
.open = acpi_fan_state_open_fs,
.read = seq_read,
.write = acpi_fan_write_state,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};
static int
acpi_fan_add_fs (
struct acpi_device *device)
static int acpi_fan_add_fs(struct acpi_device *device)
{
struct proc_dir_entry *entry = NULL;
struct proc_dir_entry *entry = NULL;
ACPI_FUNCTION_TRACE("acpi_fan_add_fs");
@ -150,7 +138,7 @@ acpi_fan_add_fs (
if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_fan_dir);
acpi_fan_dir);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
acpi_device_dir(device)->owner = THIS_MODULE;
@ -158,11 +146,12 @@ acpi_fan_add_fs (
/* 'status' [R/W] */
entry = create_proc_entry(ACPI_FAN_FILE_STATE,
S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device));
if (!entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_FAN_FILE_STATE));
"Unable to create '%s' fs entry\n",
ACPI_FAN_FILE_STATE));
else {
entry->proc_fops = &acpi_fan_state_ops;
entry->data = acpi_driver_data(device);
@ -172,16 +161,12 @@ acpi_fan_add_fs (
return_VALUE(0);
}
static int
acpi_fan_remove_fs (
struct acpi_device *device)
static int acpi_fan_remove_fs(struct acpi_device *device)
{
ACPI_FUNCTION_TRACE("acpi_fan_remove_fs");
if (acpi_device_dir(device)) {
remove_proc_entry(ACPI_FAN_FILE_STATE,
acpi_device_dir(device));
remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device));
remove_proc_entry(acpi_device_bid(device), acpi_fan_dir);
acpi_device_dir(device) = NULL;
}
@ -189,18 +174,15 @@ acpi_fan_remove_fs (
return_VALUE(0);
}
/* --------------------------------------------------------------------------
Driver Interface
-------------------------------------------------------------------------- */
static int
acpi_fan_add (
struct acpi_device *device)
static int acpi_fan_add(struct acpi_device *device)
{
int result = 0;
struct acpi_fan *fan = NULL;
int state = 0;
int result = 0;
struct acpi_fan *fan = NULL;
int state = 0;
ACPI_FUNCTION_TRACE("acpi_fan_add");
@ -213,14 +195,14 @@ acpi_fan_add (
memset(fan, 0, sizeof(struct acpi_fan));
fan->handle = device->handle;
strcpy(acpi_device_name(device), ACPI_FAN_DEVICE_NAME);
strcpy(acpi_device_name(device), "Fan");
strcpy(acpi_device_class(device), ACPI_FAN_CLASS);
acpi_driver_data(device) = fan;
result = acpi_bus_get_power(fan->handle, &state);
if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error reading power state\n"));
"Error reading power state\n"));
goto end;
}
@ -229,30 +211,26 @@ acpi_fan_add (
goto end;
printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
acpi_device_name(device), acpi_device_bid(device),
!device->power.state?"on":"off");
acpi_device_name(device), acpi_device_bid(device),
!device->power.state ? "on" : "off");
end:
end:
if (result)
kfree(fan);
return_VALUE(result);
}
static int
acpi_fan_remove (
struct acpi_device *device,
int type)
static int acpi_fan_remove(struct acpi_device *device, int type)
{
struct acpi_fan *fan = NULL;
struct acpi_fan *fan = NULL;
ACPI_FUNCTION_TRACE("acpi_fan_remove");
if (!device || !acpi_driver_data(device))
return_VALUE(-EINVAL);
fan = (struct acpi_fan *) acpi_driver_data(device);
fan = (struct acpi_fan *)acpi_driver_data(device);
acpi_fan_remove_fs(device);
@ -261,11 +239,9 @@ acpi_fan_remove (
return_VALUE(0);
}
static int __init
acpi_fan_init (void)
static int __init acpi_fan_init(void)
{
int result = 0;
int result = 0;
ACPI_FUNCTION_TRACE("acpi_fan_init");
@ -283,9 +259,7 @@ acpi_fan_init (void)
return_VALUE(0);
}
static void __exit
acpi_fan_exit (void)
static void __exit acpi_fan_exit(void)
{
ACPI_FUNCTION_TRACE("acpi_fan_exit");
@ -296,7 +270,5 @@ acpi_fan_exit (void)
return_VOID;
}
module_init(acpi_fan_init);
module_exit(acpi_fan_exit);

View File

@ -29,7 +29,8 @@ int register_acpi_bus_type(struct acpi_bus_type *type)
down_write(&bus_type_sem);
list_add_tail(&type->list, &bus_type_list);
up_write(&bus_type_sem);
printk(KERN_INFO PREFIX "bus type %s registered\n", type->bus->name);
printk(KERN_INFO PREFIX "bus type %s registered\n",
type->bus->name);
return 0;
}
return -ENODEV;
@ -45,7 +46,8 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type)
down_write(&bus_type_sem);
list_del_init(&type->list);
up_write(&bus_type_sem);
printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", type->bus->name);
printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n",
type->bus->name);
return 0;
}
return -ENODEV;
@ -168,9 +170,6 @@ find_pci_rootbridge(acpi_handle handle, u32 lvl, void *context, void **rv)
status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &seg);
if (status == AE_NOT_FOUND) {
/* Assume seg = 0 */
printk(KERN_INFO PREFIX
"Assume root bridge [%s] segment is 0\n",
(char *)buffer.pointer);
status = AE_OK;
seg = 0;
}

Some files were not shown because too many files have changed in this diff Show More