Skip to contentSkip to conversation

ACPICA related patch queue for Linux-3.7

PATCH In review Len Brown 2 participants 25 messages Sep 23, 2012

Subsystems (3)
lore
Share & tools
lore

Len Brown

author reviewer
#0 lore raw

Here is my ACPICA branch queued for Linux-3.7

Please let me know if you see troubles with any of them.

Note that the acpidump utility is also in here. Since it lost its home on kernel.org in pmtools, and it depends on kernel headers, it seemed to make sense to put it here. Yes, it is a bit dusty, and could use some clean-up...

thanks,
Len Brown, Intel Open Source Technology Center

author reviewer
#1 lore raw

PATCH 1/23 ACPI: delelte more BFS/GTS related definition and code

From: Feng Tang <[email protected]>

This is a follow on for commmit 3f6f49c7 "ACPI: delete _GTS/_BFS support" to do more cleanup.

---
 drivers/acpi/acpica/hwxfsleep.c | 1 -
 include/acpi/acnames.h          | 2 --
 include/acpi/actypes.h          | 7 -------
 3 files changed, 10 deletions(-)
drivers/acpi/acpica/hwxfsleep.c +0 -1
index 1f165a7..0ff1ece 100644
@@ -381,7 +381,6 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
  * FUNCTION:    acpi_leave_sleep_state_prep
  *
  * PARAMETERS:  sleep_state         - Which sleep state we are exiting
- *              flags               - ACPI_EXECUTE_BFS to run optional method
  *
  * RETURN:      Status
  *
include/acpi/acnames.h +0 -2
index d988ac5..d2f61dd 100644
@@ -66,8 +66,6 @@
 
 /* Method names - these methods must appear at the namespace root */
 
-#define METHOD_PATHNAME__BFS    "\\_BFS"
-#define METHOD_PATHNAME__GTS    "\\_GTS"
 #define METHOD_PATHNAME__PTS    "\\_PTS"
 #define METHOD_PATHNAME__SST    "\\_SI._SST"
 #define METHOD_PATHNAME__WAK    "\\_WAK"
include/acpi/actypes.h +0 -7
index 3d00bd5..a85bae9 100644
@@ -519,13 +519,6 @@ typedef u64 acpi_integer;
 #define ACPI_SLEEP_TYPE_INVALID         0xFF
 
 /*
- * Sleep/Wake flags
- */
-#define ACPI_NO_OPTIONAL_METHODS        0x00	/* Do not execute any optional methods */
-#define ACPI_EXECUTE_GTS                0x01	/* For enter sleep interface */
-#define ACPI_EXECUTE_BFS                0x02	/* For leave sleep prep interface */
-
-/*
  * Standard notify values
  */
 #define ACPI_NOTIFY_BUS_CHECK           (u8) 0x00
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#2 lore raw

PATCH 2/23 ACPICA: Enable Scope change to root during module-level code execution.

In reply to Len Brown

From: Bob Moore <[email protected]>

Allows constructs like this:

    If (XXXX)
        Scope (\)
        ...
---
 drivers/acpi/acpica/dswload.c  | 14 ++++++++++++++
 drivers/acpi/acpica/dswload2.c | 14 ++++++++++++++
 2 files changed, 28 insertions(+)
drivers/acpi/acpica/dswload.c +14 -0
index 552aa3a..5575100 100644
@@ -230,6 +230,20 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
 			walk_state->scope_info->common.value = ACPI_TYPE_ANY;
 			break;
 
