Skip to contentSkip to conversation

ACPICA: 20140627 Release

PATCH New Lv Zheng 1 participant 26 messages Jul 8, 2014

Subsystems (2)
lore
Share & tools
lore

Lv Zheng

author
#0 lore raw

cover ACPICA: 20140627 Release

The previous cover letter contains a wrong message ID, this cover is re-sent to make a thread top of the 20140627 release patches.

The 20140627 ACPICA kernel-resident subsystem updates are linuxized based on the pm/linux-next branch to form this patchset.

The patchset has passed the following build/boot tests. Build tests are performed as follows:
1. i386 + default + COFNIG_ACPI=y
2. i386 + allyes + CONFIG_ACPI=y
3. i386 + default + COFNIG_ACPI=n
4. i386 + allyes + CONFIG_ACPI=n
5. x86_64 + default + COFNIG_ACPI=y
6. x86_64 + allyes + CONFIG_ACPI=y
7. x86_64 + default + COFNIG_ACPI=n
8. x86_64 + allyes + CONFIG_ACPI=n
Boot tests are performed as follows:
1. i386 + default + COFNIG_ACPI=y
2. x86_64 + default + COFNIG_ACPI=y
Where:
1. i386: machine named as "Dell Inspiron Mini 1010"
2. x86_64: machine named as "HP Compaq 8200 Elite SFF PC"
3. default: kernel configuration with following items enabled:
All hardware drivers related to the machines of i386/x86_64 All drivers/acpi configurations
All platform drivers

Bob Moore (2):
ACPICA: utprint/oslibcfs: cleanup - no functional change.
ACPICA: Update version to 20140627.

David E. Box (3):
ACPICA: Utilities: Fix memory leak in acpi_ut_copy_iobject_to_iobject
ACPICA: Utilities: Validate full RSDP header
ACPICA: Namespace: Properly null terminate objects detached from a
namespace node

Lv Zheng (20):
ACPICA: acpidump: Add support for ACPI 1.0 GUID in Linux
ACPICA: Utilities: Fix an issue with non-native ACPI_IS_PRINT()
ACPICA: Utilities: Add support to read table from files.
ACPICA: OSL: Update environments to improve portability.
ACPICA: Utilities: Cleanup DEFINE_ACPI_GLOBALS by moving
acpi_ut_init_global() from utglobal.c to utinit.c.
ACPICA: OSL: Cleanup acpi_os_printf()/acpi_os_vprintf() stubs.
ACPICA: OSL: Add portable file IO to improve portability.
ACPICA: Utilities: Add formatted printing APIs.
ACPICA: Utilities: Introduce acpi_log_error() to improve portability.
ACPICA: Application: Enhance ACPI_USAGE_xxx/ACPI_OPTION with
acpi_os_printf() to improve portability.
ACPICA: Common: Enhance cm_get_file_size() to improve portability.
ACPICA: Common: Enhance acpi_getopt() to improve portability.
ACPICA: acpidump: Add memory/string OSL usage to improve portability.
ACPICA: acpidump: Remove exit() from generic layer to improve
portability.
ACPICA: acpidump: Replace file IOs with new APIs to improve
portability.
ACPICA: acpidump: Reduce freopen() invocations to improve
portability.
ACPICA: OSL: Update acpidump to reduce source code differences.
ACPICA: Executer: Fix trivial issues in
acpi_get_serial_access_bytes().
ACPICA: Hardware: back port of a recursive locking fix.
ACPICA: Tables: Merge DMAR table structure updates.

 drivers/acpi/acpica/Makefile                       |    2 +-
 drivers/acpi/acpica/acapps.h                       |    9 +-
 drivers/acpi/acpica/acdebug.h                      |    3 -
 drivers/acpi/acpica/acglobal.h                     |    8 +-
 drivers/acpi/acpica/acutils.h                      |   39 +-
 drivers/acpi/acpica/exfield.c                      |    4 +-
 drivers/acpi/acpica/hwregs.c                       |    3 +-
 drivers/acpi/acpica/nsobject.c                     |   11 +
 drivers/acpi/acpica/utbuffer.c                     |  128 ++
 drivers/acpi/acpica/utcopy.c                       |    6 +
 drivers/acpi/acpica/utdebug.c                      |   26 +
 drivers/acpi/acpica/utfileio.c                     |  332 +++++
 drivers/acpi/acpica/utglobal.c                     |  146 ---
 drivers/acpi/acpica/utinit.c                       |  145 +++
 drivers/acpi/acpica/utprint.c                      |  661 ++++++++++
 include/acpi/acpiosxf.h                            |   31 +
 include/acpi/acpixf.h                              |   22 +-
 include/acpi/actbl2.h                              |    2 +-
 include/acpi/actypes.h                             |   14 +
 include/acpi/platform/acenv.h                      |   53 +-
 tools/power/acpi/Makefile                          |    5 +
 tools/power/acpi/common/cmfsize.c                  |   20 +-
 tools/power/acpi/common/getopt.c                   |   14 +-
 .../acpi/os_specific/service_layers/oslibcfs.c     |  214 ++++
 .../acpi/os_specific/service_layers/oslinuxtbl.c   |   48 +-
 .../acpi/os_specific/service_layers/osunixxf.c     | 1311 ++++++++++++++++++++
 tools/power/acpi/tools/acpidump/acpidump.h         |    3 +-
 tools/power/acpi/tools/acpidump/apdump.c           |  108 +-
 tools/power/acpi/tools/acpidump/apfiles.c          |   92 +-
 tools/power/acpi/tools/acpidump/apmain.c           |   96 +-
 30 files changed, 3216 insertions(+), 340 deletions(-)
 create mode 100644 drivers/acpi/acpica/utfileio.c
 create mode 100644 drivers/acpi/acpica/utprint.c
 create mode 100644 tools/power/acpi/os_specific/service_layers/oslibcfs.c
 create mode 100644 tools/power/acpi/os_specific/service_layers/osunixxf.c
Signature · 1 line
1.7.10
author
#1 lore raw

PATCH 1/25 ACPICA: Utilities: Fix memory leak in acpi_ut_copy_iobject_to_iobject

From: "David E. Box" <[email protected]>

Adds return status check on copy routines to delete the allocated destination object if either copy fails. Reported by Colin Ian King on bugs.acpica.org, Bug 1087.
The last applicable commit:
Commit: 3371c19c294a4cb3649aa4e84606be8a1d999e61
Subject: ACPICA: Remove ACPI_GET_OBJECT_TYPE macro

Reference: https://bugs.acpica.org/show_bug.cgi?id=1087

---
 drivers/acpi/acpica/utcopy.c |    6 ++++++
 1 file changed, 6 insertions(+)
drivers/acpi/acpica/utcopy.c +6 -0
index 270c164..ff601c0 100644
@@ -1001,5 +1001,11 @@ acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
 		status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
 	}
 
+	/* Delete the allocated object if copy failed */
+
+	if (ACPI_FAILURE(status)) {
+		acpi_ut_remove_reference(*dest_desc);
+	}
+
 	return_ACPI_STATUS(status);
 }
Signature · 1 line
1.7.10
author
#2 lore raw

PATCH 2/25 ACPICA: acpidump: Add support for ACPI 1.0 GUID in Linux

In reply to Lv Zheng

For older EFI platforms, searches for the RSDP using ACPI 1.0 GUID if the 2.0 GUID search fails.

---
 .../acpi/os_specific/service_layers/oslinuxtbl.c   |   48 +++++++++++++++++---
 1 file changed, 41 insertions(+), 7 deletions(-)
