aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-04-05 14:16:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-05 14:16:25 -0400
commit32fb6c17566ec66de87324a834c7776f40e35e78 (patch)
tree87b8ed5d66495536fbb452255c3eacd1cfb0c43a /drivers/acpi/acpica
parent45e36c1666aa6c8b0c538abcf984b336184d8c3f (diff)
parent7ec0a7290797f57b780f792d12f4bcc19c83aa4f (diff)
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (140 commits) ACPI: processor: use .notify method instead of installing handler directly ACPI: button: use .notify method instead of installing handler directly ACPI: support acpi_device_ops .notify methods toshiba-acpi: remove MAINTAINERS entry ACPI: battery: asynchronous init acer-wmi: Update copyright notice & documentation acer-wmi: Cleanup the failure cleanup handling acer-wmi: Blacklist Acer Aspire One video: build fix thinkpad-acpi: rework brightness support thinkpad-acpi: enhanced debugging messages for the fan subdriver thinkpad-acpi: enhanced debugging messages for the hotkey subdriver thinkpad-acpi: enhanced debugging messages for rfkill subdrivers thinkpad-acpi: restrict access to some firmware LEDs thinkpad-acpi: remove HKEY disable functionality thinkpad-acpi: add new debug helpers and warn of deprecated atts thinkpad-acpi: add missing log levels thinkpad-acpi: cleanup debug helpers thinkpad-acpi: documentation cleanup thinkpad-acpi: drop ibm-acpi alias ...
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r--drivers/acpi/acpica/Makefile4
-rw-r--r--drivers/acpi/acpica/acglobal.h11
-rw-r--r--drivers/acpi/acpica/achware.h12
-rw-r--r--drivers/acpi/acpica/aclocal.h60
-rw-r--r--drivers/acpi/acpica/acmacros.h4
-rw-r--r--drivers/acpi/acpica/acobject.h1
-rw-r--r--drivers/acpi/acpica/acpredef.h41
-rw-r--r--drivers/acpi/acpica/actables.h9
-rw-r--r--drivers/acpi/acpica/acutils.h15
-rw-r--r--drivers/acpi/acpica/dsinit.c16
-rw-r--r--drivers/acpi/acpica/dsmthdat.c2
-rw-r--r--drivers/acpi/acpica/dsobject.c6
-rw-r--r--drivers/acpi/acpica/dsopcode.c32
-rw-r--r--drivers/acpi/acpica/dsutils.c2
-rw-r--r--drivers/acpi/acpica/dswexec.c5
-rw-r--r--drivers/acpi/acpica/evevent.c18
-rw-r--r--drivers/acpi/acpica/evgpe.c7
-rw-r--r--drivers/acpi/acpica/evgpeblk.c70
-rw-r--r--drivers/acpi/acpica/evmisc.c16
-rw-r--r--drivers/acpi/acpica/evregion.c5
-rw-r--r--drivers/acpi/acpica/evrgnini.c22
-rw-r--r--drivers/acpi/acpica/evxface.c3
-rw-r--r--drivers/acpi/acpica/evxfevnt.c24
-rw-r--r--drivers/acpi/acpica/evxfregn.c3
-rw-r--r--drivers/acpi/acpica/exconfig.c17
-rw-r--r--drivers/acpi/acpica/exconvrt.c11
-rw-r--r--drivers/acpi/acpica/exdump.c59
-rw-r--r--drivers/acpi/acpica/exfield.c29
-rw-r--r--drivers/acpi/acpica/exfldio.c14
-rw-r--r--drivers/acpi/acpica/exmisc.c14
-rw-r--r--drivers/acpi/acpica/exoparg1.c13
-rw-r--r--drivers/acpi/acpica/exoparg2.c2
-rw-r--r--drivers/acpi/acpica/exoparg3.c7
-rw-r--r--drivers/acpi/acpica/exprep.c2
-rw-r--r--drivers/acpi/acpica/exregion.c4
-rw-r--r--drivers/acpi/acpica/exresnte.c8
-rw-r--r--drivers/acpi/acpica/exresolv.c9
-rw-r--r--drivers/acpi/acpica/exresop.c23
-rw-r--r--drivers/acpi/acpica/exstore.c18
-rw-r--r--drivers/acpi/acpica/exstoren.c29
-rw-r--r--drivers/acpi/acpica/exutils.c2
-rw-r--r--drivers/acpi/acpica/hwacpi.c9
-rw-r--r--drivers/acpi/acpica/hwgpe.c21
-rw-r--r--drivers/acpi/acpica/hwregs.c322
-rw-r--r--drivers/acpi/acpica/hwsleep.c130
-rw-r--r--drivers/acpi/acpica/hwvalid.c258
-rw-r--r--drivers/acpi/acpica/hwxface.c279
-rw-r--r--drivers/acpi/acpica/nsaccess.c54
-rw-r--r--drivers/acpi/acpica/nsalloc.c24
-rw-r--r--drivers/acpi/acpica/nsdump.c24
-rw-r--r--drivers/acpi/acpica/nseval.c2
-rw-r--r--drivers/acpi/acpica/nsinit.c19
-rw-r--r--drivers/acpi/acpica/nsload.c4
-rw-r--r--drivers/acpi/acpica/nsobject.c18
-rw-r--r--drivers/acpi/acpica/nsparse.c10
-rw-r--r--drivers/acpi/acpica/nspredef.c38
-rw-r--r--drivers/acpi/acpica/nssearch.c14
-rw-r--r--drivers/acpi/acpica/nsutils.c27
-rw-r--r--drivers/acpi/acpica/nswalk.c12
-rw-r--r--drivers/acpi/acpica/nsxfeval.c36
-rw-r--r--drivers/acpi/acpica/rscalc.c7
-rw-r--r--drivers/acpi/acpica/rscreate.c15
-rw-r--r--drivers/acpi/acpica/tbfadt.c363
-rw-r--r--drivers/acpi/acpica/tbinstal.c82
-rw-r--r--drivers/acpi/acpica/tbutils.c106
-rw-r--r--drivers/acpi/acpica/tbxface.c71
-rw-r--r--drivers/acpi/acpica/tbxfroot.c4
-rw-r--r--drivers/acpi/acpica/utcopy.c30
-rw-r--r--drivers/acpi/acpica/utdelete.c6
-rw-r--r--drivers/acpi/acpica/uteval.c98
-rw-r--r--drivers/acpi/acpica/utglobal.c17
-rw-r--r--drivers/acpi/acpica/utlock.c175
-rw-r--r--drivers/acpi/acpica/utmisc.c3
-rw-r--r--drivers/acpi/acpica/utmutex.c23
-rw-r--r--drivers/acpi/acpica/utobject.c11
75 files changed, 1804 insertions, 1157 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 3f23298ee3fd..17e50824a6f1 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -18,7 +18,7 @@ obj-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\
18 excreate.o exmisc.o exoparg2.o exregion.o exstore.o exutils.o \ 18 excreate.o exmisc.o exoparg2.o exregion.o exstore.o exutils.o \
19 exdump.o exmutex.o exoparg3.o exresnte.o exstoren.o 19 exdump.o exmutex.o exoparg3.o exresnte.o exstoren.o
20 20
21obj-y += hwacpi.o hwgpe.o hwregs.o hwsleep.o hwxface.o 21obj-y += hwacpi.o hwgpe.o hwregs.o hwsleep.o hwxface.o hwvalid.o
22 22
23obj-$(ACPI_FUTURE_USAGE) += hwtimer.o 23obj-$(ACPI_FUTURE_USAGE) += hwtimer.o
24 24
@@ -41,4 +41,4 @@ obj-y += tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o
41 41
42obj-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 42obj-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
43 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \ 43 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
44 utstate.o utmutex.o utobject.o utresrc.o 44 utstate.o utmutex.o utobject.o utresrc.o utlock.o
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index ddb40f5c68fc..16e5210ae936 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -148,9 +148,12 @@ ACPI_EXTERN struct acpi_internal_rsdt acpi_gbl_root_table_list;
148ACPI_EXTERN struct acpi_table_fadt acpi_gbl_FADT; 148ACPI_EXTERN struct acpi_table_fadt acpi_gbl_FADT;
149ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS; 149ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS;
150 150
151/* These addresses are calculated from FADT address values */ 151/* These addresses are calculated from the FADT Event Block addresses */
152 152
153ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_status;
153ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable; 154ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable;
155
156ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_status;
154ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable; 157ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable;
155 158
156/* 159/*
@@ -162,6 +165,10 @@ ACPI_EXTERN u8 acpi_gbl_integer_bit_width;
162ACPI_EXTERN u8 acpi_gbl_integer_byte_width; 165ACPI_EXTERN u8 acpi_gbl_integer_byte_width;
163ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; 166ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
164 167
168/* Reader/Writer lock is used for namespace walk and dynamic table unload */
169
170ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock;
171
165/***************************************************************************** 172/*****************************************************************************
166 * 173 *
167 * Mutual exlusion within ACPICA subsystem 174 * Mutual exlusion within ACPICA subsystem
@@ -245,6 +252,7 @@ ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
245ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; 252ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
246ACPI_EXTERN u8 acpi_gbl_events_initialized; 253ACPI_EXTERN u8 acpi_gbl_events_initialized;
247ACPI_EXTERN u8 acpi_gbl_system_awake_and_running; 254ACPI_EXTERN u8 acpi_gbl_system_awake_and_running;
255ACPI_EXTERN u8 acpi_gbl_osi_data;
248 256
249#ifndef DEFINE_ACPI_GLOBALS 257#ifndef DEFINE_ACPI_GLOBALS
250 258
@@ -371,7 +379,6 @@ ACPI_EXTERN char *acpi_gbl_db_buffer;
371ACPI_EXTERN char *acpi_gbl_db_filename; 379ACPI_EXTERN char *acpi_gbl_db_filename;
372ACPI_EXTERN u32 acpi_gbl_db_debug_level; 380ACPI_EXTERN u32 acpi_gbl_db_debug_level;
373ACPI_EXTERN u32 acpi_gbl_db_console_debug_level; 381ACPI_EXTERN u32 acpi_gbl_db_console_debug_level;
374ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr;
375ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node; 382ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node;
376 383
377/* 384/*
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 58c69dc49ab4..4afa3d8e0efb 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -64,14 +64,22 @@ u32 acpi_hw_get_mode(void);
64 */ 64 */
65struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id); 65struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id);
66 66
67acpi_status 67acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control);
68acpi_hw_register_read(u32 register_id, u32 * return_value); 68
69acpi_status acpi_hw_register_read(u32 register_id, u32 *return_value);
69 70
70acpi_status acpi_hw_register_write(u32 register_id, u32 value); 71acpi_status acpi_hw_register_write(u32 register_id, u32 value);
71 72
72acpi_status acpi_hw_clear_acpi_status(void); 73acpi_status acpi_hw_clear_acpi_status(void);
73 74
74/* 75/*
76 * hwvalid - Port I/O with validation
77 */
78acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width);
79
80acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width);
81
82/*
75 * hwgpe - GPE support 83 * hwgpe - GPE support
76 */ 84 */
77acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info); 85acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 492d02761bb7..772ee5c4ccca 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -108,6 +108,14 @@ static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
108#endif 108#endif
109#endif 109#endif
110 110
111/* Lock structure for reader/writer interfaces */
112
113struct acpi_rw_lock {
114 acpi_mutex writer_mutex;
115 acpi_mutex reader_mutex;
116 u32 num_readers;
117};
118
111/* 119/*
112 * Predefined handles for spinlocks used within the subsystem. 120 * Predefined handles for spinlocks used within the subsystem.
113 * These spinlocks are created by acpi_ut_mutex_initialize 121 * These spinlocks are created by acpi_ut_mutex_initialize
@@ -772,7 +780,19 @@ struct acpi_bit_register_info {
772 * must be preserved. 780 * must be preserved.
773 */ 781 */
774#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ 782#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */
775#define ACPI_PM1_CONTROL_PRESERVED_BITS 0x0200 /* Bit 9 (whatever) */ 783
784/* Write-only bits must be zeroed by software */
785
786#define ACPI_PM1_CONTROL_WRITEONLY_BITS 0x2004 /* Bits 13, 2 */
787
788/* For control registers, both ignored and reserved bits must be preserved */
789
790#define ACPI_PM1_CONTROL_IGNORED_BITS 0x0201 /* Bits 9, 0(SCI_EN) */
791#define ACPI_PM1_CONTROL_RESERVED_BITS 0xC1F8 /* Bits 14-15, 3-8 */
792#define ACPI_PM1_CONTROL_PRESERVED_BITS \
793 (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS)
794
795#define ACPI_PM2_CONTROL_PRESERVED_BITS 0xFFFFFFFE /* All except bit 0 */
776 796
777/* 797/*
778 * Register IDs 798 * Register IDs
@@ -781,12 +801,10 @@ struct acpi_bit_register_info {
781#define ACPI_REGISTER_PM1_STATUS 0x01 801#define ACPI_REGISTER_PM1_STATUS 0x01
782#define ACPI_REGISTER_PM1_ENABLE 0x02 802#define ACPI_REGISTER_PM1_ENABLE 0x02
783#define ACPI_REGISTER_PM1_CONTROL 0x03 803#define ACPI_REGISTER_PM1_CONTROL 0x03
784#define ACPI_REGISTER_PM1A_CONTROL 0x04 804#define ACPI_REGISTER_PM2_CONTROL 0x04
785#define ACPI_REGISTER_PM1B_CONTROL 0x05 805#define ACPI_REGISTER_PM_TIMER 0x05
786#define ACPI_REGISTER_PM2_CONTROL 0x06 806#define ACPI_REGISTER_PROCESSOR_BLOCK 0x06
787#define ACPI_REGISTER_PM_TIMER 0x07 807#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x07
788#define ACPI_REGISTER_PROCESSOR_BLOCK 0x08
789#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09
790 808
791/* Masks used to access the bit_registers */ 809/* Masks used to access the bit_registers */
792 810
@@ -818,7 +836,7 @@ struct acpi_bit_register_info {
818#define ACPI_BITMASK_SCI_ENABLE 0x0001 836#define ACPI_BITMASK_SCI_ENABLE 0x0001
819#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 837#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
820#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 838#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004
821#define ACPI_BITMASK_SLEEP_TYPE_X 0x1C00 839#define ACPI_BITMASK_SLEEP_TYPE 0x1C00
822#define ACPI_BITMASK_SLEEP_ENABLE 0x2000 840#define ACPI_BITMASK_SLEEP_ENABLE 0x2000
823 841
824#define ACPI_BITMASK_ARB_DISABLE 0x0001 842#define ACPI_BITMASK_ARB_DISABLE 0x0001
@@ -844,11 +862,35 @@ struct acpi_bit_register_info {
844#define ACPI_BITPOSITION_SCI_ENABLE 0x00 862#define ACPI_BITPOSITION_SCI_ENABLE 0x00
845#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 863#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01
846#define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02 864#define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02
847#define ACPI_BITPOSITION_SLEEP_TYPE_X 0x0A 865#define ACPI_BITPOSITION_SLEEP_TYPE 0x0A
848#define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D 866#define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D
849 867
850#define ACPI_BITPOSITION_ARB_DISABLE 0x00 868#define ACPI_BITPOSITION_ARB_DISABLE 0x00
851 869
870/* Structs and definitions for _OSI support and I/O port validation */
871
872#define ACPI_OSI_WIN_2000 0x01
873#define ACPI_OSI_WIN_XP 0x02
874#define ACPI_OSI_WIN_XP_SP1 0x03
875#define ACPI_OSI_WINSRV_2003 0x04
876#define ACPI_OSI_WIN_XP_SP2 0x05
877#define ACPI_OSI_WINSRV_2003_SP1 0x06
878#define ACPI_OSI_WIN_VISTA 0x07
879
880#define ACPI_ALWAYS_ILLEGAL 0x00
881
882struct acpi_interface_info {
883 char *name;
884 u8 value;
885};
886
887struct acpi_port_info {
888 char *name;
889 u16 start;
890 u16 end;
891 u8 osi_dependency;
892};
893
852/***************************************************************************** 894/*****************************************************************************
853 * 895 *
854 * Resource descriptors 896 * Resource descriptors
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 9c127e8e2d6d..91ac7d7b4402 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -292,10 +292,6 @@
292#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type) 292#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type)
293#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t) 293#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t)
294 294
295/* Macro to test the object type */
296
297#define ACPI_GET_OBJECT_TYPE(d) (((union acpi_operand_object *)(void *)(d))->common.type)
298
299/* 295/*
300 * Macros for the master AML opcode table 296 * Macros for the master AML opcode table
301 */ 297 */
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index eb6f038b03d9..544dcf834922 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -97,7 +97,6 @@
97#define AOPOBJ_OBJECT_INITIALIZED 0x08 97#define AOPOBJ_OBJECT_INITIALIZED 0x08
98#define AOPOBJ_SETUP_COMPLETE 0x10 98#define AOPOBJ_SETUP_COMPLETE 0x10
99#define AOPOBJ_SINGLE_DATUM 0x20 99#define AOPOBJ_SINGLE_DATUM 0x20
100#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an op_region address */
101 100
102/****************************************************************************** 101/******************************************************************************
103 * 102 *
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 16a9ca9a66e4..63f656ae3604 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -52,41 +52,44 @@
52 * 1) PTYPE1 packages do not contain sub-packages. 52 * 1) PTYPE1 packages do not contain sub-packages.
53 * 53 *
54 * ACPI_PTYPE1_FIXED: Fixed length, 1 or 2 object types: 54 * ACPI_PTYPE1_FIXED: Fixed length, 1 or 2 object types:
55 * object type 55 * object type
56 * count 56 * count
57 * object type 57 * object type
58 * count 58 * count
59 * 59 *
60 * ACPI_PTYPE1_VAR: Variable length: 60 * ACPI_PTYPE1_VAR: Variable length:
61 * object type (Int/Buf/Ref) 61 * object type (Int/Buf/Ref)
62 * 62 *
63 * ACPI_PTYPE1_OPTION: Package has some required and some optional elements: 63 * ACPI_PTYPE1_OPTION: Package has some required and some optional elements
64 * Used for _PRW 64 * (Used for _PRW)
65 * 65 *
66 * 66 *
67 * 2) PTYPE2 packages contain a variable number of sub-packages. Each of the 67 * 2) PTYPE2 packages contain a variable number of sub-packages. Each of the
68 * different types describe the contents of each of the sub-packages. 68 * different types describe the contents of each of the sub-packages.
69 * 69 *
70 * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types: 70 * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types:
71 * object type 71 * object type
72 * count 72 * count
73 * object type 73 * object type
74 * count 74 * count
75 * (Used for _ALR,_MLS,_PSS,_TRT,_TSS)
75 * 76 *
76 * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element: 77 * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element:
77 * object type 78 * object type
79 * (Used for _CSD,_PSD,_TSD)
78 * 80 *
79 * ACPI_PTYPE2_PKG_COUNT: Count of subpackages at start, 1 or 2 object types: 81 * ACPI_PTYPE2_PKG_COUNT: Count of subpackages at start, 1 or 2 object types:
80 * object type 82 * object type
81 * count 83 * count
82 * object type 84 * object type
83 * count 85 * count
86 * (Used for _CST)
84 * 87 *
85 * ACPI_PTYPE2_FIXED: Each subpackage is of fixed length: 88 * ACPI_PTYPE2_FIXED: Each subpackage is of fixed length
86 * Used for _PRT 89 * (Used for _PRT)
87 * 90 *
88 * ACPI_PTYPE2_MIN: Each subpackage has a variable but minimum length 91 * ACPI_PTYPE2_MIN: Each subpackage has a variable but minimum length
89 * Used for _HPX 92 * (Used for _HPX)
90 * 93 *
91 *****************************************************************************/ 94 *****************************************************************************/
92 95
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 7ce6e33c7f78..01c76b8ea7ba 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -49,7 +49,7 @@ acpi_status acpi_allocate_root_table(u32 initial_table_count);
49/* 49/*
50 * tbfadt - FADT parse/convert/validate 50 * tbfadt - FADT parse/convert/validate
51 */ 51 */
52void acpi_tb_parse_fadt(u32 table_index, u8 flags); 52void acpi_tb_parse_fadt(u32 table_index);
53 53
54void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length); 54void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length);
55 55
@@ -79,7 +79,7 @@ void acpi_tb_delete_table(struct acpi_table_desc *table_desc);
79 79
80void acpi_tb_terminate(void); 80void acpi_tb_terminate(void);
81 81
82void acpi_tb_delete_namespace_by_owner(u32 table_index); 82acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index);
83 83
84acpi_status acpi_tb_allocate_owner_id(u32 table_index); 84acpi_status acpi_tb_allocate_owner_id(u32 table_index);
85 85
@@ -109,9 +109,8 @@ acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length);
109 109
110void 110void
111acpi_tb_install_table(acpi_physical_address address, 111acpi_tb_install_table(acpi_physical_address address,
112 u8 flags, char *signature, u32 table_index); 112 char *signature, u32 table_index);
113 113
114acpi_status 114acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address);
115acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags);
116 115
117#endif /* __ACTABLES_H__ */ 116#endif /* __ACTABLES_H__ */
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 80d8813484fe..897810ba0ccc 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -346,6 +346,21 @@ acpi_status
346acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest); 346acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest);
347 347
348/* 348/*
349 * utlock - reader/writer locks
350 */
351acpi_status acpi_ut_create_rw_lock(struct acpi_rw_lock *lock);
352
353void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock);
354
355acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock);
356
357acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock);
358
359acpi_status acpi_ut_acquire_write_lock(struct acpi_rw_lock *lock);
360
361void acpi_ut_release_write_lock(struct acpi_rw_lock *lock);
362
363/*
349 * utobject - internal object create/delete/cache routines 364 * utobject - internal object create/delete/cache routines
350 */ 365 */
351union acpi_operand_object *acpi_ut_create_internal_object_dbg(const char 366union acpi_operand_object *acpi_ut_create_internal_object_dbg(const char
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index eb144b13d8fa..3aae13f30c5e 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -180,11 +180,23 @@ acpi_ds_initialize_objects(u32 table_index,
180 180
181 /* Walk entire namespace from the supplied root */ 181 /* Walk entire namespace from the supplied root */
182 182
183 status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, 183 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
184 acpi_ds_init_one_object, &info, NULL); 184 if (ACPI_FAILURE(status)) {
185 return_ACPI_STATUS(status);
186 }
187
188 /*
189 * We don't use acpi_walk_namespace since we do not want to acquire
190 * the namespace reader lock.
191 */
192 status =
193 acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
194 ACPI_NS_WALK_UNLOCK, acpi_ds_init_one_object,
195 &info, NULL);
185 if (ACPI_FAILURE(status)) { 196 if (ACPI_FAILURE(status)) {
186 ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); 197 ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));
187 } 198 }
199 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
188 200
189 status = acpi_get_table_by_index(table_index, &table); 201 status = acpi_get_table_by_index(table_index, &table);
190 if (ACPI_FAILURE(status)) { 202 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index da0f5468184c..22b1a3ce2c94 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -713,6 +713,6 @@ acpi_ds_method_data_get_type(u16 opcode,
713 713
714 /* Get the object type */ 714 /* Get the object type */
715 715
716 return_VALUE(ACPI_GET_OBJECT_TYPE(object)); 716 return_VALUE(object->type);
717} 717}
718#endif 718#endif
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 15c628e6aa00..dab3f48f0b42 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -565,7 +565,7 @@ acpi_ds_create_node(struct acpi_walk_state *walk_state,
565 565
566 /* Re-type the object according to its argument */ 566 /* Re-type the object according to its argument */
567 567
568 node->type = ACPI_GET_OBJECT_TYPE(obj_desc); 568 node->type = obj_desc->common.type;
569 569
570 /* Attach obj to node */ 570 /* Attach obj to node */
571 571
@@ -619,7 +619,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
619 619
620 /* Perform per-object initialization */ 620 /* Perform per-object initialization */
621 621
622 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 622 switch (obj_desc->common.type) {
623 case ACPI_TYPE_BUFFER: 623 case ACPI_TYPE_BUFFER:
624 624
625 /* 625 /*
@@ -803,7 +803,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
803 default: 803 default:
804 804
805 ACPI_ERROR((AE_INFO, "Unimplemented data type: %X", 805 ACPI_ERROR((AE_INFO, "Unimplemented data type: %X",
806 ACPI_GET_OBJECT_TYPE(obj_desc))); 806 obj_desc->common.type));
807 807
808 status = AE_AML_OPERAND_TYPE; 808 status = AE_AML_OPERAND_TYPE;
809 break; 809 break;
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index 0c3b4dd60e8a..b4c87b5053e6 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -397,30 +397,6 @@ acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
397 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), 397 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
398 extra_desc->extra.aml_length, 398 extra_desc->extra.aml_length,
399 extra_desc->extra.aml_start); 399 extra_desc->extra.aml_start);
400 if (ACPI_FAILURE(status)) {
401 return_ACPI_STATUS(status);
402 }
403
404 /* Validate the region address/length via the host OS */
405
406 status = acpi_os_validate_address(obj_desc->region.space_id,
407 obj_desc->region.address,
408 (acpi_size) obj_desc->region.length,
409 acpi_ut_get_node_name(node));
410
411 if (ACPI_FAILURE(status)) {
412 /*
413 * Invalid address/length. We will emit an error message and mark
414 * the region as invalid, so that it will cause an additional error if
415 * it is ever used. Then return AE_OK.
416 */
417 ACPI_EXCEPTION((AE_INFO, status,
418 "During address validation of OpRegion [%4.4s]",
419 node->name.ascii));
420 obj_desc->common.flags |= AOPOBJ_INVALID;
421 status = AE_OK;
422 }
423
424 return_ACPI_STATUS(status); 400 return_ACPI_STATUS(status);
425} 401}
426 402
@@ -484,7 +460,7 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
484 460
485 /* Host object must be a Buffer */ 461 /* Host object must be a Buffer */
486 462
487 if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) { 463 if (buffer_desc->common.type != ACPI_TYPE_BUFFER) {
488 ACPI_ERROR((AE_INFO, 464 ACPI_ERROR((AE_INFO,
489 "Target of Create Field is not a Buffer object - %s", 465 "Target of Create Field is not a Buffer object - %s",
490 acpi_ut_get_object_type_name(buffer_desc))); 466 acpi_ut_get_object_type_name(buffer_desc)));
@@ -1365,10 +1341,8 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1365 if ((ACPI_GET_DESCRIPTOR_TYPE 1341 if ((ACPI_GET_DESCRIPTOR_TYPE
1366 (walk_state->results->results.obj_desc[0]) == 1342 (walk_state->results->results.obj_desc[0]) ==
1367 ACPI_DESC_TYPE_OPERAND) 1343 ACPI_DESC_TYPE_OPERAND)
1368 && 1344 && ((walk_state->results->results.obj_desc[0])->
1369 (ACPI_GET_OBJECT_TYPE 1345 common.type == ACPI_TYPE_LOCAL_REFERENCE)
1370 (walk_state->results->results.obj_desc[0]) ==
1371 ACPI_TYPE_LOCAL_REFERENCE)
1372 && ((walk_state->results->results.obj_desc[0])-> 1346 && ((walk_state->results->results.obj_desc[0])->
1373 reference.class != ACPI_REFCLASS_INDEX)) { 1347 reference.class != ACPI_REFCLASS_INDEX)) {
1374 status = 1348 status =
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index dabc23a46176..dfa104102926 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -816,7 +816,7 @@ acpi_status acpi_ds_evaluate_name_path(struct acpi_walk_state *walk_state)
816 goto push_result; 816 goto push_result;
817 } 817 }
818 818
819 type = ACPI_GET_OBJECT_TYPE(*operand); 819 type = (*operand)->common.type;
820 820
821 status = acpi_ex_resolve_to_value(operand, walk_state); 821 status = acpi_ex_resolve_to_value(operand, walk_state);
822 if (ACPI_FAILURE(status)) { 822 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c
index 350e6656bc89..f0280856dc0e 100644
--- a/drivers/acpi/acpica/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -138,11 +138,10 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
138 goto cleanup; 138 goto cleanup;
139 } 139 }
140 140
141 if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) { 141 if (local_obj_desc->common.type != ACPI_TYPE_INTEGER) {
142 ACPI_ERROR((AE_INFO, 142 ACPI_ERROR((AE_INFO,
143 "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X", 143 "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X",
144 obj_desc, walk_state, 144 obj_desc, walk_state, obj_desc->common.type));
145 ACPI_GET_OBJECT_TYPE(obj_desc)));
146 145
147 status = AE_AML_OPERAND_TYPE; 146 status = AE_AML_OPERAND_TYPE;
148 goto cleanup; 147 goto cleanup;
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index 803edd9e3f6a..cd55c774e882 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -183,7 +183,7 @@ acpi_status acpi_ev_install_xrupt_handlers(void)
183 * 183 *
184 * RETURN: Status 184 * RETURN: Status
185 * 185 *
186 * DESCRIPTION: Install the fixed event handlers and enable the fixed events. 186 * DESCRIPTION: Install the fixed event handlers and disable all fixed events.
187 * 187 *
188 ******************************************************************************/ 188 ******************************************************************************/
189 189
@@ -200,12 +200,13 @@ static acpi_status acpi_ev_fixed_event_initialize(void)
200 acpi_gbl_fixed_event_handlers[i].handler = NULL; 200 acpi_gbl_fixed_event_handlers[i].handler = NULL;
201 acpi_gbl_fixed_event_handlers[i].context = NULL; 201 acpi_gbl_fixed_event_handlers[i].context = NULL;
202 202
203 /* Enable the fixed event */ 203 /* Disable the fixed event */
204 204
205 if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) { 205 if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) {
206 status = 206 status =
207 acpi_set_register(acpi_gbl_fixed_event_info[i]. 207 acpi_write_bit_register(acpi_gbl_fixed_event_info
208 enable_register_id, 0); 208 [i].enable_register_id,
209 ACPI_DISABLE_EVENT);
209 if (ACPI_FAILURE(status)) { 210 if (ACPI_FAILURE(status)) {
210 return (status); 211 return (status);
211 } 212 }
@@ -288,16 +289,17 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
288 289
289 /* Clear the status bit */ 290 /* Clear the status bit */
290 291
291 (void)acpi_set_register(acpi_gbl_fixed_event_info[event]. 292 (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
292 status_register_id, 1); 293 status_register_id, ACPI_CLEAR_STATUS);
293 294
294 /* 295 /*
295 * Make sure we've got a handler. If not, report an error. The event is 296 * Make sure we've got a handler. If not, report an error. The event is
296 * disabled to prevent further interrupts. 297 * disabled to prevent further interrupts.
297 */ 298 */
298 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { 299 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) {
299 (void)acpi_set_register(acpi_gbl_fixed_event_info[event]. 300 (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
300 enable_register_id, 0); 301 enable_register_id,
302 ACPI_DISABLE_EVENT);
301 303
302 ACPI_ERROR((AE_INFO, 304 ACPI_ERROR((AE_INFO,
303 "No installed handler for fixed event [%08X]", 305 "No installed handler for fixed event [%08X]",
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index f345ced36477..b9d8ee69ca6c 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -88,10 +88,10 @@ acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type)
88 88
89 status = acpi_ev_disable_gpe(gpe_event_info); 89 status = acpi_ev_disable_gpe(gpe_event_info);
90 90
91 /* Type was validated above */ 91 /* Clear the type bits and insert the new Type */
92 92
93 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ 93 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK;
94 gpe_event_info->flags |= type; /* Insert type */ 94 gpe_event_info->flags |= type;
95 return_ACPI_STATUS(status); 95 return_ACPI_STATUS(status);
96} 96}
97 97
@@ -122,6 +122,7 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
122 if (!gpe_register_info) { 122 if (!gpe_register_info) {
123 return_ACPI_STATUS(AE_NOT_EXIST); 123 return_ACPI_STATUS(AE_NOT_EXIST);
124 } 124 }
125
125 register_bit = (u8) 126 register_bit = (u8)
126 (1 << 127 (1 <<
127 (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number)); 128 (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number));
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 484cc0565d5b..7b3463639422 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -104,9 +104,9 @@ u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
104 104
105 while (gpe_block) { 105 while (gpe_block) {
106 if ((&gpe_block->event_info[0] <= gpe_event_info) && 106 if ((&gpe_block->event_info[0] <= gpe_event_info) &&
107 (&gpe_block-> 107 (&gpe_block->event_info[((acpi_size)
108 event_info[((acpi_size) gpe_block-> 108 gpe_block->
109 register_count) * 8] > 109 register_count) * 8] >
110 gpe_event_info)) { 110 gpe_event_info)) {
111 return (TRUE); 111 return (TRUE);
112 } 112 }
@@ -210,10 +210,9 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
210 /* Now look at the individual GPEs in this byte register */ 210 /* Now look at the individual GPEs in this byte register */
211 211
212 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { 212 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
213 gpe_event_info = 213 gpe_event_info = &gpe_block->event_info[((acpi_size) i *
214 &gpe_block-> 214 ACPI_GPE_REGISTER_WIDTH)
215 event_info[((acpi_size) i * 215 + j];
216 ACPI_GPE_REGISTER_WIDTH) + j];
217 216
218 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 217 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
219 ACPI_GPE_DISPATCH_HANDLER) { 218 ACPI_GPE_DISPATCH_HANDLER) {
@@ -293,8 +292,8 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
293 /* Unknown method type, just ignore it! */ 292 /* Unknown method type, just ignore it! */
294 293
295 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, 294 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
296 "Ignoring unknown GPE method type: %s (name not of form _Lxx or _Exx)", 295 "Ignoring unknown GPE method type: %s "
297 name)); 296 "(name not of form _Lxx or _Exx)", name));
298 return_ACPI_STATUS(AE_OK); 297 return_ACPI_STATUS(AE_OK);
299 } 298 }
300 299
@@ -306,17 +305,16 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
306 /* Conversion failed; invalid method, just ignore it */ 305 /* Conversion failed; invalid method, just ignore it */
307 306
308 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, 307 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
309 "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)", 308 "Could not extract GPE number from name: %s "
310 name)); 309 "(name is not of form _Lxx or _Exx)", name));
311 return_ACPI_STATUS(AE_OK); 310 return_ACPI_STATUS(AE_OK);
312 } 311 }
313 312
314 /* Ensure that we have a valid GPE number for this GPE block */ 313 /* Ensure that we have a valid GPE number for this GPE block */
315 314
316 if ((gpe_number < gpe_block->block_base_number) || 315 if ((gpe_number < gpe_block->block_base_number) ||
317 (gpe_number >= 316 (gpe_number >= (gpe_block->block_base_number +
318 (gpe_block->block_base_number + 317 (gpe_block->register_count * 8)))) {
319 (gpe_block->register_count * 8)))) {
320 /* 318 /*
321 * Not valid for this GPE block, just ignore it. However, it may be 319 * Not valid for this GPE block, just ignore it. However, it may be
322 * valid for a different GPE block, since GPE0 and GPE1 methods both 320 * valid for a different GPE block, since GPE0 and GPE1 methods both
@@ -408,7 +406,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
408 */ 406 */
409 obj_desc = pkg_desc->package.elements[0]; 407 obj_desc = pkg_desc->package.elements[0];
410 408
411 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 409 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
412 410
413 /* Use FADT-defined GPE device (from definition of _PRW) */ 411 /* Use FADT-defined GPE device (from definition of _PRW) */
414 412
@@ -417,15 +415,15 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
417 /* Integer is the GPE number in the FADT described GPE blocks */ 415 /* Integer is the GPE number in the FADT described GPE blocks */
418 416
419 gpe_number = (u32) obj_desc->integer.value; 417 gpe_number = (u32) obj_desc->integer.value;
420 } else if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { 418 } else if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
421 419
422 /* Package contains a GPE reference and GPE number within a GPE block */ 420 /* Package contains a GPE reference and GPE number within a GPE block */
423 421
424 if ((obj_desc->package.count < 2) || 422 if ((obj_desc->package.count < 2) ||
425 (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[0]) != 423 ((obj_desc->package.elements[0])->common.type !=
426 ACPI_TYPE_LOCAL_REFERENCE) 424 ACPI_TYPE_LOCAL_REFERENCE) ||
427 || (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[1]) != 425 ((obj_desc->package.elements[1])->common.type !=
428 ACPI_TYPE_INTEGER)) { 426 ACPI_TYPE_INTEGER)) {
429 goto cleanup; 427 goto cleanup;
430 } 428 }
431 429
@@ -450,11 +448,11 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
450 */ 448 */
451 if ((gpe_device == target_gpe_device) && 449 if ((gpe_device == target_gpe_device) &&
452 (gpe_number >= gpe_block->block_base_number) && 450 (gpe_number >= gpe_block->block_base_number) &&
453 (gpe_number < 451 (gpe_number < gpe_block->block_base_number +
454 gpe_block->block_base_number + (gpe_block->register_count * 8))) { 452 (gpe_block->register_count * 8))) {
455 gpe_event_info = 453 gpe_event_info = &gpe_block->event_info[gpe_number -
456 &gpe_block->event_info[gpe_number - 454 gpe_block->
457 gpe_block->block_base_number]; 455 block_base_number];
458 456
459 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ 457 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */
460 458
@@ -1033,8 +1031,8 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
1033 * 1) are "runtime" or "run/wake" GPEs, and 1031 * 1) are "runtime" or "run/wake" GPEs, and
1034 * 2) have a corresponding _Lxx or _Exx method 1032 * 2) have a corresponding _Lxx or _Exx method
1035 * 1033 *
1036 * Any other GPEs within this block must be enabled via the acpi_enable_gpe() 1034 * Any other GPEs within this block must be enabled via the
1037 * external interface. 1035 * acpi_enable_gpe() external interface.
1038 */ 1036 */
1039 wake_gpe_count = 0; 1037 wake_gpe_count = 0;
1040 gpe_enabled_count = 0; 1038 gpe_enabled_count = 0;
@@ -1044,14 +1042,13 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
1044 1042
1045 /* Get the info block for this particular GPE */ 1043 /* Get the info block for this particular GPE */
1046 1044
1047 gpe_event_info = 1045 gpe_event_info = &gpe_block->event_info[((acpi_size) i *
1048 &gpe_block-> 1046 ACPI_GPE_REGISTER_WIDTH)
1049 event_info[((acpi_size) i * 1047 + j];
1050 ACPI_GPE_REGISTER_WIDTH) + j];
1051 1048
1052 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 1049 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
1053 ACPI_GPE_DISPATCH_METHOD) 1050 ACPI_GPE_DISPATCH_METHOD) &&
1054 && (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) { 1051 (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) {
1055 gpe_enabled_count++; 1052 gpe_enabled_count++;
1056 } 1053 }
1057 1054
@@ -1105,8 +1102,8 @@ acpi_status acpi_ev_gpe_initialize(void)
1105 /* 1102 /*
1106 * Initialize the GPE Block(s) defined in the FADT 1103 * Initialize the GPE Block(s) defined in the FADT
1107 * 1104 *
1108 * Why the GPE register block lengths are divided by 2: From the ACPI Spec, 1105 * Why the GPE register block lengths are divided by 2: From the ACPI
1109 * section "General-Purpose Event Registers", we have: 1106 * Spec, section "General-Purpose Event Registers", we have:
1110 * 1107 *
1111 * "Each register block contains two registers of equal length 1108 * "Each register block contains two registers of equal length
1112 * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the 1109 * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
@@ -1163,7 +1160,8 @@ acpi_status acpi_ev_gpe_initialize(void)
1163 if ((register_count0) && 1160 if ((register_count0) &&
1164 (gpe_number_max >= acpi_gbl_FADT.gpe1_base)) { 1161 (gpe_number_max >= acpi_gbl_FADT.gpe1_base)) {
1165 ACPI_ERROR((AE_INFO, 1162 ACPI_ERROR((AE_INFO,
1166 "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1", 1163 "GPE0 block (GPE 0 to %d) overlaps the GPE1 block "
1164 "(GPE %d to %d) - Ignoring GPE1",
1167 gpe_number_max, acpi_gbl_FADT.gpe1_base, 1165 gpe_number_max, acpi_gbl_FADT.gpe1_base,
1168 acpi_gbl_FADT.gpe1_base + 1166 acpi_gbl_FADT.gpe1_base +
1169 ((register_count1 * 1167 ((register_count1 *
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 5f893057bcc6..ce224e1eaa89 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -163,10 +163,10 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
163 * 2) Global device notify handler 163 * 2) Global device notify handler
164 * 3) Per-device notify handler 164 * 3) Per-device notify handler
165 */ 165 */
166 if ((acpi_gbl_system_notify.handler 166 if ((acpi_gbl_system_notify.handler &&
167 && (notify_value <= ACPI_MAX_SYS_NOTIFY)) 167 (notify_value <= ACPI_MAX_SYS_NOTIFY)) ||
168 || (acpi_gbl_device_notify.handler 168 (acpi_gbl_device_notify.handler &&
169 && (notify_value > ACPI_MAX_SYS_NOTIFY)) || handler_obj) { 169 (notify_value > ACPI_MAX_SYS_NOTIFY)) || handler_obj) {
170 notify_info = acpi_ut_create_generic_state(); 170 notify_info = acpi_ut_create_generic_state();
171 if (!notify_info) { 171 if (!notify_info) {
172 return (AE_NO_MEMORY); 172 return (AE_NO_MEMORY);
@@ -174,7 +174,8 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
174 174
175 if (!handler_obj) { 175 if (!handler_obj) {
176 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 176 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
177 "Executing system notify handler for Notify (%4.4s, %X) node %p\n", 177 "Executing system notify handler for Notify (%4.4s, %X) "
178 "node %p\n",
178 acpi_ut_get_node_name(node), 179 acpi_ut_get_node_name(node),
179 notify_value, node)); 180 notify_value, node));
180 } 181 }
@@ -534,8 +535,9 @@ acpi_status acpi_ev_release_global_lock(void)
534 */ 535 */
535 if (pending) { 536 if (pending) {
536 status = 537 status =
537 acpi_set_register(ACPI_BITREG_GLOBAL_LOCK_RELEASE, 538 acpi_write_bit_register
538 1); 539 (ACPI_BITREG_GLOBAL_LOCK_RELEASE,
540 ACPI_ENABLE_EVENT);
539 } 541 }
540 542
541 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 543 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 665c0887ab4d..538d63264555 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -691,7 +691,7 @@ acpi_ev_install_handler(acpi_handle obj_handle,
691 691
692 /* Devices are handled different than regions */ 692 /* Devices are handled different than regions */
693 693
694 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_DEVICE) { 694 if (obj_desc->common.type == ACPI_TYPE_DEVICE) {
695 695
696 /* Check if this Device already has a handler for this address space */ 696 /* Check if this Device already has a handler for this address space */
697 697
@@ -703,7 +703,8 @@ acpi_ev_install_handler(acpi_handle obj_handle,
703 if (next_handler_obj->address_space.space_id == 703 if (next_handler_obj->address_space.space_id ==
704 handler_obj->address_space.space_id) { 704 handler_obj->address_space.space_id) {
705 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, 705 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
706 "Found handler for region [%s] in device %p(%p) handler %p\n", 706 "Found handler for region [%s] in device %p(%p) "
707 "handler %p\n",
707 acpi_ut_get_region_name 708 acpi_ut_get_region_name
708 (handler_obj->address_space. 709 (handler_obj->address_space.
709 space_id), obj_desc, 710 space_id), obj_desc,
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index f3f1fb45c3dc..284a7becbe96 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -241,7 +241,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
241 status = AE_OK; 241 status = AE_OK;
242 } else { 242 } else {
243 ACPI_EXCEPTION((AE_INFO, status, 243 ACPI_EXCEPTION((AE_INFO, status,
244 "Could not install PciConfig handler for Root Bridge %4.4s", 244 "Could not install PciConfig handler "
245 "for Root Bridge %4.4s",
245 acpi_ut_get_node_name 246 acpi_ut_get_node_name
246 (pci_root_node))); 247 (pci_root_node)));
247 } 248 }
@@ -293,9 +294,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
293 * Get the PCI device and function numbers from the _ADR object contained 294 * Get the PCI device and function numbers from the _ADR object contained
294 * in the parent's scope. 295 * in the parent's scope.
295 */ 296 */
296 status = 297 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR,
297 acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, pci_device_node, 298 pci_device_node, &pci_value);
298 &pci_value);
299 299
300 /* 300 /*
301 * The default is zero, and since the allocation above zeroed the data, 301 * The default is zero, and since the allocation above zeroed the data,
@@ -308,18 +308,16 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
308 308
309 /* The PCI segment number comes from the _SEG method */ 309 /* The PCI segment number comes from the _SEG method */
310 310
311 status = 311 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG,
312 acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, pci_root_node, 312 pci_root_node, &pci_value);
313 &pci_value);
314 if (ACPI_SUCCESS(status)) { 313 if (ACPI_SUCCESS(status)) {
315 pci_id->segment = ACPI_LOWORD(pci_value); 314 pci_id->segment = ACPI_LOWORD(pci_value);
316 } 315 }
317 316
318 /* The PCI bus number comes from the _BBN method */ 317 /* The PCI bus number comes from the _BBN method */
319 318
320 status = 319 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN,
321 acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, pci_root_node, 320 pci_root_node, &pci_value);
322 &pci_value);
323 if (ACPI_SUCCESS(status)) { 321 if (ACPI_SUCCESS(status)) {
324 pci_id->bus = ACPI_LOWORD(pci_value); 322 pci_id->bus = ACPI_LOWORD(pci_value);
325 } 323 }
@@ -632,8 +630,8 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
632 acpi_ns_locked); 630 acpi_ns_locked);
633 631
634 /* 632 /*
635 * Tell all users that this region is usable by running the _REG 633 * Tell all users that this region is usable by
636 * method 634 * running the _REG method
637 */ 635 */
638 if (acpi_ns_locked) { 636 if (acpi_ns_locked) {
639 status = 637 status =
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 3aca9010a11e..10b8543dd466 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -631,7 +631,8 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
631 631
632 /* Setup up dispatch flags to indicate handler (vs. method) */ 632 /* Setup up dispatch flags to indicate handler (vs. method) */
633 633
634 gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ 634 gpe_event_info->flags &=
635 ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
635 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); 636 gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER);
636 637
637 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 638 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 35485e4b60a6..d0a080747ec3 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -172,8 +172,8 @@ acpi_status acpi_enable_event(u32 event, u32 flags)
172 * register bit) 172 * register bit)
173 */ 173 */
174 status = 174 status =
175 acpi_set_register(acpi_gbl_fixed_event_info[event]. 175 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
176 enable_register_id, 1); 176 enable_register_id, ACPI_ENABLE_EVENT);
177 if (ACPI_FAILURE(status)) { 177 if (ACPI_FAILURE(status)) {
178 return_ACPI_STATUS(status); 178 return_ACPI_STATUS(status);
179 } 179 }
@@ -181,8 +181,8 @@ acpi_status acpi_enable_event(u32 event, u32 flags)
181 /* Make sure that the hardware responded */ 181 /* Make sure that the hardware responded */
182 182
183 status = 183 status =
184 acpi_get_register(acpi_gbl_fixed_event_info[event]. 184 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
185 enable_register_id, &value); 185 enable_register_id, &value);
186 if (ACPI_FAILURE(status)) { 186 if (ACPI_FAILURE(status)) {
187 return_ACPI_STATUS(status); 187 return_ACPI_STATUS(status);
188 } 188 }
@@ -354,15 +354,15 @@ acpi_status acpi_disable_event(u32 event, u32 flags)
354 * register bit) 354 * register bit)
355 */ 355 */
356 status = 356 status =
357 acpi_set_register(acpi_gbl_fixed_event_info[event]. 357 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
358 enable_register_id, 0); 358 enable_register_id, ACPI_DISABLE_EVENT);
359 if (ACPI_FAILURE(status)) { 359 if (ACPI_FAILURE(status)) {
360 return_ACPI_STATUS(status); 360 return_ACPI_STATUS(status);
361 } 361 }
362 362
363 status = 363 status =
364 acpi_get_register(acpi_gbl_fixed_event_info[event]. 364 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
365 enable_register_id, &value); 365 enable_register_id, &value);
366 if (ACPI_FAILURE(status)) { 366 if (ACPI_FAILURE(status)) {
367 return_ACPI_STATUS(status); 367 return_ACPI_STATUS(status);
368 } 368 }
@@ -407,8 +407,8 @@ acpi_status acpi_clear_event(u32 event)
407 * register bit) 407 * register bit)
408 */ 408 */
409 status = 409 status =
410 acpi_set_register(acpi_gbl_fixed_event_info[event]. 410 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
411 status_register_id, 1); 411 status_register_id, ACPI_CLEAR_STATUS);
412 412
413 return_ACPI_STATUS(status); 413 return_ACPI_STATUS(status);
414} 414}
@@ -495,7 +495,7 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
495 /* Get the status of the requested fixed event */ 495 /* Get the status of the requested fixed event */
496 496
497 status = 497 status =
498 acpi_get_register(acpi_gbl_fixed_event_info[event]. 498 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
499 enable_register_id, &value); 499 enable_register_id, &value);
500 if (ACPI_FAILURE(status)) 500 if (ACPI_FAILURE(status))
501 return_ACPI_STATUS(status); 501 return_ACPI_STATUS(status);
@@ -503,7 +503,7 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
503 *event_status = value; 503 *event_status = value;
504 504
505 status = 505 status =
506 acpi_get_register(acpi_gbl_fixed_event_info[event]. 506 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
507 status_register_id, &value); 507 status_register_id, &value);
508 if (ACPI_FAILURE(status)) 508 if (ACPI_FAILURE(status))
509 return_ACPI_STATUS(status); 509 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index 479e7a3721be..7c3d2d356ffb 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -193,7 +193,8 @@ acpi_remove_address_space_handler(acpi_handle device,
193 /* Matched space_id, first dereference this in the Regions */ 193 /* Matched space_id, first dereference this in the Regions */
194 194
195 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, 195 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
196 "Removing address handler %p(%p) for region %s on Device %p(%p)\n", 196 "Removing address handler %p(%p) for region %s "
197 "on Device %p(%p)\n",
197 handler_obj, handler, 198 handler_obj, handler,
198 acpi_ut_get_region_name(space_id), 199 acpi_ut_get_region_name(space_id),
199 node, obj_desc)); 200 node, obj_desc));
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 932bbc26aa04..3deb20a126b2 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -291,7 +291,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
291 291
292 /* Source Object can be either an op_region or a Buffer/Field */ 292 /* Source Object can be either an op_region or a Buffer/Field */
293 293
294 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 294 switch (obj_desc->common.type) {
295 case ACPI_TYPE_REGION: 295 case ACPI_TYPE_REGION:
296 296
297 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 297 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -501,7 +501,7 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
501 */ 501 */
502 if ((!ddb_handle) || 502 if ((!ddb_handle) ||
503 (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) || 503 (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
504 (ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) { 504 (ddb_handle->common.type != ACPI_TYPE_LOCAL_REFERENCE)) {
505 return_ACPI_STATUS(AE_BAD_PARAMETER); 505 return_ACPI_STATUS(AE_BAD_PARAMETER);
506 } 506 }
507 507
@@ -520,13 +520,14 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
520 } 520 }
521 } 521 }
522 522
523 /* 523 /* Delete the portion of the namespace owned by this table */
524 * Delete the entire namespace under this table Node 524
525 * (Offset contains the table_id) 525 status = acpi_tb_delete_namespace_by_owner(table_index);
526 */ 526 if (ACPI_FAILURE(status)) {
527 acpi_tb_delete_namespace_by_owner(table_index); 527 return_ACPI_STATUS(status);
528 (void)acpi_tb_release_owner_id(table_index); 528 }
529 529
530 (void)acpi_tb_release_owner_id(table_index);
530 acpi_tb_set_table_loaded_flag(table_index, FALSE); 531 acpi_tb_set_table_loaded_flag(table_index, FALSE);
531 532
532 /* Table unloaded, remove a reference to the ddb_handle object */ 533 /* Table unloaded, remove a reference to the ddb_handle object */
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 0be10188316e..37d0d39e60a6 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -82,7 +82,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
82 82
83 ACPI_FUNCTION_TRACE_PTR(ex_convert_to_integer, obj_desc); 83 ACPI_FUNCTION_TRACE_PTR(ex_convert_to_integer, obj_desc);
84 84
85 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 85 switch (obj_desc->common.type) {
86 case ACPI_TYPE_INTEGER: 86 case ACPI_TYPE_INTEGER:
87 87
88 /* No conversion necessary */ 88 /* No conversion necessary */
@@ -116,7 +116,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
116 116
117 /* String conversion is different than Buffer conversion */ 117 /* String conversion is different than Buffer conversion */
118 118
119 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 119 switch (obj_desc->common.type) {
120 case ACPI_TYPE_STRING: 120 case ACPI_TYPE_STRING:
121 121
122 /* 122 /*
@@ -206,7 +206,7 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
206 206
207 ACPI_FUNCTION_TRACE_PTR(ex_convert_to_buffer, obj_desc); 207 ACPI_FUNCTION_TRACE_PTR(ex_convert_to_buffer, obj_desc);
208 208
209 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 209 switch (obj_desc->common.type) {
210 case ACPI_TYPE_BUFFER: 210 case ACPI_TYPE_BUFFER:
211 211
212 /* No conversion necessary */ 212 /* No conversion necessary */
@@ -409,7 +409,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
409 409
410 ACPI_FUNCTION_TRACE_PTR(ex_convert_to_string, obj_desc); 410 ACPI_FUNCTION_TRACE_PTR(ex_convert_to_string, obj_desc);
411 411
412 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 412 switch (obj_desc->common.type) {
413 case ACPI_TYPE_STRING: 413 case ACPI_TYPE_STRING:
414 414
415 /* No conversion necessary */ 415 /* No conversion necessary */
@@ -605,8 +605,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
605 default: 605 default:
606 /* No conversion allowed for these types */ 606 /* No conversion allowed for these types */
607 607
608 if (destination_type != 608 if (destination_type != source_desc->common.type) {
609 ACPI_GET_OBJECT_TYPE(source_desc)) {
610 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 609 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
611 "Explicit operator, will store (%s) over existing type (%s)\n", 610 "Explicit operator, will store (%s) over existing type (%s)\n",
612 acpi_ut_get_object_type_name 611 acpi_ut_get_object_type_name
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index aa313574b0df..89d141fdae0b 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -350,6 +350,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
350 break; 350 break;
351 351
352 case ACPI_EXD_TYPE: 352 case ACPI_EXD_TYPE:
353
353 acpi_ex_out_string("Type", 354 acpi_ex_out_string("Type",
354 acpi_ut_get_object_type_name 355 acpi_ut_get_object_type_name
355 (obj_desc)); 356 (obj_desc));
@@ -422,6 +423,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
422 break; 423 break;
423 424
424 default: 425 default:
426
425 acpi_os_printf("**** Invalid table opcode [%X] ****\n", 427 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
426 info->opcode); 428 info->opcode);
427 return; 429 return;
@@ -492,7 +494,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
492 494
493 /* Decode object type */ 495 /* Decode object type */
494 496
495 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 497 switch (obj_desc->common.type) {
496 case ACPI_TYPE_LOCAL_REFERENCE: 498 case ACPI_TYPE_LOCAL_REFERENCE:
497 499
498 acpi_os_printf("Reference: [%s] ", 500 acpi_os_printf("Reference: [%s] ",
@@ -527,44 +529,16 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
527 type)); 529 type));
528 break; 530 break;
529 531
530 case ACPI_REFCLASS_ARG: 532 case ACPI_REFCLASS_NAME:
531
532 acpi_os_printf("%X", obj_desc->reference.value);
533
534 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
535
536 /* Value is an Integer */
537
538 acpi_os_printf(" value is [%8.8X%8.8x]",
539 ACPI_FORMAT_UINT64(obj_desc->
540 integer.
541 value));
542 }
543 533
544 acpi_os_printf("\n"); 534 acpi_os_printf("- [%4.4s]\n",
535 obj_desc->reference.node->name.ascii);
545 break; 536 break;
546 537
538 case ACPI_REFCLASS_ARG:
547 case ACPI_REFCLASS_LOCAL: 539 case ACPI_REFCLASS_LOCAL:
548 540
549 acpi_os_printf("%X", obj_desc->reference.value); 541 acpi_os_printf("%X\n", obj_desc->reference.value);
550
551 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
552
553 /* Value is an Integer */
554
555 acpi_os_printf(" value is [%8.8X%8.8x]",
556 ACPI_FORMAT_UINT64(obj_desc->
557 integer.
558 value));
559 }
560
561 acpi_os_printf("\n");
562 break;
563
564 case ACPI_REFCLASS_NAME:
565
566 acpi_os_printf("- [%4.4s]\n",
567 obj_desc->reference.node->name.ascii);
568 break; 542 break;
569 543
570 default: /* Unknown reference class */ 544 default: /* Unknown reference class */
@@ -661,8 +635,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
661 case ACPI_TYPE_LOCAL_REGION_FIELD: 635 case ACPI_TYPE_LOCAL_REGION_FIELD:
662 636
663 acpi_os_printf 637 acpi_os_printf
664 ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", 638 ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at "
665 obj_desc->field.bit_length, 639 "byte=%X bit=%X of below:\n", obj_desc->field.bit_length,
666 obj_desc->field.access_byte_width, 640 obj_desc->field.access_byte_width,
667 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK, 641 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
668 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK, 642 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
@@ -686,9 +660,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
686 660
687 if (!obj_desc->buffer_field.buffer_obj) { 661 if (!obj_desc->buffer_field.buffer_obj) {
688 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n")); 662 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
689 } else 663 } else if ((obj_desc->buffer_field.buffer_obj)->common.type !=
690 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj) 664 ACPI_TYPE_BUFFER) {
691 != ACPI_TYPE_BUFFER) {
692 acpi_os_printf("*not a Buffer*\n"); 665 acpi_os_printf("*not a Buffer*\n");
693 } else { 666 } else {
694 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj, 667 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
@@ -737,8 +710,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
737 default: 710 default:
738 /* Unknown Type */ 711 /* Unknown Type */
739 712
740 acpi_os_printf("Unknown Type %X\n", 713 acpi_os_printf("Unknown Type %X\n", obj_desc->common.type);
741 ACPI_GET_OBJECT_TYPE(obj_desc));
742 break; 714 break;
743 } 715 }
744 716
@@ -939,7 +911,7 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
939 911
940 /* Packages may only contain a few object types */ 912 /* Packages may only contain a few object types */
941 913
942 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 914 switch (obj_desc->common.type) {
943 case ACPI_TYPE_INTEGER: 915 case ACPI_TYPE_INTEGER:
944 916
945 acpi_os_printf("[Integer] = %8.8X%8.8X\n", 917 acpi_os_printf("[Integer] = %8.8X%8.8X\n",
@@ -990,8 +962,7 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
990 962
991 default: 963 default:
992 964
993 acpi_os_printf("[Unknown Type] %X\n", 965 acpi_os_printf("[Unknown Type] %X\n", obj_desc->common.type);
994 ACPI_GET_OBJECT_TYPE(obj_desc));
995 break; 966 break;
996 } 967 }
997} 968}
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index a352d0233857..546dcdd86785 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -84,7 +84,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
84 return_ACPI_STATUS(AE_BAD_PARAMETER); 84 return_ACPI_STATUS(AE_BAD_PARAMETER);
85 } 85 }
86 86
87 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 87 if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
88 /* 88 /*
89 * If the buffer_field arguments have not been previously evaluated, 89 * If the buffer_field arguments have not been previously evaluated,
90 * evaluate them now and save the results. 90 * evaluate them now and save the results.
@@ -95,9 +95,8 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
95 return_ACPI_STATUS(status); 95 return_ACPI_STATUS(status);
96 } 96 }
97 } 97 }
98 } else 98 } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
99 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) 99 (obj_desc->field.region_obj->region.space_id ==
100 && (obj_desc->field.region_obj->region.space_id ==
101 ACPI_ADR_SPACE_SMBUS)) { 100 ACPI_ADR_SPACE_SMBUS)) {
102 /* 101 /*
103 * This is an SMBus read. We must create a buffer to hold the data 102 * This is an SMBus read. We must create a buffer to hold the data
@@ -163,7 +162,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
163 162
164 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 163 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
165 "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", 164 "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
166 obj_desc, ACPI_GET_OBJECT_TYPE(obj_desc), buffer, 165 obj_desc, obj_desc->common.type, buffer,
167 (u32) length)); 166 (u32) length));
168 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 167 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
169 "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n", 168 "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n",
@@ -222,7 +221,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
222 return_ACPI_STATUS(AE_AML_NO_OPERAND); 221 return_ACPI_STATUS(AE_AML_NO_OPERAND);
223 } 222 }
224 223
225 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 224 if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
226 /* 225 /*
227 * If the buffer_field arguments have not been previously evaluated, 226 * If the buffer_field arguments have not been previously evaluated,
228 * evaluate them now and save the results. 227 * evaluate them now and save the results.
@@ -233,9 +232,8 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
233 return_ACPI_STATUS(status); 232 return_ACPI_STATUS(status);
234 } 233 }
235 } 234 }
236 } else 235 } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
237 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD) 236 (obj_desc->field.region_obj->region.space_id ==
238 && (obj_desc->field.region_obj->region.space_id ==
239 ACPI_ADR_SPACE_SMBUS)) { 237 ACPI_ADR_SPACE_SMBUS)) {
240 /* 238 /*
241 * This is an SMBus write. We will bypass the entire field mechanism 239 * This is an SMBus write. We will bypass the entire field mechanism
@@ -243,7 +241,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
243 * 241 *
244 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). 242 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE).
245 */ 243 */
246 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { 244 if (source_desc->common.type != ACPI_TYPE_BUFFER) {
247 ACPI_ERROR((AE_INFO, 245 ACPI_ERROR((AE_INFO,
248 "SMBus write requires Buffer, found type %s", 246 "SMBus write requires Buffer, found type %s",
249 acpi_ut_get_object_type_name(source_desc))); 247 acpi_ut_get_object_type_name(source_desc)));
@@ -291,7 +289,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
291 289
292 /* Get a pointer to the data to be written */ 290 /* Get a pointer to the data to be written */
293 291
294 switch (ACPI_GET_OBJECT_TYPE(source_desc)) { 292 switch (source_desc->common.type) {
295 case ACPI_TYPE_INTEGER: 293 case ACPI_TYPE_INTEGER:
296 buffer = &source_desc->integer.value; 294 buffer = &source_desc->integer.value;
297 length = sizeof(source_desc->integer.value); 295 length = sizeof(source_desc->integer.value);
@@ -314,15 +312,14 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
314 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 312 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
315 "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n", 313 "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n",
316 source_desc, 314 source_desc,
317 acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE 315 acpi_ut_get_type_name(source_desc->common.type),
318 (source_desc)), 316 source_desc->common.type, buffer, length));
319 ACPI_GET_OBJECT_TYPE(source_desc), buffer, length));
320 317
321 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 318 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
322 "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n", 319 "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n",
323 obj_desc, 320 obj_desc,
324 acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)), 321 acpi_ut_get_type_name(obj_desc->common.type),
325 ACPI_GET_OBJECT_TYPE(obj_desc), 322 obj_desc->common.type,
326 obj_desc->common_field.bit_length, 323 obj_desc->common_field.bit_length,
327 obj_desc->common_field.start_field_bit_offset, 324 obj_desc->common_field.start_field_bit_offset,
328 obj_desc->common_field.base_byte_offset)); 325 obj_desc->common_field.base_byte_offset));
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index ef58ac4e687b..99cee61e655d 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -94,9 +94,9 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
94 94
95 /* We must have a valid region */ 95 /* We must have a valid region */
96 96
97 if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) { 97 if (rgn_desc->common.type != ACPI_TYPE_REGION) {
98 ACPI_ERROR((AE_INFO, "Needed Region, found type %X (%s)", 98 ACPI_ERROR((AE_INFO, "Needed Region, found type %X (%s)",
99 ACPI_GET_OBJECT_TYPE(rgn_desc), 99 rgn_desc->common.type,
100 acpi_ut_get_object_type_name(rgn_desc))); 100 acpi_ut_get_object_type_name(rgn_desc)));
101 101
102 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 102 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
@@ -113,12 +113,6 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
113 } 113 }
114 } 114 }
115 115
116 /* Exit if Address/Length have been disallowed by the host OS */
117
118 if (rgn_desc->common.flags & AOPOBJ_INVALID) {
119 return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS);
120 }
121
122 /* 116 /*
123 * Exit now for SMBus address space, it has a non-linear address space 117 * Exit now for SMBus address space, it has a non-linear address space
124 * and the request cannot be directly validated 118 * and the request cannot be directly validated
@@ -390,7 +384,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
390 * index_field - Write to an Index Register, then read/write from/to a 384 * index_field - Write to an Index Register, then read/write from/to a
391 * Data Register 385 * Data Register
392 */ 386 */
393 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 387 switch (obj_desc->common.type) {
394 case ACPI_TYPE_BUFFER_FIELD: 388 case ACPI_TYPE_BUFFER_FIELD:
395 /* 389 /*
396 * If the buffer_field arguments have not been previously evaluated, 390 * If the buffer_field arguments have not been previously evaluated,
@@ -527,7 +521,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
527 default: 521 default:
528 522
529 ACPI_ERROR((AE_INFO, "Wrong object type in field I/O %X", 523 ACPI_ERROR((AE_INFO, "Wrong object type in field I/O %X",
530 ACPI_GET_OBJECT_TYPE(obj_desc))); 524 obj_desc->common.type));
531 status = AE_AML_INTERNAL; 525 status = AE_AML_INTERNAL;
532 break; 526 break;
533 } 527 }
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c
index 6b0747ac683b..998eac329937 100644
--- a/drivers/acpi/acpica/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -80,7 +80,7 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
80 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { 80 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
81 case ACPI_DESC_TYPE_OPERAND: 81 case ACPI_DESC_TYPE_OPERAND:
82 82
83 if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) { 83 if (obj_desc->common.type != ACPI_TYPE_LOCAL_REFERENCE) {
84 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 84 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
85 } 85 }
86 86
@@ -260,7 +260,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
260 * guaranteed to be either Integer/String/Buffer by the operand 260 * guaranteed to be either Integer/String/Buffer by the operand
261 * resolution mechanism. 261 * resolution mechanism.
262 */ 262 */
263 switch (ACPI_GET_OBJECT_TYPE(operand0)) { 263 switch (operand0->common.type) {
264 case ACPI_TYPE_INTEGER: 264 case ACPI_TYPE_INTEGER:
265 status = 265 status =
266 acpi_ex_convert_to_integer(operand1, &local_operand1, 16); 266 acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
@@ -277,7 +277,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
277 277
278 default: 278 default:
279 ACPI_ERROR((AE_INFO, "Invalid object type: %X", 279 ACPI_ERROR((AE_INFO, "Invalid object type: %X",
280 ACPI_GET_OBJECT_TYPE(operand0))); 280 operand0->common.type));
281 status = AE_AML_INTERNAL; 281 status = AE_AML_INTERNAL;
282 } 282 }
283 283
@@ -298,7 +298,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
298 * 2) Two Strings concatenated to produce a new String 298 * 2) Two Strings concatenated to produce a new String
299 * 3) Two Buffers concatenated to produce a new Buffer 299 * 3) Two Buffers concatenated to produce a new Buffer
300 */ 300 */
301 switch (ACPI_GET_OBJECT_TYPE(operand0)) { 301 switch (operand0->common.type) {
302 case ACPI_TYPE_INTEGER: 302 case ACPI_TYPE_INTEGER:
303 303
304 /* Result of two Integers is a Buffer */ 304 /* Result of two Integers is a Buffer */
@@ -379,7 +379,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
379 /* Invalid object type, should not happen here */ 379 /* Invalid object type, should not happen here */
380 380
381 ACPI_ERROR((AE_INFO, "Invalid object type: %X", 381 ACPI_ERROR((AE_INFO, "Invalid object type: %X",
382 ACPI_GET_OBJECT_TYPE(operand0))); 382 operand0->common.type));
383 status = AE_AML_INTERNAL; 383 status = AE_AML_INTERNAL;
384 goto cleanup; 384 goto cleanup;
385 } 385 }
@@ -581,7 +581,7 @@ acpi_ex_do_logical_op(u16 opcode,
581 * guaranteed to be either Integer/String/Buffer by the operand 581 * guaranteed to be either Integer/String/Buffer by the operand
582 * resolution mechanism. 582 * resolution mechanism.
583 */ 583 */
584 switch (ACPI_GET_OBJECT_TYPE(operand0)) { 584 switch (operand0->common.type) {
585 case ACPI_TYPE_INTEGER: 585 case ACPI_TYPE_INTEGER:
586 status = 586 status =
587 acpi_ex_convert_to_integer(operand1, &local_operand1, 16); 587 acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
@@ -608,7 +608,7 @@ acpi_ex_do_logical_op(u16 opcode,
608 /* 608 /*
609 * Two cases: 1) Both Integers, 2) Both Strings or Buffers 609 * Two cases: 1) Both Integers, 2) Both Strings or Buffers
610 */ 610 */
611 if (ACPI_GET_OBJECT_TYPE(operand0) == ACPI_TYPE_INTEGER) { 611 if (operand0->common.type == ACPI_TYPE_INTEGER) {
612 /* 612 /*
613 * 1) Both operands are of type integer 613 * 1) Both operands are of type integer
614 * Note: local_operand1 may have changed above 614 * Note: local_operand1 may have changed above
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index b530480cc7d5..9635d21e568d 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -807,11 +807,9 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
807 acpi_namespace_node *) 807 acpi_namespace_node *)
808 operand[0]); 808 operand[0]);
809 if (temp_desc 809 if (temp_desc
810 && 810 && ((temp_desc->common.type == ACPI_TYPE_STRING)
811 ((ACPI_GET_OBJECT_TYPE(temp_desc) == 811 || (temp_desc->common.type ==
812 ACPI_TYPE_STRING) 812 ACPI_TYPE_LOCAL_REFERENCE))) {
813 || (ACPI_GET_OBJECT_TYPE(temp_desc) ==
814 ACPI_TYPE_LOCAL_REFERENCE))) {
815 operand[0] = temp_desc; 813 operand[0] = temp_desc;
816 acpi_ut_add_reference(temp_desc); 814 acpi_ut_add_reference(temp_desc);
817 } else { 815 } else {
@@ -819,7 +817,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
819 goto cleanup; 817 goto cleanup;
820 } 818 }
821 } else { 819 } else {
822 switch (ACPI_GET_OBJECT_TYPE(operand[0])) { 820 switch ((operand[0])->common.type) {
823 case ACPI_TYPE_LOCAL_REFERENCE: 821 case ACPI_TYPE_LOCAL_REFERENCE:
824 /* 822 /*
825 * This is a deref_of (local_x | arg_x) 823 * This is a deref_of (local_x | arg_x)
@@ -877,8 +875,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
877 875
878 if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) != 876 if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) !=
879 ACPI_DESC_TYPE_NAMED) { 877 ACPI_DESC_TYPE_NAMED) {
880 if (ACPI_GET_OBJECT_TYPE(operand[0]) == 878 if ((operand[0])->common.type == ACPI_TYPE_STRING) {
881 ACPI_TYPE_STRING) {
882 /* 879 /*
883 * This is a deref_of (String). The string is a reference 880 * This is a deref_of (String). The string is a reference
884 * to a named ACPI object. 881 * to a named ACPI object.
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index 0b4f513ca885..85d95c92dfd3 100644
--- a/drivers/acpi/acpica/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -399,7 +399,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
399 * At this point, the Source operand is a String, Buffer, or Package. 399 * At this point, the Source operand is a String, Buffer, or Package.
400 * Verify that the index is within range. 400 * Verify that the index is within range.
401 */ 401 */
402 switch (ACPI_GET_OBJECT_TYPE(operand[0])) { 402 switch ((operand[0])->common.type) {
403 case ACPI_TYPE_STRING: 403 case ACPI_TYPE_STRING:
404 404
405 if (index >= operand[0]->string.length) { 405 if (index >= operand[0]->string.length) {
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index c6520bbf882b..253f9e122584 100644
--- a/drivers/acpi/acpica/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -161,9 +161,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
161 * Create the return object. The Source operand is guaranteed to be 161 * Create the return object. The Source operand is guaranteed to be
162 * either a String or a Buffer, so just use its type. 162 * either a String or a Buffer, so just use its type.
163 */ 163 */
164 return_desc = 164 return_desc = acpi_ut_create_internal_object((operand[0])->
165 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE 165 common.type);
166 (operand[0]));
167 if (!return_desc) { 166 if (!return_desc) {
168 status = AE_NO_MEMORY; 167 status = AE_NO_MEMORY;
169 goto cleanup; 168 goto cleanup;
@@ -191,7 +190,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
191 190
192 /* Strings always have a sub-pointer, not so for buffers */ 191 /* Strings always have a sub-pointer, not so for buffers */
193 192
194 switch (ACPI_GET_OBJECT_TYPE(operand[0])) { 193 switch ((operand[0])->common.type) {
195 case ACPI_TYPE_STRING: 194 case ACPI_TYPE_STRING:
196 195
197 /* Always allocate a new buffer for the String */ 196 /* Always allocate a new buffer for the String */
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index a226f74d4a5c..52fec07064f0 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -279,7 +279,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
279 return_UINT32(0); 279 return_UINT32(0);
280 } 280 }
281 281
282 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 282 if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
283 /* 283 /*
284 * buffer_field access can be on any byte boundary, so the 284 * buffer_field access can be on any byte boundary, so the
285 * byte_alignment is always 1 byte -- regardless of any byte_alignment 285 * byte_alignment is always 1 byte -- regardless of any byte_alignment
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 76ec8ff903b8..3a54b737d2da 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -294,14 +294,14 @@ acpi_ex_system_io_space_handler(u32 function,
294 switch (function) { 294 switch (function) {
295 case ACPI_READ: 295 case ACPI_READ:
296 296
297 status = acpi_os_read_port((acpi_io_address) address, 297 status = acpi_hw_read_port((acpi_io_address) address,
298 &value32, bit_width); 298 &value32, bit_width);
299 *value = value32; 299 *value = value32;
300 break; 300 break;
301 301
302 case ACPI_WRITE: 302 case ACPI_WRITE:
303 303
304 status = acpi_os_write_port((acpi_io_address) address, 304 status = acpi_hw_write_port((acpi_io_address) address,
305 (u32) * value, bit_width); 305 (u32) * value, bit_width);
306 break; 306 break;
307 307
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index a063a74006f6..607958ff467c 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -136,7 +136,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
136 switch (entry_type) { 136 switch (entry_type) {
137 case ACPI_TYPE_PACKAGE: 137 case ACPI_TYPE_PACKAGE:
138 138
139 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) { 139 if (source_desc->common.type != ACPI_TYPE_PACKAGE) {
140 ACPI_ERROR((AE_INFO, "Object not a Package, type %s", 140 ACPI_ERROR((AE_INFO, "Object not a Package, type %s",
141 acpi_ut_get_object_type_name(source_desc))); 141 acpi_ut_get_object_type_name(source_desc)));
142 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 142 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
@@ -154,7 +154,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
154 154
155 case ACPI_TYPE_BUFFER: 155 case ACPI_TYPE_BUFFER:
156 156
157 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { 157 if (source_desc->common.type != ACPI_TYPE_BUFFER) {
158 ACPI_ERROR((AE_INFO, "Object not a Buffer, type %s", 158 ACPI_ERROR((AE_INFO, "Object not a Buffer, type %s",
159 acpi_ut_get_object_type_name(source_desc))); 159 acpi_ut_get_object_type_name(source_desc)));
160 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 160 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
@@ -172,7 +172,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
172 172
173 case ACPI_TYPE_STRING: 173 case ACPI_TYPE_STRING:
174 174
175 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) { 175 if (source_desc->common.type != ACPI_TYPE_STRING) {
176 ACPI_ERROR((AE_INFO, "Object not a String, type %s", 176 ACPI_ERROR((AE_INFO, "Object not a String, type %s",
177 acpi_ut_get_object_type_name(source_desc))); 177 acpi_ut_get_object_type_name(source_desc)));
178 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 178 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
@@ -186,7 +186,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
186 186
187 case ACPI_TYPE_INTEGER: 187 case ACPI_TYPE_INTEGER:
188 188
189 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) { 189 if (source_desc->common.type != ACPI_TYPE_INTEGER) {
190 ACPI_ERROR((AE_INFO, "Object not a Integer, type %s", 190 ACPI_ERROR((AE_INFO, "Object not a Integer, type %s",
191 acpi_ut_get_object_type_name(source_desc))); 191 acpi_ut_get_object_type_name(source_desc)));
192 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 192 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index f6105a6d6126..c93b54ce7f78 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -149,7 +149,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
149 149
150 /* This is a union acpi_operand_object */ 150 /* This is a union acpi_operand_object */
151 151
152 switch (ACPI_GET_OBJECT_TYPE(stack_desc)) { 152 switch (stack_desc->common.type) {
153 case ACPI_TYPE_LOCAL_REFERENCE: 153 case ACPI_TYPE_LOCAL_REFERENCE:
154 154
155 ref_type = stack_desc->reference.class; 155 ref_type = stack_desc->reference.class;
@@ -297,8 +297,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
297 297
298 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 298 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
299 "FieldRead SourceDesc=%p Type=%X\n", 299 "FieldRead SourceDesc=%p Type=%X\n",
300 stack_desc, 300 stack_desc, stack_desc->common.type));
301 ACPI_GET_OBJECT_TYPE(stack_desc)));
302 301
303 status = 302 status =
304 acpi_ex_read_data_from_field(walk_state, stack_desc, 303 acpi_ex_read_data_from_field(walk_state, stack_desc,
@@ -386,7 +385,7 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
386 * specification of the object_type and size_of operators). This means 385 * specification of the object_type and size_of operators). This means
387 * traversing the list of possibly many nested references. 386 * traversing the list of possibly many nested references.
388 */ 387 */
389 while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { 388 while (obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
390 switch (obj_desc->reference.class) { 389 switch (obj_desc->reference.class) {
391 case ACPI_REFCLASS_REFOF: 390 case ACPI_REFCLASS_REFOF:
392 case ACPI_REFCLASS_NAME: 391 case ACPI_REFCLASS_NAME:
@@ -518,7 +517,7 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
518 * Now we are guaranteed to have an object that has not been created 517 * Now we are guaranteed to have an object that has not been created
519 * via the ref_of or Index operators. 518 * via the ref_of or Index operators.
520 */ 519 */
521 type = ACPI_GET_OBJECT_TYPE(obj_desc); 520 type = obj_desc->common.type;
522 521
523 exit: 522 exit:
524 /* Convert internal types to external types */ 523 /* Convert internal types to external types */
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c
index 3c3802764bfb..5c729a9e9131 100644
--- a/drivers/acpi/acpica/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -212,7 +212,7 @@ acpi_ex_resolve_operands(u16 opcode,
212 212
213 /* ACPI internal object */ 213 /* ACPI internal object */
214 214
215 object_type = ACPI_GET_OBJECT_TYPE(obj_desc); 215 object_type = obj_desc->common.type;
216 216
217 /* Check for bad acpi_object_type */ 217 /* Check for bad acpi_object_type */
218 218
@@ -287,8 +287,7 @@ acpi_ex_resolve_operands(u16 opcode,
287 287
288 if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == 288 if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
289 ACPI_DESC_TYPE_OPERAND) 289 ACPI_DESC_TYPE_OPERAND)
290 && (ACPI_GET_OBJECT_TYPE(obj_desc) == 290 && (obj_desc->common.type == ACPI_TYPE_STRING)) {
291 ACPI_TYPE_STRING)) {
292 /* 291 /*
293 * String found - the string references a named object and 292 * String found - the string references a named object and
294 * must be resolved to a node 293 * must be resolved to a node
@@ -336,7 +335,7 @@ acpi_ex_resolve_operands(u16 opcode,
336 * -- All others must be resolved below. 335 * -- All others must be resolved below.
337 */ 336 */
338 if ((opcode == AML_STORE_OP) && 337 if ((opcode == AML_STORE_OP) &&
339 (ACPI_GET_OBJECT_TYPE(*stack_ptr) == 338 ((*stack_ptr)->common.type ==
340 ACPI_TYPE_LOCAL_REFERENCE) 339 ACPI_TYPE_LOCAL_REFERENCE)
341 && ((*stack_ptr)->reference.class == ACPI_REFCLASS_INDEX)) { 340 && ((*stack_ptr)->reference.class == ACPI_REFCLASS_INDEX)) {
342 goto next_operand; 341 goto next_operand;
@@ -490,7 +489,7 @@ acpi_ex_resolve_operands(u16 opcode,
490 489
491 /* Need an operand of type INTEGER, STRING or BUFFER */ 490 /* Need an operand of type INTEGER, STRING or BUFFER */
492 491
493 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 492 switch (obj_desc->common.type) {
494 case ACPI_TYPE_INTEGER: 493 case ACPI_TYPE_INTEGER:
495 case ACPI_TYPE_STRING: 494 case ACPI_TYPE_STRING:
496 case ACPI_TYPE_BUFFER: 495 case ACPI_TYPE_BUFFER:
@@ -512,7 +511,7 @@ acpi_ex_resolve_operands(u16 opcode,
512 511
513 /* Need an operand of type STRING or BUFFER */ 512 /* Need an operand of type STRING or BUFFER */
514 513
515 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 514 switch (obj_desc->common.type) {
516 case ACPI_TYPE_STRING: 515 case ACPI_TYPE_STRING:
517 case ACPI_TYPE_BUFFER: 516 case ACPI_TYPE_BUFFER:
518 517
@@ -553,7 +552,7 @@ acpi_ex_resolve_operands(u16 opcode,
553 * The only reference allowed here is a direct reference to 552 * The only reference allowed here is a direct reference to
554 * a namespace node. 553 * a namespace node.
555 */ 554 */
556 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 555 switch (obj_desc->common.type) {
557 case ACPI_TYPE_PACKAGE: 556 case ACPI_TYPE_PACKAGE:
558 case ACPI_TYPE_STRING: 557 case ACPI_TYPE_STRING:
559 case ACPI_TYPE_BUFFER: 558 case ACPI_TYPE_BUFFER:
@@ -576,7 +575,7 @@ acpi_ex_resolve_operands(u16 opcode,
576 575
577 /* Need a buffer or package or (ACPI 2.0) String */ 576 /* Need a buffer or package or (ACPI 2.0) String */
578 577
579 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 578 switch (obj_desc->common.type) {
580 case ACPI_TYPE_PACKAGE: 579 case ACPI_TYPE_PACKAGE:
581 case ACPI_TYPE_STRING: 580 case ACPI_TYPE_STRING:
582 case ACPI_TYPE_BUFFER: 581 case ACPI_TYPE_BUFFER:
@@ -598,7 +597,7 @@ acpi_ex_resolve_operands(u16 opcode,
598 597
599 /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ 598 /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */
600 599
601 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 600 switch (obj_desc->common.type) {
602 case ACPI_TYPE_BUFFER: 601 case ACPI_TYPE_BUFFER:
603 case ACPI_TYPE_REGION: 602 case ACPI_TYPE_REGION:
604 603
@@ -619,7 +618,7 @@ acpi_ex_resolve_operands(u16 opcode,
619 618
620 /* Used by the Store() operator only */ 619 /* Used by the Store() operator only */
621 620
622 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 621 switch (obj_desc->common.type) {
623 case ACPI_TYPE_INTEGER: 622 case ACPI_TYPE_INTEGER:
624 case ACPI_TYPE_PACKAGE: 623 case ACPI_TYPE_PACKAGE:
625 case ACPI_TYPE_STRING: 624 case ACPI_TYPE_STRING:
@@ -677,8 +676,8 @@ acpi_ex_resolve_operands(u16 opcode,
677 * required object type (Simple cases only). 676 * required object type (Simple cases only).
678 */ 677 */
679 status = acpi_ex_check_object_type(type_needed, 678 status = acpi_ex_check_object_type(type_needed,
680 ACPI_GET_OBJECT_TYPE 679 (*stack_ptr)->common.type,
681 (*stack_ptr), *stack_ptr); 680 *stack_ptr);
682 if (ACPI_FAILURE(status)) { 681 if (ACPI_FAILURE(status)) {
683 return_ACPI_STATUS(status); 682 return_ACPI_STATUS(status);
684 } 683 }
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index e35e9b4f6a4e..90d606196c99 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -129,7 +129,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
129 129
130 /* source_desc is of type ACPI_DESC_TYPE_OPERAND */ 130 /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
131 131
132 switch (ACPI_GET_OBJECT_TYPE(source_desc)) { 132 switch (source_desc->common.type) {
133 case ACPI_TYPE_INTEGER: 133 case ACPI_TYPE_INTEGER:
134 134
135 /* Output correct integer width */ 135 /* Output correct integer width */
@@ -324,7 +324,7 @@ acpi_ex_store(union acpi_operand_object *source_desc,
324 324
325 /* Destination object must be a Reference or a Constant object */ 325 /* Destination object must be a Reference or a Constant object */
326 326
327 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { 327 switch (dest_desc->common.type) {
328 case ACPI_TYPE_LOCAL_REFERENCE: 328 case ACPI_TYPE_LOCAL_REFERENCE:
329 break; 329 break;
330 330
@@ -460,9 +460,8 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
460 */ 460 */
461 obj_desc = *(index_desc->reference.where); 461 obj_desc = *(index_desc->reference.where);
462 462
463 if (ACPI_GET_OBJECT_TYPE(source_desc) == 463 if (source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE &&
464 ACPI_TYPE_LOCAL_REFERENCE 464 source_desc->reference.class == ACPI_REFCLASS_TABLE) {
465 && source_desc->reference.class == ACPI_REFCLASS_TABLE) {
466 465
467 /* This is a DDBHandle, just add a reference to it */ 466 /* This is a DDBHandle, just add a reference to it */
468 467
@@ -520,8 +519,8 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
520 * by the INDEX_OP code. 519 * by the INDEX_OP code.
521 */ 520 */
522 obj_desc = index_desc->reference.object; 521 obj_desc = index_desc->reference.object;
523 if ((ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_BUFFER) && 522 if ((obj_desc->common.type != ACPI_TYPE_BUFFER) &&
524 (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_STRING)) { 523 (obj_desc->common.type != ACPI_TYPE_STRING)) {
525 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 524 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
526 } 525 }
527 526
@@ -529,7 +528,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
529 * The assignment of the individual elements will be slightly 528 * The assignment of the individual elements will be slightly
530 * different for each source type. 529 * different for each source type.
531 */ 530 */
532 switch (ACPI_GET_OBJECT_TYPE(source_desc)) { 531 switch (source_desc->common.type) {
533 case ACPI_TYPE_INTEGER: 532 case ACPI_TYPE_INTEGER:
534 533
535 /* Use the least-significant byte of the integer */ 534 /* Use the least-significant byte of the integer */
@@ -707,8 +706,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
707 /* No conversions for all other types. Just attach the source object */ 706 /* No conversions for all other types. Just attach the source object */
708 707
709 status = acpi_ns_attach_object(node, source_desc, 708 status = acpi_ns_attach_object(node, source_desc,
710 ACPI_GET_OBJECT_TYPE 709 source_desc->common.type);
711 (source_desc));
712 break; 710 break;
713 } 711 }
714 712
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c
index 145d15305f70..608e838d537e 100644
--- a/drivers/acpi/acpica/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -96,8 +96,7 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
96 * are all essentially the same. This case handles the 96 * are all essentially the same. This case handles the
97 * "interchangeable" types Integer, String, and Buffer. 97 * "interchangeable" types Integer, String, and Buffer.
98 */ 98 */
99 if (ACPI_GET_OBJECT_TYPE(source_desc) == 99 if (source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
100 ACPI_TYPE_LOCAL_REFERENCE) {
101 100
102 /* Resolve a reference object first */ 101 /* Resolve a reference object first */
103 102
@@ -117,13 +116,11 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
117 116
118 /* Must have a Integer, Buffer, or String */ 117 /* Must have a Integer, Buffer, or String */
119 118
120 if ((ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) && 119 if ((source_desc->common.type != ACPI_TYPE_INTEGER) &&
121 (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) && 120 (source_desc->common.type != ACPI_TYPE_BUFFER) &&
122 (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) && 121 (source_desc->common.type != ACPI_TYPE_STRING) &&
123 !((ACPI_GET_OBJECT_TYPE(source_desc) == 122 !((source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
124 ACPI_TYPE_LOCAL_REFERENCE) 123 (source_desc->reference.class == ACPI_REFCLASS_TABLE))) {
125 && (source_desc->reference.class ==
126 ACPI_REFCLASS_TABLE))) {
127 124
128 /* Conversion successful but still not a valid type */ 125 /* Conversion successful but still not a valid type */
129 126
@@ -218,8 +215,7 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
218 return_ACPI_STATUS(status); 215 return_ACPI_STATUS(status);
219 } 216 }
220 217
221 if (ACPI_GET_OBJECT_TYPE(source_desc) != 218 if (source_desc->common.type != dest_desc->common.type) {
222 ACPI_GET_OBJECT_TYPE(dest_desc)) {
223 /* 219 /*
224 * The source type does not match the type of the destination. 220 * The source type does not match the type of the destination.
225 * Perform the "implicit conversion" of the source to the current type 221 * Perform the "implicit conversion" of the source to the current type
@@ -229,11 +225,10 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
229 * Otherwise, actual_src_desc is a temporary object to hold the 225 * Otherwise, actual_src_desc is a temporary object to hold the
230 * converted object. 226 * converted object.
231 */ 227 */
232 status = 228 status = acpi_ex_convert_to_target_type(dest_desc->common.type,
233 acpi_ex_convert_to_target_type(ACPI_GET_OBJECT_TYPE 229 source_desc,
234 (dest_desc), source_desc, 230 &actual_src_desc,
235 &actual_src_desc, 231 walk_state);
236 walk_state);
237 if (ACPI_FAILURE(status)) { 232 if (ACPI_FAILURE(status)) {
238 return_ACPI_STATUS(status); 233 return_ACPI_STATUS(status);
239 } 234 }
@@ -252,7 +247,7 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
252 * We now have two objects of identical types, and we can perform a 247 * We now have two objects of identical types, and we can perform a
253 * copy of the *value* of the source object. 248 * copy of the *value* of the source object.
254 */ 249 */
255 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { 250 switch (dest_desc->common.type) {
256 case ACPI_TYPE_INTEGER: 251 case ACPI_TYPE_INTEGER:
257 252
258 dest_desc->integer.value = actual_src_desc->integer.value; 253 dest_desc->integer.value = actual_src_desc->integer.value;
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index 32b85d68e756..87730e944132 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -221,7 +221,7 @@ void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
221 */ 221 */
222 if ((!obj_desc) || 222 if ((!obj_desc) ||
223 (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) || 223 (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) ||
224 (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) { 224 (obj_desc->common.type != ACPI_TYPE_INTEGER)) {
225 return; 225 return;
226 } 226 }
227 227
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index a9d4fea4167f..9af361a191e7 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -86,7 +86,8 @@ acpi_status acpi_hw_set_mode(u32 mode)
86 */ 86 */
87 if (!acpi_gbl_FADT.acpi_enable && !acpi_gbl_FADT.acpi_disable) { 87 if (!acpi_gbl_FADT.acpi_enable && !acpi_gbl_FADT.acpi_disable) {
88 ACPI_ERROR((AE_INFO, 88 ACPI_ERROR((AE_INFO,
89 "No ACPI mode transition supported in this system (enable/disable both zero)")); 89 "No ACPI mode transition supported in this system "
90 "(enable/disable both zero)"));
90 return_ACPI_STATUS(AE_OK); 91 return_ACPI_STATUS(AE_OK);
91 } 92 }
92 93
@@ -95,7 +96,7 @@ acpi_status acpi_hw_set_mode(u32 mode)
95 96
96 /* BIOS should have disabled ALL fixed and GP events */ 97 /* BIOS should have disabled ALL fixed and GP events */
97 98
98 status = acpi_os_write_port(acpi_gbl_FADT.smi_command, 99 status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
99 (u32) acpi_gbl_FADT.acpi_enable, 8); 100 (u32) acpi_gbl_FADT.acpi_enable, 8);
100 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 101 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
101 "Attempting to enable ACPI mode\n")); 102 "Attempting to enable ACPI mode\n"));
@@ -107,7 +108,7 @@ acpi_status acpi_hw_set_mode(u32 mode)
107 * BIOS should clear all fixed status bits and restore fixed event 108 * BIOS should clear all fixed status bits and restore fixed event
108 * enable bits to default 109 * enable bits to default
109 */ 110 */
110 status = acpi_os_write_port(acpi_gbl_FADT.smi_command, 111 status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
111 (u32) acpi_gbl_FADT.acpi_disable, 112 (u32) acpi_gbl_FADT.acpi_disable,
112 8); 113 8);
113 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 114 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -172,7 +173,7 @@ u32 acpi_hw_get_mode(void)
172 return_UINT32(ACPI_SYS_MODE_ACPI); 173 return_UINT32(ACPI_SYS_MODE_ACPI);
173 } 174 }
174 175
175 status = acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value); 176 status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value);
176 if (ACPI_FAILURE(status)) { 177 if (ACPI_FAILURE(status)) {
177 return_UINT32(ACPI_SYS_MODE_LEGACY); 178 return_UINT32(ACPI_SYS_MODE_LEGACY);
178 } 179 }
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 2013b66745d2..d3b7e37c9eed 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -89,10 +89,9 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
89 89
90 /* Clear just the bit that corresponds to this GPE */ 90 /* Clear just the bit that corresponds to this GPE */
91 91
92 ACPI_CLEAR_BIT(enable_mask, 92 ACPI_CLEAR_BIT(enable_mask, ((u32)1 <<
93 ((u32) 1 << 93 (gpe_event_info->gpe_number -
94 (gpe_event_info->gpe_number - 94 gpe_register_info->base_gpe_number)));
95 gpe_register_info->base_gpe_number)));
96 95
97 /* Write the updated enable mask */ 96 /* Write the updated enable mask */
98 97
@@ -156,10 +155,9 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
156 155
157 ACPI_FUNCTION_ENTRY(); 156 ACPI_FUNCTION_ENTRY();
158 157
159 register_bit = (u8) 158 register_bit = (u8)(1 <<
160 (1 << 159 (gpe_event_info->gpe_number -
161 (gpe_event_info->gpe_number - 160 gpe_event_info->register_info->base_gpe_number));
162 gpe_event_info->register_info->base_gpe_number));
163 161
164 /* 162 /*
165 * Write a one to the appropriate bit in the status register to 163 * Write a one to the appropriate bit in the status register to
@@ -206,10 +204,9 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
206 204
207 /* Get the register bitmask for this GPE */ 205 /* Get the register bitmask for this GPE */
208 206
209 register_bit = (u8) 207 register_bit = (u8)(1 <<
210 (1 << 208 (gpe_event_info->gpe_number -
211 (gpe_event_info->gpe_number - 209 gpe_event_info->register_info->base_gpe_number));
212 gpe_event_info->register_info->base_gpe_number));
213 210
214 /* GPE currently enabled? (enabled for runtime?) */ 211 /* GPE currently enabled? (enabled for runtime?) */
215 212
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 4dc43b018517..7b2fb602b5cb 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -51,6 +51,17 @@
51#define _COMPONENT ACPI_HARDWARE 51#define _COMPONENT ACPI_HARDWARE
52ACPI_MODULE_NAME("hwregs") 52ACPI_MODULE_NAME("hwregs")
53 53
54/* Local Prototypes */
55static acpi_status
56acpi_hw_read_multiple(u32 *value,
57 struct acpi_generic_address *register_a,
58 struct acpi_generic_address *register_b);
59
60static acpi_status
61acpi_hw_write_multiple(u32 value,
62 struct acpi_generic_address *register_a,
63 struct acpi_generic_address *register_b);
64
54/******************************************************************************* 65/*******************************************************************************
55 * 66 *
56 * FUNCTION: acpi_hw_clear_acpi_status 67 * FUNCTION: acpi_hw_clear_acpi_status
@@ -60,9 +71,9 @@ ACPI_MODULE_NAME("hwregs")
60 * RETURN: Status 71 * RETURN: Status
61 * 72 *
62 * DESCRIPTION: Clears all fixed and general purpose status bits 73 * DESCRIPTION: Clears all fixed and general purpose status bits
63 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
64 * 74 *
65 ******************************************************************************/ 75 ******************************************************************************/
76
66acpi_status acpi_hw_clear_acpi_status(void) 77acpi_status acpi_hw_clear_acpi_status(void)
67{ 78{
68 acpi_status status; 79 acpi_status status;
@@ -70,28 +81,20 @@ acpi_status acpi_hw_clear_acpi_status(void)
70 81
71 ACPI_FUNCTION_TRACE(hw_clear_acpi_status); 82 ACPI_FUNCTION_TRACE(hw_clear_acpi_status);
72 83
73 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n", 84 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %0llX\n",
74 ACPI_BITMASK_ALL_FIXED_STATUS, 85 ACPI_BITMASK_ALL_FIXED_STATUS,
75 (u16) acpi_gbl_FADT.xpm1a_event_block.address)); 86 acpi_gbl_xpm1a_status.address));
76 87
77 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); 88 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
78 89
90 /* Clear the fixed events in PM1 A/B */
91
79 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, 92 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
80 ACPI_BITMASK_ALL_FIXED_STATUS); 93 ACPI_BITMASK_ALL_FIXED_STATUS);
81 if (ACPI_FAILURE(status)) { 94 if (ACPI_FAILURE(status)) {
82 goto unlock_and_exit; 95 goto unlock_and_exit;
83 } 96 }
84 97
85 /* Clear the fixed events */
86
87 if (acpi_gbl_FADT.xpm1b_event_block.address) {
88 status = acpi_write(ACPI_BITMASK_ALL_FIXED_STATUS,
89 &acpi_gbl_FADT.xpm1b_event_block);
90 if (ACPI_FAILURE(status)) {
91 goto unlock_and_exit;
92 }
93 }
94
95 /* Clear the GPE Bits in all GPE registers in all GPE blocks */ 98 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
96 99
97 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); 100 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
@@ -128,6 +131,42 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
128 131
129/****************************************************************************** 132/******************************************************************************
130 * 133 *
134 * FUNCTION: acpi_hw_write_pm1_control
135 *
136 * PARAMETERS: pm1a_control - Value to be written to PM1A control
137 * pm1b_control - Value to be written to PM1B control
138 *
139 * RETURN: Status
140 *
141 * DESCRIPTION: Write the PM1 A/B control registers. These registers are
142 * different than than the PM1 A/B status and enable registers
143 * in that different values can be written to the A/B registers.
144 * Most notably, the SLP_TYP bits can be different, as per the
145 * values returned from the _Sx predefined methods.
146 *
147 ******************************************************************************/
148
149acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control)
150{
151 acpi_status status;
152
153 ACPI_FUNCTION_TRACE(hw_write_pm1_control);
154
155 status = acpi_write(pm1a_control, &acpi_gbl_FADT.xpm1a_control_block);
156 if (ACPI_FAILURE(status)) {
157 return_ACPI_STATUS(status);
158 }
159
160 if (acpi_gbl_FADT.xpm1b_control_block.address) {
161 status =
162 acpi_write(pm1b_control,
163 &acpi_gbl_FADT.xpm1b_control_block);
164 }
165 return_ACPI_STATUS(status);
166}
167
168/******************************************************************************
169 *
131 * FUNCTION: acpi_hw_register_read 170 * FUNCTION: acpi_hw_register_read
132 * 171 *
133 * PARAMETERS: register_id - ACPI Register ID 172 * PARAMETERS: register_id - ACPI Register ID
@@ -141,64 +180,56 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
141acpi_status 180acpi_status
142acpi_hw_register_read(u32 register_id, u32 * return_value) 181acpi_hw_register_read(u32 register_id, u32 * return_value)
143{ 182{
144 u32 value1 = 0; 183 u32 value = 0;
145 u32 value2 = 0;
146 acpi_status status; 184 acpi_status status;
147 185
148 ACPI_FUNCTION_TRACE(hw_register_read); 186 ACPI_FUNCTION_TRACE(hw_register_read);
149 187
150 switch (register_id) { 188 switch (register_id) {
151 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 189 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
152
153 status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_event_block);
154 if (ACPI_FAILURE(status)) {
155 goto exit;
156 }
157
158 /* PM1B is optional */
159 190
160 status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_event_block); 191 status = acpi_hw_read_multiple(&value,
161 value1 |= value2; 192 &acpi_gbl_xpm1a_status,
193 &acpi_gbl_xpm1b_status);
162 break; 194 break;
163 195
164 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ 196 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
165 197
166 status = acpi_read(&value1, &acpi_gbl_xpm1a_enable); 198 status = acpi_hw_read_multiple(&value,
167 if (ACPI_FAILURE(status)) { 199 &acpi_gbl_xpm1a_enable,
168 goto exit; 200 &acpi_gbl_xpm1b_enable);
169 }
170
171 /* PM1B is optional */
172
173 status = acpi_read(&value2, &acpi_gbl_xpm1b_enable);
174 value1 |= value2;
175 break; 201 break;
176 202
177 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 203 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
178 204
179 status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_control_block); 205 status = acpi_hw_read_multiple(&value,
180 if (ACPI_FAILURE(status)) { 206 &acpi_gbl_FADT.
181 goto exit; 207 xpm1a_control_block,
182 } 208 &acpi_gbl_FADT.
209 xpm1b_control_block);
183 210
184 status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_control_block); 211 /*
185 value1 |= value2; 212 * Zero the write-only bits. From the ACPI specification, "Hardware
213 * Write-Only Bits": "Upon reads to registers with write-only bits,
214 * software masks out all write-only bits."
215 */
216 value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS;
186 break; 217 break;
187 218
188 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 219 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
189 220
190 status = acpi_read(&value1, &acpi_gbl_FADT.xpm2_control_block); 221 status = acpi_read(&value, &acpi_gbl_FADT.xpm2_control_block);
191 break; 222 break;
192 223
193 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 224 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
194 225
195 status = acpi_read(&value1, &acpi_gbl_FADT.xpm_timer_block); 226 status = acpi_read(&value, &acpi_gbl_FADT.xpm_timer_block);
196 break; 227 break;
197 228
198 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 229 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
199 230
200 status = 231 status =
201 acpi_os_read_port(acpi_gbl_FADT.smi_command, &value1, 8); 232 acpi_hw_read_port(acpi_gbl_FADT.smi_command, &value, 8);
202 break; 233 break;
203 234
204 default: 235 default:
@@ -207,10 +238,8 @@ acpi_hw_register_read(u32 register_id, u32 * return_value)
207 break; 238 break;
208 } 239 }
209 240
210 exit:
211
212 if (ACPI_SUCCESS(status)) { 241 if (ACPI_SUCCESS(status)) {
213 *return_value = value1; 242 *return_value = value;
214 } 243 }
215 244
216 return_ACPI_STATUS(status); 245 return_ACPI_STATUS(status);
@@ -250,52 +279,42 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
250 ACPI_FUNCTION_TRACE(hw_register_write); 279 ACPI_FUNCTION_TRACE(hw_register_write);
251 280
252 switch (register_id) { 281 switch (register_id) {
253 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 282 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
254 283 /*
255 /* Perform a read first to preserve certain bits (per ACPI spec) */ 284 * Handle the "ignored" bit in PM1 Status. According to the ACPI
256 285 * specification, ignored bits are to be preserved when writing.
257 status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, 286 * Normally, this would mean a read/modify/write sequence. However,
258 &read_value); 287 * preserving a bit in the status register is different. Writing a
259 if (ACPI_FAILURE(status)) { 288 * one clears the status, and writing a zero preserves the status.
260 goto exit; 289 * Therefore, we must always write zero to the ignored bit.
261 } 290 *
262 291 * This behavior is clarified in the ACPI 4.0 specification.
263 /* Insert the bits to be preserved */ 292 */
264 293 value &= ~ACPI_PM1_STATUS_PRESERVED_BITS;
265 ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
266 read_value);
267
268 /* Now we can write the data */
269
270 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_event_block);
271 if (ACPI_FAILURE(status)) {
272 goto exit;
273 }
274
275 /* PM1B is optional */
276 294
277 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_event_block); 295 status = acpi_hw_write_multiple(value,
296 &acpi_gbl_xpm1a_status,
297 &acpi_gbl_xpm1b_status);
278 break; 298 break;
279 299
280 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ 300 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access */
281 301
282 status = acpi_write(value, &acpi_gbl_xpm1a_enable); 302 status = acpi_hw_write_multiple(value,
283 if (ACPI_FAILURE(status)) { 303 &acpi_gbl_xpm1a_enable,
284 goto exit; 304 &acpi_gbl_xpm1b_enable);
285 }
286
287 /* PM1B is optional */
288
289 status = acpi_write(value, &acpi_gbl_xpm1b_enable);
290 break; 305 break;
291 306
292 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 307 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
293 308
294 /* 309 /*
295 * Perform a read first to preserve certain bits (per ACPI spec) 310 * Perform a read first to preserve certain bits (per ACPI spec)
311 * Note: This includes SCI_EN, we never want to change this bit
296 */ 312 */
297 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, 313 status = acpi_hw_read_multiple(&read_value,
298 &read_value); 314 &acpi_gbl_FADT.
315 xpm1a_control_block,
316 &acpi_gbl_FADT.
317 xpm1b_control_block);
299 if (ACPI_FAILURE(status)) { 318 if (ACPI_FAILURE(status)) {
300 goto exit; 319 goto exit;
301 } 320 }
@@ -307,25 +326,29 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
307 326
308 /* Now we can write the data */ 327 /* Now we can write the data */
309 328
310 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block); 329 status = acpi_hw_write_multiple(value,
311 if (ACPI_FAILURE(status)) { 330 &acpi_gbl_FADT.
312 goto exit; 331 xpm1a_control_block,
313 } 332 &acpi_gbl_FADT.
314 333 xpm1b_control_block);
315 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
316 break; 334 break;
317 335
318 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ 336 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
319
320 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
321 break;
322 337
323 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ 338 /*
339 * For control registers, all reserved bits must be preserved,
340 * as per the ACPI spec.
341 */
342 status =
343 acpi_read(&read_value, &acpi_gbl_FADT.xpm2_control_block);
344 if (ACPI_FAILURE(status)) {
345 goto exit;
346 }
324 347
325 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block); 348 /* Insert the bits to be preserved */
326 break;
327 349
328 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 350 ACPI_INSERT_BITS(value, ACPI_PM2_CONTROL_PRESERVED_BITS,
351 read_value);
329 352
330 status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block); 353 status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block);
331 break; 354 break;
@@ -340,10 +363,11 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
340 /* SMI_CMD is currently always in IO space */ 363 /* SMI_CMD is currently always in IO space */
341 364
342 status = 365 status =
343 acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8); 366 acpi_hw_write_port(acpi_gbl_FADT.smi_command, value, 8);
344 break; 367 break;
345 368
346 default: 369 default:
370 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id));
347 status = AE_BAD_PARAMETER; 371 status = AE_BAD_PARAMETER;
348 break; 372 break;
349 } 373 }
@@ -351,3 +375,103 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
351 exit: 375 exit:
352 return_ACPI_STATUS(status); 376 return_ACPI_STATUS(status);
353} 377}
378
379/******************************************************************************
380 *
381 * FUNCTION: acpi_hw_read_multiple
382 *
383 * PARAMETERS: Value - Where the register value is returned
384 * register_a - First ACPI register (required)
385 * register_b - Second ACPI register (optional)
386 *
387 * RETURN: Status
388 *
389 * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B)
390 *
391 ******************************************************************************/
392
393static acpi_status
394acpi_hw_read_multiple(u32 *value,
395 struct acpi_generic_address *register_a,
396 struct acpi_generic_address *register_b)
397{
398 u32 value_a = 0;
399 u32 value_b = 0;
400 acpi_status status;
401
402 /* The first register is always required */
403
404 status = acpi_read(&value_a, register_a);
405 if (ACPI_FAILURE(status)) {
406 return (status);
407 }
408
409 /* Second register is optional */
410
411 if (register_b->address) {
412 status = acpi_read(&value_b, register_b);
413 if (ACPI_FAILURE(status)) {
414 return (status);
415 }
416 }
417
418 /*
419 * OR the two return values together. No shifting or masking is necessary,
420 * because of how the PM1 registers are defined in the ACPI specification:
421 *
422 * "Although the bits can be split between the two register blocks (each
423 * register block has a unique pointer within the FADT), the bit positions
424 * are maintained. The register block with unimplemented bits (that is,
425 * those implemented in the other register block) always returns zeros,
426 * and writes have no side effects"
427 */
428 *value = (value_a | value_b);
429 return (AE_OK);
430}
431
432/******************************************************************************
433 *
434 * FUNCTION: acpi_hw_write_multiple
435 *
436 * PARAMETERS: Value - The value to write
437 * register_a - First ACPI register (required)
438 * register_b - Second ACPI register (optional)
439 *
440 * RETURN: Status
441 *
442 * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B)
443 *
444 ******************************************************************************/
445
446static acpi_status
447acpi_hw_write_multiple(u32 value,
448 struct acpi_generic_address *register_a,
449 struct acpi_generic_address *register_b)
450{
451 acpi_status status;
452
453 /* The first register is always required */
454
455 status = acpi_write(value, register_a);
456 if (ACPI_FAILURE(status)) {
457 return (status);
458 }
459
460 /*
461 * Second register is optional
462 *
463 * No bit shifting or clearing is necessary, because of how the PM1
464 * registers are defined in the ACPI specification:
465 *
466 * "Although the bits can be split between the two register blocks (each
467 * register block has a unique pointer within the FADT), the bit positions
468 * are maintained. The register block with unimplemented bits (that is,
469 * those implemented in the other register block) always returns zeros,
470 * and writes have no side effects"
471 */
472 if (register_b->address) {
473 status = acpi_write(value, register_b);
474 }
475
476 return (status);
477}
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index a2af2a4f2f26..baa5fc05e124 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -90,6 +90,7 @@ acpi_set_firmware_waking_vector(u32 physical_address)
90 90
91ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector) 91ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
92 92
93#if ACPI_MACHINE_WIDTH == 64
93/******************************************************************************* 94/*******************************************************************************
94 * 95 *
95 * FUNCTION: acpi_set_firmware_waking_vector64 96 * FUNCTION: acpi_set_firmware_waking_vector64
@@ -100,7 +101,8 @@ ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
100 * RETURN: Status 101 * RETURN: Status
101 * 102 *
102 * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if 103 * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if
103 * it exists in the table. 104 * it exists in the table. This function is intended for use with
105 * 64-bit host operating systems.
104 * 106 *
105 ******************************************************************************/ 107 ******************************************************************************/
106acpi_status 108acpi_status
@@ -124,6 +126,7 @@ acpi_set_firmware_waking_vector64(u64 physical_address)
124} 126}
125 127
126ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64) 128ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64)
129#endif
127 130
128/******************************************************************************* 131/*******************************************************************************
129 * 132 *
@@ -147,9 +150,8 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
147 150
148 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep); 151 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep);
149 152
150 /* 153 /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */
151 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. 154
152 */
153 status = acpi_get_sleep_type_data(sleep_state, 155 status = acpi_get_sleep_type_data(sleep_state,
154 &acpi_gbl_sleep_type_a, 156 &acpi_gbl_sleep_type_a,
155 &acpi_gbl_sleep_type_b); 157 &acpi_gbl_sleep_type_b);
@@ -223,8 +225,8 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
223 ******************************************************************************/ 225 ******************************************************************************/
224acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) 226acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
225{ 227{
226 u32 PM1Acontrol; 228 u32 pm1a_control;
227 u32 PM1Bcontrol; 229 u32 pm1b_control;
228 struct acpi_bit_register_info *sleep_type_reg_info; 230 struct acpi_bit_register_info *sleep_type_reg_info;
229 struct acpi_bit_register_info *sleep_enable_reg_info; 231 struct acpi_bit_register_info *sleep_enable_reg_info;
230 u32 in_value; 232 u32 in_value;
@@ -242,13 +244,14 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
242 } 244 }
243 245
244 sleep_type_reg_info = 246 sleep_type_reg_info =
245 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); 247 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
246 sleep_enable_reg_info = 248 sleep_enable_reg_info =
247 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); 249 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
248 250
249 /* Clear wake status */ 251 /* Clear wake status */
250 252
251 status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); 253 status =
254 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
252 if (ACPI_FAILURE(status)) { 255 if (ACPI_FAILURE(status)) {
253 return_ACPI_STATUS(status); 256 return_ACPI_STATUS(status);
254 } 257 }
@@ -289,24 +292,25 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
289 292
290 /* Get current value of PM1A control */ 293 /* Get current value of PM1A control */
291 294
292 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); 295 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
296 &pm1a_control);
293 if (ACPI_FAILURE(status)) { 297 if (ACPI_FAILURE(status)) {
294 return_ACPI_STATUS(status); 298 return_ACPI_STATUS(status);
295 } 299 }
296 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 300 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
297 "Entering sleep state [S%d]\n", sleep_state)); 301 "Entering sleep state [S%d]\n", sleep_state));
298 302
299 /* Clear SLP_EN and SLP_TYP fields */ 303 /* Clear the SLP_EN and SLP_TYP fields */
300 304
301 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | 305 pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
302 sleep_enable_reg_info->access_bit_mask); 306 sleep_enable_reg_info->access_bit_mask);
303 PM1Bcontrol = PM1Acontrol; 307 pm1b_control = pm1a_control;
304 308
305 /* Insert SLP_TYP bits */ 309 /* Insert the SLP_TYP bits */
306 310
307 PM1Acontrol |= 311 pm1a_control |=
308 (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); 312 (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
309 PM1Bcontrol |= 313 pm1b_control |=
310 (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); 314 (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
311 315
312 /* 316 /*
@@ -314,37 +318,25 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
314 * poorly implemented hardware. 318 * poorly implemented hardware.
315 */ 319 */
316 320
317 /* Write #1: fill in SLP_TYP data */ 321 /* Write #1: write the SLP_TYP data to the PM1 Control registers */
318 322
319 status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, 323 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
320 PM1Acontrol);
321 if (ACPI_FAILURE(status)) { 324 if (ACPI_FAILURE(status)) {
322 return_ACPI_STATUS(status); 325 return_ACPI_STATUS(status);
323 } 326 }
324 327
325 status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, 328 /* Insert the sleep enable (SLP_EN) bit */
326 PM1Bcontrol);
327 if (ACPI_FAILURE(status)) {
328 return_ACPI_STATUS(status);
329 }
330 329
331 /* Insert SLP_ENABLE bit */ 330 pm1a_control |= sleep_enable_reg_info->access_bit_mask;
331 pm1b_control |= sleep_enable_reg_info->access_bit_mask;
332 332
333 PM1Acontrol |= sleep_enable_reg_info->access_bit_mask; 333 /* Flush caches, as per ACPI specification */
334 PM1Bcontrol |= sleep_enable_reg_info->access_bit_mask;
335
336 /* Write #2: SLP_TYP + SLP_EN */
337 334
338 ACPI_FLUSH_CPU_CACHE(); 335 ACPI_FLUSH_CPU_CACHE();
339 336
340 status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, 337 /* Write #2: Write both SLP_TYP + SLP_EN */
341 PM1Acontrol);
342 if (ACPI_FAILURE(status)) {
343 return_ACPI_STATUS(status);
344 }
345 338
346 status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, 339 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
347 PM1Bcontrol);
348 if (ACPI_FAILURE(status)) { 340 if (ACPI_FAILURE(status)) {
349 return_ACPI_STATUS(status); 341 return_ACPI_STATUS(status);
350 } 342 }
@@ -357,8 +349,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
357 * Wait ten seconds, then try again. This is to get S4/S5 to work on 349 * Wait ten seconds, then try again. This is to get S4/S5 to work on
358 * all machines. 350 * all machines.
359 * 351 *
360 * We wait so long to allow chipsets that poll this reg very slowly to 352 * We wait so long to allow chipsets that poll this reg very slowly
361 * still read the right value. Ideally, this block would go 353 * to still read the right value. Ideally, this block would go
362 * away entirely. 354 * away entirely.
363 */ 355 */
364 acpi_os_stall(10000000); 356 acpi_os_stall(10000000);
@@ -374,7 +366,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
374 /* Wait until we enter sleep state */ 366 /* Wait until we enter sleep state */
375 367
376 do { 368 do {
377 status = acpi_get_register_unlocked(ACPI_BITREG_WAKE_STATUS, 369 status = acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS,
378 &in_value); 370 &in_value);
379 if (ACPI_FAILURE(status)) { 371 if (ACPI_FAILURE(status)) {
380 return_ACPI_STATUS(status); 372 return_ACPI_STATUS(status);
@@ -408,7 +400,10 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
408 400
409 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios); 401 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios);
410 402
411 status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); 403 /* Clear the wake status bit (PM1) */
404
405 status =
406 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
412 if (ACPI_FAILURE(status)) { 407 if (ACPI_FAILURE(status)) {
413 return_ACPI_STATUS(status); 408 return_ACPI_STATUS(status);
414 } 409 }
@@ -435,12 +430,13 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
435 430
436 ACPI_FLUSH_CPU_CACHE(); 431 ACPI_FLUSH_CPU_CACHE();
437 432
438 status = acpi_os_write_port(acpi_gbl_FADT.smi_command, 433 status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
439 (u32) acpi_gbl_FADT.S4bios_request, 8); 434 (u32) acpi_gbl_FADT.S4bios_request, 8);
440 435
441 do { 436 do {
442 acpi_os_stall(1000); 437 acpi_os_stall(1000);
443 status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value); 438 status =
439 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
444 if (ACPI_FAILURE(status)) { 440 if (ACPI_FAILURE(status)) {
445 return_ACPI_STATUS(status); 441 return_ACPI_STATUS(status);
446 } 442 }
@@ -471,8 +467,8 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
471 acpi_status status; 467 acpi_status status;
472 struct acpi_bit_register_info *sleep_type_reg_info; 468 struct acpi_bit_register_info *sleep_type_reg_info;
473 struct acpi_bit_register_info *sleep_enable_reg_info; 469 struct acpi_bit_register_info *sleep_enable_reg_info;
474 u32 PM1Acontrol; 470 u32 pm1a_control;
475 u32 PM1Bcontrol; 471 u32 pm1b_control;
476 472
477 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); 473 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
478 474
@@ -486,38 +482,34 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
486 &acpi_gbl_sleep_type_b); 482 &acpi_gbl_sleep_type_b);
487 if (ACPI_SUCCESS(status)) { 483 if (ACPI_SUCCESS(status)) {
488 sleep_type_reg_info = 484 sleep_type_reg_info =
489 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); 485 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
490 sleep_enable_reg_info = 486 sleep_enable_reg_info =
491 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); 487 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
492 488
493 /* Get current value of PM1A control */ 489 /* Get current value of PM1A control */
494 490
495 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, 491 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
496 &PM1Acontrol); 492 &pm1a_control);
497 if (ACPI_SUCCESS(status)) { 493 if (ACPI_SUCCESS(status)) {
498 494
499 /* Clear SLP_EN and SLP_TYP fields */ 495 /* Clear the SLP_EN and SLP_TYP fields */
500 496
501 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | 497 pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
502 sleep_enable_reg_info-> 498 sleep_enable_reg_info->
503 access_bit_mask); 499 access_bit_mask);
504 PM1Bcontrol = PM1Acontrol; 500 pm1b_control = pm1a_control;
505 501
506 /* Insert SLP_TYP bits */ 502 /* Insert the SLP_TYP bits */
507 503
508 PM1Acontrol |= 504 pm1a_control |= (acpi_gbl_sleep_type_a <<
509 (acpi_gbl_sleep_type_a << sleep_type_reg_info-> 505 sleep_type_reg_info->bit_position);
510 bit_position); 506 pm1b_control |= (acpi_gbl_sleep_type_b <<
511 PM1Bcontrol |= 507 sleep_type_reg_info->bit_position);
512 (acpi_gbl_sleep_type_b << sleep_type_reg_info->
513 bit_position);
514 508
515 /* Just ignore any errors */ 509 /* Write the control registers and ignore any errors */
516 510
517 (void)acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, 511 (void)acpi_hw_write_pm1_control(pm1a_control,
518 PM1Acontrol); 512 pm1b_control);
519 (void)acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
520 PM1Bcontrol);
521 } 513 }
522 } 514 }
523 515
@@ -603,19 +595,21 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
603 * it to determine whether the system is rebooting or resuming. Clear 595 * it to determine whether the system is rebooting or resuming. Clear
604 * it for compatibility. 596 * it for compatibility.
605 */ 597 */
606 acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); 598 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1);
607 599
608 acpi_gbl_system_awake_and_running = TRUE; 600 acpi_gbl_system_awake_and_running = TRUE;
609 601
610 /* Enable power button */ 602 /* Enable power button */
611 603
612 (void) 604 (void)
613 acpi_set_register(acpi_gbl_fixed_event_info 605 acpi_write_bit_register(acpi_gbl_fixed_event_info
614 [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1); 606 [ACPI_EVENT_POWER_BUTTON].
607 enable_register_id, ACPI_ENABLE_EVENT);
615 608
616 (void) 609 (void)
617 acpi_set_register(acpi_gbl_fixed_event_info 610 acpi_write_bit_register(acpi_gbl_fixed_event_info
618 [ACPI_EVENT_POWER_BUTTON].status_register_id, 1); 611 [ACPI_EVENT_POWER_BUTTON].
612 status_register_id, ACPI_CLEAR_STATUS);
619 613
620 arg.integer.value = ACPI_SST_WORKING; 614 arg.integer.value = ACPI_SST_WORKING;
621 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 615 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
new file mode 100644
index 000000000000..bd3c937b0ac0
--- /dev/null
+++ b/drivers/acpi/acpica/hwvalid.c
@@ -0,0 +1,258 @@
1
2/******************************************************************************
3 *
4 * Module Name: hwvalid - I/O request validation
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2009, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <acpi/acpi.h>
46#include "accommon.h"
47
48#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwvalid")
50
51/* Local prototypes */
52static acpi_status
53acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width);
54
55/*
56 * Protected I/O ports. Some ports are always illegal, and some are
57 * conditionally illegal. This table must remain ordered by port address.
58 *
59 * The table is used to implement the Microsoft port access rules that
60 * first appeared in Windows XP. Some ports are always illegal, and some
61 * ports are only illegal if the BIOS calls _OSI with a win_xP string or
62 * later (meaning that the BIOS itelf is post-XP.)
63 *
64 * This provides ACPICA with the desired port protections and
65 * Microsoft compatibility.
66 *
67 * Description of port entries:
68 * DMA: DMA controller
69 * PIC0: Programmable Interrupt Controller (8259_a)
70 * PIT1: System Timer 1
71 * PIT2: System Timer 2 failsafe
72 * RTC: Real-time clock
73 * CMOS: Extended CMOS
74 * DMA1: DMA 1 page registers
75 * DMA1L: DMA 1 Ch 0 low page
76 * DMA2: DMA 2 page registers
77 * DMA2L: DMA 2 low page refresh
78 * ARBC: Arbitration control
79 * SETUP: Reserved system board setup
80 * POS: POS channel select
81 * PIC1: Cascaded PIC
82 * IDMA: ISA DMA
83 * ELCR: PIC edge/level registers
84 * PCI: PCI configuration space
85 */
86static const struct acpi_port_info acpi_protected_ports[] = {
87 {"DMA", 0x0000, 0x000F, ACPI_OSI_WIN_XP},
88 {"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL},
89 {"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP},
90 {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP},
91 {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP},
92 {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP},
93 {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP},
94 {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP},
95 {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP},
96 {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP},
97 {"ARBC", 0x0090, 0x0091, ACPI_OSI_WIN_XP},
98 {"SETUP", 0x0093, 0x0094, ACPI_OSI_WIN_XP},
99 {"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP},
100 {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL},
101 {"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP},
102 {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL},
103 {"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP}
104};
105
106#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (acpi_protected_ports)
107
108/******************************************************************************
109 *
110 * FUNCTION: acpi_hw_validate_io_request
111 *
112 * PARAMETERS: Address Address of I/O port/register
113 * bit_width Number of bits (8,16,32)
114 *
115 * RETURN: Status
116 *
117 * DESCRIPTION: Validates an I/O request (address/length). Certain ports are
118 * always illegal and some ports are only illegal depending on
119 * the requests the BIOS AML code makes to the predefined
120 * _OSI method.
121 *
122 ******************************************************************************/
123
124static acpi_status
125acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width)
126{
127 u32 i;
128 u32 byte_width;
129 acpi_io_address last_address;
130 const struct acpi_port_info *port_info;
131
132 ACPI_FUNCTION_TRACE(hw_validate_io_request);
133
134 /* Supported widths are 8/16/32 */
135
136 if ((bit_width != 8) && (bit_width != 16) && (bit_width != 32)) {
137 return AE_BAD_PARAMETER;
138 }
139
140 port_info = acpi_protected_ports;
141 byte_width = ACPI_DIV_8(bit_width);
142 last_address = address + byte_width - 1;
143
144 ACPI_DEBUG_PRINT((ACPI_DB_IO, "Address %p LastAddress %p Length %X",
145 ACPI_CAST_PTR(void, address), ACPI_CAST_PTR(void,
146 last_address),
147 byte_width));
148
149 /* Maximum 16-bit address in I/O space */
150
151 if (last_address > ACPI_UINT16_MAX) {
152 ACPI_ERROR((AE_INFO,
153 "Illegal I/O port address/length above 64K: 0x%p/%X",
154 ACPI_CAST_PTR(void, address), byte_width));
155 return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS);
156 }
157
158 /* Exit if requested address is not within the protected port table */
159
160 if (address > acpi_protected_ports[ACPI_PORT_INFO_ENTRIES - 1].end) {
161 return_ACPI_STATUS(AE_OK);
162 }
163
164 /* Check request against the list of protected I/O ports */
165
166 for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, port_info++) {
167 /*
168 * Check if the requested address range will write to a reserved
169 * port. Four cases to consider:
170 *
171 * 1) Address range is contained completely in the port address range
172 * 2) Address range overlaps port range at the port range start
173 * 3) Address range overlaps port range at the port range end
174 * 4) Address range completely encompasses the port range
175 */
176 if ((address <= port_info->end)
177 && (last_address >= port_info->start)) {
178
179 /* Port illegality may depend on the _OSI calls made by the BIOS */
180
181 if (acpi_gbl_osi_data >= port_info->osi_dependency) {
182 ACPI_ERROR((AE_INFO,
183 "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)",
184 ACPI_CAST_PTR(void, address),
185 byte_width, port_info->name,
186 port_info->start, port_info->end));
187
188 return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS);
189 }
190 }
191
192 /* Finished if address range ends before the end of this port */
193
194 if (last_address <= port_info->end) {
195 break;
196 }
197 }
198
199 return_ACPI_STATUS(AE_OK);
200}
201
202/******************************************************************************
203 *
204 * FUNCTION: acpi_hw_read_port
205 *
206 * PARAMETERS: Address Address of I/O port/register to read
207 * Value Where value is placed
208 * Width Number of bits
209 *
210 * RETURN: Value read from port
211 *
212 * DESCRIPTION: Read data from an I/O port or register. This is a front-end
213 * to acpi_os_read_port that performs validation on both the port
214 * address and the length.
215 *
216 *****************************************************************************/
217
218acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width)
219{
220 acpi_status status;
221
222 status = acpi_hw_validate_io_request(address, width);
223 if (ACPI_FAILURE(status)) {
224 return status;
225 }
226
227 status = acpi_os_read_port(address, value, width);
228 return status;
229}
230
231/******************************************************************************
232 *
233 * FUNCTION: acpi_hw_write_port
234 *
235 * PARAMETERS: Address Address of I/O port/register to write
236 * Value Value to write
237 * Width Number of bits
238 *
239 * RETURN: None
240 *
241 * DESCRIPTION: Write data to an I/O port or register. This is a front-end
242 * to acpi_os_write_port that performs validation on both the port
243 * address and the length.
244 *
245 *****************************************************************************/
246
247acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width)
248{
249 acpi_status status;
250
251 status = acpi_hw_validate_io_request(address, width);
252 if (ACPI_FAILURE(status)) {
253 return status;
254 }
255
256 status = acpi_os_write_port(address, value, width);
257 return status;
258}
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index ae597c0ab53f..9829979f2bdd 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -107,19 +107,18 @@ acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg)
107 ACPI_FUNCTION_NAME(acpi_read); 107 ACPI_FUNCTION_NAME(acpi_read);
108 108
109 /* 109 /*
110 * Must have a valid pointer to a GAS structure, and 110 * Must have a valid pointer to a GAS structure, and a non-zero address
111 * a non-zero address within. However, don't return an error 111 * within.
112 * because the PM1A/B code must not fail if B isn't present.
113 */ 112 */
114 if (!reg) { 113 if (!reg) {
115 return (AE_OK); 114 return (AE_BAD_PARAMETER);
116 } 115 }
117 116
118 /* Get a local copy of the address. Handles possible alignment issues */ 117 /* Get a local copy of the address. Handles possible alignment issues */
119 118
120 ACPI_MOVE_64_TO_64(&address, &reg->address); 119 ACPI_MOVE_64_TO_64(&address, &reg->address);
121 if (!address) { 120 if (!address) {
122 return (AE_OK); 121 return (AE_BAD_ADDRESS);
123 } 122 }
124 123
125 /* Supported widths are 8/16/32 */ 124 /* Supported widths are 8/16/32 */
@@ -134,8 +133,8 @@ acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg)
134 *value = 0; 133 *value = 0;
135 134
136 /* 135 /*
137 * Two address spaces supported: Memory or IO. 136 * Two address spaces supported: Memory or IO. PCI_Config is
138 * PCI_Config is not supported here because the GAS struct is insufficient 137 * not supported here because the GAS structure is insufficient
139 */ 138 */
140 switch (reg->space_id) { 139 switch (reg->space_id) {
141 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 140 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
@@ -147,7 +146,7 @@ acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg)
147 case ACPI_ADR_SPACE_SYSTEM_IO: 146 case ACPI_ADR_SPACE_SYSTEM_IO:
148 147
149 status = 148 status =
150 acpi_os_read_port((acpi_io_address) address, value, width); 149 acpi_hw_read_port((acpi_io_address) address, value, width);
151 break; 150 break;
152 151
153 default: 152 default:
@@ -187,19 +186,18 @@ acpi_status acpi_write(u32 value, struct acpi_generic_address *reg)
187 ACPI_FUNCTION_NAME(acpi_write); 186 ACPI_FUNCTION_NAME(acpi_write);
188 187
189 /* 188 /*
190 * Must have a valid pointer to a GAS structure, and 189 * Must have a valid pointer to a GAS structure, and a non-zero address
191 * a non-zero address within. However, don't return an error 190 * within.
192 * because the PM1A/B code must not fail if B isn't present.
193 */ 191 */
194 if (!reg) { 192 if (!reg) {
195 return (AE_OK); 193 return (AE_BAD_PARAMETER);
196 } 194 }
197 195
198 /* Get a local copy of the address. Handles possible alignment issues */ 196 /* Get a local copy of the address. Handles possible alignment issues */
199 197
200 ACPI_MOVE_64_TO_64(&address, &reg->address); 198 ACPI_MOVE_64_TO_64(&address, &reg->address);
201 if (!address) { 199 if (!address) {
202 return (AE_OK); 200 return (AE_BAD_ADDRESS);
203 } 201 }
204 202
205 /* Supported widths are 8/16/32 */ 203 /* Supported widths are 8/16/32 */
@@ -222,7 +220,7 @@ acpi_status acpi_write(u32 value, struct acpi_generic_address *reg)
222 220
223 case ACPI_ADR_SPACE_SYSTEM_IO: 221 case ACPI_ADR_SPACE_SYSTEM_IO:
224 222
225 status = acpi_os_write_port((acpi_io_address) address, value, 223 status = acpi_hw_write_port((acpi_io_address) address, value,
226 width); 224 width);
227 break; 225 break;
228 226
@@ -244,24 +242,36 @@ ACPI_EXPORT_SYMBOL(acpi_write)
244 242
245/******************************************************************************* 243/*******************************************************************************
246 * 244 *
247 * FUNCTION: acpi_get_register_unlocked 245 * FUNCTION: acpi_read_bit_register
248 * 246 *
249 * PARAMETERS: register_id - ID of ACPI bit_register to access 247 * PARAMETERS: register_id - ID of ACPI Bit Register to access
250 * return_value - Value that was read from the register 248 * return_value - Value that was read from the register,
249 * normalized to bit position zero.
251 * 250 *
252 * RETURN: Status and the value read from specified Register. Value 251 * RETURN: Status and the value read from the specified Register. Value
253 * returned is normalized to bit0 (is shifted all the way right) 252 * returned is normalized to bit0 (is shifted all the way right)
254 * 253 *
255 * DESCRIPTION: ACPI bit_register read function. Does not acquire the HW lock. 254 * DESCRIPTION: ACPI bit_register read function. Does not acquire the HW lock.
256 * 255 *
256 * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
257 * PM2 Control.
258 *
259 * Note: The hardware lock is not required when reading the ACPI bit registers
260 * since almost all of them are single bit and it does not matter that
261 * the parent hardware register can be split across two physical
262 * registers. The only multi-bit field is SLP_TYP in the PM1 control
263 * register, but this field does not cross an 8-bit boundary (nor does
264 * it make much sense to actually read this field.)
265 *
257 ******************************************************************************/ 266 ******************************************************************************/
258acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value) 267acpi_status acpi_read_bit_register(u32 register_id, u32 *return_value)
259{ 268{
260 u32 register_value = 0;
261 struct acpi_bit_register_info *bit_reg_info; 269 struct acpi_bit_register_info *bit_reg_info;
270 u32 register_value;
271 u32 value;
262 acpi_status status; 272 acpi_status status;
263 273
264 ACPI_FUNCTION_TRACE(acpi_get_register_unlocked); 274 ACPI_FUNCTION_TRACE_U32(acpi_read_bit_register, register_id);
265 275
266 /* Get the info structure corresponding to the requested ACPI Register */ 276 /* Get the info structure corresponding to the requested ACPI Register */
267 277
@@ -270,209 +280,133 @@ acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value)
270 return_ACPI_STATUS(AE_BAD_PARAMETER); 280 return_ACPI_STATUS(AE_BAD_PARAMETER);
271 } 281 }
272 282
273 /* Read from the register */ 283 /* Read the entire parent register */
274 284
275 status = acpi_hw_register_read(bit_reg_info->parent_register, 285 status = acpi_hw_register_read(bit_reg_info->parent_register,
276 &register_value); 286 &register_value);
277 287 if (ACPI_FAILURE(status)) {
278 if (ACPI_SUCCESS(status)) { 288 return_ACPI_STATUS(status);
279
280 /* Normalize the value that was read */
281
282 register_value =
283 ((register_value & bit_reg_info->access_bit_mask)
284 >> bit_reg_info->bit_position);
285
286 *return_value = register_value;
287
288 ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read value %8.8X register %X\n",
289 register_value,
290 bit_reg_info->parent_register));
291 } 289 }
292 290
293 return_ACPI_STATUS(status); 291 /* Normalize the value that was read, mask off other bits */
294}
295 292
296ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked) 293 value = ((register_value & bit_reg_info->access_bit_mask)
294 >> bit_reg_info->bit_position);
297 295
298/******************************************************************************* 296 ACPI_DEBUG_PRINT((ACPI_DB_IO,
299 * 297 "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
300 * FUNCTION: acpi_get_register 298 register_id, bit_reg_info->parent_register,
301 * 299 register_value, value));
302 * PARAMETERS: register_id - ID of ACPI bit_register to access
303 * return_value - Value that was read from the register
304 *
305 * RETURN: Status and the value read from specified Register. Value
306 * returned is normalized to bit0 (is shifted all the way right)
307 *
308 * DESCRIPTION: ACPI bit_register read function.
309 *
310 ******************************************************************************/
311acpi_status acpi_get_register(u32 register_id, u32 *return_value)
312{
313 acpi_status status;
314 acpi_cpu_flags flags;
315
316 flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
317 status = acpi_get_register_unlocked(register_id, return_value);
318 acpi_os_release_lock(acpi_gbl_hardware_lock, flags);
319 300
320 return (status); 301 *return_value = value;
302 return_ACPI_STATUS(AE_OK);
321} 303}
322 304
323ACPI_EXPORT_SYMBOL(acpi_get_register) 305ACPI_EXPORT_SYMBOL(acpi_read_bit_register)
324 306
325/******************************************************************************* 307/*******************************************************************************
326 * 308 *
327 * FUNCTION: acpi_set_register 309 * FUNCTION: acpi_write_bit_register
328 * 310 *
329 * PARAMETERS: register_id - ID of ACPI bit_register to access 311 * PARAMETERS: register_id - ID of ACPI Bit Register to access
330 * Value - (only used on write) value to write to the 312 * Value - Value to write to the register, in bit
331 * Register, NOT pre-normalized to the bit pos 313 * position zero. The bit is automaticallly
314 * shifted to the correct position.
332 * 315 *
333 * RETURN: Status 316 * RETURN: Status
334 * 317 *
335 * DESCRIPTION: ACPI Bit Register write function. 318 * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock
319 * since most operations require a read/modify/write sequence.
320 *
321 * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
322 * PM2 Control.
323 *
324 * Note that at this level, the fact that there may be actually two
325 * hardware registers (A and B - and B may not exist) is abstracted.
336 * 326 *
337 ******************************************************************************/ 327 ******************************************************************************/
338acpi_status acpi_set_register(u32 register_id, u32 value) 328acpi_status acpi_write_bit_register(u32 register_id, u32 value)
339{ 329{
340 u32 register_value = 0;
341 struct acpi_bit_register_info *bit_reg_info; 330 struct acpi_bit_register_info *bit_reg_info;
342 acpi_status status;
343 acpi_cpu_flags lock_flags; 331 acpi_cpu_flags lock_flags;
332 u32 register_value;
333 acpi_status status = AE_OK;
344 334
345 ACPI_FUNCTION_TRACE_U32(acpi_set_register, register_id); 335 ACPI_FUNCTION_TRACE_U32(acpi_write_bit_register, register_id);
346 336
347 /* Get the info structure corresponding to the requested ACPI Register */ 337 /* Get the info structure corresponding to the requested ACPI Register */
348 338
349 bit_reg_info = acpi_hw_get_bit_register_info(register_id); 339 bit_reg_info = acpi_hw_get_bit_register_info(register_id);
350 if (!bit_reg_info) { 340 if (!bit_reg_info) {
351 ACPI_ERROR((AE_INFO, "Bad ACPI HW RegisterId: %X",
352 register_id));
353 return_ACPI_STATUS(AE_BAD_PARAMETER); 341 return_ACPI_STATUS(AE_BAD_PARAMETER);
354 } 342 }
355 343
356 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); 344 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
357 345
358 /* Always do a register read first so we can insert the new bits */
359
360 status = acpi_hw_register_read(bit_reg_info->parent_register,
361 &register_value);
362 if (ACPI_FAILURE(status)) {
363 goto unlock_and_exit;
364 }
365
366 /* 346 /*
367 * Decode the Register ID 347 * At this point, we know that the parent register is one of the
368 * Register ID = [Register block ID] | [bit ID] 348 * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control
369 *
370 * Check bit ID to fine locate Register offset.
371 * Check Mask to determine Register offset, and then read-write.
372 */ 349 */
373 switch (bit_reg_info->parent_register) { 350 if (bit_reg_info->parent_register != ACPI_REGISTER_PM1_STATUS) {
374 case ACPI_REGISTER_PM1_STATUS:
375
376 /* 351 /*
377 * Status Registers are different from the rest. Clear by 352 * 1) Case for PM1 Enable, PM1 Control, and PM2 Control
378 * writing 1, and writing 0 has no effect. So, the only relevant 353 *
379 * information is the single bit we're interested in, all others should 354 * Perform a register read to preserve the bits that we are not
380 * be written as 0 so they will be left unchanged. 355 * interested in
381 */ 356 */
382 value = ACPI_REGISTER_PREPARE_BITS(value, 357 status = acpi_hw_register_read(bit_reg_info->parent_register,
383 bit_reg_info->bit_position,
384 bit_reg_info->
385 access_bit_mask);
386 if (value) {
387 status =
388 acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
389 (u16) value);
390 register_value = 0;
391 }
392 break;
393
394 case ACPI_REGISTER_PM1_ENABLE:
395
396 ACPI_REGISTER_INSERT_VALUE(register_value,
397 bit_reg_info->bit_position,
398 bit_reg_info->access_bit_mask,
399 value);
400
401 status = acpi_hw_register_write(ACPI_REGISTER_PM1_ENABLE,
402 (u16) register_value);
403 break;
404
405 case ACPI_REGISTER_PM1_CONTROL:
406
407 /*
408 * Write the PM1 Control register.
409 * Note that at this level, the fact that there are actually TWO
410 * registers (A and B - and B may not exist) is abstracted.
411 */
412 ACPI_DEBUG_PRINT((ACPI_DB_IO, "PM1 control: Read %X\n",
413 register_value));
414
415 ACPI_REGISTER_INSERT_VALUE(register_value,
416 bit_reg_info->bit_position,
417 bit_reg_info->access_bit_mask,
418 value);
419
420 status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
421 (u16) register_value);
422 break;
423
424 case ACPI_REGISTER_PM2_CONTROL:
425
426 status = acpi_hw_register_read(ACPI_REGISTER_PM2_CONTROL,
427 &register_value); 358 &register_value);
428 if (ACPI_FAILURE(status)) { 359 if (ACPI_FAILURE(status)) {
429 goto unlock_and_exit; 360 goto unlock_and_exit;
430 } 361 }
431 362
432 ACPI_DEBUG_PRINT((ACPI_DB_IO, 363 /*
433 "PM2 control: Read %X from %8.8X%8.8X\n", 364 * Insert the input bit into the value that was just read
434 register_value, 365 * and write the register
435 ACPI_FORMAT_UINT64(acpi_gbl_FADT. 366 */
436 xpm2_control_block.
437 address)));
438
439 ACPI_REGISTER_INSERT_VALUE(register_value, 367 ACPI_REGISTER_INSERT_VALUE(register_value,
440 bit_reg_info->bit_position, 368 bit_reg_info->bit_position,
441 bit_reg_info->access_bit_mask, 369 bit_reg_info->access_bit_mask,
442 value); 370 value);
443 371
444 ACPI_DEBUG_PRINT((ACPI_DB_IO, 372 status = acpi_hw_register_write(bit_reg_info->parent_register,
445 "About to write %4.4X to %8.8X%8.8X\n", 373 register_value);
446 register_value, 374 } else {
447 ACPI_FORMAT_UINT64(acpi_gbl_FADT. 375 /*
448 xpm2_control_block. 376 * 2) Case for PM1 Status
449 address))); 377 *
378 * The Status register is different from the rest. Clear an event
379 * by writing 1, writing 0 has no effect. So, the only relevant
380 * information is the single bit we're interested in, all others
381 * should be written as 0 so they will be left unchanged.
382 */
383 register_value = ACPI_REGISTER_PREPARE_BITS(value,
384 bit_reg_info->
385 bit_position,
386 bit_reg_info->
387 access_bit_mask);
450 388
451 status = acpi_hw_register_write(ACPI_REGISTER_PM2_CONTROL, 389 /* No need to write the register if value is all zeros */
452 (u8) (register_value));
453 break;
454 390
455 default: 391 if (register_value) {
456 break; 392 status =
393 acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
394 register_value);
395 }
457 } 396 }
458 397
459 unlock_and_exit: 398 ACPI_DEBUG_PRINT((ACPI_DB_IO,
460 399 "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n",
461 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); 400 register_id, bit_reg_info->parent_register, value,
462 401 register_value));
463 /* Normalize the value that was read */
464 402
465 ACPI_DEBUG_EXEC(register_value = 403unlock_and_exit:
466 ((register_value & bit_reg_info->access_bit_mask) >>
467 bit_reg_info->bit_position));
468 404
469 ACPI_DEBUG_PRINT((ACPI_DB_IO, 405 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
470 "Set bits: %8.8X actual %8.8X register %X\n", value,
471 register_value, bit_reg_info->parent_register));
472 return_ACPI_STATUS(status); 406 return_ACPI_STATUS(status);
473} 407}
474 408
475ACPI_EXPORT_SYMBOL(acpi_set_register) 409ACPI_EXPORT_SYMBOL(acpi_write_bit_register)
476 410
477/******************************************************************************* 411/*******************************************************************************
478 * 412 *
@@ -534,7 +468,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
534 468
535 /* It must be of type Package */ 469 /* It must be of type Package */
536 470
537 else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) { 471 else if (info->return_object->common.type != ACPI_TYPE_PACKAGE) {
538 ACPI_ERROR((AE_INFO, 472 ACPI_ERROR((AE_INFO,
539 "Sleep State return object is not a Package")); 473 "Sleep State return object is not a Package"));
540 status = AE_AML_OPERAND_TYPE; 474 status = AE_AML_OPERAND_TYPE;
@@ -555,12 +489,13 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
555 489
556 /* The first two elements must both be of type Integer */ 490 /* The first two elements must both be of type Integer */
557 491
558 else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0]) 492 else if (((info->return_object->package.elements[0])->common.type
559 != ACPI_TYPE_INTEGER) || 493 != ACPI_TYPE_INTEGER) ||
560 (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1]) 494 ((info->return_object->package.elements[1])->common.type
561 != ACPI_TYPE_INTEGER)) { 495 != ACPI_TYPE_INTEGER)) {
562 ACPI_ERROR((AE_INFO, 496 ACPI_ERROR((AE_INFO,
563 "Sleep State return package elements are not both Integers (%s, %s)", 497 "Sleep State return package elements are not both Integers "
498 "(%s, %s)",
564 acpi_ut_get_object_type_name(info->return_object-> 499 acpi_ut_get_object_type_name(info->return_object->
565 package.elements[0]), 500 package.elements[0]),
566 acpi_ut_get_object_type_name(info->return_object-> 501 acpi_ut_get_object_type_name(info->return_object->
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index 88303ebe924c..9c3cdbe2d82a 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -118,9 +118,8 @@ acpi_status acpi_ns_root_initialize(void)
118 } 118 }
119 119
120 /* 120 /*
121 * Name entered successfully. 121 * Name entered successfully. If entry in pre_defined_names[] specifies
122 * If entry in pre_defined_names[] specifies an 122 * an initial value, create the initial value.
123 * initial value, create the initial value.
124 */ 123 */
125 if (init_val->val) { 124 if (init_val->val) {
126 status = acpi_os_predefined_override(init_val, &val); 125 status = acpi_os_predefined_override(init_val, &val);
@@ -178,9 +177,8 @@ acpi_status acpi_ns_root_initialize(void)
178 177
179 case ACPI_TYPE_STRING: 178 case ACPI_TYPE_STRING:
180 179
181 /* 180 /* Build an object around the static string */
182 * Build an object around the static string 181
183 */
184 obj_desc->string.length = 182 obj_desc->string.length =
185 (u32) ACPI_STRLEN(val); 183 (u32) ACPI_STRLEN(val);
186 obj_desc->string.pointer = val; 184 obj_desc->string.pointer = val;
@@ -234,8 +232,7 @@ acpi_status acpi_ns_root_initialize(void)
234 /* Store pointer to value descriptor in the Node */ 232 /* Store pointer to value descriptor in the Node */
235 233
236 status = acpi_ns_attach_object(new_node, obj_desc, 234 status = acpi_ns_attach_object(new_node, obj_desc,
237 ACPI_GET_OBJECT_TYPE 235 obj_desc->common.type);
238 (obj_desc));
239 236
240 /* Remove local reference to the object */ 237 /* Remove local reference to the object */
241 238
@@ -315,10 +312,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
315 return_ACPI_STATUS(AE_NO_NAMESPACE); 312 return_ACPI_STATUS(AE_NO_NAMESPACE);
316 } 313 }
317 314
318 /* 315 /* Get the prefix scope. A null scope means use the root scope */
319 * Get the prefix scope. 316
320 * A null scope means use the root scope
321 */
322 if ((!scope_info) || (!scope_info->scope.node)) { 317 if ((!scope_info) || (!scope_info->scope.node)) {
323 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 318 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
324 "Null scope prefix, using root node (%p)\n", 319 "Null scope prefix, using root node (%p)\n",
@@ -338,8 +333,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
338 if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) { 333 if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) {
339 /* 334 /*
340 * This node might not be a actual "scope" node (such as a 335 * This node might not be a actual "scope" node (such as a
341 * Device/Method, etc.) It could be a Package or other object node. 336 * Device/Method, etc.) It could be a Package or other object
342 * Backup up the tree to find the containing scope node. 337 * node. Backup up the tree to find the containing scope node.
343 */ 338 */
344 while (!acpi_ns_opens_scope(prefix_node->type) && 339 while (!acpi_ns_opens_scope(prefix_node->type) &&
345 prefix_node->type != ACPI_TYPE_ANY) { 340 prefix_node->type != ACPI_TYPE_ANY) {
@@ -349,7 +344,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
349 } 344 }
350 } 345 }
351 346
352 /* Save type TBD: may be no longer necessary */ 347 /* Save type. TBD: may be no longer necessary */
353 348
354 type_to_check_for = type; 349 type_to_check_for = type;
355 350
@@ -414,6 +409,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
414 /* Name is fully qualified, no search rules apply */ 409 /* Name is fully qualified, no search rules apply */
415 410
416 search_parent_flag = ACPI_NS_NO_UPSEARCH; 411 search_parent_flag = ACPI_NS_NO_UPSEARCH;
412
417 /* 413 /*
418 * Point past this prefix to the name segment 414 * Point past this prefix to the name segment
419 * part or the next Parent Prefix 415 * part or the next Parent Prefix
@@ -429,7 +425,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
429 /* Current scope has no parent scope */ 425 /* Current scope has no parent scope */
430 426
431 ACPI_ERROR((AE_INFO, 427 ACPI_ERROR((AE_INFO,
432 "ACPI path has too many parent prefixes (^) - reached beyond root node")); 428 "ACPI path has too many parent prefixes (^) "
429 "- reached beyond root node"));
433 return_ACPI_STATUS(AE_NOT_FOUND); 430 return_ACPI_STATUS(AE_NOT_FOUND);
434 } 431 }
435 } 432 }
@@ -531,9 +528,9 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
531 while (num_segments && current_node) { 528 while (num_segments && current_node) {
532 num_segments--; 529 num_segments--;
533 if (!num_segments) { 530 if (!num_segments) {
534 /* 531
535 * This is the last segment, enable typechecking 532 /* This is the last segment, enable typechecking */
536 */ 533
537 this_search_type = type; 534 this_search_type = type;
538 535
539 /* 536 /*
@@ -584,9 +581,9 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
584 if (num_segments > 0) { 581 if (num_segments > 0) {
585 /* 582 /*
586 * If we have an alias to an object that opens a scope (such as a 583 * If we have an alias to an object that opens a scope (such as a
587 * device or processor), we need to dereference the alias here so that 584 * device or processor), we need to dereference the alias here so
588 * we can access any children of the original node (via the remaining 585 * that we can access any children of the original node (via the
589 * segments). 586 * remaining segments).
590 */ 587 */
591 if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) { 588 if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) {
592 if (!this_node->object) { 589 if (!this_node->object) {
@@ -594,8 +591,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
594 } 591 }
595 592
596 if (acpi_ns_opens_scope 593 if (acpi_ns_opens_scope
597 (((struct acpi_namespace_node *)this_node-> 594 (((struct acpi_namespace_node *)
598 object)->type)) { 595 this_node->object)->type)) {
599 this_node = 596 this_node =
600 (struct acpi_namespace_node *) 597 (struct acpi_namespace_node *)
601 this_node->object; 598 this_node->object;
@@ -639,8 +636,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
639 636
640 /* 637 /*
641 * If this is the last name segment and we are not looking for a 638 * If this is the last name segment and we are not looking for a
642 * specific type, but the type of found object is known, use that type 639 * specific type, but the type of found object is known, use that
643 * to (later) see if it opens a scope. 640 * type to (later) see if it opens a scope.
644 */ 641 */
645 if (type == ACPI_TYPE_ANY) { 642 if (type == ACPI_TYPE_ANY) {
646 type = this_node->type; 643 type = this_node->type;
@@ -653,9 +650,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
653 current_node = this_node; 650 current_node = this_node;
654 } 651 }
655 652
656 /* 653 /* Always check if we need to open a new scope */
657 * Always check if we need to open a new scope 654
658 */
659 if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) { 655 if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) {
660 /* 656 /*
661 * If entry is a type which opens a scope, push the new scope on the 657 * If entry is a type which opens a scope, push the new scope on the
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index f976d848fe82..aceb93111967 100644
--- a/drivers/acpi/acpica/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -76,8 +76,7 @@ struct acpi_namespace_node *acpi_ns_create_node(u32 name)
76 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++); 76 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++);
77 77
78#ifdef ACPI_DBG_TRACK_ALLOCATIONS 78#ifdef ACPI_DBG_TRACK_ALLOCATIONS
79 temp = 79 temp = acpi_gbl_ns_node_list->total_allocated -
80 acpi_gbl_ns_node_list->total_allocated -
81 acpi_gbl_ns_node_list->total_freed; 80 acpi_gbl_ns_node_list->total_freed;
82 if (temp > acpi_gbl_ns_node_list->max_occupied) { 81 if (temp > acpi_gbl_ns_node_list->max_occupied) {
83 acpi_gbl_ns_node_list->max_occupied = temp; 82 acpi_gbl_ns_node_list->max_occupied = temp;
@@ -145,9 +144,8 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node)
145 144
146 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); 145 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
147 146
148 /* 147 /* Detach an object if there is one, then delete the node */
149 * Detach an object if there is one, then delete the node 148
150 */
151 acpi_ns_detach_object(node); 149 acpi_ns_detach_object(node);
152 (void)acpi_os_release_object(acpi_gbl_namespace_cache, node); 150 (void)acpi_os_release_object(acpi_gbl_namespace_cache, node);
153 return_VOID; 151 return_VOID;
@@ -183,9 +181,8 @@ void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namesp
183 ACPI_FUNCTION_TRACE(ns_install_node); 181 ACPI_FUNCTION_TRACE(ns_install_node);
184 182
185 /* 183 /*
186 * Get the owner ID from the Walk state 184 * Get the owner ID from the Walk state. The owner ID is used to track
187 * The owner ID is used to track table deletion and 185 * table deletion and deletion of objects created by methods.
188 * deletion of objects created by methods
189 */ 186 */
190 if (walk_state) { 187 if (walk_state) {
191 owner_id = walk_state->owner_id; 188 owner_id = walk_state->owner_id;
@@ -260,9 +257,8 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
260 return_VOID; 257 return_VOID;
261 } 258 }
262 259
263 /* 260 /* Deallocate all children at this level */
264 * Deallocate all children at this level 261
265 */
266 do { 262 do {
267 263
268 /* Get the things we need */ 264 /* Get the things we need */
@@ -285,9 +281,8 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
285 "Object %p, Remaining %X\n", child_node, 281 "Object %p, Remaining %X\n", child_node,
286 acpi_gbl_current_node_count)); 282 acpi_gbl_current_node_count));
287 283
288 /* 284 /* Detach an object if there is one, then free the child node */
289 * Detach an object if there is one, then free the child node 285
290 */
291 acpi_ns_detach_object(child_node); 286 acpi_ns_detach_object(child_node);
292 287
293 /* Now we can delete the node */ 288 /* Now we can delete the node */
@@ -304,7 +299,6 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
304 /* Clear the parent's child pointer */ 299 /* Clear the parent's child pointer */
305 300
306 parent_node->child = NULL; 301 parent_node->child = NULL;
307
308 return_VOID; 302 return_VOID;
309} 303}
310 304
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index 0da33c8e9ba2..2bad613db73a 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -181,6 +181,12 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
181 } 181 }
182 182
183 this_node = acpi_ns_map_handle_to_node(obj_handle); 183 this_node = acpi_ns_map_handle_to_node(obj_handle);
184 if (!this_node) {
185 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n",
186 obj_handle));
187 return (AE_OK);
188 }
189
184 type = this_node->type; 190 type = this_node->type;
185 191
186 /* Check if the owner matches */ 192 /* Check if the owner matches */
@@ -214,9 +220,8 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
214 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); 220 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
215 } 221 }
216 222
217 /* 223 /* Now we can print out the pertinent information */
218 * Now we can print out the pertinent information 224
219 */
220 acpi_os_printf(" %-12s %p %2.2X ", 225 acpi_os_printf(" %-12s %p %2.2X ",
221 acpi_ut_get_type_name(type), this_node, 226 acpi_ut_get_type_name(type), this_node,
222 this_node->owner_id); 227 this_node->owner_id);
@@ -509,7 +514,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
509 514
510 case ACPI_DESC_TYPE_OPERAND: 515 case ACPI_DESC_TYPE_OPERAND:
511 516
512 obj_type = ACPI_GET_OBJECT_TYPE(obj_desc); 517 obj_type = obj_desc->common.type;
513 518
514 if (obj_type > ACPI_TYPE_LOCAL_MAX) { 519 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
515 acpi_os_printf 520 acpi_os_printf
@@ -539,9 +544,8 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
539 goto cleanup; 544 goto cleanup;
540 } 545 }
541 546
542 /* 547 /* Valid object, get the pointer to next level, if any */
543 * Valid object, get the pointer to next level, if any 548
544 */
545 switch (obj_type) { 549 switch (obj_type) {
546 case ACPI_TYPE_BUFFER: 550 case ACPI_TYPE_BUFFER:
547 case ACPI_TYPE_STRING: 551 case ACPI_TYPE_STRING:
@@ -602,14 +606,14 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
602 * display_type - 0 or ACPI_DISPLAY_SUMMARY 606 * display_type - 0 or ACPI_DISPLAY_SUMMARY
603 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX 607 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
604 * for an effectively unlimited depth. 608 * for an effectively unlimited depth.
605 * owner_id - Dump only objects owned by this ID. Use 609 * owner_id - Dump only objects owned by this ID. Use
606 * ACPI_UINT32_MAX to match all owners. 610 * ACPI_UINT32_MAX to match all owners.
607 * start_handle - Where in namespace to start/end search 611 * start_handle - Where in namespace to start/end search
608 * 612 *
609 * RETURN: None 613 * RETURN: None
610 * 614 *
611 * DESCRIPTION: Dump typed objects within the loaded namespace. 615 * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
612 * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object. 616 * acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
613 * 617 *
614 ******************************************************************************/ 618 ******************************************************************************/
615 619
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index 0f3d5f9b5966..8e7dec1176c9 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -155,7 +155,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
155 } 155 }
156 156
157 157
158 ACPI_DUMP_PATHNAME(info->resolved_node, "Execute Method:", 158 ACPI_DUMP_PATHNAME(info->resolved_node, "ACPI: Execute Method",
159 ACPI_LV_INFO, _COMPONENT); 159 ACPI_LV_INFO, _COMPONENT);
160 160
161 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 161 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 13501cb81863..2adfcf329e15 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -103,7 +103,8 @@ acpi_status acpi_ns_initialize_objects(void)
103 } 103 }
104 104
105 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 105 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
106 "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n", 106 "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd "
107 "Buffers %hd/%hd Packages (%hd nodes)\n",
107 info.op_region_init, info.op_region_count, 108 info.op_region_init, info.op_region_count,
108 info.field_init, info.field_count, 109 info.field_init, info.field_count,
109 info.buffer_init, info.buffer_count, 110 info.buffer_init, info.buffer_count,
@@ -148,7 +149,8 @@ acpi_status acpi_ns_initialize_devices(void)
148 info.num_INI = 0; 149 info.num_INI = 0;
149 150
150 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 151 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
151 "Initializing Device/Processor/Thermal objects by executing _INI methods:")); 152 "Initializing Device/Processor/Thermal objects "
153 "by executing _INI methods:"));
152 154
153 /* Tree analysis: find all subtrees that contain _INI methods */ 155 /* Tree analysis: find all subtrees that contain _INI methods */
154 156
@@ -180,7 +182,8 @@ acpi_status acpi_ns_initialize_devices(void)
180 } 182 }
181 183
182 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 184 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
183 "\nExecuted %hd _INI methods requiring %hd _STA executions (examined %hd objects)\n", 185 "\nExecuted %hd _INI methods requiring %hd _STA executions "
186 "(examined %hd objects)\n",
184 info.num_INI, info.num_STA, info.device_count)); 187 info.num_INI, info.num_STA, info.device_count));
185 188
186 return_ACPI_STATUS(status); 189 return_ACPI_STATUS(status);
@@ -263,16 +266,14 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
263 return (AE_OK); 266 return (AE_OK);
264 } 267 }
265 268
266 /* 269 /* If the object is already initialized, nothing else to do */
267 * If the object is already initialized, nothing else to do 270
268 */
269 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 271 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
270 return (AE_OK); 272 return (AE_OK);
271 } 273 }
272 274
273 /* 275 /* Must lock the interpreter before executing AML code */
274 * Must lock the interpreter before executing AML code 276
275 */
276 acpi_ex_enter_interpreter(); 277 acpi_ex_enter_interpreter();
277 278
278 /* 279 /*
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index a0ba9e12379e..dcd7a6adbbbc 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -128,12 +128,12 @@ acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node)
128 * parse trees. 128 * parse trees.
129 */ 129 */
130 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 130 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
131 "**** Begin Table Method Parsing and Object Initialization ****\n")); 131 "**** Begin Table Method Parsing and Object Initialization\n"));
132 132
133 status = acpi_ds_initialize_objects(table_index, node); 133 status = acpi_ds_initialize_objects(table_index, node);
134 134
135 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 135 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
136 "**** Completed Table Method Parsing and Object Initialization ****\n")); 136 "**** Completed Table Method Parsing and Object Initialization\n"));
137 137
138 return_ACPI_STATUS(status); 138 return_ACPI_STATUS(status);
139} 139}
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
index 08a97a57f8f9..3eb20bfda9d8 100644
--- a/drivers/acpi/acpica/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -209,8 +209,7 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node)
209 209
210 obj_desc = node->object; 210 obj_desc = node->object;
211 211
212 if (!obj_desc || 212 if (!obj_desc || (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) {
213 (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA)) {
214 return_VOID; 213 return_VOID;
215 } 214 }
216 215
@@ -220,8 +219,7 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node)
220 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) { 219 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) {
221 node->object = obj_desc->common.next_object; 220 node->object = obj_desc->common.next_object;
222 if (node->object && 221 if (node->object &&
223 (ACPI_GET_OBJECT_TYPE(node->object) != 222 ((node->object)->common.type != ACPI_TYPE_LOCAL_DATA)) {
224 ACPI_TYPE_LOCAL_DATA)) {
225 node->object = node->object->common.next_object; 223 node->object = node->object->common.next_object;
226 } 224 }
227 } 225 }
@@ -267,7 +265,7 @@ union acpi_operand_object *acpi_ns_get_attached_object(struct
267 ((ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_OPERAND) 265 ((ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_OPERAND)
268 && (ACPI_GET_DESCRIPTOR_TYPE(node->object) != 266 && (ACPI_GET_DESCRIPTOR_TYPE(node->object) !=
269 ACPI_DESC_TYPE_NAMED)) 267 ACPI_DESC_TYPE_NAMED))
270 || (ACPI_GET_OBJECT_TYPE(node->object) == ACPI_TYPE_LOCAL_DATA)) { 268 || ((node->object)->common.type == ACPI_TYPE_LOCAL_DATA)) {
271 return_PTR(NULL); 269 return_PTR(NULL);
272 } 270 }
273 271
@@ -294,9 +292,9 @@ union acpi_operand_object *acpi_ns_get_secondary_object(union
294 ACPI_FUNCTION_TRACE_PTR(ns_get_secondary_object, obj_desc); 292 ACPI_FUNCTION_TRACE_PTR(ns_get_secondary_object, obj_desc);
295 293
296 if ((!obj_desc) || 294 if ((!obj_desc) ||
297 (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) || 295 (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA) ||
298 (!obj_desc->common.next_object) || 296 (!obj_desc->common.next_object) ||
299 (ACPI_GET_OBJECT_TYPE(obj_desc->common.next_object) == 297 ((obj_desc->common.next_object)->common.type ==
300 ACPI_TYPE_LOCAL_DATA)) { 298 ACPI_TYPE_LOCAL_DATA)) {
301 return_PTR(NULL); 299 return_PTR(NULL);
302 } 300 }
@@ -331,7 +329,7 @@ acpi_ns_attach_data(struct acpi_namespace_node *node,
331 prev_obj_desc = NULL; 329 prev_obj_desc = NULL;
332 obj_desc = node->object; 330 obj_desc = node->object;
333 while (obj_desc) { 331 while (obj_desc) {
334 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) && 332 if ((obj_desc->common.type == ACPI_TYPE_LOCAL_DATA) &&
335 (obj_desc->data.handler == handler)) { 333 (obj_desc->data.handler == handler)) {
336 return (AE_ALREADY_EXISTS); 334 return (AE_ALREADY_EXISTS);
337 } 335 }
@@ -385,7 +383,7 @@ acpi_ns_detach_data(struct acpi_namespace_node * node,
385 prev_obj_desc = NULL; 383 prev_obj_desc = NULL;
386 obj_desc = node->object; 384 obj_desc = node->object;
387 while (obj_desc) { 385 while (obj_desc) {
388 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) && 386 if ((obj_desc->common.type == ACPI_TYPE_LOCAL_DATA) &&
389 (obj_desc->data.handler == handler)) { 387 (obj_desc->data.handler == handler)) {
390 if (prev_obj_desc) { 388 if (prev_obj_desc) {
391 prev_obj_desc->common.next_object = 389 prev_obj_desc->common.next_object =
@@ -428,7 +426,7 @@ acpi_ns_get_attached_data(struct acpi_namespace_node * node,
428 426
429 obj_desc = node->object; 427 obj_desc = node->object;
430 while (obj_desc) { 428 while (obj_desc) {
431 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) && 429 if ((obj_desc->common.type == ACPI_TYPE_LOCAL_DATA) &&
432 (obj_desc->data.handler == handler)) { 430 (obj_desc->data.handler == handler)) {
433 *data = obj_desc->data.pointer; 431 *data = obj_desc->data.pointer;
434 return (AE_OK); 432 return (AE_OK);
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index b9e8d0070b6f..662a4bd5b621 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -176,9 +176,8 @@ acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node)
176 * performs another complete parse of the AML. 176 * performs another complete parse of the AML.
177 */ 177 */
178 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n")); 178 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n"));
179 status = 179 status = acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS1,
180 acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS1, table_index, 180 table_index, start_node);
181 start_node);
182 if (ACPI_FAILURE(status)) { 181 if (ACPI_FAILURE(status)) {
183 return_ACPI_STATUS(status); 182 return_ACPI_STATUS(status);
184 } 183 }
@@ -193,9 +192,8 @@ acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node)
193 * parse objects are all cached. 192 * parse objects are all cached.
194 */ 193 */
195 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n")); 194 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n"));
196 status = 195 status = acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS2,
197 acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS2, table_index, 196 table_index, start_node);
198 start_node);
199 if (ACPI_FAILURE(status)) { 197 if (ACPI_FAILURE(status)) {
200 return_ACPI_STATUS(status); 198 return_ACPI_STATUS(status);
201 } 199 }
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 452703290d35..d9e8cbc6e679 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -79,7 +79,9 @@ acpi_ns_check_package(char *pathname,
79static acpi_status 79static acpi_status
80acpi_ns_check_package_elements(char *pathname, 80acpi_ns_check_package_elements(char *pathname,
81 union acpi_operand_object **elements, 81 union acpi_operand_object **elements,
82 u8 type1, u32 count1, u8 type2, u32 count2); 82 u8 type1,
83 u32 count1,
84 u8 type2, u32 count2, u32 start_index);
83 85
84static acpi_status 86static acpi_status
85acpi_ns_check_object_type(char *pathname, 87acpi_ns_check_object_type(char *pathname,
@@ -221,7 +223,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
221 223
222 /* For returned Package objects, check the type of all sub-objects */ 224 /* For returned Package objects, check the type of all sub-objects */
223 225
224 if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_PACKAGE) { 226 if (return_object->common.type == ACPI_TYPE_PACKAGE) {
225 status = 227 status =
226 acpi_ns_check_package(pathname, return_object_ptr, 228 acpi_ns_check_package(pathname, return_object_ptr,
227 predefined); 229 predefined);
@@ -302,7 +304,8 @@ acpi_ns_check_parameter_count(char *pathname,
302 if ((user_param_count != required_params_current) && 304 if ((user_param_count != required_params_current) &&
303 (user_param_count != required_params_old)) { 305 (user_param_count != required_params_old)) {
304 ACPI_WARNING((AE_INFO, 306 ACPI_WARNING((AE_INFO,
305 "%s: Parameter count mismatch - caller passed %d, ACPI requires %d", 307 "%s: Parameter count mismatch - "
308 "caller passed %d, ACPI requires %d",
306 pathname, user_param_count, 309 pathname, user_param_count,
307 required_params_current)); 310 required_params_current));
308 } 311 }
@@ -472,7 +475,7 @@ acpi_ns_check_package(char *pathname,
472 package->ret_info. 475 package->ret_info.
473 object_type2, 476 object_type2,
474 package->ret_info. 477 package->ret_info.
475 count2); 478 count2, 0);
476 if (ACPI_FAILURE(status)) { 479 if (ACPI_FAILURE(status)) {
477 return (status); 480 return (status);
478 } 481 }
@@ -623,7 +626,7 @@ acpi_ns_check_package(char *pathname,
623 object_type2, 626 object_type2,
624 package-> 627 package->
625 ret_info. 628 ret_info.
626 count2); 629 count2, 0);
627 if (ACPI_FAILURE(status)) { 630 if (ACPI_FAILURE(status)) {
628 return (status); 631 return (status);
629 } 632 }
@@ -672,7 +675,8 @@ acpi_ns_check_package(char *pathname,
672 object_type1, 675 object_type1,
673 sub_package-> 676 sub_package->
674 package. 677 package.
675 count, 0, 0); 678 count, 0, 0,
679 0);
676 if (ACPI_FAILURE(status)) { 680 if (ACPI_FAILURE(status)) {
677 return (status); 681 return (status);
678 } 682 }
@@ -710,7 +714,8 @@ acpi_ns_check_package(char *pathname,
710 ret_info. 714 ret_info.
711 object_type1, 715 object_type1,
712 (expected_count 716 (expected_count
713 - 1), 0, 0); 717 - 1), 0, 0,
718 1);
714 if (ACPI_FAILURE(status)) { 719 if (ACPI_FAILURE(status)) {
715 return (status); 720 return (status);
716 } 721 }
@@ -758,6 +763,7 @@ acpi_ns_check_package(char *pathname,
758 * Count1 - Count for first group 763 * Count1 - Count for first group
759 * Type2 - Object type for second group 764 * Type2 - Object type for second group
760 * Count2 - Count for second group 765 * Count2 - Count for second group
766 * start_index - Start of the first group of elements
761 * 767 *
762 * RETURN: Status 768 * RETURN: Status
763 * 769 *
@@ -769,7 +775,9 @@ acpi_ns_check_package(char *pathname,
769static acpi_status 775static acpi_status
770acpi_ns_check_package_elements(char *pathname, 776acpi_ns_check_package_elements(char *pathname,
771 union acpi_operand_object **elements, 777 union acpi_operand_object **elements,
772 u8 type1, u32 count1, u8 type2, u32 count2) 778 u8 type1,
779 u32 count1,
780 u8 type2, u32 count2, u32 start_index)
773{ 781{
774 union acpi_operand_object **this_element = elements; 782 union acpi_operand_object **this_element = elements;
775 acpi_status status; 783 acpi_status status;
@@ -782,7 +790,7 @@ acpi_ns_check_package_elements(char *pathname,
782 */ 790 */
783 for (i = 0; i < count1; i++) { 791 for (i = 0; i < count1; i++) {
784 status = acpi_ns_check_object_type(pathname, this_element, 792 status = acpi_ns_check_object_type(pathname, this_element,
785 type1, i); 793 type1, i + start_index);
786 if (ACPI_FAILURE(status)) { 794 if (ACPI_FAILURE(status)) {
787 return (status); 795 return (status);
788 } 796 }
@@ -791,7 +799,8 @@ acpi_ns_check_package_elements(char *pathname,
791 799
792 for (i = 0; i < count2; i++) { 800 for (i = 0; i < count2; i++) {
793 status = acpi_ns_check_object_type(pathname, this_element, 801 status = acpi_ns_check_object_type(pathname, this_element,
794 type2, (i + count1)); 802 type2,
803 (i + count1 + start_index));
795 if (ACPI_FAILURE(status)) { 804 if (ACPI_FAILURE(status)) {
796 return (status); 805 return (status);
797 } 806 }
@@ -858,7 +867,7 @@ acpi_ns_check_object_type(char *pathname,
858 * from all of the predefined names (including elements of returned 867 * from all of the predefined names (including elements of returned
859 * packages) 868 * packages)
860 */ 869 */
861 switch (ACPI_GET_OBJECT_TYPE(return_object)) { 870 switch (return_object->common.type) {
862 case ACPI_TYPE_INTEGER: 871 case ACPI_TYPE_INTEGER:
863 return_btype = ACPI_RTYPE_INTEGER; 872 return_btype = ACPI_RTYPE_INTEGER;
864 break; 873 break;
@@ -901,7 +910,7 @@ acpi_ns_check_object_type(char *pathname,
901 910
902 /* For reference objects, check that the reference type is correct */ 911 /* For reference objects, check that the reference type is correct */
903 912
904 if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_LOCAL_REFERENCE) { 913 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
905 status = acpi_ns_check_reference(pathname, return_object); 914 status = acpi_ns_check_reference(pathname, return_object);
906 } 915 }
907 916
@@ -974,7 +983,8 @@ acpi_ns_check_reference(char *pathname,
974 } 983 }
975 984
976 ACPI_WARNING((AE_INFO, 985 ACPI_WARNING((AE_INFO,
977 "%s: Return type mismatch - unexpected reference object type [%s] %2.2X", 986 "%s: Return type mismatch - "
987 "unexpected reference object type [%s] %2.2X",
978 pathname, acpi_ut_get_reference_name(return_object), 988 pathname, acpi_ut_get_reference_name(return_object),
979 return_object->reference.class)); 989 return_object->reference.class));
980 990
@@ -1006,7 +1016,7 @@ acpi_ns_repair_object(u32 expected_btypes,
1006 union acpi_operand_object *new_object; 1016 union acpi_operand_object *new_object;
1007 acpi_size length; 1017 acpi_size length;
1008 1018
1009 switch (ACPI_GET_OBJECT_TYPE(return_object)) { 1019 switch (return_object->common.type) {
1010 case ACPI_TYPE_BUFFER: 1020 case ACPI_TYPE_BUFFER:
1011 1021
1012 if (!(expected_btypes & ACPI_RTYPE_STRING)) { 1022 if (!(expected_btypes & ACPI_RTYPE_STRING)) {
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index 6fea13f3f52d..f9b4f51bf8f2 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -167,7 +167,8 @@ acpi_ns_search_one_scope(u32 target_name,
167 /* Searched entire namespace level, not found */ 167 /* Searched entire namespace level, not found */
168 168
169 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 169 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
170 "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", 170 "Name [%4.4s] (%s) not found in search in scope [%4.4s] "
171 "%p first child %p\n",
171 ACPI_CAST_PTR(char, &target_name), 172 ACPI_CAST_PTR(char, &target_name),
172 acpi_ut_get_type_name(type), 173 acpi_ut_get_type_name(type),
173 acpi_ut_get_node_name(parent_node), parent_node, 174 acpi_ut_get_node_name(parent_node), parent_node,
@@ -239,9 +240,8 @@ acpi_ns_search_parent_tree(u32 target_name,
239 acpi_ut_get_node_name(parent_node), 240 acpi_ut_get_node_name(parent_node),
240 ACPI_CAST_PTR(char, &target_name))); 241 ACPI_CAST_PTR(char, &target_name)));
241 242
242 /* 243 /* Search parents until target is found or we have backed up to the root */
243 * Search parents until target is found or we have backed up to the root 244
244 */
245 while (parent_node) { 245 while (parent_node) {
246 /* 246 /*
247 * Search parent scope. Use TYPE_ANY because we don't care about the 247 * Search parent scope. Use TYPE_ANY because we don't care about the
@@ -395,9 +395,9 @@ acpi_ns_search_and_enter(u32 target_name,
395 return_ACPI_STATUS(AE_NO_MEMORY); 395 return_ACPI_STATUS(AE_NO_MEMORY);
396 } 396 }
397#ifdef ACPI_ASL_COMPILER 397#ifdef ACPI_ASL_COMPILER
398 /* 398
399 * Node is an object defined by an External() statement 399 /* Node is an object defined by an External() statement */
400 */ 400
401 if (flags & ACPI_NS_EXTERNAL) { 401 if (flags & ACPI_NS_EXTERNAL) {
402 new_node->flags |= ANOBJ_IS_EXTERNAL; 402 new_node->flags |= ANOBJ_IS_EXTERNAL;
403 } 403 }
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index 3e1149bf4aa5..78277ed08339 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -325,9 +325,8 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
325 next_external_char++; 325 next_external_char++;
326 } 326 }
327 } else { 327 } else {
328 /* 328 /* Handle Carat prefixes */
329 * Handle Carat prefixes 329
330 */
331 while (*next_external_char == '^') { 330 while (*next_external_char == '^') {
332 info->num_carats++; 331 info->num_carats++;
333 next_external_char++; 332 next_external_char++;
@@ -552,9 +551,8 @@ acpi_ns_externalize_name(u32 internal_name_length,
552 return_ACPI_STATUS(AE_BAD_PARAMETER); 551 return_ACPI_STATUS(AE_BAD_PARAMETER);
553 } 552 }
554 553
555 /* 554 /* Check for a prefix (one '\' | one or more '^') */
556 * Check for a prefix (one '\' | one or more '^'). 555
557 */
558 switch (internal_name[0]) { 556 switch (internal_name[0]) {
559 case '\\': 557 case '\\':
560 prefix_length = 1; 558 prefix_length = 1;
@@ -580,7 +578,7 @@ acpi_ns_externalize_name(u32 internal_name_length,
580 } 578 }
581 579
582 /* 580 /*
583 * Check for object names. Note that there could be 0-255 of these 581 * Check for object names. Note that there could be 0-255 of these
584 * 4-byte elements. 582 * 4-byte elements.
585 */ 583 */
586 if (prefix_length < internal_name_length) { 584 if (prefix_length < internal_name_length) {
@@ -637,9 +635,8 @@ acpi_ns_externalize_name(u32 internal_name_length,
637 return_ACPI_STATUS(AE_BAD_PATHNAME); 635 return_ACPI_STATUS(AE_BAD_PATHNAME);
638 } 636 }
639 637
640 /* 638 /* Build the converted_name */
641 * Build converted_name 639
642 */
643 *converted_name = ACPI_ALLOCATE_ZEROED(required_length); 640 *converted_name = ACPI_ALLOCATE_ZEROED(required_length);
644 if (!(*converted_name)) { 641 if (!(*converted_name)) {
645 return_ACPI_STATUS(AE_NO_MEMORY); 642 return_ACPI_STATUS(AE_NO_MEMORY);
@@ -685,6 +682,9 @@ acpi_ns_externalize_name(u32 internal_name_length,
685 * and keep all pointers within this subsystem - however this introduces 682 * and keep all pointers within this subsystem - however this introduces
686 * more (and perhaps unnecessary) overhead. 683 * more (and perhaps unnecessary) overhead.
687 * 684 *
685 * The current implemenation is basically a placeholder until such time comes
686 * that it is needed.
687 *
688 ******************************************************************************/ 688 ******************************************************************************/
689 689
690struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle) 690struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
@@ -692,9 +692,8 @@ struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
692 692
693 ACPI_FUNCTION_ENTRY(); 693 ACPI_FUNCTION_ENTRY();
694 694
695 /* 695 /* Parameter validation */
696 * Simple implementation 696
697 */
698 if ((!handle) || (handle == ACPI_ROOT_OBJECT)) { 697 if ((!handle) || (handle == ACPI_ROOT_OBJECT)) {
699 return (acpi_gbl_root_node); 698 return (acpi_gbl_root_node);
700 } 699 }
@@ -872,7 +871,7 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
872 (flags | ACPI_NS_DONT_OPEN_SCOPE), NULL, 871 (flags | ACPI_NS_DONT_OPEN_SCOPE), NULL,
873 return_node); 872 return_node);
874 if (ACPI_FAILURE(status)) { 873 if (ACPI_FAILURE(status)) {
875 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s, %s\n", 874 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s, %s\n",
876 pathname, acpi_format_exception(status))); 875 pathname, acpi_format_exception(status)));
877 } 876 }
878 877
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 200895fa2728..83e3aa6d4b9b 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -135,8 +135,8 @@ struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, struct
135 * starting (and ending) at the node specified by start_handle. 135 * starting (and ending) at the node specified by start_handle.
136 * The user_function is called whenever a node that matches 136 * The user_function is called whenever a node that matches
137 * the type parameter is found. If the user function returns 137 * the type parameter is found. If the user function returns
138 * a non-zero value, the search is terminated immediately and this 138 * a non-zero value, the search is terminated immediately and
139 * value is returned to the caller. 139 * this value is returned to the caller.
140 * 140 *
141 * The point of this procedure is to provide a generic namespace 141 * The point of this procedure is to provide a generic namespace
142 * walk routine that can be called from multiple places to 142 * walk routine that can be called from multiple places to
@@ -200,10 +200,10 @@ acpi_ns_walk_namespace(acpi_object_type type,
200 /* 200 /*
201 * Ignore all temporary namespace nodes (created during control 201 * Ignore all temporary namespace nodes (created during control
202 * method execution) unless told otherwise. These temporary nodes 202 * method execution) unless told otherwise. These temporary nodes
203 * can cause a race condition because they can be deleted during the 203 * can cause a race condition because they can be deleted during
204 * execution of the user function (if the namespace is unlocked before 204 * the execution of the user function (if the namespace is
205 * invocation of the user function.) Only the debugger namespace dump 205 * unlocked before invocation of the user function.) Only the
206 * will examine the temporary nodes. 206 * debugger namespace dump will examine the temporary nodes.
207 */ 207 */
208 if ((child_node->flags & ANOBJ_TEMPORARY) && 208 if ((child_node->flags & ANOBJ_TEMPORARY) &&
209 !(flags & ACPI_NS_WALK_TEMP_NODES)) { 209 !(flags & ACPI_NS_WALK_TEMP_NODES)) {
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index 22a7171ac1ed..045054037c2d 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -387,8 +387,7 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info)
387 387
388 /* We are interested in reference objects only */ 388 /* We are interested in reference objects only */
389 389
390 if (ACPI_GET_OBJECT_TYPE(info->return_object) != 390 if ((info->return_object)->common.type != ACPI_TYPE_LOCAL_REFERENCE) {
391 ACPI_TYPE_LOCAL_REFERENCE) {
392 return; 391 return;
393 } 392 }
394 393
@@ -476,21 +475,40 @@ acpi_walk_namespace(acpi_object_type type,
476 } 475 }
477 476
478 /* 477 /*
479 * Lock the namespace around the walk. 478 * Need to acquire the namespace reader lock to prevent interference
480 * The namespace will be unlocked/locked around each call 479 * with any concurrent table unloads (which causes the deletion of
481 * to the user function - since this function 480 * namespace objects). We cannot allow the deletion of a namespace node
482 * must be allowed to make Acpi calls itself. 481 * while the user function is using it. The exception to this are the
482 * nodes created and deleted during control method execution -- these
483 * nodes are marked as temporary nodes and are ignored by the namespace
484 * walk. Thus, control methods can be executed while holding the
485 * namespace deletion lock (and the user function can execute control
486 * methods.)
487 */
488 status = acpi_ut_acquire_read_lock(&acpi_gbl_namespace_rw_lock);
489 if (ACPI_FAILURE(status)) {
490 return status;
491 }
492
493 /*
494 * Lock the namespace around the walk. The namespace will be
495 * unlocked/locked around each call to the user function - since the user
496 * function must be allowed to make ACPICA calls itself (for example, it
497 * will typically execute control methods during device enumeration.)
483 */ 498 */
484 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 499 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
485 if (ACPI_FAILURE(status)) { 500 if (ACPI_FAILURE(status)) {
486 return_ACPI_STATUS(status); 501 goto unlock_and_exit;
487 } 502 }
488 503
489 status = acpi_ns_walk_namespace(type, start_object, max_depth, 504 status = acpi_ns_walk_namespace(type, start_object, max_depth,
490 ACPI_NS_WALK_UNLOCK, 505 ACPI_NS_WALK_UNLOCK, user_function,
491 user_function, context, return_value); 506 context, return_value);
492 507
493 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 508 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
509
510 unlock_and_exit:
511 (void)acpi_ut_release_read_lock(&acpi_gbl_namespace_rw_lock);
494 return_ACPI_STATUS(status); 512 return_ACPI_STATUS(status);
495} 513}
496 514
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 52865ee6bc77..b6667ff059e5 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -557,9 +557,9 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
557 table_index++) { 557 table_index++) {
558 if (*sub_object_list && /* Null object allowed */ 558 if (*sub_object_list && /* Null object allowed */
559 ((ACPI_TYPE_STRING == 559 ((ACPI_TYPE_STRING ==
560 ACPI_GET_OBJECT_TYPE(*sub_object_list)) || 560 (*sub_object_list)->common.type) ||
561 ((ACPI_TYPE_LOCAL_REFERENCE == 561 ((ACPI_TYPE_LOCAL_REFERENCE ==
562 ACPI_GET_OBJECT_TYPE(*sub_object_list)) && 562 (*sub_object_list)->common.type) &&
563 ((*sub_object_list)->reference.class == 563 ((*sub_object_list)->reference.class ==
564 ACPI_REFCLASS_NAME)))) { 564 ACPI_REFCLASS_NAME)))) {
565 name_found = TRUE; 565 name_found = TRUE;
@@ -575,8 +575,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
575 /* Was a String type found? */ 575 /* Was a String type found? */
576 576
577 if (name_found) { 577 if (name_found) {
578 if (ACPI_GET_OBJECT_TYPE(*sub_object_list) == 578 if ((*sub_object_list)->common.type == ACPI_TYPE_STRING) {
579 ACPI_TYPE_STRING) {
580 /* 579 /*
581 * The length String.Length field does not include the 580 * The length String.Length field does not include the
582 * terminating NULL, add 1 581 * terminating NULL, add 1
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index 61566b1a0616..663f692fffcf 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -212,7 +212,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
212 212
213 /* Each element of the top-level package must also be a package */ 213 /* Each element of the top-level package must also be a package */
214 214
215 if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) { 215 if ((*top_object_list)->common.type != ACPI_TYPE_PACKAGE) {
216 ACPI_ERROR((AE_INFO, 216 ACPI_ERROR((AE_INFO,
217 "(PRT[%X]) Need sub-package, found %s", 217 "(PRT[%X]) Need sub-package, found %s",
218 index, 218 index,
@@ -240,7 +240,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
240 /* 1) First subobject: Dereference the PRT.Address */ 240 /* 1) First subobject: Dereference the PRT.Address */
241 241
242 obj_desc = sub_object_list[0]; 242 obj_desc = sub_object_list[0];
243 if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER) { 243 if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
244 ACPI_ERROR((AE_INFO, 244 ACPI_ERROR((AE_INFO,
245 "(PRT[%X].Address) Need Integer, found %s", 245 "(PRT[%X].Address) Need Integer, found %s",
246 index, 246 index,
@@ -253,7 +253,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
253 /* 2) Second subobject: Dereference the PRT.Pin */ 253 /* 2) Second subobject: Dereference the PRT.Pin */
254 254
255 obj_desc = sub_object_list[1]; 255 obj_desc = sub_object_list[1];
256 if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER) { 256 if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
257 ACPI_ERROR((AE_INFO, 257 ACPI_ERROR((AE_INFO,
258 "(PRT[%X].Pin) Need Integer, found %s", 258 "(PRT[%X].Pin) Need Integer, found %s",
259 index, 259 index,
@@ -265,7 +265,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
265 * If BIOS erroneously reversed the _PRT source_name and source_index, 265 * If BIOS erroneously reversed the _PRT source_name and source_index,
266 * then reverse them back. 266 * then reverse them back.
267 */ 267 */
268 if (ACPI_GET_OBJECT_TYPE(sub_object_list[3]) != 268 if ((sub_object_list[3])->common.type !=
269 ACPI_TYPE_INTEGER) { 269 ACPI_TYPE_INTEGER) {
270 if (acpi_gbl_enable_interpreter_slack) { 270 if (acpi_gbl_enable_interpreter_slack) {
271 source_name_index = 3; 271 source_name_index = 3;
@@ -291,8 +291,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
291 * other ACPI implementations. 291 * other ACPI implementations.
292 */ 292 */
293 obj_desc = sub_object_list[3]; 293 obj_desc = sub_object_list[3];
294 if (!obj_desc 294 if (!obj_desc || (obj_desc->common.type != ACPI_TYPE_INTEGER)) {
295 || (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) {
296 sub_object_list[3] = sub_object_list[2]; 295 sub_object_list[3] = sub_object_list[2];
297 sub_object_list[2] = obj_desc; 296 sub_object_list[2] = obj_desc;
298 297
@@ -307,7 +306,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
307 */ 306 */
308 obj_desc = sub_object_list[source_name_index]; 307 obj_desc = sub_object_list[source_name_index];
309 if (obj_desc) { 308 if (obj_desc) {
310 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 309 switch (obj_desc->common.type) {
311 case ACPI_TYPE_LOCAL_REFERENCE: 310 case ACPI_TYPE_LOCAL_REFERENCE:
312 311
313 if (obj_desc->reference.class != 312 if (obj_desc->reference.class !=
@@ -380,7 +379,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
380 /* 4) Fourth subobject: Dereference the PRT.source_index */ 379 /* 4) Fourth subobject: Dereference the PRT.source_index */
381 380
382 obj_desc = sub_object_list[source_index_index]; 381 obj_desc = sub_object_list[source_index_index];
383 if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER) { 382 if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
384 ACPI_ERROR((AE_INFO, 383 ACPI_ERROR((AE_INFO,
385 "(PRT[%X].SourceIndex) Need Integer, found %s", 384 "(PRT[%X].SourceIndex) Need Integer, found %s",
386 index, 385 index,
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 3636e4f8fb73..71e655d14cb0 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -57,6 +57,8 @@ static void acpi_tb_convert_fadt(void);
57 57
58static void acpi_tb_validate_fadt(void); 58static void acpi_tb_validate_fadt(void);
59 59
60static void acpi_tb_setup_fadt_registers(void);
61
60/* Table for conversion of FADT to common internal format and FADT validation */ 62/* Table for conversion of FADT to common internal format and FADT validation */
61 63
62typedef struct acpi_fadt_info { 64typedef struct acpi_fadt_info {
@@ -130,7 +132,38 @@ static struct acpi_fadt_info fadt_info_table[] = {
130 ACPI_FADT_SEPARATE_LENGTH} 132 ACPI_FADT_SEPARATE_LENGTH}
131}; 133};
132 134
133#define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info)) 135#define ACPI_FADT_INFO_ENTRIES \
136 (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info))
137
138/* Table used to split Event Blocks into separate status/enable registers */
139
140typedef struct acpi_fadt_pm_info {
141 struct acpi_generic_address *target;
142 u8 source;
143 u8 register_num;
144
145} acpi_fadt_pm_info;
146
147static struct acpi_fadt_pm_info fadt_pm_info_table[] = {
148 {&acpi_gbl_xpm1a_status,
149 ACPI_FADT_OFFSET(xpm1a_event_block),
150 0},
151
152 {&acpi_gbl_xpm1a_enable,
153 ACPI_FADT_OFFSET(xpm1a_event_block),
154 1},
155
156 {&acpi_gbl_xpm1b_status,
157 ACPI_FADT_OFFSET(xpm1b_event_block),
158 0},
159
160 {&acpi_gbl_xpm1b_enable,
161 ACPI_FADT_OFFSET(xpm1b_event_block),
162 1}
163};
164
165#define ACPI_FADT_PM_INFO_ENTRIES \
166 (sizeof (fadt_pm_info_table) / sizeof (struct acpi_fadt_pm_info))
134 167
135/******************************************************************************* 168/*******************************************************************************
136 * 169 *
@@ -172,7 +205,6 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
172 * FUNCTION: acpi_tb_parse_fadt 205 * FUNCTION: acpi_tb_parse_fadt
173 * 206 *
174 * PARAMETERS: table_index - Index for the FADT 207 * PARAMETERS: table_index - Index for the FADT
175 * Flags - Flags
176 * 208 *
177 * RETURN: None 209 * RETURN: None
178 * 210 *
@@ -181,7 +213,7 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
181 * 213 *
182 ******************************************************************************/ 214 ******************************************************************************/
183 215
184void acpi_tb_parse_fadt(u32 table_index, u8 flags) 216void acpi_tb_parse_fadt(u32 table_index)
185{ 217{
186 u32 length; 218 u32 length;
187 struct acpi_table_header *table; 219 struct acpi_table_header *table;
@@ -208,7 +240,7 @@ void acpi_tb_parse_fadt(u32 table_index, u8 flags)
208 */ 240 */
209 (void)acpi_tb_verify_checksum(table, length); 241 (void)acpi_tb_verify_checksum(table, length);
210 242
211 /* Obtain a local copy of the FADT in common ACPI 2.0+ format */ 243 /* Create a local copy of the FADT in common ACPI 2.0+ format */
212 244
213 acpi_tb_create_local_fadt(table, length); 245 acpi_tb_create_local_fadt(table, length);
214 246
@@ -219,10 +251,10 @@ void acpi_tb_parse_fadt(u32 table_index, u8 flags)
219 /* Obtain the DSDT and FACS tables via their addresses within the FADT */ 251 /* Obtain the DSDT and FACS tables via their addresses within the FADT */
220 252
221 acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt, 253 acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt,
222 flags, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); 254 ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
223 255
224 acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs, 256 acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs,
225 flags, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); 257 ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
226} 258}
227 259
228/******************************************************************************* 260/*******************************************************************************
@@ -266,11 +298,17 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
266 ACPI_MEMCPY(&acpi_gbl_FADT, table, 298 ACPI_MEMCPY(&acpi_gbl_FADT, table,
267 ACPI_MIN(length, sizeof(struct acpi_table_fadt))); 299 ACPI_MIN(length, sizeof(struct acpi_table_fadt)));
268 300
269 /* 301 /* Convert the local copy of the FADT to the common internal format */
270 * 1) Convert the local copy of the FADT to the common internal format 302
271 * 2) Validate some of the important values within the FADT
272 */
273 acpi_tb_convert_fadt(); 303 acpi_tb_convert_fadt();
304
305 /* Validate FADT values now, before we make any changes */
306
307 acpi_tb_validate_fadt();
308
309 /* Initialize the global ACPI register structures */
310
311 acpi_tb_setup_fadt_registers();
274} 312}
275 313
276/******************************************************************************* 314/*******************************************************************************
@@ -282,31 +320,35 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
282 * RETURN: None 320 * RETURN: None
283 * 321 *
284 * DESCRIPTION: Converts all versions of the FADT to a common internal format. 322 * DESCRIPTION: Converts all versions of the FADT to a common internal format.
285 * Expand all 32-bit addresses to 64-bit. 323 * Expand 32-bit addresses to 64-bit as necessary.
286 * 324 *
287 * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), 325 * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt),
288 * and must contain a copy of the actual FADT. 326 * and must contain a copy of the actual FADT.
289 * 327 *
290 * ACPICA will use the "X" fields of the FADT for all addresses. 328 * Notes on 64-bit register addresses:
329 *
330 * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
331 * fields of the FADT for all ACPI register addresses.
291 * 332 *
292 * "X" fields are optional extensions to the original V1.0 fields. Even if 333 * The 64-bit "X" fields are optional extensions to the original 32-bit FADT
293 * they are present in the structure, they can be optionally not used by 334 * V1.0 fields. Even if they are present in the FADT, they are optional and
294 * setting them to zero. Therefore, we must selectively expand V1.0 fields 335 * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
295 * if the corresponding X field is zero. 336 * 32-bit V1.0 fields if the corresponding X field is zero.
296 * 337 *
297 * For ACPI 1.0 FADTs, all address fields are expanded to the corresponding 338 * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the
298 * "X" fields. 339 * corresponding "X" fields in the internal FADT.
299 * 340 *
300 * For ACPI 2.0 FADTs, any "X" fields that are NULL are filled in by 341 * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
301 * expanding the corresponding ACPI 1.0 field. 342 * to the corresponding 64-bit X fields. For compatibility with other ACPI
343 * implementations, we ignore the 64-bit field if the 32-bit field is valid,
344 * regardless of whether the host OS is 32-bit or 64-bit.
302 * 345 *
303 ******************************************************************************/ 346 ******************************************************************************/
304 347
305static void acpi_tb_convert_fadt(void) 348static void acpi_tb_convert_fadt(void)
306{ 349{
307 u8 pm1_register_bit_width; 350 struct acpi_generic_address *address64;
308 u8 pm1_register_byte_width; 351 u32 address32;
309 struct acpi_generic_address *target64;
310 u32 i; 352 u32 i;
311 353
312 /* Update the local FADT table header length */ 354 /* Update the local FADT table header length */
@@ -355,140 +397,56 @@ static void acpi_tb_convert_fadt(void)
355 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" 397 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
356 * generic address structures as necessary. Later code will always use 398 * generic address structures as necessary. Later code will always use
357 * the 64-bit address structures. 399 * the 64-bit address structures.
400 *
401 * March 2009:
402 * We now always use the 32-bit address if it is valid (non-null). This
403 * is not in accordance with the ACPI specification which states that
404 * the 64-bit address supersedes the 32-bit version, but we do this for
405 * compatibility with other ACPI implementations. Most notably, in the
406 * case where both the 32 and 64 versions are non-null, we use the 32-bit
407 * version. This is the only address that is guaranteed to have been
408 * tested by the BIOS manufacturer.
358 */ 409 */
359 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 410 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
360 target64 = 411 address32 = *ACPI_ADD_PTR(u32,
361 ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, 412 &acpi_gbl_FADT,
362 fadt_info_table[i].address64); 413 fadt_info_table[i].address32);
363 414
364 /* Expand only if the 64-bit X target is null */ 415 address64 = ACPI_ADD_PTR(struct acpi_generic_address,
416 &acpi_gbl_FADT,
417 fadt_info_table[i].address64);
365 418
366 if (!target64->address) { 419 /*
420 * If both 32- and 64-bit addresses are valid (non-zero),
421 * they must match.
422 */
423 if (address64->address && address32 &&
424 (address64->address != (u64) address32)) {
425 ACPI_ERROR((AE_INFO,
426 "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 32",
427 fadt_info_table[i].name, address32,
428 ACPI_FORMAT_UINT64(address64->address)));
429 }
367 430
368 /* The space_id is always I/O for the 32-bit legacy address fields */ 431 /* Always use 32-bit address if it is valid (non-null) */
369 432
370 acpi_tb_init_generic_address(target64, 433 if (address32) {
434 /*
435 * Copy the 32-bit address to the 64-bit GAS structure. The
436 * Space ID is always I/O for 32-bit legacy address fields
437 */
438 acpi_tb_init_generic_address(address64,
371 ACPI_ADR_SPACE_SYSTEM_IO, 439 ACPI_ADR_SPACE_SYSTEM_IO,
372 *ACPI_ADD_PTR(u8, 440 *ACPI_ADD_PTR(u8,
373 &acpi_gbl_FADT, 441 &acpi_gbl_FADT,
374 fadt_info_table 442 fadt_info_table
375 [i].length), 443 [i].length),
376 (u64) * ACPI_ADD_PTR(u32, 444 address32);
377 &acpi_gbl_FADT,
378 fadt_info_table
379 [i].
380 address32));
381 }
382 }
383
384 /* Validate FADT values now, before we make any changes */
385
386 acpi_tb_validate_fadt();
387
388 /*
389 * Optionally check all register lengths against the default values and
390 * update them if they are incorrect.
391 */
392 if (acpi_gbl_use_default_register_widths) {
393 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
394 target64 =
395 ACPI_ADD_PTR(struct acpi_generic_address,
396 &acpi_gbl_FADT,
397 fadt_info_table[i].address64);
398
399 /*
400 * If a valid register (Address != 0) and the (default_length > 0)
401 * (Not a GPE register), then check the width against the default.
402 */
403 if ((target64->address) &&
404 (fadt_info_table[i].default_length > 0) &&
405 (fadt_info_table[i].default_length !=
406 target64->bit_width)) {
407 ACPI_WARNING((AE_INFO,
408 "Invalid length for %s: %d, using default %d",
409 fadt_info_table[i].name,
410 target64->bit_width,
411 fadt_info_table[i].
412 default_length));
413
414 /* Incorrect size, set width to the default */
415
416 target64->bit_width =
417 fadt_info_table[i].default_length;
418 }
419 } 445 }
420 } 446 }
421
422 /*
423 * Get the length of the individual PM1 registers (enable and status).
424 * Each register is defined to be (event block length / 2).
425 */
426 pm1_register_bit_width =
427 (u8)ACPI_DIV_2(acpi_gbl_FADT.xpm1a_event_block.bit_width);
428 pm1_register_byte_width = (u8)ACPI_DIV_8(pm1_register_bit_width);
429
430 /*
431 * Adjust the lengths of the PM1 Event Blocks so that they can be used to
432 * access the PM1 status register(s). Use (width / 2)
433 */
434 acpi_gbl_FADT.xpm1a_event_block.bit_width = pm1_register_bit_width;
435 acpi_gbl_FADT.xpm1b_event_block.bit_width = pm1_register_bit_width;
436
437 /*
438 * Calculate separate GAS structs for the PM1 Enable registers.
439 * These addresses do not appear (directly) in the FADT, so it is
440 * useful to calculate them once, here.
441 *
442 * The PM event blocks are split into two register blocks, first is the
443 * PM Status Register block, followed immediately by the PM Enable
444 * Register block. Each is of length (xpm1x_event_block.bit_width/2).
445 *
446 * On various systems the v2 fields (and particularly the bit widths)
447 * cannot be relied upon, though. Hence resort to using the v1 length
448 * here (and warn about the inconsistency).
449 */
450 if (acpi_gbl_FADT.xpm1a_event_block.bit_width
451 != acpi_gbl_FADT.pm1_event_length * 8)
452 printk(KERN_WARNING "FADT: "
453 "X_PM1a_EVT_BLK.bit_width (%u) does not match"
454 " PM1_EVT_LEN (%u)\n",
455 acpi_gbl_FADT.xpm1a_event_block.bit_width,
456 acpi_gbl_FADT.pm1_event_length);
457
458 /* The PM1A register block is required */
459
460 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
461 acpi_gbl_FADT.xpm1a_event_block.space_id,
462 pm1_register_byte_width,
463 (acpi_gbl_FADT.xpm1a_event_block.address +
464 pm1_register_byte_width));
465 /* Don't forget to copy space_id of the GAS */
466 acpi_gbl_xpm1a_enable.space_id =
467 acpi_gbl_FADT.xpm1a_event_block.space_id;
468
469 /* The PM1B register block is optional, ignore if not present */
470
471 if (acpi_gbl_FADT.xpm1b_event_block.address) {
472 if (acpi_gbl_FADT.xpm1b_event_block.bit_width
473 != acpi_gbl_FADT.pm1_event_length * 8)
474 printk(KERN_WARNING "FADT: "
475 "X_PM1b_EVT_BLK.bit_width (%u) does not match"
476 " PM1_EVT_LEN (%u)\n",
477 acpi_gbl_FADT.xpm1b_event_block.bit_width,
478 acpi_gbl_FADT.pm1_event_length);
479 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
480 acpi_gbl_FADT.xpm1b_event_block.space_id,
481 pm1_register_byte_width,
482 (acpi_gbl_FADT.xpm1b_event_block.
483 address + pm1_register_byte_width));
484 /* Don't forget to copy space_id of the GAS */
485 acpi_gbl_xpm1b_enable.space_id =
486 acpi_gbl_FADT.xpm1b_event_block.space_id;
487
488 }
489} 447}
490 448
491/****************************************************************************** 449/*******************************************************************************
492 * 450 *
493 * FUNCTION: acpi_tb_validate_fadt 451 * FUNCTION: acpi_tb_validate_fadt
494 * 452 *
@@ -525,18 +483,22 @@ static void acpi_tb_validate_fadt(void)
525 (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) { 483 (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
526 ACPI_WARNING((AE_INFO, 484 ACPI_WARNING((AE_INFO,
527 "32/64X FACS address mismatch in FADT - " 485 "32/64X FACS address mismatch in FADT - "
528 "two FACS tables! %8.8X/%8.8X%8.8X", 486 "%8.8X/%8.8X%8.8X, using 32",
529 acpi_gbl_FADT.facs, 487 acpi_gbl_FADT.facs,
530 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs))); 488 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs)));
489
490 acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
531 } 491 }
532 492
533 if (acpi_gbl_FADT.dsdt && 493 if (acpi_gbl_FADT.dsdt &&
534 (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) { 494 (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
535 ACPI_WARNING((AE_INFO, 495 ACPI_WARNING((AE_INFO,
536 "32/64X DSDT address mismatch in FADT - " 496 "32/64X DSDT address mismatch in FADT - "
537 "two DSDT tables! %8.8X/%8.8X%8.8X", 497 "%8.8X/%8.8X%8.8X, using 32",
538 acpi_gbl_FADT.dsdt, 498 acpi_gbl_FADT.dsdt,
539 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt))); 499 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt)));
500
501 acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
540 } 502 }
541 503
542 /* Examine all of the 64-bit extended address fields (X fields) */ 504 /* Examine all of the 64-bit extended address fields (X fields) */
@@ -561,7 +523,8 @@ static void acpi_tb_validate_fadt(void)
561 * For each extended field, check for length mismatch between the 523 * For each extended field, check for length mismatch between the
562 * legacy length field and the corresponding 64-bit X length field. 524 * legacy length field and the corresponding 64-bit X length field.
563 */ 525 */
564 if (address64 && (address64->bit_width != ACPI_MUL_8(length))) { 526 if (address64->address &&
527 (address64->bit_width != ACPI_MUL_8(length))) {
565 ACPI_WARNING((AE_INFO, 528 ACPI_WARNING((AE_INFO,
566 "32/64X length mismatch in %s: %d/%d", 529 "32/64X length mismatch in %s: %d/%d",
567 name, ACPI_MUL_8(length), 530 name, ACPI_MUL_8(length),
@@ -575,7 +538,8 @@ static void acpi_tb_validate_fadt(void)
575 */ 538 */
576 if (!address64->address || !length) { 539 if (!address64->address || !length) {
577 ACPI_ERROR((AE_INFO, 540 ACPI_ERROR((AE_INFO,
578 "Required field %s has zero address and/or length: %8.8X%8.8X/%X", 541 "Required field %s has zero address and/or length:"
542 " %8.8X%8.8X/%X",
579 name, 543 name,
580 ACPI_FORMAT_UINT64(address64-> 544 ACPI_FORMAT_UINT64(address64->
581 address), 545 address),
@@ -584,27 +548,112 @@ static void acpi_tb_validate_fadt(void)
584 } else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) { 548 } else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) {
585 /* 549 /*
586 * Field is optional (PM2Control, GPE0, GPE1) AND has its own 550 * Field is optional (PM2Control, GPE0, GPE1) AND has its own
587 * length field. If present, both the address and length must be valid. 551 * length field. If present, both the address and length must
552 * be valid.
588 */ 553 */
589 if ((address64->address && !length) 554 if ((address64->address && !length) ||
590 || (!address64->address && length)) { 555 (!address64->address && length)) {
591 ACPI_WARNING((AE_INFO, 556 ACPI_WARNING((AE_INFO,
592 "Optional field %s has zero address or length: %8.8X%8.8X/%X", 557 "Optional field %s has zero address or length: "
558 "%8.8X%8.8X/%X",
593 name, 559 name,
594 ACPI_FORMAT_UINT64(address64-> 560 ACPI_FORMAT_UINT64(address64->
595 address), 561 address),
596 length)); 562 length));
597 } 563 }
598 } 564 }
565 }
566}
599 567
600 /* If both 32- and 64-bit addresses are valid (non-zero), they must match */ 568/*******************************************************************************
569 *
570 * FUNCTION: acpi_tb_setup_fadt_registers
571 *
572 * PARAMETERS: None, uses acpi_gbl_FADT.
573 *
574 * RETURN: None
575 *
576 * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
577 * force FADT register definitions to their default lengths.
578 *
579 ******************************************************************************/
601 580
602 if (address64->address && *address32 && 581static void acpi_tb_setup_fadt_registers(void)
603 (address64->address != (u64) * address32)) { 582{
604 ACPI_ERROR((AE_INFO, 583 struct acpi_generic_address *target64;
605 "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 64X", 584 struct acpi_generic_address *source64;
606 name, *address32, 585 u8 pm1_register_byte_width;
607 ACPI_FORMAT_UINT64(address64->address))); 586 u32 i;
587
588 /*
589 * Optionally check all register lengths against the default values and
590 * update them if they are incorrect.
591 */
592 if (acpi_gbl_use_default_register_widths) {
593 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
594 target64 =
595 ACPI_ADD_PTR(struct acpi_generic_address,
596 &acpi_gbl_FADT,
597 fadt_info_table[i].address64);
598
599 /*
600 * If a valid register (Address != 0) and the (default_length > 0)
601 * (Not a GPE register), then check the width against the default.
602 */
603 if ((target64->address) &&
604 (fadt_info_table[i].default_length > 0) &&
605 (fadt_info_table[i].default_length !=
606 target64->bit_width)) {
607 ACPI_WARNING((AE_INFO,
608 "Invalid length for %s: %d, using default %d",
609 fadt_info_table[i].name,
610 target64->bit_width,
611 fadt_info_table[i].
612 default_length));
613
614 /* Incorrect size, set width to the default */
615
616 target64->bit_width =
617 fadt_info_table[i].default_length;
618 }
619 }
620 }
621
622 /*
623 * Get the length of the individual PM1 registers (enable and status).
624 * Each register is defined to be (event block length / 2). Extra divide
625 * by 8 converts bits to bytes.
626 */
627 pm1_register_byte_width = (u8)
628 ACPI_DIV_16(acpi_gbl_FADT.xpm1a_event_block.bit_width);
629
630 /*
631 * Calculate separate GAS structs for the PM1x (A/B) Status and Enable
632 * registers. These addresses do not appear (directly) in the FADT, so it
633 * is useful to pre-calculate them from the PM1 Event Block definitions.
634 *
635 * The PM event blocks are split into two register blocks, first is the
636 * PM Status Register block, followed immediately by the PM Enable
637 * Register block. Each is of length (pm1_event_length/2)
638 *
639 * Note: The PM1A event block is required by the ACPI specification.
640 * However, the PM1B event block is optional and is rarely, if ever,
641 * used.
642 */
643
644 for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++) {
645 source64 =
646 ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT,
647 fadt_pm_info_table[i].source);
648
649 if (source64->address) {
650 acpi_tb_init_generic_address(fadt_pm_info_table[i].
651 target, source64->space_id,
652 pm1_register_byte_width,
653 source64->address +
654 (fadt_pm_info_table[i].
655 register_num *
656 pm1_register_byte_width));
608 } 657 }
609 } 658 }
610} 659}
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 37374b21969d..f865d5a096de 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -103,7 +103,9 @@ acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc)
103 * 103 *
104 * RETURN: Status 104 * RETURN: Status
105 * 105 *
106 * DESCRIPTION: This function is called to add the ACPI table 106 * DESCRIPTION: This function is called to add an ACPI table. It is used to
107 * dynamically load tables via the Load and load_table AML
108 * operators.
107 * 109 *
108 ******************************************************************************/ 110 ******************************************************************************/
109 111
@@ -112,6 +114,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
112{ 114{
113 u32 i; 115 u32 i;
114 acpi_status status = AE_OK; 116 acpi_status status = AE_OK;
117 struct acpi_table_header *override_table = NULL;
115 118
116 ACPI_FUNCTION_TRACE(tb_add_table); 119 ACPI_FUNCTION_TRACE(tb_add_table);
117 120
@@ -201,6 +204,29 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
201 } 204 }
202 } 205 }
203 206
207 /*
208 * ACPI Table Override:
209 * Allow the host to override dynamically loaded tables.
210 */
211 status = acpi_os_table_override(table_desc->pointer, &override_table);
212 if (ACPI_SUCCESS(status) && override_table) {
213 ACPI_INFO((AE_INFO,
214 "%4.4s @ 0x%p Table override, replaced with:",
215 table_desc->pointer->signature,
216 ACPI_CAST_PTR(void, table_desc->address)));
217
218 /* We can delete the table that was passed as a parameter */
219
220 acpi_tb_delete_table(table_desc);
221
222 /* Setup descriptor for the new table */
223
224 table_desc->address = ACPI_PTR_TO_PHYSADDR(override_table);
225 table_desc->pointer = override_table;
226 table_desc->length = override_table->length;
227 table_desc->flags = ACPI_TABLE_ORIGIN_OVERRIDE;
228 }
229
204 /* Add the table to the global root table list */ 230 /* Add the table to the global root table list */
205 231
206 status = acpi_tb_store_table(table_desc->address, table_desc->pointer, 232 status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
@@ -247,8 +273,9 @@ acpi_status acpi_tb_resize_root_table_list(void)
247 /* Increase the Table Array size */ 273 /* Increase the Table Array size */
248 274
249 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list. 275 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list.
250 size + ACPI_ROOT_TABLE_SIZE_INCREMENT) 276 size +
251 * sizeof(struct acpi_table_desc)); 277 ACPI_ROOT_TABLE_SIZE_INCREMENT) *
278 sizeof(struct acpi_table_desc));
252 if (!tables) { 279 if (!tables) {
253 ACPI_ERROR((AE_INFO, 280 ACPI_ERROR((AE_INFO,
254 "Could not allocate new root table array")); 281 "Could not allocate new root table array"));
@@ -407,27 +434,56 @@ void acpi_tb_terminate(void)
407 * 434 *
408 * PARAMETERS: table_index - Table index 435 * PARAMETERS: table_index - Table index
409 * 436 *
410 * RETURN: None 437 * RETURN: Status
411 * 438 *
412 * DESCRIPTION: Delete all namespace objects created when this table was loaded. 439 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
413 * 440 *
414 ******************************************************************************/ 441 ******************************************************************************/
415 442
416void acpi_tb_delete_namespace_by_owner(u32 table_index) 443acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
417{ 444{
418 acpi_owner_id owner_id; 445 acpi_owner_id owner_id;
446 acpi_status status;
447
448 ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
449
450 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
451 if (ACPI_FAILURE(status)) {
452 return_ACPI_STATUS(status);
453 }
454
455 if (table_index >= acpi_gbl_root_table_list.count) {
456
457 /* The table index does not exist */
419 458
420 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
421 if (table_index < acpi_gbl_root_table_list.count) {
422 owner_id =
423 acpi_gbl_root_table_list.tables[table_index].owner_id;
424 } else {
425 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 459 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
426 return; 460 return_ACPI_STATUS(AE_NOT_EXIST);
427 } 461 }
428 462
463 /* Get the owner ID for this table, used to delete namespace nodes */
464
465 owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
429 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 466 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
467
468 /*
469 * Need to acquire the namespace writer lock to prevent interference
470 * with any concurrent namespace walks. The interpreter must be
471 * released during the deletion since the acquisition of the deletion
472 * lock may block, and also since the execution of a namespace walk
473 * must be allowed to use the interpreter.
474 */
475 acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
476 status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
477
430 acpi_ns_delete_namespace_by_owner(owner_id); 478 acpi_ns_delete_namespace_by_owner(owner_id);
479 if (ACPI_FAILURE(status)) {
480 return_ACPI_STATUS(status);
481 }
482
483 acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
484
485 status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
486 return_ACPI_STATUS(status);
431} 487}
432 488
433/******************************************************************************* 489/*******************************************************************************
@@ -535,8 +591,8 @@ u8 acpi_tb_is_table_loaded(u32 table_index)
535 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 591 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
536 if (table_index < acpi_gbl_root_table_list.count) { 592 if (table_index < acpi_gbl_root_table_list.count) {
537 is_loaded = (u8) 593 is_loaded = (u8)
538 (acpi_gbl_root_table_list.tables[table_index]. 594 (acpi_gbl_root_table_list.tables[table_index].flags &
539 flags & ACPI_TABLE_IS_LOADED); 595 ACPI_TABLE_IS_LOADED);
540 } 596 }
541 597
542 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 598 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 22ce48985720..ef7d2c2d8f0b 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -177,19 +177,23 @@ acpi_tb_print_table_header(acpi_physical_address address,
177 struct acpi_table_header *header) 177 struct acpi_table_header *header)
178{ 178{
179 179
180 /*
181 * The reason that the Address is cast to a void pointer is so that we
182 * can use %p which will work properly on both 32-bit and 64-bit hosts.
183 */
180 if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { 184 if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
181 185
182 /* FACS only has signature and length fields of common table header */ 186 /* FACS only has signature and length fields */
183 187
184 ACPI_INFO((AE_INFO, "%4.4s %08lX, %04X", 188 ACPI_INFO((AE_INFO, "%4.4s %p %05X",
185 header->signature, (unsigned long)address, 189 header->signature, ACPI_CAST_PTR(void, address),
186 header->length)); 190 header->length));
187 } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) { 191 } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) {
188 192
189 /* RSDP has no common fields */ 193 /* RSDP has no common fields */
190 194
191 ACPI_INFO((AE_INFO, "RSDP %08lX, %04X (r%d %6.6s)", 195 ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)",
192 (unsigned long)address, 196 ACPI_CAST_PTR (void, address),
193 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> 197 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
194 revision > 198 revision >
195 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, 199 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
@@ -202,8 +206,8 @@ acpi_tb_print_table_header(acpi_physical_address address,
202 /* Standard ACPI table with full common header */ 206 /* Standard ACPI table with full common header */
203 207
204 ACPI_INFO((AE_INFO, 208 ACPI_INFO((AE_INFO,
205 "%4.4s %08lX, %04X (r%d %6.6s %8.8s %8X %4.4s %8X)", 209 "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)",
206 header->signature, (unsigned long)address, 210 header->signature, ACPI_CAST_PTR (void, address),
207 header->length, header->revision, header->oem_id, 211 header->length, header->revision, header->oem_id,
208 header->oem_table_id, header->oem_revision, 212 header->oem_table_id, header->oem_revision,
209 header->asl_compiler_id, 213 header->asl_compiler_id,
@@ -280,22 +284,28 @@ u8 acpi_tb_checksum(u8 *buffer, u32 length)
280 * FUNCTION: acpi_tb_install_table 284 * FUNCTION: acpi_tb_install_table
281 * 285 *
282 * PARAMETERS: Address - Physical address of DSDT or FACS 286 * PARAMETERS: Address - Physical address of DSDT or FACS
283 * Flags - Flags
284 * Signature - Table signature, NULL if no need to 287 * Signature - Table signature, NULL if no need to
285 * match 288 * match
286 * table_index - Index into root table array 289 * table_index - Index into root table array
287 * 290 *
288 * RETURN: None 291 * RETURN: None
289 * 292 *
290 * DESCRIPTION: Install an ACPI table into the global data structure. 293 * DESCRIPTION: Install an ACPI table into the global data structure. The
294 * table override mechanism is implemented here to allow the host
295 * OS to replace any table before it is installed in the root
296 * table array.
291 * 297 *
292 ******************************************************************************/ 298 ******************************************************************************/
293 299
294void 300void
295acpi_tb_install_table(acpi_physical_address address, 301acpi_tb_install_table(acpi_physical_address address,
296 u8 flags, char *signature, u32 table_index) 302 char *signature, u32 table_index)
297{ 303{
298 struct acpi_table_header *table; 304 u8 flags;
305 acpi_status status;
306 struct acpi_table_header *table_to_install;
307 struct acpi_table_header *mapped_table;
308 struct acpi_table_header *override_table = NULL;
299 309
300 if (!address) { 310 if (!address) {
301 ACPI_ERROR((AE_INFO, 311 ACPI_ERROR((AE_INFO,
@@ -306,41 +316,69 @@ acpi_tb_install_table(acpi_physical_address address,
306 316
307 /* Map just the table header */ 317 /* Map just the table header */
308 318
309 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); 319 mapped_table =
310 if (!table) { 320 acpi_os_map_memory(address, sizeof(struct acpi_table_header));
321 if (!mapped_table) {
311 return; 322 return;
312 } 323 }
313 324
314 /* If a particular signature is expected, signature must match */ 325 /* If a particular signature is expected (DSDT/FACS), it must match */
315 326
316 if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) { 327 if (signature && !ACPI_COMPARE_NAME(mapped_table->signature, signature)) {
317 ACPI_ERROR((AE_INFO, 328 ACPI_ERROR((AE_INFO,
318 "Invalid signature 0x%X for ACPI table [%s]", 329 "Invalid signature 0x%X for ACPI table, expected [%s]",
319 *ACPI_CAST_PTR(u32, table->signature), signature)); 330 *ACPI_CAST_PTR(u32, mapped_table->signature),
331 signature));
320 goto unmap_and_exit; 332 goto unmap_and_exit;
321 } 333 }
322 334
335 /*
336 * ACPI Table Override:
337 *
338 * Before we install the table, let the host OS override it with a new
339 * one if desired. Any table within the RSDT/XSDT can be replaced,
340 * including the DSDT which is pointed to by the FADT.
341 */
342 status = acpi_os_table_override(mapped_table, &override_table);
343 if (ACPI_SUCCESS(status) && override_table) {
344 ACPI_INFO((AE_INFO,
345 "%4.4s @ 0x%p Table override, replaced with:",
346 mapped_table->signature, ACPI_CAST_PTR(void,
347 address)));
348
349 acpi_gbl_root_table_list.tables[table_index].pointer =
350 override_table;
351 address = ACPI_PTR_TO_PHYSADDR(override_table);
352
353 table_to_install = override_table;
354 flags = ACPI_TABLE_ORIGIN_OVERRIDE;
355 } else {
356 table_to_install = mapped_table;
357 flags = ACPI_TABLE_ORIGIN_MAPPED;
358 }
359
323 /* Initialize the table entry */ 360 /* Initialize the table entry */
324 361
325 acpi_gbl_root_table_list.tables[table_index].address = address; 362 acpi_gbl_root_table_list.tables[table_index].address = address;
326 acpi_gbl_root_table_list.tables[table_index].length = table->length; 363 acpi_gbl_root_table_list.tables[table_index].length =
364 table_to_install->length;
327 acpi_gbl_root_table_list.tables[table_index].flags = flags; 365 acpi_gbl_root_table_list.tables[table_index].flags = flags;
328 366
329 ACPI_MOVE_32_TO_32(& 367 ACPI_MOVE_32_TO_32(&
330 (acpi_gbl_root_table_list.tables[table_index]. 368 (acpi_gbl_root_table_list.tables[table_index].
331 signature), table->signature); 369 signature), table_to_install->signature);
332 370
333 acpi_tb_print_table_header(address, table); 371 acpi_tb_print_table_header(address, table_to_install);
334 372
335 if (table_index == ACPI_TABLE_INDEX_DSDT) { 373 if (table_index == ACPI_TABLE_INDEX_DSDT) {
336 374
337 /* Global integer width is based upon revision of the DSDT */ 375 /* Global integer width is based upon revision of the DSDT */
338 376
339 acpi_ut_set_integer_width(table->revision); 377 acpi_ut_set_integer_width(table_to_install->revision);
340 } 378 }
341 379
342 unmap_and_exit: 380 unmap_and_exit:
343 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); 381 acpi_os_unmap_memory(mapped_table, sizeof(struct acpi_table_header));
344} 382}
345 383
346/******************************************************************************* 384/*******************************************************************************
@@ -379,7 +417,8 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
379 } else { 417 } else {
380 /* 418 /*
381 * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return 419 * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return
382 * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, return 64-bit 420 * 64-bit platform, XSDT: Move (unaligned) 64-bit to local,
421 * return 64-bit
383 */ 422 */
384 ACPI_MOVE_64_TO_64(&address64, table_entry); 423 ACPI_MOVE_64_TO_64(&address64, table_entry);
385 424
@@ -389,7 +428,8 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
389 /* Will truncate 64-bit address to 32 bits, issue warning */ 428 /* Will truncate 64-bit address to 32 bits, issue warning */
390 429
391 ACPI_WARNING((AE_INFO, 430 ACPI_WARNING((AE_INFO,
392 "64-bit Physical Address in XSDT is too large (%8.8X%8.8X), truncating", 431 "64-bit Physical Address in XSDT is too large (%8.8X%8.8X),"
432 " truncating",
393 ACPI_FORMAT_UINT64(address64))); 433 ACPI_FORMAT_UINT64(address64)));
394 } 434 }
395#endif 435#endif
@@ -402,7 +442,6 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
402 * FUNCTION: acpi_tb_parse_root_table 442 * FUNCTION: acpi_tb_parse_root_table
403 * 443 *
404 * PARAMETERS: Rsdp - Pointer to the RSDP 444 * PARAMETERS: Rsdp - Pointer to the RSDP
405 * Flags - Flags
406 * 445 *
407 * RETURN: Status 446 * RETURN: Status
408 * 447 *
@@ -416,7 +455,7 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
416 ******************************************************************************/ 455 ******************************************************************************/
417 456
418acpi_status __init 457acpi_status __init
419acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags) 458acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
420{ 459{
421 struct acpi_table_rsdp *rsdp; 460 struct acpi_table_rsdp *rsdp;
422 u32 table_entry_size; 461 u32 table_entry_size;
@@ -513,13 +552,12 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
513 552
514 /* Calculate the number of tables described in the root table */ 553 /* Calculate the number of tables described in the root table */
515 554
516 table_count = 555 table_count = (u32)((table->length - sizeof(struct acpi_table_header)) /
517 (u32) ((table->length - 556 table_entry_size);
518 sizeof(struct acpi_table_header)) / table_entry_size);
519
520 /* 557 /*
521 * First two entries in the table array are reserved for the DSDT and FACS, 558 * First two entries in the table array are reserved for the DSDT
522 * which are not actually present in the RSDT/XSDT - they come from the FADT 559 * and FACS, which are not actually present in the RSDT/XSDT - they
560 * come from the FADT
523 */ 561 */
524 table_entry = 562 table_entry =
525 ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header); 563 ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
@@ -567,14 +605,14 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
567 */ 605 */
568 for (i = 2; i < acpi_gbl_root_table_list.count; i++) { 606 for (i = 2; i < acpi_gbl_root_table_list.count; i++) {
569 acpi_tb_install_table(acpi_gbl_root_table_list.tables[i]. 607 acpi_tb_install_table(acpi_gbl_root_table_list.tables[i].
570 address, flags, NULL, i); 608 address, NULL, i);
571 609
572 /* Special case for FADT - get the DSDT and FACS */ 610 /* Special case for FADT - get the DSDT and FACS */
573 611
574 if (ACPI_COMPARE_NAME 612 if (ACPI_COMPARE_NAME
575 (&acpi_gbl_root_table_list.tables[i].signature, 613 (&acpi_gbl_root_table_list.tables[i].signature,
576 ACPI_SIG_FADT)) { 614 ACPI_SIG_FADT)) {
577 acpi_tb_parse_fadt(i, flags); 615 acpi_tb_parse_fadt(i);
578 } 616 }
579 } 617 }
580 618
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index ab0aff3c7d6a..a88f02bd6c94 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -150,8 +150,7 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array,
150 * Root Table Array. This array contains the information of the RSDT/XSDT 150 * Root Table Array. This array contains the information of the RSDT/XSDT
151 * in a common, more useable format. 151 * in a common, more useable format.
152 */ 152 */
153 status = 153 status = acpi_tb_parse_root_table(rsdp_address);
154 acpi_tb_parse_root_table(rsdp_address, ACPI_TABLE_ORIGIN_MAPPED);
155 return_ACPI_STATUS(status); 154 return_ACPI_STATUS(status);
156} 155}
157 156
@@ -247,7 +246,7 @@ acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
247 246
248ACPI_EXPORT_SYMBOL(acpi_load_table) 247ACPI_EXPORT_SYMBOL(acpi_load_table)
249 248
250/****************************************************************************** 249/*******************************************************************************
251 * 250 *
252 * FUNCTION: acpi_get_table_header 251 * FUNCTION: acpi_get_table_header
253 * 252 *
@@ -262,7 +261,7 @@ ACPI_EXPORT_SYMBOL(acpi_load_table)
262 * NOTE: Caller is responsible in unmapping the header with 261 * NOTE: Caller is responsible in unmapping the header with
263 * acpi_os_unmap_memory 262 * acpi_os_unmap_memory
264 * 263 *
265 *****************************************************************************/ 264 ******************************************************************************/
266acpi_status 265acpi_status
267acpi_get_table_header(char *signature, 266acpi_get_table_header(char *signature,
268 u32 instance, struct acpi_table_header *out_table_header) 267 u32 instance, struct acpi_table_header *out_table_header)
@@ -277,9 +276,8 @@ acpi_get_table_header(char *signature,
277 return (AE_BAD_PARAMETER); 276 return (AE_BAD_PARAMETER);
278 } 277 }
279 278
280 /* 279 /* Walk the root table list */
281 * Walk the root table list 280
282 */
283 for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) { 281 for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) {
284 if (!ACPI_COMPARE_NAME 282 if (!ACPI_COMPARE_NAME
285 (&(acpi_gbl_root_table_list.tables[i].signature), 283 (&(acpi_gbl_root_table_list.tables[i].signature),
@@ -292,8 +290,8 @@ acpi_get_table_header(char *signature,
292 } 290 }
293 291
294 if (!acpi_gbl_root_table_list.tables[i].pointer) { 292 if (!acpi_gbl_root_table_list.tables[i].pointer) {
295 if ((acpi_gbl_root_table_list.tables[i]. 293 if ((acpi_gbl_root_table_list.tables[i].flags &
296 flags & ACPI_TABLE_ORIGIN_MASK) == 294 ACPI_TABLE_ORIGIN_MASK) ==
297 ACPI_TABLE_ORIGIN_MAPPED) { 295 ACPI_TABLE_ORIGIN_MAPPED) {
298 header = 296 header =
299 acpi_os_map_memory(acpi_gbl_root_table_list. 297 acpi_os_map_memory(acpi_gbl_root_table_list.
@@ -324,7 +322,7 @@ acpi_get_table_header(char *signature,
324 322
325ACPI_EXPORT_SYMBOL(acpi_get_table_header) 323ACPI_EXPORT_SYMBOL(acpi_get_table_header)
326 324
327/****************************************************************************** 325/*******************************************************************************
328 * 326 *
329 * FUNCTION: acpi_unload_table_id 327 * FUNCTION: acpi_unload_table_id
330 * 328 *
@@ -375,7 +373,7 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
375 * 373 *
376 * DESCRIPTION: Finds and verifies an ACPI table. 374 * DESCRIPTION: Finds and verifies an ACPI table.
377 * 375 *
378 *****************************************************************************/ 376 ******************************************************************************/
379acpi_status 377acpi_status
380acpi_get_table_with_size(char *signature, 378acpi_get_table_with_size(char *signature,
381 u32 instance, struct acpi_table_header **out_table, 379 u32 instance, struct acpi_table_header **out_table,
@@ -391,9 +389,8 @@ acpi_get_table_with_size(char *signature,
391 return (AE_BAD_PARAMETER); 389 return (AE_BAD_PARAMETER);
392 } 390 }
393 391
394 /* 392 /* Walk the root table list */
395 * Walk the root table list 393
396 */
397 for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) { 394 for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) {
398 if (!ACPI_COMPARE_NAME 395 if (!ACPI_COMPARE_NAME
399 (&(acpi_gbl_root_table_list.tables[i].signature), 396 (&(acpi_gbl_root_table_list.tables[i].signature),
@@ -502,7 +499,6 @@ ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
502static acpi_status acpi_tb_load_namespace(void) 499static acpi_status acpi_tb_load_namespace(void)
503{ 500{
504 acpi_status status; 501 acpi_status status;
505 struct acpi_table_header *table;
506 u32 i; 502 u32 i;
507 503
508 ACPI_FUNCTION_TRACE(tb_load_namespace); 504 ACPI_FUNCTION_TRACE(tb_load_namespace);
@@ -526,58 +522,28 @@ static acpi_status acpi_tb_load_namespace(void)
526 goto unlock_and_exit; 522 goto unlock_and_exit;
527 } 523 }
528 524
529 /* 525 /* A valid DSDT is required */
530 * Find DSDT table
531 */
532 status =
533 acpi_os_table_override(acpi_gbl_root_table_list.
534 tables[ACPI_TABLE_INDEX_DSDT].pointer,
535 &table);
536 if (ACPI_SUCCESS(status) && table) {
537 /*
538 * DSDT table has been found
539 */
540 acpi_tb_delete_table(&acpi_gbl_root_table_list.
541 tables[ACPI_TABLE_INDEX_DSDT]);
542 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer =
543 table;
544 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].length =
545 table->length;
546 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].flags =
547 ACPI_TABLE_ORIGIN_UNKNOWN;
548
549 ACPI_INFO((AE_INFO, "Table DSDT replaced by host OS"));
550 acpi_tb_print_table_header(0, table);
551
552 if (no_auto_ssdt == 0) {
553 printk(KERN_WARNING "ACPI: DSDT override uses original SSDTs unless \"acpi_no_auto_ssdt\"\n");
554 }
555 }
556 526
557 status = 527 status =
558 acpi_tb_verify_table(&acpi_gbl_root_table_list. 528 acpi_tb_verify_table(&acpi_gbl_root_table_list.
559 tables[ACPI_TABLE_INDEX_DSDT]); 529 tables[ACPI_TABLE_INDEX_DSDT]);
560 if (ACPI_FAILURE(status)) { 530 if (ACPI_FAILURE(status)) {
561 531
562 /* A valid DSDT is required */
563
564 status = AE_NO_ACPI_TABLES; 532 status = AE_NO_ACPI_TABLES;
565 goto unlock_and_exit; 533 goto unlock_and_exit;
566 } 534 }
567 535
568 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 536 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
569 537
570 /* 538 /* Load and parse tables */
571 * Load and parse tables. 539
572 */
573 status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node); 540 status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node);
574 if (ACPI_FAILURE(status)) { 541 if (ACPI_FAILURE(status)) {
575 return_ACPI_STATUS(status); 542 return_ACPI_STATUS(status);
576 } 543 }
577 544
578 /* 545 /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
579 * Load any SSDT or PSDT tables. Note: Loop leaves tables locked 546
580 */
581 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 547 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
582 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { 548 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
583 if ((!ACPI_COMPARE_NAME 549 if ((!ACPI_COMPARE_NAME
@@ -630,9 +596,8 @@ acpi_status acpi_load_tables(void)
630 596
631 ACPI_FUNCTION_TRACE(acpi_load_tables); 597 ACPI_FUNCTION_TRACE(acpi_load_tables);
632 598
633 /* 599 /* Load the namespace from the tables */
634 * Load the namespace from the tables 600
635 */
636 status = acpi_tb_load_namespace(); 601 status = acpi_tb_load_namespace();
637 if (ACPI_FAILURE(status)) { 602 if (ACPI_FAILURE(status)) {
638 ACPI_EXCEPTION((AE_INFO, status, 603 ACPI_EXCEPTION((AE_INFO, status,
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index b7fc8dd43341..85ea834199e2 100644
--- a/drivers/acpi/acpica/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -75,8 +75,8 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp)
75 * Note: Sometimes there exists more than one RSDP in memory; the valid 75 * Note: Sometimes there exists more than one RSDP in memory; the valid
76 * RSDP has a valid checksum, all others have an invalid checksum. 76 * RSDP has a valid checksum, all others have an invalid checksum.
77 */ 77 */
78 if (ACPI_STRNCMP((char *)rsdp, ACPI_SIG_RSDP, sizeof(ACPI_SIG_RSDP) - 1) 78 if (ACPI_STRNCMP((char *)rsdp, ACPI_SIG_RSDP,
79 != 0) { 79 sizeof(ACPI_SIG_RSDP) - 1) != 0) {
80 80
81 /* Nope, BAD Signature */ 81 /* Nope, BAD Signature */
82 82
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index b0dcfd3c872a..919624f123d5 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -135,11 +135,11 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
135 * In general, the external object will be the same type as 135 * In general, the external object will be the same type as
136 * the internal object 136 * the internal object
137 */ 137 */
138 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); 138 external_object->type = internal_object->common.type;
139 139
140 /* However, only a limited number of external types are supported */ 140 /* However, only a limited number of external types are supported */
141 141
142 switch (ACPI_GET_OBJECT_TYPE(internal_object)) { 142 switch (internal_object->common.type) {
143 case ACPI_TYPE_STRING: 143 case ACPI_TYPE_STRING:
144 144
145 external_object->string.pointer = (char *)data_space; 145 external_object->string.pointer = (char *)data_space;
@@ -222,8 +222,8 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
222 */ 222 */
223 ACPI_ERROR((AE_INFO, 223 ACPI_ERROR((AE_INFO,
224 "Unsupported object type, cannot convert to external object: %s", 224 "Unsupported object type, cannot convert to external object: %s",
225 acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE 225 acpi_ut_get_type_name(internal_object->common.
226 (internal_object)))); 226 type)));
227 227
228 return_ACPI_STATUS(AE_SUPPORT); 228 return_ACPI_STATUS(AE_SUPPORT);
229 } 229 }
@@ -355,7 +355,7 @@ acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
355 info.object_space = 0; 355 info.object_space = 0;
356 info.num_packages = 1; 356 info.num_packages = 1;
357 357
358 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); 358 external_object->type = internal_object->common.type;
359 external_object->package.count = internal_object->package.count; 359 external_object->package.count = internal_object->package.count;
360 external_object->package.elements = ACPI_CAST_PTR(union acpi_object, 360 external_object->package.elements = ACPI_CAST_PTR(union acpi_object,
361 info.free_space); 361 info.free_space);
@@ -399,7 +399,7 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
399 399
400 ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject); 400 ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject);
401 401
402 if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) { 402 if (internal_object->common.type == ACPI_TYPE_PACKAGE) {
403 /* 403 /*
404 * Package object: Copy all subobjects (including 404 * Package object: Copy all subobjects (including
405 * nested packages) 405 * nested packages)
@@ -496,8 +496,9 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
496 case ACPI_TYPE_STRING: 496 case ACPI_TYPE_STRING:
497 497
498 internal_object->string.pointer = 498 internal_object->string.pointer =
499 ACPI_ALLOCATE_ZEROED((acpi_size) external_object->string. 499 ACPI_ALLOCATE_ZEROED((acpi_size)
500 length + 1); 500 external_object->string.length + 1);
501
501 if (!internal_object->string.pointer) { 502 if (!internal_object->string.pointer) {
502 goto error_exit; 503 goto error_exit;
503 } 504 }
@@ -697,7 +698,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
697 698
698 /* Handle the objects with extra data */ 699 /* Handle the objects with extra data */
699 700
700 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { 701 switch (dest_desc->common.type) {
701 case ACPI_TYPE_BUFFER: 702 case ACPI_TYPE_BUFFER:
702 /* 703 /*
703 * Allocate and copy the actual buffer if and only if: 704 * Allocate and copy the actual buffer if and only if:
@@ -814,8 +815,8 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type,
814 * This is a simple object, just copy it 815 * This is a simple object, just copy it
815 */ 816 */
816 target_object = 817 target_object =
817 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE 818 acpi_ut_create_internal_object(source_object->
818 (source_object)); 819 common.type);
819 if (!target_object) { 820 if (!target_object) {
820 return (AE_NO_MEMORY); 821 return (AE_NO_MEMORY);
821 } 822 }
@@ -892,7 +893,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
892 893
893 ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_ipackage); 894 ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_ipackage);
894 895
895 dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj); 896 dest_obj->common.type = source_obj->common.type;
896 dest_obj->common.flags = source_obj->common.flags; 897 dest_obj->common.flags = source_obj->common.flags;
897 dest_obj->package.count = source_obj->package.count; 898 dest_obj->package.count = source_obj->package.count;
898 899
@@ -950,15 +951,14 @@ acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
950 951
951 /* Create the top level object */ 952 /* Create the top level object */
952 953
953 *dest_desc = 954 *dest_desc = acpi_ut_create_internal_object(source_desc->common.type);
954 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc));
955 if (!*dest_desc) { 955 if (!*dest_desc) {
956 return_ACPI_STATUS(AE_NO_MEMORY); 956 return_ACPI_STATUS(AE_NO_MEMORY);
957 } 957 }
958 958
959 /* Copy the object and possible subobjects */ 959 /* Copy the object and possible subobjects */
960 960
961 if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) { 961 if (source_desc->common.type == ACPI_TYPE_PACKAGE) {
962 status = 962 status =
963 acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc, 963 acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc,
964 walk_state); 964 walk_state);
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
index a0be9e39531e..a5ee23bc4f55 100644
--- a/drivers/acpi/acpica/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -86,7 +86,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
86 * Must delete or free any pointers within the object that are not 86 * Must delete or free any pointers within the object that are not
87 * actual ACPI objects (for example, a raw buffer pointer). 87 * actual ACPI objects (for example, a raw buffer pointer).
88 */ 88 */
89 switch (ACPI_GET_OBJECT_TYPE(object)) { 89 switch (object->common.type) {
90 case ACPI_TYPE_STRING: 90 case ACPI_TYPE_STRING:
91 91
92 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 92 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
@@ -382,7 +382,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
382 object, new_count)); 382 object, new_count));
383 } 383 }
384 384
385 if (ACPI_GET_OBJECT_TYPE(object) == ACPI_TYPE_METHOD) { 385 if (object->common.type == ACPI_TYPE_METHOD) {
386 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 386 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
387 "Method Obj %p Refs=%X, [Decremented]\n", 387 "Method Obj %p Refs=%X, [Decremented]\n",
388 object, new_count)); 388 object, new_count));
@@ -469,7 +469,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
469 * All sub-objects must have their reference count incremented also. 469 * All sub-objects must have their reference count incremented also.
470 * Different object types have different subobjects. 470 * Different object types have different subobjects.
471 */ 471 */
472 switch (ACPI_GET_OBJECT_TYPE(object)) { 472 switch (object->common.type) {
473 case ACPI_TYPE_DEVICE: 473 case ACPI_TYPE_DEVICE:
474 case ACPI_TYPE_PROCESSOR: 474 case ACPI_TYPE_PROCESSOR:
475 case ACPI_TYPE_POWER: 475 case ACPI_TYPE_POWER:
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index 9c9897dbe907..006b16c26017 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -59,26 +59,35 @@ acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
59 59
60/* 60/*
61 * Strings supported by the _OSI predefined (internal) method. 61 * Strings supported by the _OSI predefined (internal) method.
62 *
63 * March 2009: Removed "Linux" as this host no longer wants to respond true
64 * for this string. Basically, the only safe OS strings are windows-related
65 * and in many or most cases represent the only test path within the
66 * BIOS-provided ASL code.
67 *
68 * The second element of each entry is used to track the newest version of
69 * Windows that the BIOS has requested.
62 */ 70 */
63static char *acpi_interfaces_supported[] = { 71static struct acpi_interface_info acpi_interfaces_supported[] = {
64 /* Operating System Vendor Strings */ 72 /* Operating System Vendor Strings */
65 73
66 "Windows 2000", /* Windows 2000 */ 74 {"Windows 2000", ACPI_OSI_WIN_2000}, /* Windows 2000 */
67 "Windows 2001", /* Windows XP */ 75 {"Windows 2001", ACPI_OSI_WIN_XP}, /* Windows XP */
68 "Windows 2001 SP1", /* Windows XP SP1 */ 76 {"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */
69 "Windows 2001 SP2", /* Windows XP SP2 */ 77 {"Windows 2001.1", ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
70 "Windows 2001.1", /* Windows Server 2003 */ 78 {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
71 "Windows 2001.1 SP1", /* Windows Server 2003 SP1 - Added 03/2006 */ 79 {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
72 "Windows 2006", /* Windows Vista - Added 03/2006 */ 80 {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */
73 81
74 /* Feature Group Strings */ 82 /* Feature Group Strings */
75 83
76 "Extended Address Space Descriptor" 84 {"Extended Address Space Descriptor", 0}
77 /* 85
78 * All "optional" feature group strings (features that are implemented 86 /*
79 * by the host) should be implemented in the host version of 87 * All "optional" feature group strings (features that are implemented
80 * acpi_os_validate_interface and should not be added here. 88 * by the host) should be implemented in the host version of
81 */ 89 * acpi_os_validate_interface and should not be added here.
90 */
82}; 91};
83 92
84/******************************************************************************* 93/*******************************************************************************
@@ -98,6 +107,7 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
98 acpi_status status; 107 acpi_status status;
99 union acpi_operand_object *string_desc; 108 union acpi_operand_object *string_desc;
100 union acpi_operand_object *return_desc; 109 union acpi_operand_object *return_desc;
110 u32 return_value;
101 u32 i; 111 u32 i;
102 112
103 ACPI_FUNCTION_TRACE(ut_osi_implementation); 113 ACPI_FUNCTION_TRACE(ut_osi_implementation);
@@ -116,19 +126,28 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
116 return_ACPI_STATUS(AE_NO_MEMORY); 126 return_ACPI_STATUS(AE_NO_MEMORY);
117 } 127 }
118 128
119 /* Default return value is 0, NOT-SUPPORTED */ 129 /* Default return value is 0, NOT SUPPORTED */
120 130
121 return_desc->integer.value = 0; 131 return_value = 0;
122 walk_state->return_desc = return_desc;
123 132
124 /* Compare input string to static table of supported interfaces */ 133 /* Compare input string to static table of supported interfaces */
125 134
126 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { 135 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
127 if (!ACPI_STRCMP 136 if (!ACPI_STRCMP(string_desc->string.pointer,
128 (string_desc->string.pointer, 137 acpi_interfaces_supported[i].name)) {
129 acpi_interfaces_supported[i])) { 138 /*
130 return_desc->integer.value = ACPI_UINT32_MAX; 139 * The interface is supported.
131 goto done; 140 * Update the osi_data if necessary. We keep track of the latest
141 * version of Windows that has been requested by the BIOS.
142 */
143 if (acpi_interfaces_supported[i].value >
144 acpi_gbl_osi_data) {
145 acpi_gbl_osi_data =
146 acpi_interfaces_supported[i].value;
147 }
148
149 return_value = ACPI_UINT32_MAX;
150 goto exit;
132 } 151 }
133 } 152 }
134 153
@@ -139,15 +158,22 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
139 */ 158 */
140 status = acpi_os_validate_interface(string_desc->string.pointer); 159 status = acpi_os_validate_interface(string_desc->string.pointer);
141 if (ACPI_SUCCESS(status)) { 160 if (ACPI_SUCCESS(status)) {
142 return_desc->integer.value = ACPI_UINT32_MAX; 161
162 /* The interface is supported */
163
164 return_value = ACPI_UINT32_MAX;
143 } 165 }
144 166
145done: 167exit:
146 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, "ACPI: BIOS _OSI(%s) %ssupported\n", 168 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
147 string_desc->string.pointer, 169 "ACPI: BIOS _OSI(%s) is %ssupported\n",
148 return_desc->integer.value == 0 ? "not-" : "")); 170 string_desc->string.pointer, return_value == 0 ? "not " : ""));
149 171
150 return_ACPI_STATUS(AE_OK); 172 /* Complete the return value */
173
174 return_desc->integer.value = return_value;
175 walk_state->return_desc = return_desc;
176 return_ACPI_STATUS (AE_OK);
151} 177}
152 178
153/******************************************************************************* 179/*******************************************************************************
@@ -167,8 +193,8 @@ acpi_status acpi_osi_invalidate(char *interface)
167 int i; 193 int i;
168 194
169 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { 195 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
170 if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i])) { 196 if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i].name)) {
171 *acpi_interfaces_supported[i] = '\0'; 197 *acpi_interfaces_supported[i].name = '\0';
172 return AE_OK; 198 return AE_OK;
173 } 199 }
174 } 200 }
@@ -248,7 +274,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
248 274
249 /* Map the return object type to the bitmapped type */ 275 /* Map the return object type to the bitmapped type */
250 276
251 switch (ACPI_GET_OBJECT_TYPE(info->return_object)) { 277 switch ((info->return_object)->common.type) {
252 case ACPI_TYPE_INTEGER: 278 case ACPI_TYPE_INTEGER:
253 return_btype = ACPI_BTYPE_INTEGER; 279 return_btype = ACPI_BTYPE_INTEGER;
254 break; 280 break;
@@ -418,7 +444,7 @@ acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
418 return_ACPI_STATUS(status); 444 return_ACPI_STATUS(status);
419 } 445 }
420 446
421 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 447 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
422 448
423 /* Convert the Numeric HID to string */ 449 /* Convert the Numeric HID to string */
424 450
@@ -459,7 +485,7 @@ acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
459 struct acpi_compatible_id *one_cid) 485 struct acpi_compatible_id *one_cid)
460{ 486{
461 487
462 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 488 switch (obj_desc->common.type) {
463 case ACPI_TYPE_INTEGER: 489 case ACPI_TYPE_INTEGER:
464 490
465 /* Convert the Numeric CID to string */ 491 /* Convert the Numeric CID to string */
@@ -527,7 +553,7 @@ acpi_ut_execute_CID(struct acpi_namespace_node * device_node,
527 /* Get the number of _CIDs returned */ 553 /* Get the number of _CIDs returned */
528 554
529 count = 1; 555 count = 1;
530 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { 556 if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
531 count = obj_desc->package.count; 557 count = obj_desc->package.count;
532 } 558 }
533 559
@@ -555,7 +581,7 @@ acpi_ut_execute_CID(struct acpi_namespace_node * device_node,
555 581
556 /* The _CID object can be either a single CID or a package (list) of CIDs */ 582 /* The _CID object can be either a single CID or a package (list) of CIDs */
557 583
558 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { 584 if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
559 585
560 /* Translate each package element */ 586 /* Translate each package element */
561 587
@@ -620,7 +646,7 @@ acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
620 return_ACPI_STATUS(status); 646 return_ACPI_STATUS(status);
621 } 647 }
622 648
623 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 649 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
624 650
625 /* Convert the Numeric UID to string */ 651 /* Convert the Numeric UID to string */
626 652
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index a3ab9d9da299..59e46f257c02 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -294,12 +294,9 @@ struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
294 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, 294 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL,
295 ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, 295 ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
296 ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, 296 ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
297 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, 297 /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL,
298 ACPI_BITPOSITION_SLEEP_TYPE_X, 298 ACPI_BITPOSITION_SLEEP_TYPE,
299 ACPI_BITMASK_SLEEP_TYPE_X}, 299 ACPI_BITMASK_SLEEP_TYPE},
300 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL,
301 ACPI_BITPOSITION_SLEEP_TYPE_X,
302 ACPI_BITMASK_SLEEP_TYPE_X},
303 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, 300 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
304 ACPI_BITPOSITION_SLEEP_ENABLE, 301 ACPI_BITPOSITION_SLEEP_ENABLE,
305 ACPI_BITMASK_SLEEP_ENABLE}, 302 ACPI_BITMASK_SLEEP_ENABLE},
@@ -476,7 +473,7 @@ char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
476 return ("[NULL Object Descriptor]"); 473 return ("[NULL Object Descriptor]");
477 } 474 }
478 475
479 return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc))); 476 return (acpi_ut_get_type_name(obj_desc->common.type));
480} 477}
481 478
482/******************************************************************************* 479/*******************************************************************************
@@ -749,7 +746,10 @@ acpi_status acpi_ut_init_globals(void)
749 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) { 746 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
750 acpi_gbl_owner_id_mask[i] = 0; 747 acpi_gbl_owner_id_mask[i] = 0;
751 } 748 }
752 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */ 749
750 /* Last owner_iD is never valid */
751
752 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
753 753
754 /* GPE support */ 754 /* GPE support */
755 755
@@ -789,6 +789,7 @@ acpi_status acpi_ut_init_globals(void)
789 acpi_gbl_trace_dbg_layer = 0; 789 acpi_gbl_trace_dbg_layer = 0;
790 acpi_gbl_debugger_configuration = DEBUGGER_THREADING; 790 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
791 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 791 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
792 acpi_gbl_osi_data = 0;
792 793
793 /* Hardware oriented */ 794 /* Hardware oriented */
794 795
diff --git a/drivers/acpi/acpica/utlock.c b/drivers/acpi/acpica/utlock.c
new file mode 100644
index 000000000000..25e03120686d
--- /dev/null
+++ b/drivers/acpi/acpica/utlock.c
@@ -0,0 +1,175 @@
1/******************************************************************************
2 *
3 * Module Name: utlock - Reader/Writer lock interfaces
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2009, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utlock")
49
50/*******************************************************************************
51 *
52 * FUNCTION: acpi_ut_create_rw_lock
53 * acpi_ut_delete_rw_lock
54 *
55 * PARAMETERS: Lock - Pointer to a valid RW lock
56 *
57 * RETURN: Status
58 *
59 * DESCRIPTION: Reader/writer lock creation and deletion interfaces.
60 *
61 ******************************************************************************/
62acpi_status acpi_ut_create_rw_lock(struct acpi_rw_lock *lock)
63{
64 acpi_status status;
65
66 lock->num_readers = 0;
67 status = acpi_os_create_mutex(&lock->reader_mutex);
68 if (ACPI_FAILURE(status)) {
69 return status;
70 }
71
72 status = acpi_os_create_mutex(&lock->writer_mutex);
73 return status;
74}
75
76void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock)
77{
78
79 acpi_os_delete_mutex(lock->reader_mutex);
80 acpi_os_delete_mutex(lock->writer_mutex);
81
82 lock->num_readers = 0;
83 lock->reader_mutex = NULL;
84 lock->writer_mutex = NULL;
85}
86
87/*******************************************************************************
88 *
89 * FUNCTION: acpi_ut_acquire_read_lock
90 * acpi_ut_release_read_lock
91 *
92 * PARAMETERS: Lock - Pointer to a valid RW lock
93 *
94 * RETURN: Status
95 *
96 * DESCRIPTION: Reader interfaces for reader/writer locks. On acquisition,
97 * only the first reader acquires the write mutex. On release,
98 * only the last reader releases the write mutex. Although this
99 * algorithm can in theory starve writers, this should not be a
100 * problem with ACPICA since the subsystem is infrequently used
101 * in comparison to (for example) an I/O system.
102 *
103 ******************************************************************************/
104
105acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock)
106{
107 acpi_status status;
108
109 status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER);
110 if (ACPI_FAILURE(status)) {
111 return status;
112 }
113
114 /* Acquire the write lock only for the first reader */
115
116 lock->num_readers++;
117 if (lock->num_readers == 1) {
118 status =
119 acpi_os_acquire_mutex(lock->writer_mutex,
120 ACPI_WAIT_FOREVER);
121 }
122
123 acpi_os_release_mutex(lock->reader_mutex);
124 return status;
125}
126
127acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock)
128{
129 acpi_status status;
130
131 status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER);
132 if (ACPI_FAILURE(status)) {
133 return status;
134 }
135
136 /* Release the write lock only for the very last reader */
137
138 lock->num_readers--;
139 if (lock->num_readers == 0) {
140 acpi_os_release_mutex(lock->writer_mutex);
141 }
142
143 acpi_os_release_mutex(lock->reader_mutex);
144 return status;
145}
146
147/*******************************************************************************
148 *
149 * FUNCTION: acpi_ut_acquire_write_lock
150 * acpi_ut_release_write_lock
151 *
152 * PARAMETERS: Lock - Pointer to a valid RW lock
153 *
154 * RETURN: Status
155 *
156 * DESCRIPTION: Writer interfaces for reader/writer locks. Simply acquire or
157 * release the writer mutex associated with the lock. Acquisition
158 * of the lock is fully exclusive and will block all readers and
159 * writers until it is released.
160 *
161 ******************************************************************************/
162
163acpi_status acpi_ut_acquire_write_lock(struct acpi_rw_lock *lock)
164{
165 acpi_status status;
166
167 status = acpi_os_acquire_mutex(lock->writer_mutex, ACPI_WAIT_FOREVER);
168 return status;
169}
170
171void acpi_ut_release_write_lock(struct acpi_rw_lock *lock)
172{
173
174 acpi_os_release_mutex(lock->writer_mutex);
175}
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index c1f7f4e1a72d..1c9e250caefb 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -938,8 +938,7 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
938 if ((!this_source_obj) || 938 if ((!this_source_obj) ||
939 (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) != 939 (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) !=
940 ACPI_DESC_TYPE_OPERAND) 940 ACPI_DESC_TYPE_OPERAND)
941 || (ACPI_GET_OBJECT_TYPE(this_source_obj) != 941 || (this_source_obj->common.type != ACPI_TYPE_PACKAGE)) {
942 ACPI_TYPE_PACKAGE)) {
943 status = 942 status =
944 walk_callback(ACPI_COPY_TYPE_SIMPLE, 943 walk_callback(ACPI_COPY_TYPE_SIMPLE,
945 this_source_obj, state, context); 944 this_source_obj, state, context);
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 14eb52c4d647..26c93a748e64 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -60,7 +60,8 @@ static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id);
60 * 60 *
61 * RETURN: Status 61 * RETURN: Status
62 * 62 *
63 * DESCRIPTION: Create the system mutex objects. 63 * DESCRIPTION: Create the system mutex objects. This includes mutexes,
64 * spin locks, and reader/writer locks.
64 * 65 *
65 ******************************************************************************/ 66 ******************************************************************************/
66 67
@@ -71,9 +72,8 @@ acpi_status acpi_ut_mutex_initialize(void)
71 72
72 ACPI_FUNCTION_TRACE(ut_mutex_initialize); 73 ACPI_FUNCTION_TRACE(ut_mutex_initialize);
73 74
74 /* 75 /* Create each of the predefined mutex objects */
75 * Create each of the predefined mutex objects 76
76 */
77 for (i = 0; i < ACPI_NUM_MUTEX; i++) { 77 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
78 status = acpi_ut_create_mutex(i); 78 status = acpi_ut_create_mutex(i);
79 if (ACPI_FAILURE(status)) { 79 if (ACPI_FAILURE(status)) {
@@ -86,6 +86,9 @@ acpi_status acpi_ut_mutex_initialize(void)
86 spin_lock_init(acpi_gbl_gpe_lock); 86 spin_lock_init(acpi_gbl_gpe_lock);
87 spin_lock_init(acpi_gbl_hardware_lock); 87 spin_lock_init(acpi_gbl_hardware_lock);
88 88
89 /* Create the reader/writer lock for namespace access */
90
91 status = acpi_ut_create_rw_lock(&acpi_gbl_namespace_rw_lock);
89 return_ACPI_STATUS(status); 92 return_ACPI_STATUS(status);
90} 93}
91 94
@@ -97,7 +100,8 @@ acpi_status acpi_ut_mutex_initialize(void)
97 * 100 *
98 * RETURN: None. 101 * RETURN: None.
99 * 102 *
100 * DESCRIPTION: Delete all of the system mutex objects. 103 * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes,
104 * spin locks, and reader/writer locks.
101 * 105 *
102 ******************************************************************************/ 106 ******************************************************************************/
103 107
@@ -107,9 +111,8 @@ void acpi_ut_mutex_terminate(void)
107 111
108 ACPI_FUNCTION_TRACE(ut_mutex_terminate); 112 ACPI_FUNCTION_TRACE(ut_mutex_terminate);
109 113
110 /* 114 /* Delete each predefined mutex object */
111 * Delete each predefined mutex object 115
112 */
113 for (i = 0; i < ACPI_NUM_MUTEX; i++) { 116 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
114 (void)acpi_ut_delete_mutex(i); 117 (void)acpi_ut_delete_mutex(i);
115 } 118 }
@@ -118,6 +121,10 @@ void acpi_ut_mutex_terminate(void)
118 121
119 acpi_os_delete_lock(acpi_gbl_gpe_lock); 122 acpi_os_delete_lock(acpi_gbl_gpe_lock);
120 acpi_os_delete_lock(acpi_gbl_hardware_lock); 123 acpi_os_delete_lock(acpi_gbl_hardware_lock);
124
125 /* Delete the reader/writer lock */
126
127 acpi_ut_delete_rw_lock(&acpi_gbl_namespace_rw_lock);
121 return_VOID; 128 return_VOID;
122} 129}
123 130
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index fd5ea7543e5b..0207b625274a 100644
--- a/drivers/acpi/acpica/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -310,7 +310,7 @@ u8 acpi_ut_valid_internal_object(void *object)
310 /* Check for a null pointer */ 310 /* Check for a null pointer */
311 311
312 if (!object) { 312 if (!object) {
313 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "**** Null Object Ptr\n")); 313 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "**** Null Object Ptr\n"));
314 return (FALSE); 314 return (FALSE);
315 } 315 }
316 316
@@ -324,7 +324,7 @@ u8 acpi_ut_valid_internal_object(void *object)
324 return (TRUE); 324 return (TRUE);
325 325
326 default: 326 default:
327 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 327 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
328 "%p is not not an ACPI operand obj [%s]\n", 328 "%p is not not an ACPI operand obj [%s]\n",
329 object, acpi_ut_get_descriptor_name(object))); 329 object, acpi_ut_get_descriptor_name(object)));
330 break; 330 break;
@@ -457,7 +457,7 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
457 * must be accessed bytewise or there may be alignment problems on 457 * must be accessed bytewise or there may be alignment problems on
458 * certain processors 458 * certain processors
459 */ 459 */
460 switch (ACPI_GET_OBJECT_TYPE(internal_object)) { 460 switch (internal_object->common.type) {
461 case ACPI_TYPE_STRING: 461 case ACPI_TYPE_STRING:
462 462
463 length += (acpi_size) internal_object->string.length + 1; 463 length += (acpi_size) internal_object->string.length + 1;
@@ -518,8 +518,7 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
518 ACPI_ERROR((AE_INFO, "Cannot convert to external object - " 518 ACPI_ERROR((AE_INFO, "Cannot convert to external object - "
519 "unsupported type [%s] %X in object %p", 519 "unsupported type [%s] %X in object %p",
520 acpi_ut_get_object_type_name(internal_object), 520 acpi_ut_get_object_type_name(internal_object),
521 ACPI_GET_OBJECT_TYPE(internal_object), 521 internal_object->common.type, internal_object));
522 internal_object));
523 status = AE_TYPE; 522 status = AE_TYPE;
524 break; 523 break;
525 } 524 }
@@ -664,7 +663,7 @@ acpi_ut_get_object_size(union acpi_operand_object *internal_object,
664 663
665 if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) == 664 if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) ==
666 ACPI_DESC_TYPE_OPERAND) 665 ACPI_DESC_TYPE_OPERAND)
667 && (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE)) { 666 && (internal_object->common.type == ACPI_TYPE_PACKAGE)) {
668 status = 667 status =
669 acpi_ut_get_package_object_size(internal_object, 668 acpi_ut_get_package_object_size(internal_object,
670 obj_length); 669 obj_length);