+		case ACPI_TYPE_METHOD:
+
+			/*
+			 * Allow scope change to root during execution of module-level
+			 * code. Root is typed METHOD during this time.
+			 */
+			if ((node == acpi_gbl_root_node) &&
+			    (walk_state->
+			     parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
+				break;
+			}
+
+			/*lint -fallthrough */
+
 		default:
 
 			/* All other types are an error */
drivers/acpi/acpica/dswload2.c +14 -0
index ae71477..89c0114 100644
@@ -230,6 +230,20 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
 			walk_state->scope_info->common.value = ACPI_TYPE_ANY;
 			break;
 
+		case ACPI_TYPE_METHOD:
+
+			/*
+			 * Allow scope change to root during execution of module-level
+			 * code. Root is typed METHOD during this time.
+			 */
+			if ((node == acpi_gbl_root_node) &&
+			    (walk_state->
+			     parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
+				break;
+			}
+
+			/*lint -fallthrough */
+
 		default:
 
 			/* All other types are an error */
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#3 lore raw

PATCH 3/23 ACPICA: Split ACPICA initialization functions to new file, utxfinit.c

In reply to Len Brown

From: Bob Moore <[email protected]>

Split utxface.c to improve modularity and reduce file size.

---
 drivers/acpi/acpica/Makefile   |   1 +
 drivers/acpi/acpica/utxface.c  | 267 +---------------------------------
 drivers/acpi/acpica/utxfinit.c | 317 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 319 insertions(+), 266 deletions(-)
 create mode 100644 drivers/acpi/acpica/utxfinit.c
drivers/acpi/acpica/Makefile +1 -0
index 0a1b343..7f1d407 100644
@@ -158,5 +158,6 @@ acpi-y +=		\
 	utresrc.o	\
 	utstate.o	\
 	utxface.o	\
+	utxfinit.o	\
 	utxferror.o	\
 	utxfmutex.o
drivers/acpi/acpica/utxface.c +1 -266

278 lines not on this page · raw message

drivers/acpi/acpica/utxfinit.c new file +317 -0

317 lines not on this page · raw message

Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#4 lore raw

PATCH 4/23 ACPICA: Comment update: Fix some typos in actble.h

In reply to Len Brown

From: Bob Moore <[email protected]>

No functional change.

---
 include/acpi/actbl.h | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)
include/acpi/actbl.h +24 -24
index 59a73e1..d54e358 100644
@@ -94,7 +94,7 @@
 struct acpi_table_header {
 	char signature[ACPI_NAME_SIZE];	/* ASCII table signature */
 	u32 length;		/* Length of table in bytes, including this header */
-	u8 revision;		/* ACPI Specification minor version # */
+	u8 revision;		/* ACPI Specification minor version number */
 	u8 checksum;		/* To make sum of entire table == 0 */
 	char oem_id[ACPI_OEM_ID_SIZE];	/* ASCII OEM identification */
 	char oem_table_id[ACPI_OEM_TABLE_ID_SIZE];	/* ASCII OEM table identification */
@@ -108,7 +108,7 @@ struct acpi_table_header {
  * GAS - Generic Address Structure (ACPI 2.0+)
  *
  * Note: Since this structure is used in the ACPI tables, it is byte aligned.
- * If misaliged access is not supported by the hardware, accesses to the
+ * If misaligned access is not supported by the hardware, accesses to the
  * 64-bit Address field must be performed with care.
  *
  ******************************************************************************/
@@ -210,18 +210,18 @@ struct acpi_table_fadt {
 	u8 preferred_profile;	/* Conveys preferred power management profile to OSPM. */
 	u16 sci_interrupt;	/* System vector of SCI interrupt */
 	u32 smi_command;	/* 32-bit Port address of SMI command port */
-	u8 acpi_enable;		/* Value to write to smi_cmd to enable ACPI */
-	u8 acpi_disable;	/* Value to write to smi_cmd to disable ACPI */
-	u8 s4_bios_request;	/* Value to write to SMI CMD to enter S4BIOS state */
+	u8 acpi_enable;		/* Value to write to SMI_CMD to enable ACPI */
+	u8 acpi_disable;	/* Value to write to SMI_CMD to disable ACPI */
+	u8 s4_bios_request;	/* Value to write to SMI_CMD to enter S4BIOS state */
 	u8 pstate_control;	/* Processor performance state control */
-	u32 pm1a_event_block;	/* 32-bit Port address of Power Mgt 1a Event Reg Blk */
-	u32 pm1b_event_block;	/* 32-bit Port address of Power Mgt 1b Event Reg Blk */
-	u32 pm1a_control_block;	/* 32-bit Port address of Power Mgt 1a Control Reg Blk */
-	u32 pm1b_control_block;	/* 32-bit Port address of Power Mgt 1b Control Reg Blk */
-	u32 pm2_control_block;	/* 32-bit Port address of Power Mgt 2 Control Reg Blk */
-	u32 pm_timer_block;	/* 32-bit Port address of Power Mgt Timer Ctrl Reg Blk */
-	u32 gpe0_block;		/* 32-bit Port address of General Purpose Event 0 Reg Blk */
-	u32 gpe1_block;		/* 32-bit Port address of General Purpose Event 1 Reg Blk */
+	u32 pm1a_event_block;	/* 32-bit port address of Power Mgt 1a Event Reg Blk */
+	u32 pm1b_event_block;	/* 32-bit port address of Power Mgt 1b Event Reg Blk */
+	u32 pm1a_control_block;	/* 32-bit port address of Power Mgt 1a Control Reg Blk */
+	u32 pm1b_control_block;	/* 32-bit port address of Power Mgt 1b Control Reg Blk */
+	u32 pm2_control_block;	/* 32-bit port address of Power Mgt 2 Control Reg Blk */
+	u32 pm_timer_block;	/* 32-bit port address of Power Mgt Timer Ctrl Reg Blk */
+	u32 gpe0_block;		/* 32-bit port address of General Purpose Event 0 Reg Blk */
+	u32 gpe1_block;		/* 32-bit port address of General Purpose Event 1 Reg Blk */
 	u8 pm1_event_length;	/* Byte Length of ports at pm1x_event_block */
 	u8 pm1_control_length;	/* Byte Length of ports at pm1x_control_block */
 	u8 pm2_control_length;	/* Byte Length of ports at pm2_control_block */
@@ -229,12 +229,12 @@ struct acpi_table_fadt {
 	u8 gpe0_block_length;	/* Byte Length of ports at gpe0_block */
 	u8 gpe1_block_length;	/* Byte Length of ports at gpe1_block */
 	u8 gpe1_base;		/* Offset in GPE number space where GPE1 events start */
-	u8 cst_control;		/* Support for the _CST object and C States change notification */
+	u8 cst_control;		/* Support for the _CST object and C-States change notification */
 	u16 c2_latency;		/* Worst case HW latency to enter/exit C2 state */
 	u16 c3_latency;		/* Worst case HW latency to enter/exit C3 state */
-	u16 flush_size;		/* Processor's memory cache line width, in bytes */
+	u16 flush_size;		/* Processor memory cache line width, in bytes */
 	u16 flush_stride;	/* Number of flush strides that need to be read */
-	u8 duty_offset;		/* Processor duty cycle index in processor's P_CNT reg */
+	u8 duty_offset;		/* Processor duty cycle index in processor P_CNT reg */
 	u8 duty_width;		/* Processor duty cycle value bit width in P_CNT register */
 	u8 day_alarm;		/* Index to day-of-month alarm in RTC CMOS RAM */
 	u8 month_alarm;		/* Index to month-of-year alarm in RTC CMOS RAM */
@@ -255,11 +255,11 @@ struct acpi_table_fadt {
 	struct acpi_generic_address xpm_timer_block;	/* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */
 	struct acpi_generic_address xgpe0_block;	/* 64-bit Extended General Purpose Event 0 Reg Blk address */
 	struct acpi_generic_address xgpe1_block;	/* 64-bit Extended General Purpose Event 1 Reg Blk address */
-	struct acpi_generic_address sleep_control;	/* 64-bit Sleep Control register */
-	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register */
+	struct acpi_generic_address sleep_control;	/* 64-bit Sleep Control register (ACPI 5.0) */
+	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register (ACPI 5.0) */
 };
 
-/* Masks for FADT Boot Architecture Flags (boot_flags) */
+/* Masks for FADT Boot Architecture Flags (boot_flags) [Vx]=Introduced in this FADT revision */
 
 #define ACPI_FADT_LEGACY_DEVICES    (1)  	/* 00: [V2] System has LPC or ISA bus devices */
 #define ACPI_FADT_8042              (1<<1)	/* 01: [V3] System has an 8042 controller on port 60/64 */
@@ -272,13 +272,13 @@ struct acpi_table_fadt {
 
 /* Masks for FADT flags */
 
-#define ACPI_FADT_WBINVD            (1)	/* 00: [V1] The wbinvd instruction works properly */
-#define ACPI_FADT_WBINVD_FLUSH      (1<<1)	/* 01: [V1] wbinvd flushes but does not invalidate caches */
+#define ACPI_FADT_WBINVD            (1)	/* 00: [V1] The WBINVD instruction works properly */
+#define ACPI_FADT_WBINVD_FLUSH      (1<<1)	/* 01: [V1] WBINVD flushes but does not invalidate caches */
 #define ACPI_FADT_C1_SUPPORTED      (1<<2)	/* 02: [V1] All processors support C1 state */
 #define ACPI_FADT_C2_MP_SUPPORTED   (1<<3)	/* 03: [V1] C2 state works on MP system */
 #define ACPI_FADT_POWER_BUTTON      (1<<4)	/* 04: [V1] Power button is handled as a control method device */
 #define ACPI_FADT_SLEEP_BUTTON      (1<<5)	/* 05: [V1] Sleep button is handled as a control method device */
-#define ACPI_FADT_FIXED_RTC         (1<<6)	/* 06: [V1] RTC wakeup status not in fixed register space */
+#define ACPI_FADT_FIXED_RTC         (1<<6)	/* 06: [V1] RTC wakeup status is not in fixed register space */
 #define ACPI_FADT_S4_RTC_WAKE       (1<<7)	/* 07: [V1] RTC alarm can wake system from S4 */
 #define ACPI_FADT_32BIT_TIMER       (1<<8)	/* 08: [V1] ACPI timer width is 32-bit (0=24-bit) */
 #define ACPI_FADT_DOCKING_SUPPORTED (1<<9)	/* 09: [V1] Docking supported */
@@ -297,7 +297,7 @@ struct acpi_table_fadt {
 
 /* Values for preferred_profile (Preferred Power Management Profiles) */
 
-enum acpi_prefered_pm_profiles {
+enum acpi_preferred_pm_profiles {
 	PM_UNSPECIFIED = 0,
 	PM_DESKTOP = 1,
 	PM_MOBILE = 2,
@@ -335,7 +335,7 @@ union acpi_name_union {
 struct acpi_table_desc {
 	acpi_physical_address address;
 	struct acpi_table_header *pointer;
-	u32 length;		/* Length fixed at 32 bits */
+	u32 length;		/* Length fixed at 32 bits (fixed in table header) */
 	union acpi_name_union signature;
 	acpi_owner_id owner_id;
 	u8 flags;
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#5 lore raw

PATCH 5/23 ACPICA: Add Windows8/Server2012 string for _OSI method.

In reply to Len Brown

From: Bob Moore <[email protected]>

This change adds a new _OSI string, "Windows 2012" for both Windows 8 and Windows Server 2012.

Quoted 1 line

From Microsoft document "How to Identify the Windows Version in ACPI

by Using _OSI", July 13, 2012.

---
 drivers/acpi/acpica/aclocal.h | 1 +
 drivers/acpi/acpica/utosi.c   | 1 +
 2 files changed, 2 insertions(+)
drivers/acpi/acpica/aclocal.h +1 -0
index cc80fe1..493529a 100644
@@ -932,6 +932,7 @@ struct acpi_bit_register_info {
 #define ACPI_OSI_WIN_VISTA_SP1          0x09
 #define ACPI_OSI_WIN_VISTA_SP2          0x0A
 #define ACPI_OSI_WIN_7                  0x0B
+#define ACPI_OSI_WIN_8                  0x0C
 
 #define ACPI_ALWAYS_ILLEGAL             0x00
 
drivers/acpi/acpica/utosi.c +1 -0
index 34ef0bd..676285d 100644
@@ -73,6 +73,7 @@ static struct acpi_interface_info acpi_default_supported_interfaces[] = {
 	{"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1},	/* Windows Vista SP1 - Added 09/2009 */
 	{"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2},	/* Windows Vista SP2 - Added 09/2010 */
 	{"Windows 2009", NULL, 0, ACPI_OSI_WIN_7},	/* Windows 7 and Server 2008 R2 - Added 09/2009 */
+	{"Windows 2012", NULL, 0, ACPI_OSI_WIN_8},	/* Windows 8 and Server 2012 - Added 08/2012 */
 
 	/* Feature Group Strings */
 
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#6 lore raw

PATCH 6/23 ACPICA: GPE Support: Update debug info for GPE tracing.

In reply to Len Brown

From: Bob Moore <[email protected]>

Add additional debug info to assist with GPE debugging.

---
 drivers/acpi/acpica/evgpe.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/acpi/acpica/evgpe.c +19 -2
index afbd5cb..3db3c56 100644
@@ -379,6 +379,18 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
 			 */
 			if (!(gpe_register_info->enable_for_run |
 			      gpe_register_info->enable_for_wake)) {
+				ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
+						  "Ignore disabled registers for GPE%02X-GPE%02X: "
+						  "RunEnable=%02X, WakeEnable=%02X\n",
+						  gpe_register_info->
+						  base_gpe_number,
+						  gpe_register_info->
+						  base_gpe_number +
+						  (ACPI_GPE_REGISTER_WIDTH - 1),
+						  gpe_register_info->
+						  enable_for_run,
+						  gpe_register_info->
+						  enable_for_wake));
 				continue;
 			}
 
@@ -401,9 +413,14 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
 			}
 
 			ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
-					  "Read GPE Register at GPE%02X: Status=%02X, Enable=%02X\n",
+					  "Read registers for GPE%02X-GPE%02X: Status=%02X, Enable=%02X, "
+					  "RunEnable=%02X, WakeEnable=%02X\n",
 					  gpe_register_info->base_gpe_number,
-					  status_reg, enable_reg));
+					  gpe_register_info->base_gpe_number +
+					  (ACPI_GPE_REGISTER_WIDTH - 1),
+					  status_reg, enable_reg,
+					  gpe_register_info->enable_for_run,
+					  gpe_register_info->enable_for_wake));
 
 			/* Check if there is anything active at all in this register */
 
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#7 lore raw

PATCH 7/23 ACPICA: Debug output: Update output for Processor object.

In reply to Len Brown

From: Bob Moore <[email protected]>

Cleanup output for Processor(). Length is a byte, not a word.

---
 drivers/acpi/acpica/nsdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpica/nsdump.c +1 -1
index 7ee4e6a..2526aaf 100644
@@ -264,7 +264,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
 		switch (type) {
 		case ACPI_TYPE_PROCESSOR:
 
-			acpi_os_printf("ID %X Len %.4X Addr %p\n",
+			acpi_os_printf("ID %02X Len %02X Addr %p\n",
 				       obj_desc->processor.proc_id,
 				       obj_desc->processor.length,
 				       ACPI_CAST_PTR(void,
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#8 lore raw

PATCH 8/23 ACPICA: GPE support: Remove extraneous parameter from low-level function.

In reply to Len Brown

From: Feng Tang <[email protected]>

The gpe_register_info argument is no longer needed, reduce it to make code simpler.

---
 drivers/acpi/acpica/achware.h |  3 +--
 drivers/acpi/acpica/evgpe.c   |  3 +--
 drivers/acpi/acpica/evxfgpe.c |  3 +--
 drivers/acpi/acpica/hwgpe.c   | 15 +++++----------
 4 files changed, 8 insertions(+), 16 deletions(-)
drivers/acpi/acpica/achware.h +1 -2
index 5de4ec7..d902d31 100644
@@ -110,8 +110,7 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width);
 /*
  * hwgpe - GPE support
  */
-u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
-			     struct acpi_gpe_register_info *gpe_register_info);
+u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info);
 
 acpi_status
 acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action);
drivers/acpi/acpica/evgpe.c +1 -2
index 3db3c56..ef0193d 100644
@@ -80,8 +80,7 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info)
 		return_ACPI_STATUS(AE_NOT_EXIST);
 	}
 
-	register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
-						gpe_register_info);
+	register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
 
 	/* Clear the run bit up front */
 
drivers/acpi/acpica/evxfgpe.c +1 -2
index 6affbdb..87c5f23 100644
@@ -357,8 +357,7 @@ acpi_status acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 ac
 		goto unlock_and_exit;
 	}
 
-	register_bit =
-	    acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
+	register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
 
 	/* Perform the action */
 
drivers/acpi/acpica/hwgpe.c +5 -10
index 25bd28c..db40765 100644
@@ -60,7 +60,6 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
  * FUNCTION:	acpi_hw_get_gpe_register_bit
  *
  * PARAMETERS:	gpe_event_info	    - Info block for the GPE
- *		gpe_register_info   - Info block for the GPE register
  *
  * RETURN:	Register mask with a one in the GPE bit position
  *
@@ -69,11 +68,10 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
  *
  ******************************************************************************/
 
-u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
-			     struct acpi_gpe_register_info *gpe_register_info)
+u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info)
 {
 	return (u32)1 << (gpe_event_info->gpe_number -
-				gpe_register_info->base_gpe_number);
+		 gpe_event_info->register_info->base_gpe_number);
 }
 
 /******************************************************************************
@@ -115,8 +113,7 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
 
 	/* Set or clear just the bit that corresponds to this GPE */
 
-	register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
-						gpe_register_info);
+	register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
 	switch (action) {
 	case ACPI_GPE_CONDITIONAL_ENABLE:
 
@@ -178,8 +175,7 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
 	 * Write a one to the appropriate bit in the status register to
 	 * clear this GPE.
 	 */
-	register_bit =
-	    acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
+	register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
 
 	status = acpi_hw_write(register_bit,
 			       &gpe_register_info->status_address);
@@ -222,8 +218,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
 
 	/* Get the register bitmask for this GPE */
 
-	register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
-						gpe_register_info);
+	register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
 
 	/* GPE currently enabled? (enabled for runtime?) */
 
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#9 lore raw