tools/power/acpi/os_specific/service_layers/oslinuxtbl.c +41 -7
index 28c5200..0dc2485 100644
@@ -77,6 +77,9 @@ osl_map_table(acpi_size address,
 
 static void osl_unmap_table(struct acpi_table_header *table);
 
+static acpi_physical_address
+osl_find_rsdp_via_efi_by_keyword(FILE * file, const char *keyword);
+
 static acpi_physical_address osl_find_rsdp_via_efi(void);
 
 static acpi_status osl_load_rsdp(void);
@@ -417,6 +420,38 @@ acpi_os_get_table_by_index(u32 index,
 
 /******************************************************************************
  *
+ * FUNCTION:    osl_find_rsdp_via_efi_by_keyword
+ *
+ * PARAMETERS:  keyword         - Character string indicating ACPI GUID version
+ *                                in the EFI table
+ *
+ * RETURN:      RSDP address if found
+ *
+ * DESCRIPTION: Find RSDP address via EFI using keyword indicating the ACPI
+ *              GUID version.
+ *
+ *****************************************************************************/
+
+static acpi_physical_address
+osl_find_rsdp_via_efi_by_keyword(FILE * file, const char *keyword)
+{
+	char buffer[80];
+	unsigned long long address = 0;
+	char format[32];
+
+	snprintf(format, 32, "%s=%s", keyword, "%llx");
+	fseek(file, 0, SEEK_SET);
+	while (fgets(buffer, 80, file)) {
+		if (sscanf(buffer, format, &address) == 1) {
+			break;
+		}
+	}
+
+	return ((acpi_physical_address) (address));
+}
+
+/******************************************************************************
+ *
  * FUNCTION:    osl_find_rsdp_via_efi
  *
  * PARAMETERS:  None
@@ -430,20 +465,19 @@ acpi_os_get_table_by_index(u32 index,
 static acpi_physical_address osl_find_rsdp_via_efi(void)
 {
 	FILE *file;
-	char buffer[80];
-	unsigned long address = 0;
+	acpi_physical_address address = 0;
 
 	file = fopen(EFI_SYSTAB, "r");
 	if (file) {
-		while (fgets(buffer, 80, file)) {
-			if (sscanf(buffer, "ACPI20=0x%lx", &address) == 1) {
-				break;
-			}
+		address = osl_find_rsdp_via_efi_by_keyword(file, "ACPI20");
+		if (!address) {
+			address =
+			    osl_find_rsdp_via_efi_by_keyword(file, "ACPI");
 		}
 		fclose(file);
 	}
 
-	return ((acpi_physical_address) (address));
+	return (address);
 }
 
 /******************************************************************************
Signature · 1 line
1.7.10
author
#3 lore raw

PATCH 3/25 ACPICA: Utilities: Fix an issue with non-native ACPI_IS_PRINT()

In reply to Lv Zheng

An error was found in the ACPICA provided non-native ACPI_IS_PRINT() causing the following difference with the native isprint() implementation:
The GNU libc isprint('\n') test result:
isprint(0x20) is FALSE
The Linux kernel isprint('\n') test result:
ACPI: isprint(0x20) is FALSE
The _acpi_ctype isprint('\n') test result:
isprint(0x20) is TRUE

The ACPI_IS_PRINT() macro generated for _acpi_ctype is wrong. It should use _ACPI_XS instead of _ACPI_SP. _ACPI_XS is white space only. Other space characters should be non printable.

This patch fixes this issue. For OSPMs that are using native standard isprint() implementations, this patch is a no-op. Lv Zheng.

---
 drivers/acpi/acpica/acutils.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpica/acutils.h +1 -1
index 1e256c5..caeb81a 100644
@@ -257,7 +257,7 @@ extern const u8 _acpi_ctype[];
 #define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
 #define ACPI_IS_UPPER(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
 #define ACPI_IS_LOWER(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
-#define ACPI_IS_PRINT(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
+#define ACPI_IS_PRINT(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
 #define ACPI_IS_ALPHA(c)  (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
 
 #endif				/* !ACPI_USE_SYSTEM_CLIBRARY */
Signature · 1 line
1.7.10
author
#4 lore raw

PATCH 4/25 ACPICA: Utilities: Add support to read table from files.

In reply to Lv Zheng

This patch is only useful for ACPICA applications, most of which are not shipped in the Linux kernel.
After the new table reading utility functions are well tested, acpidump can also switch to use the generic acpi_ut_read_table_xxx() APIs. Currently this patch is no-op as acpidump does not link to the new APIs.

---
 drivers/acpi/acpica/acdebug.h  |    3 -
 drivers/acpi/acpica/acutils.h  |    8 +
 drivers/acpi/acpica/utfileio.c |  337 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 345 insertions(+), 3 deletions(-)
 create mode 100644 drivers/acpi/acpica/utfileio.c
drivers/acpi/acpica/acdebug.h +0 -3
Index: linux-acpica/drivers/acpi/acpica/acdebug.h
===================================================================
@@ -233,9 +233,6 @@ acpi_status acpi_db_load_acpi_table(char
 acpi_status
 acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table);
 
-acpi_status
-acpi_db_read_table_from_file(char *filename, struct acpi_table_header **table);
-
 /*
  * dbhistry - debugger HISTORY command
  */
drivers/acpi/acpica/acutils.h +8 -0
Index: linux-acpica/drivers/acpi/acpica/acutils.h
===================================================================
@@ -394,6 +394,14 @@ acpi_ut_execute_power_methods(struct acp
 			      u8 method_count, u8 *out_values);
 
 /*
+ * utfileio - file operations
+ */
+#ifdef ACPI_APPLICATION
+acpi_status
+acpi_ut_read_table_from_file(char *filename, struct acpi_table_header **table);
+#endif
+
+/*
  * utids - device ID support
  */
 acpi_status
drivers/acpi/acpica/utfileio.c new file +337 -0

337 lines not on this page · raw message

drivers/acpi/acpica/Makefile +1 -1
Index: linux-acpica/drivers/acpi/acpica/Makefile
===================================================================
@@ -175,5 +175,5 @@ acpi-y +=		\
 	utxferror.o	\
 	utxfmutex.o
 
-acpi-$(ACPI_FUTURE_USAGE) += uttrack.o utcache.o
+acpi-$(ACPI_FUTURE_USAGE) += utfileio.o uttrack.o utcache.o
 
author
#5 lore raw

PATCH 5/25 ACPICA: Utilities: Validate full RSDP header

In reply to Lv Zheng

From: "David E. Box" <[email protected]>

Implement proper RSDP validation in acpi_ut_read_table(). Prevents a segmentation fault that can occur if a user passes the wrong file to iasl.

This patch is only useful for iasl, which is not shipped in the Linux kernel.
After the new table reading utility functions are well tested, acpidump can also switch to use the generic acpi_ut_read_table_xxx() APIs. Currently this patch is no-op as acpidump does not link to the new APIs.

---
 drivers/acpi/acpica/utfileio.c |   19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/acpi/acpica/utfileio.c +7 -12
index c8f6359..bdf9914 100644
@@ -150,6 +150,7 @@ acpi_ut_read_table(FILE * fp,
 	acpi_status status;
 	u32 file_size;
 	u8 standard_header = TRUE;
+	s32 count;
 
 	/* Get the file size */
 
@@ -164,27 +165,21 @@ acpi_ut_read_table(FILE * fp,
 
 	/* Read the signature */
 
-	if (fread(&table_header, 1, 4, fp) != 4) {
-		acpi_os_printf("Could not read the table signature\n");
+	fseek(fp, 0, SEEK_SET);
+
+	count = fread(&table_header, 1, sizeof(struct acpi_table_header), fp);
+	if (count != sizeof(struct acpi_table_header)) {
+		acpi_os_printf("Could not read the table header\n");
 		return (AE_BAD_HEADER);
 	}
 
-	fseek(fp, 0, SEEK_SET);
-
 	/* The RSDP table does not have standard ACPI header */
 
-	if (ACPI_COMPARE_NAME(table_header.signature, "RSD ")) {
+	if (ACPI_VALIDATE_RSDP_SIG(table_header.signature)) {
 		*table_length = file_size;
 		standard_header = FALSE;
 	} else {
-		/* Read the table header */
 
-		if (fread
-		    (&table_header, 1, sizeof(struct acpi_table_header),
-		     fp) != sizeof(struct acpi_table_header)) {
-			acpi_os_printf("Could not read the table header\n");
-			return (AE_BAD_HEADER);
-		}
 #if 0
 		/* Validate the table header/length */
 
Signature · 1 line
1.7.10
author
#6 lore raw

PATCH 6/25 ACPICA: Namespace: Properly null terminate objects detached from a namespace node

In reply to Lv Zheng

From: "David E. Box" <[email protected]>

Fixes a bug exposed by an ACPICA unit test around the acpi_attach_data()/acpi_detach_data() APIs where the failure to null terminate a detached object led to the creation of a circular linked list (and infinite looping) when the object is reattached.

Reported in acpica bugzilla #1063

Reference: https://bugs.acpica.org/show_bug.cgi?id=1063

---
 drivers/acpi/acpica/nsobject.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/acpi/acpica/nsobject.c +11 -0
index fe54a8c..f1ea8e5 100644
@@ -239,6 +239,17 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node)
 		}
 	}
 
+	/*
+	 * Detach the object from any data objects (which are still held by
+	 * the namespace node)
+	 */
+
+	if (obj_desc->common.next_object &&
+	    ((obj_desc->common.next_object)->common.type ==
+	     ACPI_TYPE_LOCAL_DATA)) {
+		obj_desc->common.next_object = NULL;
+	}
+
 	/* Reset the node type to untyped */
 
 	node->type = ACPI_TYPE_ANY;
Signature · 1 line
1.7.10
author
#7 lore raw

PATCH 7/25 ACPICA: OSL: Update environments to improve portability.

In reply to Lv Zheng

This patch is only useful for ACPICA applications, most of which are not shipped in the kernel.
This patch contains some environment updates that will be used by acpidump because:
1. The follow-up commits will release osunixxf.c to the Linux kernel for acpidump to link, and
2. Such environment settings will be used to avoid linkage issues.

---
 include/acpi/platform/acenv.h |   48 ++++++++++++++++++++++++++++++-----------
 1 file changed, 36 insertions(+), 12 deletions(-)
include/acpi/platform/acenv.h +36 -12
index e863dd5..b6429e4 100644
@@ -87,20 +87,14 @@
 #define ACPI_DBG_TRACK_ALLOCATIONS
 #endif
 
-/* acpi_names configuration. Single threaded with debugger output enabled. */
-
-#ifdef ACPI_NAMES_APP
-#define ACPI_DEBUGGER
-#define ACPI_APPLICATION
-#define ACPI_SINGLE_THREADED
-#endif
-
 /*
- * acpi_bin/acpi_dump/acpi_src/acpi_xtract/Example configuration. All single
- * threaded, with no debug output.
+ * acpi_bin/acpi_dump/acpi_help/acpi_names/acpi_src/acpi_xtract/Example configuration.
+ * All single threaded.
  */
 #if (defined ACPI_BIN_APP)      || \
 	(defined ACPI_DUMP_APP)     || \
+	(defined ACPI_HELP_APP)     || \
+	(defined ACPI_NAMES_APP)    || \
 	(defined ACPI_SRC_APP)      || \
 	(defined ACPI_XTRACT_APP)   || \
 	(defined ACPI_EXAMPLE_APP)
@@ -108,12 +102,39 @@
 #define ACPI_SINGLE_THREADED
 #endif
 
+/* acpi_help configuration. Error messages disabled. */
+
 #ifdef ACPI_HELP_APP
-#define ACPI_APPLICATION
-#define ACPI_SINGLE_THREADED
 #define ACPI_NO_ERROR_MESSAGES
 #endif
 
+/* acpi_names configuration. Debug output enabled. */
+
+#ifdef ACPI_NAMES_APP
+#define ACPI_DEBUG_OUTPUT
+#endif
+
+/* acpi_exec/acpi_names/Example configuration. Native RSDP used. */
+
+#if (defined ACPI_EXEC_APP)     || \
+	(defined ACPI_EXAMPLE_APP)  || \
+	(defined ACPI_NAMES_APP)
+#define ACPI_USE_NATIVE_RSDP_POINTER
+#endif
+
+/* acpi_dump configuration. Native mapping used if provied by OSPMs */
+
+#ifdef ACPI_DUMP_APP
+#define ACPI_USE_NATIVE_MEMORY_MAPPING
+#endif
+
+/* acpi_names/Example configuration. Hardware disabled */
+
+#if (defined ACPI_EXAMPLE_APP)  || \
+	(defined ACPI_NAMES_APP)
+#define ACPI_REDUCED_HARDWARE 1
+#endif
+
 /* Linkable ACPICA library */
 
 #ifdef ACPI_LIBRARY
@@ -185,6 +206,9 @@
 #elif defined(_AED_EFI)
 #include "acefi.h"
 
+#elif defined(_GNU_EFI)
+#include "acefi.h"
+
 #elif defined(__HAIKU__)
 #include "achaiku.h"
 
Signature · 1 line
1.7.10
author
#8 lore raw

PATCH 8/25 ACPICA: Utilities: Cleanup DEFINE_ACPI_GLOBALS by moving acpi_ut_init_global() from utglobal.c to utinit.c.

In reply to Lv Zheng

The utglobal.c is used to define and initialize global variables. It makes sense if just adding utglobal.o to applications that are using such variables. But acpi_ut_init_globals() is preventing us from doing so as this initialization function references other components' initializations code, which leads to the requirement that many files should also get linked if one wants to link utglobal.o.

It is possible to just move acpi_ut_init_global() to utinit.c for applications that require this function to link.

By linking utglobal.o, we can stop defining DEFINE_ACPI_GLOBALS for applications (currently only acpidump is affected). Lv Zheng.

---
 drivers/acpi/acpica/utglobal.c             |  146 ----------------------------
 drivers/acpi/acpica/utinit.c               |  146 ++++++++++++++++++++++++++++
 tools/power/acpi/Makefile                  |    1 +
 tools/power/acpi/tools/acpidump/acpidump.h |    1 -
 4 files changed, 147 insertions(+), 147 deletions(-)
drivers/acpi/acpica/utglobal.c +0 -146
index d69be3c..77ceac7 100644
@@ -214,152 +214,6 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
 };
 #endif				/* !ACPI_REDUCED_HARDWARE */
 
-/*******************************************************************************
- *
- * FUNCTION:    acpi_ut_init_globals
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Initialize ACPICA globals. All globals that require specific
- *              initialization should be initialized here. This allows for
- *              a warm restart.
- *
- ******************************************************************************/
-
-acpi_status acpi_ut_init_globals(void)
-{
-	acpi_status status;
-	u32 i;
-
-	ACPI_FUNCTION_TRACE(ut_init_globals);
-
-	/* Create all memory caches */
-
-	status = acpi_ut_create_caches();
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
-	/* Address Range lists */
-
-	for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) {
-		acpi_gbl_address_range_list[i] = NULL;
-	}
-
-	/* Mutex locked flags */
-
-	for (i = 0; i < ACPI_NUM_MUTEX; i++) {
-		acpi_gbl_mutex_info[i].mutex = NULL;
-		acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
-		acpi_gbl_mutex_info[i].use_count = 0;
-	}
-
-	for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
-		acpi_gbl_owner_id_mask[i] = 0;
-	}
-
-	/* Last owner_ID is never valid */
-
-	acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
-
-	/* Event counters */
-
-	acpi_method_count = 0;
-	acpi_sci_count = 0;
-	acpi_gpe_count = 0;
-
-	for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
-		acpi_fixed_event_count[i] = 0;
-	}
-
-#if (!ACPI_REDUCED_HARDWARE)
-
-	/* GPE/SCI support */
-
-	acpi_gbl_all_gpes_initialized = FALSE;
-	acpi_gbl_gpe_xrupt_list_head = NULL;
-	acpi_gbl_gpe_fadt_blocks[0] = NULL;
-	acpi_gbl_gpe_fadt_blocks[1] = NULL;
-	acpi_current_gpe_count = 0;
-
-	acpi_gbl_global_event_handler = NULL;
-	acpi_gbl_sci_handler_list = NULL;
-
-#endif				/* !ACPI_REDUCED_HARDWARE */
-
-	/* Global handlers */
-
-	acpi_gbl_global_notify[0].handler = NULL;
-	acpi_gbl_global_notify[1].handler = NULL;
-	acpi_gbl_exception_handler = NULL;
-	acpi_gbl_init_handler = NULL;
-	acpi_gbl_table_handler = NULL;
-	acpi_gbl_interface_handler = NULL;
-
-	/* Global Lock support */
-
-	acpi_gbl_global_lock_semaphore = NULL;
-	acpi_gbl_global_lock_mutex = NULL;
-	acpi_gbl_global_lock_acquired = FALSE;
-	acpi_gbl_global_lock_handle = 0;
-	acpi_gbl_global_lock_present = FALSE;
-
-	/* Miscellaneous variables */
-
-	acpi_gbl_DSDT = NULL;
-	acpi_gbl_cm_single_step = FALSE;
-	acpi_gbl_shutdown = FALSE;
-	acpi_gbl_ns_lookup_count = 0;
-	acpi_gbl_ps_find_count = 0;
-	acpi_gbl_acpi_hardware_present = TRUE;
-	acpi_gbl_last_owner_id_index = 0;
-	acpi_gbl_next_owner_id_offset = 0;
-	acpi_gbl_trace_dbg_level = 0;
-	acpi_gbl_trace_dbg_layer = 0;
-	acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
-	acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
-	acpi_gbl_osi_mutex = NULL;
-	acpi_gbl_reg_methods_executed = FALSE;
-
-	/* Hardware oriented */
-
-	acpi_gbl_events_initialized = FALSE;
-	acpi_gbl_system_awake_and_running = TRUE;
-
-	/* Namespace */
-
-	acpi_gbl_module_code_list = NULL;
-	acpi_gbl_root_node = NULL;
-	acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
-	acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
-	acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
-	acpi_gbl_root_node_struct.parent = NULL;
-	acpi_gbl_root_node_struct.child = NULL;
-	acpi_gbl_root_node_struct.peer = NULL;
-	acpi_gbl_root_node_struct.object = NULL;
-
-#ifdef ACPI_DISASSEMBLER
-	acpi_gbl_external_list = NULL;
-	acpi_gbl_num_external_methods = 0;
-	acpi_gbl_resolved_external_methods = 0;
-#endif
-
-#ifdef ACPI_DEBUG_OUTPUT
-	acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
-#endif
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-	acpi_gbl_display_final_mem_stats = FALSE;
-	acpi_gbl_disable_mem_tracking = FALSE;
-#endif
-
-	ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = FALSE);
-
-	return_ACPI_STATUS(AE_OK);
-}
-
 /* Public globals */
 
 ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