PATCH 9/23 ACPICA: Headers: Add support for CSRT and DBG2 ACPI tables.

In reply to Len Brown

From: Bob Moore <[email protected]>

These tables are defined outside of the ACPI specification.

---
 include/acpi/actbl2.h | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/acpi/actbl3.h |   1 -
 2 files changed, 111 insertions(+), 1 deletion(-)
include/acpi/actbl2.h +111 -0
index d9ceb3d..b74476c 100644
@@ -63,6 +63,8 @@
  */
 #define ACPI_SIG_ASF            "ASF!"	/* Alert Standard Format table */
 #define ACPI_SIG_BOOT           "BOOT"	/* Simple Boot Flag Table */
+#define ACPI_SIG_CSRT           "CSRT"	/* Core System Resource Table */
+#define ACPI_SIG_DBG2           "DBG2"	/* Debug Port table type 2 */
 #define ACPI_SIG_DBGP           "DBGP"	/* Debug Port table */
 #define ACPI_SIG_DMAR           "DMAR"	/* DMA Remapping table */
 #define ACPI_SIG_HPET           "HPET"	/* High Precision Event Timer table */
@@ -232,6 +234,115 @@ struct acpi_table_boot {
 
 /*******************************************************************************
  *
+ * CSRT - Core System Resource Table
+ *        Version 0
+ *
+ * Conforms to the "Core System Resource Table (CSRT)", November 14, 2011
+ *
+ ******************************************************************************/
+
+struct acpi_table_csrt {
+	struct acpi_table_header header;	/* Common ACPI table header */
+};
+
+/* Resource Group subtable */
+
+struct acpi_csrt_group {
+	u32 length;
+	u32 vendor_id;
+	u32 subvendor_id;
+	u16 device_id;
+	u16 subdevice_id;
+	u16 revision;
+	u16 reserved;
+	u32 info_length;
+
+	/* Shared data (length = info_length) immediately follows */
+};
+
+/* Resource Descriptor subtable */
+
+struct acpi_csrt_descriptor {
+	u32 length;
+	u16 type;
+	u16 subtype;
+	u32 uid;
+
+	/* Resource-specific information immediately follows */
+};
+
+/* Resource Types */
+
+#define ACPI_CSRT_TYPE_INTERRUPT    0x0001
+#define ACPI_CSRT_TYPE_TIMER        0x0002
+#define ACPI_CSRT_TYPE_DMA          0x0003
+
+/* Resource Subtypes */
+
+#define ACPI_CSRT_XRUPT_LINE        0x0000
+#define ACPI_CSRT_XRUPT_CONTROLLER  0x0001
+#define ACPI_CSRT_TIMER             0x0000
+#define ACPI_CSRT_DMA_CHANNEL       0x0000
+#define ACPI_CSRT_DMA_CONTROLLER    0x0001
+
+/*******************************************************************************
+ *
+ * DBG2 - Debug Port Table 2
+ *        Version 0 (Both main table and subtables)
+ *
+ * Conforms to "Microsoft Debug Port Table 2 (DBG2)", May 22 2012.
+ *
+ ******************************************************************************/
+
+struct acpi_table_dbg2 {
+	struct acpi_table_header header;	/* Common ACPI table header */
+	u32 info_offset;
+	u32 info_count;
+};
+
+/* Debug Device Information Subtable */
+
+struct acpi_dbg2_device {
+	u8 revision;
+	u16 length;
+	u8 register_count;	/* Number of base_address registers */
+	u16 namepath_length;
+	u16 namepath_offset;
+	u16 oem_data_length;
+	u16 oem_data_offset;
+	u16 port_type;
+	u16 port_subtype;
+	u16 reserved;
+	u16 base_address_offset;
+	u16 address_size_offset;
+	/*
+	 * Data that follows:
+	 *    base_address (required) - Each in 12-byte Generic Address Structure format.
+	 *    address_size (required) - Array of u32 sizes corresponding to each base_address register.
+	 *    Namepath    (required) - Null terminated string. Single dot if not supported.
+	 *    oem_data    (optional) - Length is oem_data_length.
+	 */
+};
+
+/* Types for port_type field above */
+
+#define ACPI_DBG2_SERIAL_PORT       0x8000
+#define ACPI_DBG2_1394_PORT         0x8001
+#define ACPI_DBG2_USB_PORT          0x8002
+#define ACPI_DBG2_NET_PORT          0x8003
+
+/* Subtypes for port_subtype field above */
+
+#define ACPI_DBG2_16550_COMPATIBLE  0x0000
+#define ACPI_DBG2_16550_SUBSET      0x0001
+
+#define ACPI_DBG2_1394_STANDARD     0x0000
+
+#define ACPI_DBG2_USB_XHCI          0x0000
+#define ACPI_DBG2_USB_EHCI          0x0001
+
+/*******************************************************************************
+ *
  * DBGP - Debug Port table
  *        Version 1
  *
include/acpi/actbl3.h +0 -1
index f65a0ed..37781ab 100644
@@ -75,7 +75,6 @@
 /* Reserved table signatures */
 
 #define ACPI_SIG_CSRT           "CSRT"	/* Core System Resources Table */
-#define ACPI_SIG_DBG2           "DBG2"	/* Debug Port table 2 */
 #define ACPI_SIG_MATR           "MATR"	/* Memory Address Translation Table */
 #define ACPI_SIG_MSDM           "MSDM"	/* Microsoft Data Management Table */
 #define ACPI_SIG_WPBT           "WPBT"	/* Windows Platform Binary Table */
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#10 lore raw

PATCH 10/23 ACPICA: Add support for complex _PLD buffers.

In reply to Len Brown

From: Bob Moore <[email protected]>

_PLD (Physical Location of Device) returns a bit-packed buffer that is difficult to parse. This change adds a new interface, AcpiDecodePldBuffer that parses the buffer into a more usable local struct. Also adds macros to both get and set individual fields within the packed _PLD buffer. Adds a new include file, acbuffer.h - which will be expanded to add structs for other ACPI names that return buffers. ACPICA BZ 954.

Emit (in comments) the decoded contents of a static _PLD buffer in order to improve comprehension of this bit-packed buffer.

Add multi-endian support to the _PLD decode routine. Deploy the multi-endian macros to extract data from the _PLD buffer.

---
 drivers/acpi/acpica/aclocal.h  |  22 +++--
 drivers/acpi/acpica/acmacros.h |  29 ++++++-
 drivers/acpi/acpica/utxface.c  |  87 +++++++++++++++++++
 include/acpi/acbuffer.h        | 192 +++++++++++++++++++++++++++++++++++++++++
 include/acpi/acnames.h         |   1 +
 include/acpi/acpixf.h          |   5 ++
 include/acpi/actbl.h           |  12 ++-
 include/acpi/actbl1.h          |  12 ++-
 include/acpi/actbl2.h          |  12 ++-
 include/acpi/actbl3.h          |  12 ++-
 10 files changed, 360 insertions(+), 24 deletions(-)
 create mode 100644 include/acpi/acbuffer.h
drivers/acpi/acpica/aclocal.h +13 -9
index 493529a..c816ee6 100644
@@ -707,15 +707,18 @@ union acpi_parse_value {
 	u8                              disasm_opcode;  /* Subtype used for disassembly */\
 	char                            aml_op_name[16])	/* Op name (debug only) */
 
-#define ACPI_DASM_BUFFER                0x00
-#define ACPI_DASM_RESOURCE              0x01
-#define ACPI_DASM_STRING                0x02
-#define ACPI_DASM_UNICODE               0x03
-#define ACPI_DASM_EISAID                0x04
-#define ACPI_DASM_MATCHOP               0x05
-#define ACPI_DASM_LNOT_PREFIX           0x06
-#define ACPI_DASM_LNOT_SUFFIX           0x07
-#define ACPI_DASM_IGNORE                0x08
+/* Flags for disasm_flags field above */
+
+#define ACPI_DASM_BUFFER                0x00	/* Buffer is a simple data buffer */
+#define ACPI_DASM_RESOURCE              0x01	/* Buffer is a Resource Descriptor */
+#define ACPI_DASM_STRING                0x02	/* Buffer is a ASCII string */
+#define ACPI_DASM_UNICODE               0x03	/* Buffer is a Unicode string */
+#define ACPI_DASM_PLD_METHOD            0x04	/* Buffer is a _PLD method bit-packed buffer */
+#define ACPI_DASM_EISAID                0x05	/* Integer is an EISAID */
+#define ACPI_DASM_MATCHOP               0x06	/* Parent opcode is a Match() operator */
+#define ACPI_DASM_LNOT_PREFIX           0x07	/* Start of a Lnot_equal (etc.) pair of opcodes */
+#define ACPI_DASM_LNOT_SUFFIX           0x08	/* End  of a Lnot_equal (etc.) pair of opcodes */
+#define ACPI_DASM_IGNORE                0x09	/* Not used at this time */
 
 /*
  * Generic operation (for example:  If, While, Store)
@@ -1025,6 +1028,7 @@ struct acpi_port_info {
  ****************************************************************************/
 
 struct acpi_db_method_info {
+	acpi_handle method;
 	acpi_handle main_thread_gate;
 	acpi_handle thread_complete_gate;
 	acpi_thread_id *threads;
drivers/acpi/acpica/acmacros.h +26 -3
index 832b619..a7f68c4 100644
@@ -277,10 +277,33 @@
 
 /* Bitfields within ACPI registers */
 
-#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask)      ((val << pos) & mask)
-#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val)  reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
+#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) \
+	((val << pos) & mask)
 
-#define ACPI_INSERT_BITS(target, mask, source)          target = ((target & (~(mask))) | (source & mask))
+#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) \
+	reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
+
+#define ACPI_INSERT_BITS(target, mask, source) \
+	target = ((target & (~(mask))) | (source & mask))
+
+/* Generic bitfield macros and masks */
+
+#define ACPI_GET_BITS(source_ptr, position, mask) \
+	((*source_ptr >> position) & mask)
+
+#define ACPI_SET_BITS(target_ptr, position, mask, value) \
+	(*target_ptr |= ((value & mask) << position))
+
+#define ACPI_1BIT_MASK      0x00000001
+#define ACPI_2BIT_MASK      0x00000003
+#define ACPI_3BIT_MASK      0x00000007
+#define ACPI_4BIT_MASK      0x0000000F
+#define ACPI_5BIT_MASK      0x0000001F
+#define ACPI_6BIT_MASK      0x0000003F
+#define ACPI_7BIT_MASK      0x0000007F
+#define ACPI_8BIT_MASK      0x000000FF
+#define ACPI_16BIT_MASK     0x0000FFFF
+#define ACPI_24BIT_MASK     0x00FFFFFF
 
 /*
  * An object of type struct acpi_namespace_node can appear in some contexts
drivers/acpi/acpica/utxface.c +87 -0

90 lines not on this page · raw message

include/acpi/acbuffer.h new file +192 -0

192 lines not on this page · raw message

include/acpi/acnames.h +1 -0
index d2f61dd..745dd24e 100644
@@ -63,6 +63,7 @@
 #define METHOD_NAME__PRW        "_PRW"
 #define METHOD_NAME__SRS        "_SRS"
 #define METHOD_NAME__CBA        "_CBA"
+#define METHOD_NAME__PLD        "_PLD"
 
 /* Method names - these methods must appear at the namespace root */
 
include/acpi/acpixf.h +5 -0
index 26a92fc..270517d 100644
@@ -52,6 +52,7 @@
 #include "acconfig.h"
 #include "actypes.h"
 #include "actbl.h"
+#include "acbuffer.h"
 
 extern u8 acpi_gbl_permanent_mmap;
 
@@ -144,6 +145,10 @@ acpi_check_address_range(acpi_adr_space_type space_id,
 			 acpi_physical_address address,
 			 acpi_size length, u8 warn);
 
+acpi_status
+acpi_decode_pld_buffer(u8 *in_buffer,
+		       acpi_size length, struct acpi_pld_info **return_buffer);
+
 /*
  * ACPI Memory management
  */
include/acpi/actbl.h +9 -3
index d54e358..4f94b1d 100644
@@ -79,9 +79,15 @@
 #pragma pack(1)
 
 /*
- * Note about bitfields: The u8 type is used for bitfields in ACPI tables.
- * This is the only type that is even remotely portable. Anything else is not
- * portable, so do not use any other bitfield types.
+ * Note: C bitfields are not used for this reason:
+ *
+ * "Bitfields are great and easy to read, but unfortunately the C language
+ * does not specify the layout of bitfields in memory, which means they are
+ * essentially useless for dealing with packed data in on-disk formats or
+ * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
+ * this decision was a design error in C. Ritchie could have picked an order
+ * and stuck with it." Norman Ramsey.
+ * See http://stackoverflow.com/a/1053662/41661
  */
 
 /*******************************************************************************
include/acpi/actbl1.h +9 -3
index 300d14e..c41d6f9 100644
@@ -79,9 +79,15 @@
 #pragma pack(1)
 
 /*
- * Note about bitfields: The u8 type is used for bitfields in ACPI tables.
- * This is the only type that is even remotely portable. Anything else is not
- * portable, so do not use any other bitfield types.
+ * Note: C bitfields are not used for this reason:
+ *
+ * "Bitfields are great and easy to read, but unfortunately the C language
+ * does not specify the layout of bitfields in memory, which means they are
+ * essentially useless for dealing with packed data in on-disk formats or
+ * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
+ * this decision was a design error in C. Ritchie could have picked an order
+ * and stuck with it." Norman Ramsey.
+ * See http://stackoverflow.com/a/1053662/41661
  */
 
 /*******************************************************************************
include/acpi/actbl2.h +9 -3
index b74476c..1b2b356 100644
@@ -98,9 +98,15 @@
 #pragma pack(1)
 
 /*
- * Note about bitfields: The u8 type is used for bitfields in ACPI tables.
- * This is the only type that is even remotely portable. Anything else is not
- * portable, so do not use any other bitfield types.
+ * Note: C bitfields are not used for this reason:
+ *
+ * "Bitfields are great and easy to read, but unfortunately the C language
+ * does not specify the layout of bitfields in memory, which means they are
+ * essentially useless for dealing with packed data in on-disk formats or
+ * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
+ * this decision was a design error in C. Ritchie could have picked an order
+ * and stuck with it." Norman Ramsey.
+ * See http://stackoverflow.com/a/1053662/41661
  */
 
 /*******************************************************************************
include/acpi/actbl3.h +9 -3
index 37781ab..8c61b5f 100644
@@ -86,9 +86,15 @@
 #pragma pack(1)
 
 /*
- * Note about bitfields: The u8 type is used for bitfields in ACPI tables.
- * This is the only type that is even remotely portable. Anything else is not
- * portable, so do not use any other bitfield types.
+ * Note: C bitfields are not used for this reason:
+ *
+ * "Bitfields are great and easy to read, but unfortunately the C language
+ * does not specify the layout of bitfields in memory, which means they are
+ * essentially useless for dealing with packed data in on-disk formats or
+ * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
+ * this decision was a design error in C. Ritchie could have picked an order
+ * and stuck with it." Norman Ramsey.
+ * See http://stackoverflow.com/a/1053662/41661
  */
 
 /*******************************************************************************
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#11 lore raw

PATCH 11/23 ACPICA: Add struct header support for _FDE, _GRT, _GTM, and _SRT names.

In reply to Len Brown

From: Bob Moore <[email protected]>

Added structs for the buffers related to these predefined names, in acbuffer.h

---
 include/acpi/acbuffer.h | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
include/acpi/acbuffer.h +43 -0
index 2c3b447..a1e45cd 100644
@@ -45,6 +45,11 @@
 #define __ACBUFFER_H__
 
 /*
+ * Contains buffer structures for these predefined names:
+ * _FDE, _GRT, _GTM, _PLD, _SRT
+ */
+
+/*
  * Note: C bitfields are not used for this reason:
  *
  * "Bitfields are great and easy to read, but unfortunately the C language
@@ -56,6 +61,44 @@
  * See http://stackoverflow.com/a/1053662/41661
  */
 
+/* _FDE return value */
+
+struct acpi_fde_info {
+	u32 floppy0;
+	u32 floppy1;
+	u32 floppy2;
+	u32 floppy3;
+	u32 tape;
+};
+
+/*
+ * _GRT return value
+ * _SRT input value
+ */
+struct acpi_grt_info {
+	u16 year;
+	u8 month;
+	u8 day;
+	u8 hour;
+	u8 minute;
+	u8 second;
+	u8 valid;
+	u16 milliseconds;
+	u16 timezone;
+	u8 daylight;
+	u8 reserved[3];
+};
+
+/* _GTM return value */
+
+struct acpi_gtm_info {
+	u32 pio_speed0;
+	u32 dma_speed0;
+	u32 pio_speed1;
+	u32 dma_speed1;
+	u32 flags;
+};
+
 /*
  * Formatted _PLD return value. The minimum size is a package containing
  * one buffer.
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#12 lore raw

PATCH 12/23 ACPICA: Update version to 20120816.

In reply to Len Brown

From: Bob Moore <[email protected]>

Version 20120816.

---
 include/acpi/acpixf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/acpixf.h +1 -1
index 270517d..03457a9 100644
@@ -47,7 +47,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20120711
+#define ACPI_CA_VERSION                 0x20120816
 
 #include "acconfig.h"
 #include "actypes.h"
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#13 lore raw

PATCH 13/23 ACPI: Use ACPICA native way to decode the PLD buffer

In reply to Len Brown

From: Feng Tang <[email protected]>

This patch is on top of the ACPICA 20120816 release, which implemented a native way to decode PLD buffer, so use it instead of leting upper level users do the decoding.

v2: Modify the check for PLD buffer length to reject buffers whose length < 16

---
 drivers/acpi/utils.c    | 11 +++++++----
 include/acpi/acpi_bus.h | 31 +------------------------------
 2 files changed, 8 insertions(+), 34 deletions(-)
drivers/acpi/utils.c +7 -4
index 3e87c9c..462f7e3 100644
@@ -384,7 +384,7 @@ acpi_evaluate_reference(acpi_handle handle,
 EXPORT_SYMBOL(acpi_evaluate_reference);
 
 acpi_status
-acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld *pld)
+acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
 {
 	acpi_status status;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -400,13 +400,16 @@ acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld *pld)
 	if (!output || output->type != ACPI_TYPE_PACKAGE
 	    || !output->package.count
 	    || output->package.elements[0].type != ACPI_TYPE_BUFFER
-	    || output->package.elements[0].buffer.length > sizeof(*pld)) {
+	    || output->package.elements[0].buffer.length < ACPI_PLD_REV1_BUFFER_SIZE) {
 		status = AE_TYPE;
 		goto out;
 	}
 
-	memcpy(pld, output->package.elements[0].buffer.pointer,
-	       output->package.elements[0].buffer.length);
+	status = acpi_decode_pld_buffer(
+			output->package.elements[0].buffer.pointer,
+			output->package.elements[0].buffer.length,
+			pld);
+
 out:
 	kfree(buffer.pointer);
 	return status;
include/acpi/acpi_bus.h +1 -30
index bde976e..0c1fcd4 100644
@@ -54,37 +54,8 @@ acpi_status
 acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event,
 			u32 status_code, struct acpi_buffer *status_buf);
 
-struct acpi_pld {
-	unsigned int revision:7; /* 0 */
-	unsigned int ignore_colour:1; /* 7 */
-	unsigned int colour:24; /* 8 */
-	unsigned int width:16; /* 32 */
-	unsigned int height:16; /* 48 */
-	unsigned int user_visible:1; /* 64 */
-	unsigned int dock:1; /* 65 */
-	unsigned int lid:1; /* 66 */
-	unsigned int panel:3; /* 67 */
-	unsigned int vertical_pos:2; /* 70 */
-	unsigned int horizontal_pos:2; /* 72 */
-	unsigned int shape:4; /* 74 */
-	unsigned int group_orientation:1; /* 78 */
-	unsigned int group_token:8; /* 79 */
-	unsigned int group_position:8; /* 87 */
-	unsigned int bay:1; /* 95 */
-	unsigned int ejectable:1; /* 96 */
-	unsigned int ospm_eject_required:1; /* 97 */
-	unsigned int cabinet_number:8; /* 98 */
-	unsigned int card_cage_number:8; /* 106 */
-	unsigned int reference:1; /* 114 */
-	unsigned int rotation:4; /* 115 */
-	unsigned int order:5; /* 119 */
-	unsigned int reserved:4; /* 124 */
-	unsigned int vertical_offset:16; /* 128 */
-	unsigned int horizontal_offset:16; /* 144 */
-} __attribute__((__packed__));
-
 acpi_status
-acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld *pld);
+acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
 #ifdef CONFIG_ACPI
 
 #include <linux/proc_fs.h>
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#14 lore raw