drivers/acpi/acpica/utinit.c +146 -0

152 lines not on this page · raw message

tools/power/acpi/Makefile +1 -0
index e5a3c4b..61446db 100644
@@ -112,6 +112,7 @@ DUMP_OBJS = \
 	tbxfroot.o\
 	utbuffer.o\
 	utexcep.o\
+	utglobal.o\
 	utmath.o\
 	utstring.o\
 	utxferror.o\
tools/power/acpi/tools/acpidump/acpidump.h +0 -1
index 46f5195..8efc848 100644
@@ -47,7 +47,6 @@
 #ifdef _DECLARE_GLOBALS
 #define EXTERN
 #define INIT_GLOBAL(a,b)        a=b
-#define DEFINE_ACPI_GLOBALS     1
 #else
 #define EXTERN                  extern
 #define INIT_GLOBAL(a,b)        a
Signature · 1 line
1.7.10
author
#9 lore raw

PATCH 9/25 ACPICA: OSL: Cleanup acpi_os_printf()/acpi_os_vprintf() stubs.

In reply to Lv Zheng

This patch is mainly for acpidump where there are redundant acpi_os_printf()/acpi_os_vprintf() stubs implemented. This patch cleans up such specific implementation by linking acpidump to osunixxf.c/oswinxf.c.

To make acpi_os_printf() exported by osunixxf.c/oswinxf.c to behave as the old acpidump specific ones, applications need to:
1. Initialize acpi_gbl_db_output_flags to ACPI_DB_CONSOLE_OUTPUT. This is automatically done by ACPI_INIT_GLOBAL(), applications need to link utglobal.o to utilize this mechanism.
2. Initialize acpi_gbl_output_file to stdout.
For GCC, assigning stdout to acpi_gbl_output_file using ACPI_INIT_GLOBAL() is not possible as stdout is not a constant in GCC environment. As an alternative solution, stdout assignment is put into acpi_os_initialize(). Thus acpi_os_initialize() need to be invoked very early by the applications to initialize the default output of acpi_os_printf().

This patch also releases osunixxf.c to the Linux kernel. Lv Zheng.

---
 drivers/acpi/acpica/acglobal.h                     |    3 +-
 drivers/acpi/acpica/acutils.h                      |    1 -
 drivers/acpi/acpica/utinit.c                       |    1 -
 tools/power/acpi/Makefile                          |    1 +
 .../acpi/os_specific/service_layers/osunixxf.c     | 1304 ++++++++++++++++++++
 tools/power/acpi/tools/acpidump/apdump.c           |   22 -
 tools/power/acpi/tools/acpidump/apmain.c           |    1 +
 7 files changed, 1308 insertions(+), 25 deletions(-)
 create mode 100644 tools/power/acpi/os_specific/service_layers/osunixxf.c
drivers/acpi/acpica/acglobal.h +2 -1
index 115eedc..78cc366 100644
@@ -297,7 +297,7 @@ ACPI_GLOBAL(u32, acpi_gbl_trace_dbg_layer);
  *
  ****************************************************************************/
 
-ACPI_GLOBAL(u8, acpi_gbl_db_output_flags);
+ACPI_INIT_GLOBAL(u8, acpi_gbl_db_output_flags, ACPI_DB_CONSOLE_OUTPUT);
 
 #ifdef ACPI_DISASSEMBLER
 
@@ -362,6 +362,7 @@ ACPI_GLOBAL(u32, acpi_gbl_num_objects);
 #ifdef ACPI_APPLICATION
 
 ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL);
+ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_output_file, NULL);
 
 #endif				/* ACPI_APPLICATION */
 
drivers/acpi/acpica/acutils.h +0 -1
index 8a44148..e0adbc1 100644
@@ -95,7 +95,6 @@ extern const char *acpi_gbl_pt_decode[];
 #ifdef ACPI_ASL_COMPILER
 
 #include <stdio.h>
-extern FILE *acpi_gbl_output_file;
 
 #define ACPI_MSG_REDIRECT_BEGIN \
 	FILE                            *output_file = acpi_gbl_output_file; \
drivers/acpi/acpica/utinit.c +0 -1
index a793662..77120ec 100644
@@ -207,7 +207,6 @@ acpi_status acpi_ut_init_globals(void)
 	acpi_gbl_trace_dbg_level = 0;
 	acpi_gbl_trace_dbg_layer = 0;
 	acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
-	acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
 	acpi_gbl_osi_mutex = NULL;
 	acpi_gbl_reg_methods_executed = FALSE;
 
tools/power/acpi/Makefile +1 -0
index 61446db..f88a251 100644
@@ -108,6 +108,7 @@ DUMP_OBJS = \
 	apmain.o\
 	osunixdir.o\
 	osunixmap.o\
+	osunixxf.o\
 	tbprint.o\
 	tbxfroot.o\
 	utbuffer.o\
tools/power/acpi/os_specific/service_layers/osunixxf.c new file +1304 -0

1,304 lines not on this page · raw message

tools/power/acpi/tools/acpidump/apdump.c +0 -22
index 3cac123..e8729aa 100644
@@ -427,25 +427,3 @@ exit:
 	free(table);
 	return (table_status);
 }
-
-/******************************************************************************
- *
- * FUNCTION:    acpi_os* print functions
- *
- * DESCRIPTION: Used for linkage with ACPICA modules
- *
- ******************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *fmt, ...)
-{
-	va_list args;
-
-	va_start(args, fmt);
-	vfprintf(stdout, fmt, args);
-	va_end(args);
-}
-
-void acpi_os_vprintf(const char *fmt, va_list args)
-{
-	vfprintf(stdout, fmt, args);
-}
tools/power/acpi/tools/acpidump/apmain.c +1 -0
index 51e8d63..c03e473 100644
@@ -288,6 +288,7 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
 	u32 i;
 
 	ACPI_DEBUG_INITIALIZE();	/* For debug version only */
+	acpi_os_initialize();
 
 	/* Process command line options */
 
Signature · 1 line
1.7.10
author
#10 lore raw

PATCH 10/25 ACPICA: OSL: Add portable file IO to improve portability.

In reply to Lv Zheng

This patch adds portable file IO to generic OSL to improve the portability of the applications.

A portable application may use different file IO interfaces than the standard C library ones. This patch thus introduces an abstract file IO layer into the generic OSL.

Note that this patch does not introduce users of such interfaces, further patches should introduce users one by one carefully with build tests performed. Lv Zheng.

---
 include/acpi/acpiosxf.h                            |   31 +++
 include/acpi/actypes.h                             |    9 +
 .../acpi/os_specific/service_layers/oslibcfs.c     |  214 ++++++++++++++++++++
 3 files changed, 254 insertions(+)
 create mode 100644 tools/power/acpi/os_specific/service_layers/oslibcfs.c
include/acpi/acpiosxf.h +31 -0
index f6f5f8a..03b3e6d 100644
@@ -399,4 +399,35 @@ char *acpi_os_get_next_filename(void *dir_handle);
 void acpi_os_close_directory(void *dir_handle);
 #endif
 
+/*
+ * File I/O and related support
+ */
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_file
+ACPI_FILE acpi_os_open_file(const char *path, u8 modes);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_file
+void acpi_os_close_file(ACPI_FILE file);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_file
+int
+acpi_os_read_file(ACPI_FILE file,
+		  void *buffer, acpi_size size, acpi_size count);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_file
+int
+acpi_os_write_file(ACPI_FILE file,
+		   void *buffer, acpi_size size, acpi_size count);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_file_offset
+long acpi_os_get_file_offset(ACPI_FILE file);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_set_file_offset
+acpi_status acpi_os_set_file_offset(ACPI_FILE file, long offset, u8 from);
+#endif
+
 #endif				/* __ACPIOSXF_H__ */
include/acpi/actypes.h +9 -0
index 19b26bb..5480209 100644
@@ -1244,4 +1244,13 @@ struct acpi_memory_list {
 #define ACPI_OSI_WIN_7                  0x0B
 #define ACPI_OSI_WIN_8                  0x0C
 
+/* Definitions of file IO */
+
+#define ACPI_FILE_READING               0x01
+#define ACPI_FILE_WRITING               0x02
+#define ACPI_FILE_BINARY                0x04
+
+#define ACPI_FILE_BEGIN                 0x01
+#define ACPI_FILE_END                   0x02
+
 #endif				/* __ACTYPES_H__ */
tools/power/acpi/os_specific/service_layers/oslibcfs.c new file +214 -0

214 lines not on this page · raw message

Signature · 1 line
1.7.10
author
#11 lore raw

PATCH 11/25 ACPICA: Utilities: Add formatted printing APIs.

In reply to Lv Zheng

This patch introduces formatted printing APIs to handle ACPICA specific formatted print requirements. Currently only specific OSPMs will use this customized printing support, Linux kernel doesn't use these APIs at this time. It will be enabled for Linux kernel resident ACPICA after being well tested. So currently this patch is a no-op.

The specific formatted printing APIs are useful to ACPICA as:
1. Some portable applications do not link standard C library, so they cannot use standard formatted print APIs directly.
2. Platform specific printing format may differ and thus not portable, for example, u64 is %ull for Linux kernel and is %uI64 for some MSVC versions.
3. Platform specific printing format may conflict with ACPICA's usages while it is not possible for ACPICA developers to test their code for all platforms. For example, developers may generate %pRxxx while Linux kernel treats %pR as structured resource printing and decodes variable argument as a "struct resource" pointer.
This patch solves above issues by introducing the new APIs.

Note that users of such APIs are not introduced in this patch. Users of acpi_os_file_vprintf()/acpi_ut_file_printf() need to invoke acpi_os_initialize(), this should be taken care by the further patches where such users are introduced. Lv Zheng.

---
 drivers/acpi/acpica/acglobal.h                     |    5 +
 drivers/acpi/acpica/acutils.h                      |   19 +
 drivers/acpi/acpica/utprint.c                      |  649 ++++++++++++++++++++
 include/acpi/actypes.h                             |    1 +
 .../acpi/os_specific/service_layers/osunixxf.c     |    7 +
 5 files changed, 681 insertions(+)
 create mode 100644 drivers/acpi/acpica/utprint.c
drivers/acpi/acpica/acglobal.h +5 -0
Index: linux-acpica/drivers/acpi/acpica/acglobal.h
===================================================================
@@ -364,6 +364,11 @@ ACPI_GLOBAL(u32, acpi_gbl_num_objects);
 ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL);
 ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_output_file, NULL);
 
+/* Print buffer */
+
+ACPI_GLOBAL(acpi_spinlock, acpi_gbl_print_lock);	/* For print buffer */
+ACPI_GLOBAL(char, acpi_gbl_print_buffer[1024]);
+
 #endif				/* ACPI_APPLICATION */
 
 /*****************************************************************************
drivers/acpi/acpica/acutils.h +19 -0
Index: linux-acpica/drivers/acpi/acpica/acutils.h
===================================================================
@@ -750,4 +750,23 @@ const struct ah_predefined_name *acpi_ah
 
 const struct ah_device_id *acpi_ah_match_hardware_id(char *hid);
 
+/*
+ * utprint - printf/vprintf output functions
+ */
+const char *acpi_ut_scan_number(const char *string, u64 *number_ptr);
+
+const char *acpi_ut_print_number(char *string, u64 number);
+
+int
+acpi_ut_vsnprintf(char *string,
+		  acpi_size size, const char *format, va_list args);
+
+int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...);
+
+#ifdef ACPI_APPLICATION
+int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args);
+
+int acpi_ut_file_printf(ACPI_FILE file, const char *format, ...);
+#endif
+
 #endif				/* _ACUTILS_H */
drivers/acpi/acpica/utprint.c new file +649 -0

649 lines not on this page · raw message

include/acpi/actypes.h +1 -0
Index: linux-acpica/include/acpi/actypes.h
===================================================================
@@ -126,6 +126,7 @@
 typedef unsigned char u8;
 typedef unsigned char u8;
 typedef unsigned short u16;
+typedef short s16;
 typedef COMPILER_DEPENDENT_UINT64 u64;
 typedef COMPILER_DEPENDENT_INT64 s64;
 
tools/power/acpi/os_specific/service_layers/osunixxf.c +7 -0
Index: linux-acpica/tools/power/acpi/os_specific/service_layers/osunixxf.c
===================================================================
@@ -182,10 +182,17 @@ static void os_exit_line_edit_mode(void)
 
 acpi_status acpi_os_initialize(void)
 {
+	acpi_status status;
 
 	acpi_gbl_output_file = stdout;
 
 	os_enter_line_edit_mode();
+
+	status = acpi_os_create_lock(&acpi_gbl_print_lock);
+	if (ACPI_FAILURE(status)) {
+		return (status);
+	}
+
 	return (AE_OK);
 }
 
drivers/acpi/acpica/Makefile +1 -1
Index: linux-acpica/drivers/acpi/acpica/Makefile
===================================================================
@@ -175,5 +175,5 @@ acpi-y +=		\
 	utxferror.o	\
 	utxfmutex.o
 
-acpi-$(ACPI_FUTURE_USAGE) += utfileio.o uttrack.o utcache.o
+acpi-$(ACPI_FUTURE_USAGE) += utfileio.o utprint.o uttrack.o utcache.o
 
author
#12 lore raw

PATCH 12/25 ACPICA: Utilities: Introduce acpi_log_error() to improve portability.

In reply to Lv Zheng

This patch is only useful for ACPICA applications, most of which are not shipped in the Linux kernel.
Note that follow-up commits will update acpidump to use this new API to improve portability.

Invocations like fprintf(stderr) and perror() are not portable, this patch introduces acpi_log_error() as a replacement, it is implemented using new portable API - acpi_ut_file_vprintf().

Note that though acpi_os_initialize() need to be invoked prior than using this new API, since no users are introduced in this patch, such invocations are not added for applications that link utprint.c in this patch. Futher patches that introduce users of acpi_log_error() should take care of this. Lv Zheng.

---
 drivers/acpi/acpica/utdebug.c |   26 ++++++++++++++++++++++++++
 include/acpi/acpixf.h         |   20 ++++++++++++++++++++
 include/acpi/platform/acenv.h |    4 ++++
 3 files changed, 50 insertions(+)
drivers/acpi/acpica/utdebug.c +26 -0
index 21a20ac..e516254 100644
@@ -561,3 +561,29 @@ acpi_ut_ptr_exit(u32 line_number,
 }
 
 #endif
+
+#ifdef ACPI_APPLICATION
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_log_error
+ *
+ * PARAMETERS:  format              - Printf format field
+ *              ...                 - Optional printf arguments
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Print error message to the console, used by applications.
+ *
+ ******************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE acpi_log_error(const char *format, ...)
+{
+	va_list args;
+
+	va_start(args, format);
+	(void)acpi_ut_file_vprintf(ACPI_FILE_ERR, format, args);
+	va_end(args);
+}
+
+ACPI_EXPORT_SYMBOL(acpi_log_error)
+#endif
include/acpi/acpixf.h +20 -0
index 35b525c..9858551 100644
@@ -335,6 +335,23 @@ ACPI_GLOBAL(u8, acpi_gbl_system_awake_and_running);
 
 #endif				/* ACPI_DEBUG_OUTPUT */
 
+/*
+ * Application prototypes
+ *
+ * All interfaces used by application will be configured
+ * out of the ACPICA build unless the ACPI_APPLICATION
+ * flag is defined.
+ */
+#ifdef ACPI_APPLICATION
+#define ACPI_APP_DEPENDENT_RETURN_VOID(prototype) \
+	prototype;
+
+#else
+#define ACPI_APP_DEPENDENT_RETURN_VOID(prototype) \
+	static ACPI_INLINE prototype {return;}
+
+#endif				/* ACPI_APPLICATION */
+
 /*****************************************************************************
  *
  * ACPICA public interface prototypes
@@ -861,6 +878,9 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6)
 						     const char *module_name,
 						     u32 component_id,
 						     const char *format, ...))
+ACPI_APP_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(1)
+				void ACPI_INTERNAL_VAR_XFACE
+				acpi_log_error(const char *format, ...))
 
 /*
  * Divergences
include/acpi/platform/acenv.h +4 -0
index b6429e4..4390ebd 100644
@@ -423,8 +423,12 @@ typedef char *va_list;
 #ifdef ACPI_APPLICATION
 #include <stdio.h>
 #define ACPI_FILE              FILE *
+#define ACPI_FILE_OUT          stdout
+#define ACPI_FILE_ERR          stderr
 #else
 #define ACPI_FILE              void *
+#define ACPI_FILE_OUT          NULL
+#define ACPI_FILE_ERR          NULL
 #endif				/* ACPI_APPLICATION */
 #endif				/* ACPI_FILE */
 
Signature · 1 line
1.7.10
author
#13 lore raw

PATCH 13/25 ACPICA: Application: Enhance ACPI_USAGE_xxx/ACPI_OPTION with acpi_os_printf() to improve portability.

In reply to Lv Zheng

This patch enhances ACPI_USAGE_xxx/ACPI_OPTION macros to use portable acpi_os_printf() so that usage functions for applications no longer rely on the printf() API.

To use acpi_os_printf() exported by osunixxf.c as a replacement of printf(), applications need to initialize acpi_gbl_output_file to stdout and initialize acpi_gbl_db_output_flags to ACPI_DB_CONSOLE_OUTPUT. The latter is automatically done by ACPI_INIT_GLOBAL(), applications need to link utglobal.o to utilize this mechanism. For GCC, assigning stdout to acpi_gbl_output_file using ACPI_INIT_GLOBAL() is not possible as stdout is not a constant in GCC environment. As an alternative solution, stdout assignment has been put into acpi_os_initialize(). Thus acpi_os_initialize() need to be invoked very early by the applications to initialize the default output of acpi_os_printf() to keep behavior consistency.
acpidump has already invoked acpi_os_initialize() in this way. Lv Zheng.