PATCH 14/23 usb-acpi: Comply with the ACPI API change

In reply to Len Brown

From: Feng Tang <[email protected]>

acpi_get_physical_device_location()'s 2nd argument has been changed in ACPI implementaion, so need a follow-on change in usb_acpi_check_pld().

Cc Matthew Garrett <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Lan Tianyu <[email protected]>
---
 drivers/usb/core/usb-acpi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/core/usb-acpi.c +3 -2
index 8947b20..ce45f55 100644
@@ -52,18 +52,19 @@ out:
 static int usb_acpi_check_pld(struct usb_device *udev, acpi_handle handle)
 {
 	acpi_status status;
-	struct acpi_pld pld;
+	struct acpi_pld_info *pld;
 
 	status = acpi_get_physical_device_location(handle, &pld);
 
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
 
-	if (pld.user_visible)
+	if (pld->user_visible)
 		udev->removable = USB_DEVICE_REMOVABLE;
 	else
 		udev->removable = USB_DEVICE_FIXED;
 
+	ACPI_FREE(pld);
 	return 0;
 }
 
Signature · 1 line
1.7.12.1.396.g16eed7c
maintainer Acked-by on v1 14/23
#15 lore raw

Re: [PATCH 14/23] usb-acpi: Comply with the ACPI API change