---
 drivers/acpi/acpica/acapps.h             |    7 +++++--
 tools/power/acpi/tools/acpidump/apmain.c |    8 ++++----
 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/acpi/acpica/acapps.h +5 -2
index 8698ffb..5bf41f8 100644
@@ -79,10 +79,13 @@
 /* Macros for usage messages */
 
 #define ACPI_USAGE_HEADER(usage) \
-	printf ("Usage: %s\nOptions:\n", usage);
+	acpi_os_printf ("Usage: %s\nOptions:\n", usage);
+
+#define ACPI_USAGE_TEXT(description) \
+	acpi_os_printf (description);
 
 #define ACPI_OPTION(name, description) \
-	printf ("  %-18s%s\n", name, description);
+	acpi_os_printf (" %-18s%s\n", name, description);
 
 #define FILE_SUFFIX_DISASSEMBLY     "dsl"
 #define ACPI_TABLE_FILE_SUFFIX      ".dat"
tools/power/acpi/tools/acpidump/apmain.c +4 -4
index c03e473..2a06a86 100644
@@ -104,7 +104,7 @@ static void ap_display_usage(void)
 	ACPI_OPTION("-v", "Display version information");
 	ACPI_OPTION("-z", "Verbose mode");
 
-	printf("\nTable Options:\n");
+	ACPI_USAGE_TEXT("\nTable Options:\n");
 
 	ACPI_OPTION("-a <Address>", "Get table via a physical address");
 	ACPI_OPTION("-f <BinaryFile>", "Get table via a binary file");
@@ -112,9 +112,9 @@ static void ap_display_usage(void)
 	ACPI_OPTION("-x", "Do not use but dump XSDT");
 	ACPI_OPTION("-x -x", "Do not use or dump XSDT");
 
-	printf("\n"
-	       "Invocation without parameters dumps all available tables\n"
-	       "Multiple mixed instances of -a, -f, and -n are supported\n\n");
+	ACPI_USAGE_TEXT("\n"
+			"Invocation without parameters dumps all available tables\n"
+			"Multiple mixed instances of -a, -f, and -n are supported\n\n");
 }
 
 /******************************************************************************
Signature · 1 line
1.7.10
author
#14 lore raw

PATCH 14/25 ACPICA: Common: Enhance cm_get_file_size() to improve portability.

In reply to Lv Zheng

This patch uses abstract file IO and acpi_log_error() APIs to enhance cm_get_file_size() so that applications that invoke this API could have portability improved.

With actual references added to abstract file IO and acpi_log_error(), the applications need to link oslibcfs.o, utdebug.o, utexcep.o, utmath.o, utprint.o and utxferror.o.
It is also required to add acpi_os_initialize() invocations if an application starts to use acpi_log_error().
acpidump has already invoked acpi_os_initialize() in this way. Lv Zheng.

---
 drivers/acpi/acpica/acapps.h      |    2 +-
 tools/power/acpi/Makefile         |    3 +++
 tools/power/acpi/common/cmfsize.c |   20 +++++++++++---------
 3 files changed, 15 insertions(+), 10 deletions(-)
drivers/acpi/acpica/acapps.h +1 -1
index 5bf41f8..3d2c882 100644
@@ -105,7 +105,7 @@ extern char *acpi_gbl_optarg;
 /*
  * cmfsize - Common get file size function
  */
-u32 cm_get_file_size(FILE * file);
+u32 cm_get_file_size(ACPI_FILE file);
 
 #ifndef ACPI_DUMP_APP
 /*
tools/power/acpi/Makefile +3 -0
index f88a251..3d1537b 100644
@@ -112,11 +112,14 @@ DUMP_OBJS = \
 	tbprint.o\
 	tbxfroot.o\
 	utbuffer.o\
+	utdebug.o\
 	utexcep.o\
 	utglobal.o\
 	utmath.o\
+	utprint.o\
 	utstring.o\
 	utxferror.o\
+	oslibcfs.o\
 	oslinuxtbl.o\
 	cmfsize.o\
 	getopt.o
tools/power/acpi/common/cmfsize.c +11 -9
index 5140e5e..f4b9533 100644
@@ -58,44 +58,46 @@ ACPI_MODULE_NAME("cmfsize")
  * RETURN:      File Size. On error, -1 (ACPI_UINT32_MAX)
  *
  * DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open.
- *              Does not disturb the current file pointer. Uses perror for
- *              error messages.
+ *              Does not disturb the current file pointer.
  *
  ******************************************************************************/
-u32 cm_get_file_size(FILE * file)
+u32 cm_get_file_size(ACPI_FILE file)
 {
 	long file_size;
 	long current_offset;
+	acpi_status status;
 
 	/* Save the current file pointer, seek to EOF to obtain file size */
 
-	current_offset = ftell(file);
+	current_offset = acpi_os_get_file_offset(file);
 	if (current_offset < 0) {
 		goto offset_error;
 	}
 
-	if (fseek(file, 0, SEEK_END)) {
+	status = acpi_os_set_file_offset(file, 0, ACPI_FILE_END);
+	if (ACPI_FAILURE(status)) {
 		goto seek_error;
 	}
 
-	file_size = ftell(file);
+	file_size = acpi_os_get_file_offset(file);
 	if (file_size < 0) {
 		goto offset_error;
 	}
 
 	/* Restore original file pointer */
 
-	if (fseek(file, current_offset, SEEK_SET)) {
+	status = acpi_os_set_file_offset(file, current_offset, ACPI_FILE_BEGIN);
+	if (ACPI_FAILURE(status)) {
 		goto seek_error;
 	}
 
 	return ((u32)file_size);
 
 offset_error:
-	perror("Could not get file offset");
+	acpi_log_error("Could not get file offset");
 	return (ACPI_UINT32_MAX);
 
 seek_error:
-	perror("Could not seek file");
+	acpi_log_error("Could not set file offset");
 	return (ACPI_UINT32_MAX);
 }
Signature · 1 line
1.7.10
author
#15 lore raw

PATCH 15/25 ACPICA: Common: Enhance acpi_getopt() to improve portability.

In reply to Lv Zheng

This patch enhances acpi_getopt() by converting the standard C library invocations into portable ACPI string APIs and acpi_log_error() to improve portability. Lv Zheng.

---
 drivers/acpi/acpica/acutils.h            |    2 ++
 include/acpi/actypes.h                   |    4 ++++
 tools/power/acpi/common/getopt.c         |   14 ++++++--------
 tools/power/acpi/tools/acpidump/apmain.c |    3 ++-
 4 files changed, 14 insertions(+), 9 deletions(-)
drivers/acpi/acpica/acutils.h +2 -0
index 85871c6..035dc29 100644
@@ -210,6 +210,8 @@ void acpi_ut_subsystem_shutdown(void);
 
 acpi_size acpi_ut_strlen(const char *string);
 
+char *acpi_ut_strchr(const char *string, int ch);
+
 char *acpi_ut_strcpy(char *dst_string, const char *src_string);
 
 char *acpi_ut_strncpy(char *dst_string,
include/acpi/actypes.h +4 -0
index 165abca..608a040 100644
@@ -1254,4 +1254,8 @@ struct acpi_memory_list {
 #define ACPI_FILE_BEGIN                 0x01
 #define ACPI_FILE_END                   0x02
 
+/* Definitions of getopt */
+
+#define ACPI_OPT_END                    -1
+
 #endif				/* __ACTYPES_H__ */
tools/power/acpi/common/getopt.c +6 -8
index a302f52..2f0f34a 100644
@@ -51,14 +51,12 @@
  *    "f|"      - Option has required single-char sub-options
  */
 
-#include <stdio.h>
-#include <string.h>
 #include <acpi/acpi.h>
 #include "accommon.h"
 #include "acapps.h"
 
 #define ACPI_OPTION_ERROR(msg, badchar) \
-	if (acpi_gbl_opterr) {fprintf (stderr, "%s%c\n", msg, badchar);}
+	if (acpi_gbl_opterr) {acpi_log_error ("%s%c\n", msg, badchar);}
 
 int acpi_gbl_opterr = 1;
 int acpi_gbl_optind = 1;
@@ -113,7 +111,7 @@ int acpi_getopt_argument(int argc, char **argv)
  * PARAMETERS:  argc, argv          - from main
  *              opts                - options info list
  *
- * RETURN:      Option character or EOF
+ * RETURN:      Option character or ACPI_OPT_END
  *
  * DESCRIPTION: Get the next option
  *
@@ -128,10 +126,10 @@ int acpi_getopt(int argc, char **argv, char *opts)
 		if (acpi_gbl_optind >= argc ||
 		    argv[acpi_gbl_optind][0] != '-' ||
 		    argv[acpi_gbl_optind][1] == '\0') {
-			return (EOF);
-		} else if (strcmp(argv[acpi_gbl_optind], "--") == 0) {
+			return (ACPI_OPT_END);
+		} else if (ACPI_STRCMP(argv[acpi_gbl_optind], "--") == 0) {
 			acpi_gbl_optind++;
-			return (EOF);
+			return (ACPI_OPT_END);
 		}
 	}
 
@@ -142,7 +140,7 @@ int acpi_getopt(int argc, char **argv, char *opts)
 	/* Make sure that the option is legal */
 
 	if (current_char == ':' ||
-	    (opts_ptr = strchr(opts, current_char)) == NULL) {
+	    (opts_ptr = ACPI_STRCHR(opts, current_char)) == NULL) {
 		ACPI_OPTION_ERROR("Illegal option: -", current_char);
 
 		if (argv[acpi_gbl_optind][++current_char_ptr] == '\0') {
tools/power/acpi/tools/acpidump/apmain.c +2 -1
index 2a06a86..9c3b259 100644
@@ -166,7 +166,8 @@ static int ap_do_options(int argc, char **argv)
 
 	/* Command line options */
 
-	while ((j = acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != EOF)
+	while ((j =
+		acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != ACPI_OPT_END)
 		switch (j) {
 			/*
 			 * Global options
Signature · 1 line
1.7.10
author
#16 lore raw

PATCH 16/25 ACPICA: acpidump: Add memory/string OSL usage to improve portability.

In reply to Lv Zheng

This patch adds code to use generic OSL for acpidump to improve the portability of this tool. Lv Zheng.

---
 include/acpi/platform/acenv.h             |    1 +
 tools/power/acpi/tools/acpidump/apdump.c  |   16 ++++++++--------
 tools/power/acpi/tools/acpidump/apfiles.c |   11 ++++++-----
 3 files changed, 15 insertions(+), 13 deletions(-)
include/acpi/platform/acenv.h +1 -0
index 4390ebd..5f8cc1f 100644
@@ -126,6 +126,7 @@
 
 #ifdef ACPI_DUMP_APP
 #define ACPI_USE_NATIVE_MEMORY_MAPPING
+#define USE_NATIVE_ALLOCATE_ZEROED
 #endif
 
 /* acpi_names/Example configuration. Hardware disabled */
tools/power/acpi/tools/acpidump/apdump.c +8 -8
index e8729aa..ccb6262 100644
@@ -252,7 +252,7 @@ int ap_dump_all_tables(void)
 		}
 
 		table_status = ap_dump_table_buffer(table, instance, address);
-		free(table);
+		ACPI_FREE(table);
 
 		if (table_status) {
 			break;
@@ -303,7 +303,7 @@ int ap_dump_table_by_address(char *ascii_address)
 	}
 
 	table_status = ap_dump_table_buffer(table, 0, address);
-	free(table);
+	ACPI_FREE(table);
 	return (table_status);
 }
 
@@ -329,7 +329,7 @@ int ap_dump_table_by_name(char *signature)
 	acpi_status status;
 	int table_status;
 
-	if (strlen(signature) != ACPI_NAME_SIZE) {
+	if (ACPI_STRLEN(signature) != ACPI_NAME_SIZE) {
 		fprintf(stderr,
 			"Invalid table signature [%s]: must be exactly 4 characters\n",
 			signature);
@@ -338,15 +338,15 @@ int ap_dump_table_by_name(char *signature)
 
 	/* Table signatures are expected to be uppercase */
 
-	strcpy(local_signature, signature);
+	ACPI_STRCPY(local_signature, signature);
 	acpi_ut_strupr(local_signature);
 
 	/* To be friendly, handle tables whose signatures do not match the name */
 
 	if (ACPI_COMPARE_NAME(local_signature, "FADT")) {
-		strcpy(local_signature, ACPI_SIG_FADT);
+		ACPI_STRCPY(local_signature, ACPI_SIG_FADT);
 	} else if (ACPI_COMPARE_NAME(local_signature, "MADT")) {
-		strcpy(local_signature, ACPI_SIG_MADT);
+		ACPI_STRCPY(local_signature, ACPI_SIG_MADT);
 	}
 
 	/* Dump all instances of this signature (to handle multiple SSDTs) */
@@ -369,7 +369,7 @@ int ap_dump_table_by_name(char *signature)
 		}
 
 		table_status = ap_dump_table_buffer(table, instance, address);
-		free(table);
+		ACPI_FREE(table);
 
 		if (table_status) {
 			break;
@@ -424,6 +424,6 @@ int ap_dump_table_from_file(char *pathname)
 	table_status = ap_dump_table_buffer(table, 0, 0);
 
 exit:
-	free(table);
+	ACPI_FREE(table);
 	return (table_status);
 }
tools/power/acpi/tools/acpidump/apfiles.c +6 -5
index 4488acc..1d12b9d 100644
@@ -130,11 +130,12 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance)
 	/* Handle multiple SSDts - create different filenames for each */
 
 	if (instance > 0) {
-		sprintf(instance_str, "%u", instance);
-		strcat(filename, instance_str);
+		acpi_ut_snprintf(instance_str, sizeof(instance_str), "%u",
+				 instance);
+		ACPI_STRCAT(filename, instance_str);
 	}
 
-	strcat(filename, ACPI_TABLE_FILE_SUFFIX);
+	ACPI_STRCAT(filename, ACPI_TABLE_FILE_SUFFIX);
 
 	if (gbl_verbose_mode) {
 		fprintf(stderr,
@@ -202,7 +203,7 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
 
 	/* Allocate a buffer for the entire file */
 
-	buffer = calloc(1, file_size);
+	buffer = ACPI_ALLOCATE_ZEROED(file_size);
 	if (!buffer) {
 		fprintf(stderr,
 			"Could not allocate file buffer of size: %u\n",
@@ -215,7 +216,7 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
 	actual = fread(buffer, 1, file_size, file);
 	if (actual != file_size) {
 		fprintf(stderr, "Could not read input file: %s\n", pathname);
-		free(buffer);
+		ACPI_FREE(buffer);
 		buffer = NULL;
 		goto cleanup;
 	}
Signature · 1 line
1.7.10
author
#17 lore raw

PATCH 17/25 ACPICA: acpidump: Remove exit() from generic layer to improve portability.

In reply to Lv Zheng

This patch removes exit() from generic acpidump code to improve the portability of this tool. Lv Zheng.

---
 tools/power/acpi/tools/acpidump/apmain.c |   50 +++++++++++++++++++-----------
 1 file changed, 32 insertions(+), 18 deletions(-)
tools/power/acpi/tools/acpidump/apmain.c +32 -18
index 9c3b259..55fd44d 100644
@@ -72,7 +72,7 @@ static void ap_display_usage(void);
 
 static int ap_do_options(int argc, char **argv);
 
-static void ap_insert_action(char *argument, u32 to_be_done);
+static int ap_insert_action(char *argument, u32 to_be_done);
 
 /* Table for deferred actions from command line options */
 
@@ -124,13 +124,13 @@ static void ap_display_usage(void)
  * PARAMETERS:  argument            - Pointer to the argument for this action
  *              to_be_done          - What to do to process this action
  *
- * RETURN:      None. Exits program if action table becomes full.
+ * RETURN:      Status
  *
  * DESCRIPTION: Add an action item to the action table
  *
  ******************************************************************************/
 
-static void ap_insert_action(char *argument, u32 to_be_done)
+static int ap_insert_action(char *argument, u32 to_be_done)
 {
 
 	/* Insert action and check for table overflow */
@@ -142,8 +142,10 @@ static void ap_insert_action(char *argument, u32 to_be_done)
 	if (current_action > AP_MAX_ACTIONS) {
 		fprintf(stderr, "Too many table options (max %u)\n",
 			AP_MAX_ACTIONS);
-		exit(-1);
+		return (-1);
 	}
+
+	return (0);
 }
 
 /******************************************************************************
@@ -186,12 +188,12 @@ static int ap_do_options(int argc, char **argv)
 		case '?':
 
 			ap_display_usage();
-			exit(0);
+			return (1);
 
 		case 'o':	/* Redirect output to a single file */
 
 			if (ap_open_output_file(acpi_gbl_optarg)) {
-				exit(-1);
+				return (-1);
 			}
 			continue;
 
@@ -204,7 +206,7 @@ static int ap_do_options(int argc, char **argv)
 				fprintf(stderr,
 					"%s: Could not convert to a physical address\n",
 					acpi_gbl_optarg);
-				exit(-1);
+				return (-1);
 			}
 			continue;
 
@@ -225,7 +227,7 @@ static int ap_do_options(int argc, char **argv)
 		case 'v':	/* Revision/version */
 
 			printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
-			exit(0);
+			return (1);
 
 		case 'z':	/* Verbose mode */
 
@@ -238,32 +240,40 @@ static int ap_do_options(int argc, char **argv)
 			 */
 		case 'a':	/* Get table by physical address */
 
-			ap_insert_action(acpi_gbl_optarg,
-					 AP_DUMP_TABLE_BY_ADDRESS);
+			if (ap_insert_action
+			    (acpi_gbl_optarg, AP_DUMP_TABLE_BY_ADDRESS)) {
+				return (-1);
+			}
 			break;
 
 		case 'f':	/* Get table from a file */
 
-			ap_insert_action(acpi_gbl_optarg,
-					 AP_DUMP_TABLE_BY_FILE);
+			if (ap_insert_action
+			    (acpi_gbl_optarg, AP_DUMP_TABLE_BY_FILE)) {
+				return (-1);
+			}
 			break;
 
 		case 'n':	/* Get table by input name (signature) */
 
-			ap_insert_action(acpi_gbl_optarg,
-					 AP_DUMP_TABLE_BY_NAME);
+			if (ap_insert_action
+			    (acpi_gbl_optarg, AP_DUMP_TABLE_BY_NAME)) {
+				return (-1);
+			}
 			break;
 
 		default:
 
 			ap_display_usage();
-			exit(-1);
+			return (-1);
 		}
 
 	/* If there are no actions, this means "get/dump all tables" */
 
 	if (current_action == 0) {
-		ap_insert_action(NULL, AP_DUMP_ALL_TABLES);
+		if (ap_insert_action(NULL, AP_DUMP_ALL_TABLES)) {
+			return (-1);
+		}
 	}
 
 	return (0);
@@ -293,8 +303,12 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
 
 	/* Process command line options */
 
-	if (ap_do_options(argc, argv)) {
-		return (-1);
+	status = ap_do_options(argc, argv);
+	if (status > 0) {
+		return (0);
+	}
+	if (status < 0) {
+		return (status);
 	}
 
 	/* Get/dump ACPI table(s) as requested */
Signature · 1 line
1.7.10
author
#18 lore raw

PATCH 18/25 ACPICA: acpidump: Replace file IOs with new APIs to improve portability.

In reply to Lv Zheng

The new APIs are enabled to offer a portable layer to access files:
1. acpi_os_XXX_file_XXX: Wrapper of fopen/fclose/fread/fwrite
2. acpi_os_printf: Wrapper of printf
3. acpi_log_error: Wrapper of fprintf(stderr)

This patch deploys such mechanisms to acpidump to improve the portability of this tool. Lv Zheng.

---
 tools/power/acpi/tools/acpidump/acpidump.h |    2 +-
 tools/power/acpi/tools/acpidump/apdump.c   |   65 ++++++++++++++--------------
 tools/power/acpi/tools/acpidump/apfiles.c  |   47 ++++++++++----------
 tools/power/acpi/tools/acpidump/apmain.c   |   27 ++++++------
 4 files changed, 69 insertions(+), 72 deletions(-)
tools/power/acpi/tools/acpidump/acpidump.h +1 -1
index 8efc848..a2d37d6 100644
@@ -68,7 +68,7 @@ EXTERN u8 INIT_GLOBAL(gbl_verbose_mode, FALSE);
 EXTERN u8 INIT_GLOBAL(gbl_binary_mode, FALSE);
 EXTERN u8 INIT_GLOBAL(gbl_dump_customized_tables, FALSE);
 EXTERN u8 INIT_GLOBAL(gbl_do_not_dump_xsdt, FALSE);
-EXTERN FILE INIT_GLOBAL(*gbl_output_file, NULL);
+EXTERN ACPI_FILE INIT_GLOBAL(gbl_output_file, NULL);
 EXTERN char INIT_GLOBAL(*gbl_output_filename, NULL);
 EXTERN u64 INIT_GLOBAL(gbl_rsdp_base, 0);
 
tools/power/acpi/tools/acpidump/apdump.c +32 -33

134 lines not on this page · raw message

tools/power/acpi/tools/acpidump/apfiles.c +23 -24

112 lines not on this page · raw message

tools/power/acpi/tools/acpidump/apmain.c +13 -14
index 55fd44d..63f7bc9 100644
@@ -140,8 +140,8 @@ static int ap_insert_action(char *argument, u32 to_be_done)
 
 	current_action++;
 	if (current_action > AP_MAX_ACTIONS) {
-		fprintf(stderr, "Too many table options (max %u)\n",
-			AP_MAX_ACTIONS);
+		acpi_log_error("Too many table options (max %u)\n",
+			       AP_MAX_ACTIONS);
 		return (-1);
 	}
 
@@ -203,9 +203,9 @@ static int ap_do_options(int argc, char **argv)
 			    acpi_ut_strtoul64(acpi_gbl_optarg, 0,
 					      &gbl_rsdp_base);
 			if (ACPI_FAILURE(status)) {
-				fprintf(stderr,
-					"%s: Could not convert to a physical address\n",
-					acpi_gbl_optarg);
+				acpi_log_error
+				    ("%s: Could not convert to a physical address\n",
+				     acpi_gbl_optarg);
 				return (-1);
 			}
 			continue;
@@ -226,13 +226,13 @@ static int ap_do_options(int argc, char **argv)
 
 		case 'v':	/* Revision/version */
 
-			printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
+			acpi_os_printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
 			return (1);
 
 		case 'z':	/* Verbose mode */
 
 			gbl_verbose_mode = TRUE;
-			fprintf(stderr, ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
+			acpi_log_error(ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
 			continue;
 
 			/*
@@ -338,9 +338,8 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
 
 		default:
 
-			fprintf(stderr,
-				"Internal error, invalid action: 0x%X\n",
-				action->to_be_done);
+			acpi_log_error("Internal error, invalid action: 0x%X\n",
+				       action->to_be_done);
 			return (-1);
 		}
 
@@ -355,12 +354,12 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
 			/* Summary for the output file */
 
 			file_size = cm_get_file_size(gbl_output_file);
-			fprintf(stderr,
-				"Output file %s contains 0x%X (%u) bytes\n\n",
-				gbl_output_filename, file_size, file_size);
+			acpi_log_error
+			    ("Output file %s contains 0x%X (%u) bytes\n\n",
+			     gbl_output_filename, file_size, file_size);
 		}
 
-		fclose(gbl_output_file);
+		acpi_os_close_file(gbl_output_file);
 	}
 
 	return (status);
Signature · 1 line
1.7.10
author
#19 lore raw

PATCH 19/25 ACPICA: acpidump: Reduce freopen() invocations to improve portability.

In reply to Lv Zheng

This patch reduces the requirement of invoking freopen() in acpidump in order to reduce the porting effort of acpidump.

This patch achieves this by turning all acpi_os_printf(stdout) into acpi_ut_file_printf(gbl_output_file). Lv Zheng.

---
 drivers/acpi/acpica/acutils.h             |    7 ++
 drivers/acpi/acpica/utbuffer.c            |  128 +++++++++++++++++++++++++++++
 tools/power/acpi/tools/acpidump/apdump.c  |   11 +--
 tools/power/acpi/tools/acpidump/apfiles.c |    6 +-
 tools/power/acpi/tools/acpidump/apmain.c  |    3 +-
 5 files changed, 146 insertions(+), 9 deletions(-)
drivers/acpi/acpica/acutils.h +7 -0
index 035dc29..ed614f4 100644
@@ -353,6 +353,13 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id);
 
 void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 offset);
 
+#ifdef ACPI_APPLICATION
+void
+acpi_ut_dump_buffer_to_file(ACPI_FILE file,
+			    u8 *buffer,
+			    u32 count, u32 display, u32 base_offset);
+#endif
+
 void acpi_ut_report_error(char *module_name, u32 line_number);
 
 void acpi_ut_report_info(char *module_name, u32 line_number);
drivers/acpi/acpica/utbuffer.c +128 -0

131 lines not on this page · raw message

tools/power/acpi/tools/acpidump/apdump.c +6 -5
index 34fa5f2..53cee78 100644
@@ -195,12 +195,13 @@ ap_dump_table_buffer(struct acpi_table_header *table,
 	 * Note: simplest to just always emit a 64-bit address. acpi_xtract
 	 * utility can handle this.
 	 */
-	acpi_os_printf("%4.4s @ 0x%8.8X%8.8X\n", table->signature,
-		       ACPI_FORMAT_UINT64(address));
+	acpi_ut_file_printf(gbl_output_file, "%4.4s @ 0x%8.8X%8.8X\n",
+			    table->signature, ACPI_FORMAT_UINT64(address));
 
-	acpi_ut_dump_buffer(ACPI_CAST_PTR(u8, table), table_length,
-			    DB_BYTE_DISPLAY, 0);
-	acpi_os_printf("\n");
+	acpi_ut_dump_buffer_to_file(gbl_output_file,
+				    ACPI_CAST_PTR(u8, table), table_length,
+				    DB_BYTE_DISPLAY, 0);
+	acpi_ut_file_printf(gbl_output_file, "\n");
 	return (0);
 }
 
tools/power/acpi/tools/acpidump/apfiles.c +3 -3
index 5699ca1..5781c13 100644
@@ -60,7 +60,7 @@
 int ap_open_output_file(char *pathname)
 {
 	struct stat stat_info;
-	FILE *file;
+	ACPI_FILE file;
 
 	/* If file exists, prompt for overwrite */
 
@@ -74,9 +74,9 @@ int ap_open_output_file(char *pathname)
 
 	/* Point stdout to the file */
 
-	file = freopen(pathname, "w", stdout);
+	file = acpi_os_open_file(pathname, ACPI_FILE_WRITING);
 	if (!file) {
-		perror("Could not open output file");
+		acpi_log_error("Could not open output file: %s\n", pathname);
 		return (-1);
 	}
 
tools/power/acpi/tools/acpidump/apmain.c +2 -1
index 63f7bc9..35bd674 100644
@@ -300,6 +300,7 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
 
 	ACPI_DEBUG_INITIALIZE();	/* For debug version only */
 	acpi_os_initialize();
+	gbl_output_file = ACPI_FILE_OUT;
 
 	/* Process command line options */
 
@@ -348,7 +349,7 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
 		}
 	}
 
-	if (gbl_output_file) {
+	if (gbl_output_filename) {
 		if (gbl_verbose_mode) {
 
 			/* Summary for the output file */
Signature · 1 line
1.7.10
author
#20 lore raw

PATCH 20/25 ACPICA: OSL: Update acpidump to reduce source code differences.

In reply to Lv Zheng

This patch is a result of an ACPICA commit to enables acpidump for EFI. For Linux kernel, this patch is a no-op. It is only required by the ACPICA release process to reduce the source code differences between the Linux kernel and the ACPICA upstream. Lv Zheng.

---
 tools/power/acpi/tools/acpidump/apfiles.c |   30 ++++++++++++++++++++++-------
 tools/power/acpi/tools/acpidump/apmain.c  |    4 ++++
 2 files changed, 27 insertions(+), 7 deletions(-)
tools/power/acpi/tools/acpidump/apfiles.c +23 -7
index 5781c13..d470046 100644
@@ -44,6 +44,27 @@
 #include "acpidump.h"
 #include "acapps.h"
 
+/* Local prototypes */
+
+static int ap_is_existing_file(char *pathname);
+
+static int ap_is_existing_file(char *pathname)
+{
+#ifndef _GNU_EFI
+	struct stat stat_info;
+
+	if (!stat(pathname, &stat_info)) {
+		acpi_log_error("Target path already exists, overwrite? [y|n] ");
+
+		if (getchar() != 'y') {
+			return (-1);
+		}
+	}
+#endif
+
+	return 0;
+}
+
 /******************************************************************************
  *
  * FUNCTION:    ap_open_output_file
@@ -59,17 +80,12 @@
 
 int ap_open_output_file(char *pathname)
 {
-	struct stat stat_info;
 	ACPI_FILE file;
 
 	/* If file exists, prompt for overwrite */
 
-	if (!stat(pathname, &stat_info)) {
-		acpi_log_error("Target path already exists, overwrite? [y|n] ");
-
-		if (getchar() != 'y') {
-			return (-1);
-		}
+	if (ap_is_existing_file(pathname) != 0) {
+		return (-1);
 	}
 
 	/* Point stdout to the file */
tools/power/acpi/tools/acpidump/apmain.c +4 -0
index 35bd674..853b4da 100644
@@ -291,7 +291,11 @@ static int ap_do_options(int argc, char **argv)
  *
  ******************************************************************************/
 
+#ifndef _GNU_EFI
 int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
+#else
+int ACPI_SYSTEM_XFACE acpi_main(int argc, char *argv[])
+#endif
 {
 	int status = 0;
 	struct ap_dump_action *action;
Signature · 1 line
1.7.10
author
#21 lore raw

PATCH 21/25 ACPICA: Executer: Fix trivial issues in acpi_get_serial_access_bytes().

In reply to Lv Zheng

This patch fixes trivial issues in acpi_get_serial_access_bytes(), no real functional bugs. Lv Zheng.

---
 drivers/acpi/acpica/exfield.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/acpica/exfield.c +2 -2
index 12878e1..1ff42c0 100644
@@ -56,7 +56,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length);
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_get_serial_access_bytes
+ * FUNCTION:    acpi_ex_get_serial_access_length
  *
  * PARAMETERS:  accessor_type   - The type of the protocol indicated by region
  *                                field access attributes
@@ -103,7 +103,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length)
 	case AML_FIELD_ATTRIB_BLOCK_CALL:
 	default:
 
-		length = ACPI_GSBUS_BUFFER_SIZE;
+		length = ACPI_GSBUS_BUFFER_SIZE - 2;
 		break;
 	}
 
Signature · 1 line
1.7.10
author
#22 lore raw

PATCH 22/25 ACPICA: utprint/oslibcfs: cleanup - no functional change.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

Some cleanup and comment update.

---
 drivers/acpi/acpica/utprint.c                      |   44 +++++++++++++-------
 .../acpi/os_specific/service_layers/oslibcfs.c     |   30 ++++++-------
 2 files changed, 43 insertions(+), 31 deletions(-)
drivers/acpi/acpica/utprint.c +28 -16
index 9d5293f..1031164 100644
@@ -67,6 +67,11 @@ static char *acpi_ut_format_number(char *string,
 
 static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper);
 
+/* Module globals */
+
+static const char acpi_gbl_lower_hex_digits[] = "0123456789abcdef";
+static const char acpi_gbl_upper_hex_digits[] = "0123456789ABCDEF";
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ut_bound_string_length
@@ -74,7 +79,7 @@ static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper);
  * PARAMETERS:  string              - String with boundary
  *              count               - Boundary of the string
  *
- * RETURN:      Length of the string.
+ * RETURN:      Length of the string. Less than or equal to Count.
  *
  * DESCRIPTION: Calculate the length of a string with boundary.
  *
@@ -114,8 +119,8 @@ static char *acpi_ut_bound_string_output(char *string, const char *end, char c)
 	if (string < end) {
 		*string = c;
 	}
-	++string;
 
+	++string;
 	return (string);
 }
 
@@ -137,14 +142,12 @@ static char *acpi_ut_bound_string_output(char *string, const char *end, char c)
 
 static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper)
 {
-	const char lower_digits[] = "0123456789abcdef";
-	const char upper_digits[] = "0123456789ABCDEF";
 	const char *digits;
 	u64 digit_index;
 	char *pos;
 
 	pos = string;
-	digits = upper ? upper_digits : lower_digits;
+	digits = upper ? acpi_gbl_upper_hex_digits : acpi_gbl_lower_hex_digits;
 
 	if (number == 0) {
 		*(pos++) = '0';
@@ -155,8 +158,8 @@ static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper)
 			*(pos++) = digits[digit_index];
 		}
 	}
-	/* *(Pos++) = '0'; */
 
+	/* *(Pos++) = '0'; */
 	return (pos);
 }
 
@@ -181,8 +184,8 @@ const char *acpi_ut_scan_number(const char *string, u64 *number_ptr)
 		number *= 10;
 		number += *(string++) - '0';
 	}
-	*number_ptr = number;
 
+	*number_ptr = number;
 	return (string);
 }
 
@@ -211,8 +214,8 @@ const char *acpi_ut_print_number(char *string, u64 number)
 	while (pos1 != ascii_string) {
 		*(pos2++) = *(--pos1);
 	}
-	*pos2 = 0;
 
+	*pos2 = 0;
 	return (string);
 }
 