Quoted 6 lines · Len Brown

From: Feng Tang <[email protected]>

acpi_get_physical_device_location()'s 2nd argument has been changed in ACPI implementaion, so need a follow-on change in usb_acpi_check_pld().

Quoted 6 lines
Cc Matthew Garrett <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Lan Tianyu <[email protected]>
author reviewer
#16 lore raw

PATCH 15/23 ACPICA: Headers: Add new ACPI 5 HEST notify type values.

In reply to Len Brown

From: Bob Moore <[email protected]>

Add values 5 (CMCI) and 6 (MCE).

---
 include/acpi/actbl1.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/acpi/actbl1.h +3 -1
index c41d6f9..280fc45 100644
@@ -495,7 +495,9 @@ enum acpi_hest_notify_types {
 	ACPI_HEST_NOTIFY_LOCAL = 2,
 	ACPI_HEST_NOTIFY_SCI = 3,
 	ACPI_HEST_NOTIFY_NMI = 4,
-	ACPI_HEST_NOTIFY_RESERVED = 5	/* 5 and greater are reserved */
+	ACPI_HEST_NOTIFY_CMCI = 5,	/* ACPI 5.0 */
+	ACPI_HEST_NOTIFY_MCE = 6,	/* ACPI 5.0 */
+	ACPI_HEST_NOTIFY_RESERVED = 7	/* 7 and greater are reserved */
 };
 
 /* Values for config_write_enable bitfield above */
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#17 lore raw

PATCH 16/23 ACPICA: Table Manager: Merge duplicate code (root table)

In reply to Len Brown

From: Lv Zheng <[email protected]>

Merge/remove duplicate code in the root table resize functions One function is external, the other is internal. Lv Zheng,

ACPICA BZ 846:
https://acpica.org/bugzilla/show_bug.cgi?id=846

---
 drivers/acpi/acpica/tbinstal.c | 20 +++++++++++++-------
 drivers/acpi/acpica/tbxface.c  | 41 +++++------------------------------------
 2 files changed, 18 insertions(+), 43 deletions(-)
drivers/acpi/acpica/tbinstal.c +13 -7
index 74f97d7..70f9d78 100644
@@ -350,6 +350,7 @@ struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
 acpi_status acpi_tb_resize_root_table_list(void)
 {
 	struct acpi_table_desc *tables;
+	u32 table_count;
 
 	ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
 
@@ -363,8 +364,13 @@ acpi_status acpi_tb_resize_root_table_list(void)
 
 	/* Increase the Table Array size */
 
-	tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list.
-				       max_table_count +
+	if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
+		table_count = acpi_gbl_root_table_list.max_table_count;
+	} else {
+		table_count = acpi_gbl_root_table_list.current_table_count;
+	}
+
+	tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
 				       ACPI_ROOT_TABLE_SIZE_INCREMENT) *
 				      sizeof(struct acpi_table_desc));
 	if (!tables) {
@@ -377,8 +383,8 @@ acpi_status acpi_tb_resize_root_table_list(void)
 
 	if (acpi_gbl_root_table_list.tables) {
 		ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
-			    (acpi_size) acpi_gbl_root_table_list.
-			    max_table_count * sizeof(struct acpi_table_desc));
+			    (acpi_size) table_count *
+			    sizeof(struct acpi_table_desc));
 
 		if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
 			ACPI_FREE(acpi_gbl_root_table_list.tables);
@@ -386,9 +392,9 @@ acpi_status acpi_tb_resize_root_table_list(void)
 	}
 
 	acpi_gbl_root_table_list.tables = tables;
-	acpi_gbl_root_table_list.max_table_count +=
-	    ACPI_ROOT_TABLE_SIZE_INCREMENT;
-	acpi_gbl_root_table_list.flags |= (u8)ACPI_ROOT_ORIGIN_ALLOCATED;
+	acpi_gbl_root_table_list.max_table_count =
+	    table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
+	acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
 
 	return_ACPI_STATUS(AE_OK);
 }