@@ -246,11 +249,12 @@ static char *acpi_ut_format_number(char *string,
 	s32 i;
 	char reversed_string[66];
 
-	/* Perform sanity checks */
+	/* Parameter validation */
 
 	if (base < 2 || base > 16) {
-		return NULL;
+		return (NULL);
 	}
+
 	if (type & ACPI_FORMAT_LEFT) {
 		type &= ~ACPI_FORMAT_ZERO;
 	}
@@ -294,6 +298,7 @@ static char *acpi_ut_format_number(char *string,
 	if (i > precision) {
 		precision = i;
 	}
+
 	width -= precision;
 
 	/* Output the string */
@@ -318,6 +323,7 @@ static char *acpi_ut_format_number(char *string,
 			string = acpi_ut_bound_string_output(string, end, zero);
 		}
 	}
+
 	while (i <= --precision) {
 		string = acpi_ut_bound_string_output(string, end, '0');
 	}
@@ -341,7 +347,7 @@ static char *acpi_ut_format_number(char *string,
  *              format              - Standard printf format
  *              args                - Argument list
  *
- * RETURN:      Size of successfully output bytes
+ * RETURN:      Number of bytes actually written.
  *
  * DESCRIPTION: Formatted output to a string using argument list pointer.
  *
@@ -428,6 +434,7 @@ acpi_ut_vsnprintf(char *string,
 		if (*format == 'h' || *format == 'l' || *format == 'L') {
 			qualifier = *format;
 			++format;
+
 			if (qualifier == 'l' && *format == 'l') {
 				qualifier = 'L';
 				++format;
@@ -450,8 +457,10 @@ acpi_ut_vsnprintf(char *string,
 									' ');
 				}
 			}
+
 			c = (char)va_arg(args, int);
 			pos = acpi_ut_bound_string_output(pos, end, c);
+
 			while (--width > 0) {
 				pos =
 				    acpi_ut_bound_string_output(pos, end, ' ');
@@ -512,10 +521,11 @@ acpi_ut_vsnprintf(char *string,
 				width = 2 * sizeof(void *);
 				type |= ACPI_FORMAT_ZERO;
 			}
+
 			p = va_arg(args, void *);
 			pos = acpi_ut_format_number(pos, end,
-						    ACPI_TO_INTEGER(p),
-						    16, width, precision, type);
+						    ACPI_TO_INTEGER(p), 16,
+						    width, precision, type);
 			continue;
 
 		default:
@@ -552,6 +562,7 @@ acpi_ut_vsnprintf(char *string,
 				number = (signed int)number;
 			}
 		}
+
 		pos = acpi_ut_format_number(pos, end, number, base,
 					    width, precision, type);
 	}
@@ -575,7 +586,7 @@ acpi_ut_vsnprintf(char *string,
  *              size                - Boundary of the string
  *              Format, ...         - Standard printf format
  *
- * RETURN:      Size of successfully output bytes
+ * RETURN:      Number of bytes actually written.
  *
  * DESCRIPTION: Formatted output to a string.
  *
@@ -602,7 +613,7 @@ int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...)
  *              format              - Standard printf format
  *              args                - Argument list
  *
- * RETURN:      Size of successfully output bytes
+ * RETURN:      Number of bytes actually written.
  *
  * DESCRIPTION: Formatted output to a file using argument list pointer.
  *
@@ -616,6 +627,7 @@ int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args)
 	flags = acpi_os_acquire_lock(acpi_gbl_print_lock);
 	length = acpi_ut_vsnprintf(acpi_gbl_print_buffer,
 				   sizeof(acpi_gbl_print_buffer), format, args);