drivers/acpi/acpica/tbxface.c +5 -36

58 lines not on this page · raw message

Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#18 lore raw

PATCH 17/23 ACPICA: Update version to 20120913

In reply to Len Brown

From: Bob Moore <[email protected]>

Version 20120913.

---
 include/acpi/acpixf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/acpixf.h +1 -1
index 03457a9..267bfc4 100644
@@ -47,7 +47,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20120816
+#define ACPI_CA_VERSION                 0x20120913
 
 #include "acconfig.h"
 #include "actypes.h"
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#19 lore raw

PATCH 18/23 tools/power/acpi/acpidump: version 20051111

In reply to Len Brown

From: Len Brown <[email protected]>

This is unchanged version 20051111, plus a small bit in DEFINE_ALTERNATE_TYPES to enable building with latest kernel headers.

---
 tools/power/acpi/Makefile   |  15 ++
 tools/power/acpi/acpidump.c | 472 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 487 insertions(+)
 create mode 100644 tools/power/acpi/Makefile
 create mode 100644 tools/power/acpi/acpidump.c
tools/power/acpi/Makefile new file +15 -0
new file mode 100644
index 0000000..faf5ff5
@@ -0,0 +1,15 @@
+PROG=	acpidump
+SRCS=	acpidump.c
+KERNEL_INCLUDE := ../../../include
+CFLAGS += -Wall -Wstrict-prototypes -Os -s -D_LINUX -DDEFINE_ALTERNATE_TYPES -I$(KERNEL_INCLUDE) 
+
+all: acpidump
+
+acpidump : $(SRCS) 
+	$(CC) $(CFLAGS) $(SRCS) -o $(PROG)
+
+CLEANFILES= $(PROG)
+
+clean : 
+	rm -f $(CLEANFILES) $(patsubst %.c,%.o, $(SRCS)) *~
+
tools/power/acpi/acpidump.c new file +472 -0

472 lines not on this page · raw message

Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#20 lore raw

PATCH 19/23 tools/power/acpi/acpidump: version 20060606

In reply to Len Brown

From: Len Brown <[email protected]>

This is unchanged version 20060606, plus a small bit in DEFINE_ALTERNATE_TYPES to enable building with latest kernel headers.

---
 tools/power/acpi/acpidump.c | 97 +++++++++++++++++++++++++++------------------
 1 file changed, 59 insertions(+), 38 deletions(-)