+
 	(void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1);
 	acpi_os_release_lock(acpi_gbl_print_lock, flags);
 
@@ -629,7 +641,7 @@ int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args)
  * PARAMETERS:  file                - File descriptor
  *              Format, ...         - Standard printf format
  *
- * RETURN:      Size of successfully output bytes
+ * RETURN:      Number of bytes actually written.
  *
  * DESCRIPTION: Formatted output to a file.
  *
tools/power/acpi/os_specific/service_layers/oslibcfs.c +15 -15
index 2da0ce8..c13ff9c 100644
@@ -1,6 +1,6 @@
 /******************************************************************************
  *
- * Module Name: oslibcfs - C library OSL for file IO
+ * Module Name: oslibcfs - C library OSL for file I/O
  *
  *****************************************************************************/
 
@@ -64,8 +64,8 @@ ACPI_MODULE_NAME("oslibcfs")
 ACPI_FILE acpi_os_open_file(const char *path, u8 modes)
 {
 	ACPI_FILE file;
-	char modes_str[4];
 	u32 i = 0;
+	char modes_str[4];
 
 	if (modes & ACPI_FILE_READING) {
 		modes_str[i++] = 'r';
@@ -76,6 +76,7 @@ ACPI_FILE acpi_os_open_file(const char *path, u8 modes)
 	if (modes & ACPI_FILE_BINARY) {
 		modes_str[i++] = 'b';
 	}
+
 	modes_str[i++] = '\0';
 
 	file = fopen(path, modes_str);
@@ -90,11 +91,11 @@ ACPI_FILE acpi_os_open_file(const char *path, u8 modes)
  *
  * FUNCTION:    acpi_os_close_file
  *
- * PARAMETERS:  file                - File descriptor
+ * PARAMETERS:  file                - An open file descriptor
  *
  * RETURN:      None.
  *
- * DESCRIPTION: Close a file.
+ * DESCRIPTION: Close a file opened via acpi_os_open_file.
  *
  ******************************************************************************/
 
@@ -107,14 +108,14 @@ void acpi_os_close_file(ACPI_FILE file)
  *
  * FUNCTION:    acpi_os_read_file
  *
- * PARAMETERS:  file                - File descriptor
+ * PARAMETERS:  file                - An open file descriptor
  *              buffer              - Data buffer
  *              size                - Data block size
  *              count               - Number of data blocks
  *
- * RETURN:      Size of successfully read buffer.
+ * RETURN:      Number of bytes actually read.
  *
- * DESCRIPTION: Read a file.
+ * DESCRIPTION: Read from a file.
  *
  ******************************************************************************/
 
@@ -135,14 +136,14 @@ acpi_os_read_file(ACPI_FILE file, void *buffer, acpi_size size, acpi_size count)
  *
  * FUNCTION:    acpi_os_write_file
  *
- * PARAMETERS:  file                - File descriptor
+ * PARAMETERS:  file                - An open file descriptor
  *              buffer              - Data buffer
  *              size                - Data block size
  *              count               - Number of data blocks
  *
- * RETURN:      Size of successfully written buffer.
+ * RETURN:      Number of bytes actually written.
  *
- * DESCRIPTION: Write a file.
+ * DESCRIPTION: Write to a file.
  *
  ******************************************************************************/
 
@@ -164,9 +165,9 @@ acpi_os_write_file(ACPI_FILE file,
  *
  * FUNCTION:    acpi_os_get_file_offset
  *
- * PARAMETERS:  file                - File descriptor
+ * PARAMETERS:  file                - An open file descriptor
  *
- * RETURN:      Size of current position.
+ * RETURN:      Current file pointer position.
  *
  * DESCRIPTION: Get current file offset.
  *
@@ -177,7 +178,6 @@ long acpi_os_get_file_offset(ACPI_FILE file)
 	long offset;
 
 	offset = ftell(file);
-
 	return (offset);
 }
 
@@ -185,8 +185,8 @@ long acpi_os_get_file_offset(ACPI_FILE file)
  *
  * FUNCTION:    acpi_os_set_file_offset
  *
- * PARAMETERS:  file                - File descriptor
- *              offset              - File offset
+ * PARAMETERS:  file                - An open file descriptor
+ *              offset              - New file offset
  *              from                - From begin/end of file
  *
  * RETURN:      Status
Signature · 1 line
1.7.10
author
#23 lore raw

PATCH 23/25 ACPICA: Hardware: back port of a recursive locking fix.

In reply to Lv Zheng

This patch is a back port result of the following Linux commit:
Commit: f7f71cfbf0c276ee3d8d856d0f35a41aed997fa4
Author: Rakib Mullick <[email protected]>
Subject: ACPI: Fix possible recursive locking in hwregs.c

As a result of different coding style rules, the back ported code generates source code differences between the Linux kernel and the ACPICA upstream. This patch reduces such source code differences.

---
 drivers/acpi/acpica/hwregs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/acpica/hwregs.c +2 -1
index e0fd9b4..a4c34d2 100644
@@ -278,8 +278,9 @@ acpi_status acpi_hw_clear_acpi_status(void)
 
 	acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
 
-	if (ACPI_FAILURE(status))
+	if (ACPI_FAILURE(status)) {
 		goto exit;
+	}
 
 	/* Clear the GPE Bits in all GPE registers in all GPE blocks */
 
Signature · 1 line
1.7.10
author
#24 lore raw

PATCH 24/25 ACPICA: Tables: Merge DMAR table structure updates.

In reply to Lv Zheng

This patch is a back port result of the following Linux commit:
Author: David Woodhouse <[email protected]>
Subject: iommu/vt-d: Add ACPI namespace device reporting structures
ACPICA need to handle old compilers where u8 object_name[] is only allowed for an initialized variable. This patch reduces back port source code differences between Linux and ACPICA upstream.

Cc David Woodhouse <[email protected]>
---
 include/acpi/actbl2.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/actbl2.h +1 -1
index 860e5c8..21314d3 100644
@@ -516,7 +516,7 @@ struct acpi_dmar_andd {
 	struct acpi_dmar_header header;
 	u8 reserved[3];
 	u8 device_number;
-	u8 object_name[];
+	char object_name[1];
 };
 
 /*******************************************************************************
Signature · 1 line
1.7.10
author
#25 lore raw

PATCH 25/25 ACPICA: Update version to 20140627.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

Version 20140627.

---
 include/acpi/acpixf.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/acpixf.h +1 -1
index 9858551..3f6e14f 100644
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20140424
+#define ACPI_CA_VERSION                 0x20140627
 
 #include <acpi/acconfig.h>
 #include <acpi/actypes.h>
Signature · 1 line
1.7.10