tools/power/acpi/acpidump.c +59 -38
index 3f0a9da..3bb8e82 100644
@@ -1,5 +1,5 @@
 /*
- * (c) Alexey Starikovskiy, Intel, 2005.
+ * (c) Alexey Starikovskiy, Intel, 2005-2006.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -77,16 +77,16 @@ static inline u8 checksum(u8 * buffer, u32 length)
 }
 
 static unsigned long psz, addr, length;
-static int print, connect;
+static int print, connect, skip;
 static u8 select_sig[4];
 
 static unsigned long read_efi_systab( void )
 {
+	char buffer[80];
+	unsigned long addr;
 	FILE *f = fopen("/sys/firmware/efi/systab", "r");
 	if (f) {
-		char buffer[80];
 		while (fgets(buffer, 80, f)) {
-			unsigned long addr;
 			if (sscanf(buffer, "ACPI20=0x%lx", &addr) == 1)
 				return addr;
 		}
@@ -97,13 +97,15 @@ static unsigned long read_efi_systab( void )
 
 static u8 *acpi_map_memory(unsigned long where, unsigned length)
 {
+	unsigned long offset;
+	u8 *there;
 	int fd = open("/dev/mem", O_RDONLY);
 	if (fd < 0) {
 		fprintf(stderr, "acpi_os_map_memory: cannot open /dev/mem\n");
 		exit(1);
 	}
-	unsigned long offset = where % psz;
-	u8 *there = mmap(NULL, length + offset, PROT_READ, MAP_PRIVATE,
+	offset = where % psz;
+	there = mmap(NULL, length + offset, PROT_READ, MAP_PRIVATE,
 			 fd, where - offset);
 	close(fd);
 	if (there == MAP_FAILED) return 0;
@@ -118,10 +120,11 @@ static void acpi_unmap_memory(u8 * there, unsigned length)
 
 static struct acpi_table_header *acpi_map_table(unsigned long where, char *sig)
 {
+	unsigned size;
 	struct acpi_table_header *tbl = (struct acpi_table_header *)
 	    acpi_map_memory(where, sizeof(struct acpi_table_header));
 	if (!tbl || (sig && memcmp(sig, tbl->signature, 4))) return 0;
-	unsigned size = tbl->length;
+	size = tbl->length;
 	acpi_unmap_memory((u8 *) tbl, sizeof(struct acpi_table_header));
 	return (struct acpi_table_header *)acpi_map_memory(where, size);
 }
@@ -133,12 +136,13 @@ static void acpi_unmap_table(struct acpi_table_header *tbl)
 
 static struct acpi_rsdp_descriptor *acpi_scan_for_rsdp(u8 *begin, u32 length)
 {
+	struct acpi_rsdp_descriptor *rsdp;
 	u8 *i, *end = begin + length;
 	/* Search from given start address for the requested length */
 	for (i = begin; i < end; i += ACPI_RSDP_SCAN_STEP) {
 		/* The signature and checksum must both be correct */
 		if (memcmp((char *)i, "RSD PTR ", 8)) continue;
-		struct acpi_rsdp_descriptor *rsdp = (struct acpi_rsdp_descriptor *)i;
+		rsdp = (struct acpi_rsdp_descriptor *)i;
 		/* Signature matches, check the appropriate checksum */
 		if (!checksum((u8 *) rsdp, (rsdp->revision < 2) ?
 			      ACPI_RSDP_CHECKSUM_LENGTH :
@@ -156,9 +160,10 @@ static struct acpi_rsdp_descriptor *acpi_scan_for_rsdp(u8 *begin, u32 length)
 static void acpi_show_data(int fd, u8 * data, int size)
 {
 	char buffer[256];
+	int len;
 	int i, remain = size;
 	while (remain > 0) {
-		int len = snprintf(buffer, 256, "  %04x:", size - remain);
+		len = snprintf(buffer, 256, "  %04x:", size - remain);
 		for (i = 0; i < 16 && i < remain; i++) {
 			len +=
 			    snprintf(&buffer[len], 256 - len, " %02x", data[i]);
@@ -200,6 +205,10 @@ static void write_table(int fd, struct acpi_table_header *tbl, unsigned long add
 			write(fd, tbl, tbl->length);
 		}
 	} else if (!select_done && !memcmp(select_sig, tbl->signature, 4)) {
+		if (skip > 0) {
+			--skip;
+			return;
+		}
 		if (print) {
 			acpi_show_table(fd, tbl, addr);
 		} else {
@@ -265,8 +274,10 @@ no_facs:
 
 static int acpi_dump_SDT(int fd, struct acpi_rsdp_descriptor *rsdp)
 {
-	struct acpi_table_header *tbl = 0;
-	int xsdt = 1;
+	struct acpi_table_header *sdt, *tbl = 0;
+	int xsdt = 1, i, num;
+	char *offset;
+	unsigned long addr;
 	if (rsdp->revision > 1 && rsdp->xsdt_physical_address) {
 		tbl = acpi_map_table(rsdp->xsdt_physical_address, "XSDT");
 	}
@@ -275,17 +286,17 @@ static int acpi_dump_SDT(int fd, struct acpi_rsdp_descriptor *rsdp)
 		tbl = acpi_map_table(rsdp->rsdt_physical_address, "RSDT");
 	}
 	if (!tbl) return 0;
-	struct acpi_table_header *sdt = malloc(tbl->length);
+	sdt = malloc(tbl->length);
 	memcpy(sdt, tbl, tbl->length);
 	acpi_unmap_table(tbl);
 	if (checksum((u8 *)sdt, sdt->length))
 		fprintf(stderr, "Wrong checksum for %s!\n", (xsdt)?"XSDT":"RSDT");
-	int i, num = (sdt->length - sizeof(struct acpi_table_header))/((xsdt)?sizeof(u64):sizeof(u32));
-	char *offset = (char *)sdt + sizeof(struct acpi_table_header);
-	unsigned long addr;
+	num = (sdt->length - sizeof(struct acpi_table_header))/((xsdt)?sizeof(u64):sizeof(u32));
+	offset = (char *)sdt + sizeof(struct acpi_table_header);
 	for (i = 0; i < num; ++i, offset += ((xsdt) ? sizeof(u64) : sizeof(u32))) {
 		addr = (xsdt) ? (unsigned long)(*(u64 *)offset):
 				(unsigned long)(*(u32 *)offset);
+		if (!addr) continue;
 		tbl = acpi_map_table(addr, 0);
 		if (!tbl) continue;
 		if (!memcmp(tbl->signature, FADT_SIG, 4)) {
@@ -330,29 +341,36 @@ static void usage(const char *progname)
 	puts("\t--binary or -b -- dump data in binary form rather than in hex-dump format");
 	puts("\t--length 0x456 or -l 0x456 -- works only with --addr, dump physical memory"
 		"\n\t\tregion without trying to understand it's contents");
+	puts("\t--skip 2 or -s 2 -- skip 2 tables of the given name and output only 3rd one");
 	puts("\t--help or -h -- this help message");
 	exit(0);
 }
 
+static struct option long_options[] = {
+	{"addr", 1, 0, 0},
+	{"table", 1, 0, 0},
+	{"output", 1, 0, 0},
+	{"binary", 0, 0, 0},
+	{"length", 1, 0, 0},
+	{"skip", 1, 0, 0},
+	{"help", 0, 0, 0},
+	{0, 0, 0, 0}
+};
 int main(int argc, char **argv)
 {
+	int option_index, c, fd;
+	u8 *raw;
+	struct acpi_rsdp_descriptor rsdpx, *x = 0;
+	char *filename = 0;
+	char buff[80];
 	memset(select_sig, 0, 4);
 	print = 1;
 	connect = 0;
-	char *filename = 0;
 	addr = length = 0;
+	skip = 0;
 	while (1) {
-		int option_index = 0;
-		static struct option long_options[] = {
-			{"addr", 1, 0, 0},
-			{"table", 1, 0, 0},
-			{"output", 1, 0, 0},
-			{"binary", 0, 0, 0},
-			{"length", 1, 0, 0},
-			{"help", 0, 0, 0},
-			{0, 0, 0, 0}
-		};
-		int c = getopt_long(argc, argv, "a:t:o:bl:h",
+		option_index = 0;
+		c = getopt_long(argc, argv, "a:t:o:bl:s:h",
 				    long_options, &option_index);
 		if (c == -1)
 			break;
@@ -376,6 +394,9 @@ int main(int argc, char **argv)
 				length = strtoul(optarg, (char **)NULL, 16);
 				break;
 			case 5:
+				skip = strtoul(optarg, (char **)NULL, 10);
+				break;
+			case 6:
 				usage(argv[0]);
 				exit(0);
 			}
@@ -395,6 +416,9 @@ int main(int argc, char **argv)
 		case 'l':
 			length = strtoul(optarg, (char **)NULL, 16);
 			break;
+		case 's':
+			skip = strtoul(optarg, (char **)NULL, 10);
+			break;
 		case 'h':
 			usage(argv[0]);
 			exit(0);
@@ -404,20 +428,19 @@ int main(int argc, char **argv)
 			exit(0);
 		}
 	}
-	
-	int fd = STDOUT_FILENO;
+
+	fd = STDOUT_FILENO;
 	if (filename) {
 		fd = creat(filename, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
 		if (fd < 0)
 			return fd;
 	}
-	
+
 	if (!select_sig[0] && !print) {
 		connect = 1;
 	}
-	
+
 	psz = sysconf(_SC_PAGESIZE);
-	u8 *raw;
 	if (length && addr) {
 		/* We know length and address, it means we just want a memory dump */
 		if (!(raw = acpi_map_memory(addr, length)))
@@ -426,7 +449,7 @@ int main(int argc, char **argv)
 		acpi_unmap_memory(raw, length);
 		return 0;
 	}
-	
+
 	length = sizeof(struct acpi_rsdp_descriptor);
 	if (!addr) {
 		addr = read_efi_systab();
@@ -435,12 +458,11 @@ int main(int argc, char **argv)
 			length = ACPI_HI_RSDP_WINDOW_SIZE;
 		}
 	}
-	
-	struct acpi_rsdp_descriptor rsdpx, *x = 0;
+
 	if (!(raw = acpi_map_memory(addr, length)) ||
-	    !(x = acpi_scan_for_rsdp(raw, length))) 
+	    !(x = acpi_scan_for_rsdp(raw, length)))
 		goto not_found;
-	
+
 	/* Find RSDP and print all found tables */
 	memcpy(&rsdpx, x, sizeof(struct acpi_rsdp_descriptor));
 	acpi_unmap_memory(raw, length);
@@ -454,7 +476,6 @@ int main(int argc, char **argv)
 		write(fd, x, (rsdpx.revision < 2) ?
 			ACPI_RSDP_CHECKSUM_LENGTH : ACPI_RSDP_XCHECKSUM_LENGTH);
 	} else if (!select_sig[0] || !memcmp("RSD PTR ", select_sig, 4)) {
-		char buff[80];
 		addr += (long)x - (long)raw;
 		length = snprintf(buff, 80, "RSD PTR @ %p\n", (void *)addr);
 		write(fd, buff, length);
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#21 lore raw

PATCH 20/23 tools/power/acpi/acpidump: version 20070714

In reply to Len Brown

From: Len Brown <[email protected]>

This is unchanged version 20070714, plus a small bit in DEFINE_ALTERNATE_TYPES to enable building with latest kernel headers.

---
 tools/power/acpi/Makefile   |   7 ++-
 tools/power/acpi/acpidump.c | 127 ++++++++++++++++++++++++++++++++++----------
 2 files changed, 103 insertions(+), 31 deletions(-)
tools/power/acpi/Makefile +3 -4
index faf5ff5..dad79a6 100644
@@ -1,11 +1,10 @@
-PROG=	acpidump
+PROG= acpidump
 SRCS=	acpidump.c
 KERNEL_INCLUDE := ../../../include
-CFLAGS += -Wall -Wstrict-prototypes -Os -s -D_LINUX -DDEFINE_ALTERNATE_TYPES -I$(KERNEL_INCLUDE) 
+CFLAGS += -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Os -s -D_LINUX -DDEFINE_ALTERNATE_TYPES -I$(KERNEL_INCLUDE) 
 
 all: acpidump
-
-acpidump : $(SRCS) 
+$(PROG) : $(SRCS)
 	$(CC) $(CFLAGS) $(SRCS) -o $(PROG)
 
 CLEANFILES= $(PROG)
tools/power/acpi/acpidump.c +100 -27

188 lines not on this page · raw message

Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#22 lore raw

PATCH 21/23 tools/power/acpi/acpidump: version 20071116

In reply to Len Brown

From: Len Brown <[email protected]>

This is unchanged version 20071116, plus a small bit in DEFINE_ALTERNATE_TYPES to enable building with latest kernel headers.

---
 tools/power/acpi/acpidump.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tools/power/acpi/acpidump.c +5 -2
index 8e5e194..a63dee9 100644
@@ -540,8 +540,11 @@ int main(int argc, char **argv)
 	if (connect) {
 		lseek(fd, sizeof(struct acpi_rsdp_descriptor), SEEK_SET);
 	}
-	if (!acpi_dump_XSDT(fd, &rsdpx))
-		goto not_found;
+	if (rsdpx.revision > 1 && rsdpx.xsdt_physical_address) {
+		/* ACPIDUMP uses xsdt table */
+		if (!acpi_dump_XSDT(fd, &rsdpx))
+			goto not_found;
+	}
 	if (!acpi_dump_RSDT(fd, &rsdpx))
 		goto not_found;
 	if (connect) {
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#23 lore raw

PATCH 22/23 tools/power/acpi/acpidump: version 20101221 - find dynamic tables in sysfs

In reply to Len Brown

From: Len Brown <[email protected]>

This is unchanged version 20101221, plus a small bit in DEFINE_ALTERNATE_TYPES to enable building with latest kernel headers.

This version finds dynamic tables exported by Linux in /sys/firmware/acpi/tables/dynamic

---
 tools/power/acpi/acpidump.c | 187 +++++++++++++++++++++-----------------------
 1 file changed, 89 insertions(+), 98 deletions(-)
tools/power/acpi/acpidump.c +89 -98
index a63dee9..0777987 100644
@@ -1,6 +1,5 @@
 /*
  * (c) Alexey Starikovskiy, Intel, 2005-2006.
- * (c) Len Brown, Intel, 2007.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -63,6 +62,8 @@ typedef long long			s64;
 #include <unistd.h>
 #include <getopt.h>
 
+#include <sys/types.h>
+#include <dirent.h>
 
 #include <acpi/acconfig.h>
 #include <acpi/platform/acenv.h>
@@ -186,40 +187,6 @@ static void acpi_show_data(int fd, u8 * data, int size)
 /*
  * Output ACPI table
  */
-
-#define MAX_TABLES 128
-int next_table_dump;
-u64 dumped_tables[MAX_TABLES];
-
-void
-set_table_dumped(u64 address) {
-	if (next_table_dump >= MAX_TABLES) {
-		printf("increase MAX_TABLES\n");
-		exit(1);
-	}
-	dumped_tables[next_table_dump++] = address;
-}
-
-/*
- * list the tables as they are dumped
- * check the list so that they are not dumped twice.
- *
- * this is needed because we follow both the XSDT and RSDT
- * which generally point to all duplicate tables
- * except the FADT
- */
-int
-check_table_dumped(u64 address) {
-	int i;
-
-	for (i = 0; i < MAX_TABLES; ++i) {
-		if (address == dumped_tables[i])
-			return 1;
-		if (dumped_tables[i] == 0)
-			return 0;
-	}
-	return 0;
-}
 static void acpi_show_table(int fd, struct acpi_table_header *table, unsigned long addr)
 {
 	char buff[80];
@@ -233,10 +200,6 @@ static void acpi_show_table(int fd, struct acpi_table_header *table, unsigned lo
 static void write_table(int fd, struct acpi_table_header *tbl, unsigned long addr)
 {
 	static int select_done = 0;
-
-	if (check_table_dumped((u64)addr))
-		return;
-
 	if (!select_sig[0]) {
 		if (print) {
 			acpi_show_table(fd, tbl, addr);
@@ -255,7 +218,6 @@ static void write_table(int fd, struct acpi_table_header *tbl, unsigned long add
 		}
 		select_done = 1;
 	}
-	set_table_dumped((u64) addr);
 }
 
 static void acpi_dump_FADT(int fd, struct acpi_table_header *tbl, unsigned long xaddr) {
@@ -312,26 +274,30 @@ no_facs:
 	write_table(fd, (struct acpi_table_header *)&x, xaddr);
 }
 
-
-static int acpi_dump_RSDT(int fd, struct acpi_rsdp_descriptor *rsdp)
+static int acpi_dump_SDT(int fd, struct acpi_rsdp_descriptor *rsdp)
 {
 	struct acpi_table_header *sdt, *tbl = 0;
-	int i, num;
+	int xsdt = 1, i, num;
 	char *offset;
 	unsigned long addr;
-
-	tbl = acpi_map_table(rsdp->rsdt_physical_address, "RSDT");
+	if (rsdp->revision > 1 && rsdp->xsdt_physical_address) {
+		tbl = acpi_map_table(rsdp->xsdt_physical_address, "XSDT");
+	}
+	if (!tbl && rsdp->rsdt_physical_address) {
+		xsdt = 0;
+		tbl = acpi_map_table(rsdp->rsdt_physical_address, "RSDT");
+	}
 	if (!tbl) return 0;
-
 	sdt = malloc(tbl->length);
 	memcpy(sdt, tbl, tbl->length);
 	acpi_unmap_table(tbl);
 	if (checksum((u8 *)sdt, sdt->length))
-		fprintf(stderr, "Wrong checksum for %s!\n", "RSDT");
-	num = (sdt->length - sizeof(struct acpi_table_header))/sizeof(u32);
+		fprintf(stderr, "Wrong checksum for %s!\n", (xsdt)?"XSDT":"RSDT");
+	num = (sdt->length - sizeof(struct acpi_table_header))/((xsdt)?sizeof(u64):sizeof(u32));
 	offset = (char *)sdt + sizeof(struct acpi_table_header);
-	for (i = 0; i < num; ++i, offset += sizeof(u32)) {
-		addr = (unsigned long)(*(u32 *)offset);
+	for (i = 0; i < num; ++i, offset += ((xsdt) ? sizeof(u64) : sizeof(u32))) {
+		addr = (xsdt) ? (unsigned long)(*(u64 *)offset):
+				(unsigned long)(*(u32 *)offset);
 		if (!addr) continue;
 		tbl = acpi_map_table(addr, 0);
 		if (!tbl) continue;
@@ -339,66 +305,92 @@ static int acpi_dump_RSDT(int fd, struct acpi_rsdp_descriptor *rsdp)
 			acpi_dump_FADT(fd, tbl, addr);
 		} else {
 			if (checksum((u8 *)tbl, tbl->length))
-				fprintf(stderr, "Wrong checksum for %.4s!\n", tbl->signature);
+				fprintf(stderr, "Wrong checksum for generic table!\n");
 			write_table(fd, tbl, addr);
 		}
 		acpi_unmap_table(tbl);
 		if (connect) {
-			(*(u32*)offset) = lseek(fd, 0, SEEK_CUR);
+			if (xsdt)
+				(*(u64*)offset) = lseek(fd, 0, SEEK_CUR);
+			else
+				(*(u32*)offset) = lseek(fd, 0, SEEK_CUR);
 		}
 	}
-	addr = (unsigned long)rsdp->rsdt_physical_address;
-	if (connect) {
-		rsdp->rsdt_physical_address = lseek(fd, 0, SEEK_CUR);
+	if (xsdt) {
+		addr = (unsigned long)rsdp->xsdt_physical_address;
+		if (connect) {
+			rsdp->xsdt_physical_address = lseek(fd, 0, SEEK_CUR);
+		}
+	} else {
+		addr = (unsigned long)rsdp->rsdt_physical_address;
+		if (connect) {
+			rsdp->rsdt_physical_address = lseek(fd, 0, SEEK_CUR);
+		}
 	}
 	write_table(fd, sdt, addr);
 	free (sdt);
 	return 1;
 }
 
+#define DYNAMIC_SSDT	"/sys/firmware/acpi/tables/dynamic"
 
-static int acpi_dump_XSDT(int fd, struct acpi_rsdp_descriptor *rsdp)
+static void acpi_dump_dynamic_SSDT(int fd)
 {
-	struct acpi_table_header *sdt, *tbl = 0;
-	int i, num;
-	char *offset;
-	unsigned long addr;
-	if (rsdp->revision > 1 && rsdp->xsdt_physical_address) {
-		tbl = acpi_map_table(rsdp->xsdt_physical_address, "XSDT");
+	struct stat file_stat;
+	char filename[256], *ptr;
+	DIR *tabledir;
+	struct dirent *entry;
+	FILE *fp;
+	int count, readcount, length;
+	struct acpi_table_header table_header, *ptable;
+
+	if (stat(DYNAMIC_SSDT, &file_stat) == -1) {
+		/* The directory doesn't exist */
+		return;
 	}
-	if (!tbl) return 0;
-
-	sdt = malloc(tbl->length);
-	memcpy(sdt, tbl, tbl->length);
-	acpi_unmap_table(tbl);
-	if (checksum((u8 *)sdt, sdt->length))
-		fprintf(stderr, "Wrong checksum for %s!\n", "XSDT");
-	num = (sdt->length - sizeof(struct acpi_table_header))/sizeof(u64);
-	offset = (char *)sdt + sizeof(struct acpi_table_header);
-	for (i = 0; i < num; ++i, offset += sizeof(u64)) {
-		addr = (unsigned long)(*(u64 *)offset);
-		if (!addr) continue;
-		tbl = acpi_map_table(addr, 0);
-		if (!tbl) continue;
-		if (!memcmp(tbl->signature, FADT_SIG, 4)) {
-			acpi_dump_FADT(fd, tbl, addr);
-		} else {
-			if (checksum((u8 *)tbl, tbl->length))
-				fprintf(stderr, "Wrong checksum for %.4s\n", tbl->signature);
-			write_table(fd, tbl, addr);
+	tabledir = opendir(DYNAMIC_SSDT);
+	if(!tabledir){
+		/*can't open the directory */
+		return;
+         }
+
+	while ((entry = readdir(tabledir)) != 0){
+		/* skip the file of . /.. */
+		if (entry->d_name[0] == '.')
+			continue;
+
+		sprintf(filename, "%s/%s", DYNAMIC_SSDT, entry->d_name);
+		fp = fopen(filename, "r");
+		if (fp == NULL) {
+			fprintf(stderr, "Can't open the file of %s\n",
+						filename);
+			continue;
 		}
-		acpi_unmap_table(tbl);
-		if (connect) {
-			(*(u64*)offset) = lseek(fd, 0, SEEK_CUR);
+		/* Read the Table header to parse the table length */
+		count = fread(&table_header, 1, sizeof(struct acpi_table_header), fp);
+		if (count < sizeof(table_header)) {
+			/* the length is lessn than ACPI table header. skip it */
+			fclose(fp);
+			continue;
 		}
+		length = table_header.length;
+		ptr = malloc(table_header.length);
+		fseek(fp, 0, SEEK_SET);
+		readcount = 0;
+		while(!feof(fp) && readcount < length) {
+			count = fread(ptr + readcount, 1, 256, fp);
+			readcount += count;
+		}
+		fclose(fp);
+		ptable = (struct acpi_table_header *) ptr;
+		if (checksum((u8 *) ptable, ptable->length))
+			fprintf(stderr, "Wrong checksum "
+					"for dynamic SSDT table!\n");
+		write_table(fd, ptable, 0);
+		free(ptr);
 	}
-	addr = (unsigned long)rsdp->xsdt_physical_address;
-	if (connect) {
-		rsdp->xsdt_physical_address = lseek(fd, 0, SEEK_CUR);
-	}
-	write_table(fd, sdt, addr);
-	free (sdt);
-	return 1;
+	closedir(tabledir);
+	return;
 }
 
 static void usage(const char *progname)
@@ -518,6 +510,7 @@ int main(int argc, char **argv)
 			goto not_found;
 		write(fd, raw, length);
 		acpi_unmap_memory(raw, length);
+		close(fd);
 		return 0;
 	}
 
@@ -540,12 +533,7 @@ int main(int argc, char **argv)
 	if (connect) {
 		lseek(fd, sizeof(struct acpi_rsdp_descriptor), SEEK_SET);
 	}
-	if (rsdpx.revision > 1 && rsdpx.xsdt_physical_address) {
-		/* ACPIDUMP uses xsdt table */
-		if (!acpi_dump_XSDT(fd, &rsdpx))
-			goto not_found;
-	}
-	if (!acpi_dump_RSDT(fd, &rsdpx))
+	if (!acpi_dump_SDT(fd, &rsdpx))
 		goto not_found;
 	if (connect) {
 		lseek(fd, 0, SEEK_SET);
@@ -560,8 +548,11 @@ int main(int argc, char **argv)
 		buff[0] = '\n';
 		write(fd, buff, 1);
 	}
+	acpi_dump_dynamic_SSDT(fd);
+	close(fd);
 	return 0;
 not_found:
+	close(fd);
 	fprintf(stderr, "ACPI tables were not found. If you know location "
 		"of RSD PTR table (from dmesg, etc), "
 		"supply it with either --addr or -a option\n");
Signature · 1 line
1.7.12.1.396.g16eed7c
author reviewer
#24 lore raw

PATCH 23/23 tools/power/acpi/acpidump: create acpidump(8), local make install targets

In reply to Len Brown

From: Len Brown <[email protected]>

---
 tools/power/acpi/Makefile   |  4 +++
 tools/power/acpi/acpidump.8 | 59 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 tools/power/acpi/acpidump.8
tools/power/acpi/Makefile +4 -0
index dad79a6..6b9cf7a 100644
@@ -12,3 +12,7 @@ CLEANFILES= $(PROG)
 clean : 
 	rm -f $(CLEANFILES) $(patsubst %.c,%.o, $(SRCS)) *~
 
+install :
+	install acpidump /usr/bin/acpidump
+	install acpidump.8 /usr/share/man/man8
+
tools/power/acpi/acpidump.8 new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
1.7.12.1.396.g16eed7c