Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f173a775 authored by Lv Zheng's avatar Lv Zheng Committed by Rafael J. Wysocki
Browse files

ACPICA: Clib: Add -nostdinc support for EFI layer

ACPICA commit d261d40ea168f8e4c4e3986de720b8651c4aba1c

This patch adds sprintf()/snprintf()/vsnprintf()/printf()/vfprintf()
support for OSPMs that have ACPI_USE_SYSTEM_CLIBRARY defined but do not
have ACPI_USE_STANDARD_HEADERS defined.

-iwithprefix include is required to include <stdarg.h> which contains
compiler specific implementation of vargs when -nostdinc is specified.
-fno-builtin is required for GCC to avoid optimization performed printf().
This optimization cannot be automatically disabled by specifying -nostdlib.
Please refer to the first link below for the details. However, the build
option changes do not affect Linux kernel builds and are not included.
Lv Zheng.

Link: http://www.ciselant.de/projects/gcc_printf/gcc_printf.html
Link: https://github.com/acpica/acpica/commit/d261d40e
Link: https://bugs.acpica.org/show_bug.cgi?id=1302


Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent e323c02d
Loading
Loading
Loading
Loading
+0 −19
Original line number Original line Diff line number Diff line
@@ -723,25 +723,6 @@ const struct ah_device_id *acpi_ah_match_hardware_id(char *hid);


const char *acpi_ah_match_uuid(u8 *data);
const char *acpi_ah_match_uuid(u8 *data);


/*
 * 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

/*
/*
 * utuuid -- UUID support functions
 * utuuid -- UUID support functions
 */
 */
+14 −16
Original line number Original line Diff line number Diff line
@@ -239,8 +239,7 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file,
	u8 buf_char;
	u8 buf_char;


	if (!buffer) {
	if (!buffer) {
		acpi_ut_file_printf(file,
		fprintf(file, "Null Buffer Pointer in DumpBuffer!\n");
				    "Null Buffer Pointer in DumpBuffer!\n");
		return;
		return;
	}
	}


@@ -254,7 +253,7 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file,


		/* Print current offset */
		/* Print current offset */


		acpi_ut_file_printf(file, "%6.4X: ", (base_offset + i));
		fprintf(file, "%6.4X: ", (base_offset + i));


		/* Print 16 hex chars */
		/* Print 16 hex chars */


@@ -263,8 +262,7 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file,


				/* Dump fill spaces */
				/* Dump fill spaces */


				acpi_ut_file_printf(file, "%*s",
				fprintf(file, "%*s", ((display * 2) + 1), " ");
						    ((display * 2) + 1), " ");
				j += display;
				j += display;
				continue;
				continue;
			}
			}
@@ -273,7 +271,7 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file,
			case DB_BYTE_DISPLAY:
			case DB_BYTE_DISPLAY:
			default:	/* Default is BYTE display */
			default:	/* Default is BYTE display */


				acpi_ut_file_printf(file, "%02X ",
				fprintf(file, "%02X ",
					buffer[(acpi_size)i + j]);
					buffer[(acpi_size)i + j]);
				break;
				break;


@@ -281,26 +279,26 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file,


				ACPI_MOVE_16_TO_32(&temp32,
				ACPI_MOVE_16_TO_32(&temp32,
						   &buffer[(acpi_size)i + j]);
						   &buffer[(acpi_size)i + j]);
				acpi_ut_file_printf(file, "%04X ", temp32);
				fprintf(file, "%04X ", temp32);
				break;
				break;


			case DB_DWORD_DISPLAY:
			case DB_DWORD_DISPLAY:


				ACPI_MOVE_32_TO_32(&temp32,
				ACPI_MOVE_32_TO_32(&temp32,
						   &buffer[(acpi_size)i + j]);
						   &buffer[(acpi_size)i + j]);
				acpi_ut_file_printf(file, "%08X ", temp32);
				fprintf(file, "%08X ", temp32);
				break;
				break;


			case DB_QWORD_DISPLAY:
			case DB_QWORD_DISPLAY:


				ACPI_MOVE_32_TO_32(&temp32,
				ACPI_MOVE_32_TO_32(&temp32,
						   &buffer[(acpi_size)i + j]);
						   &buffer[(acpi_size)i + j]);
				acpi_ut_file_printf(file, "%08X", temp32);
				fprintf(file, "%08X", temp32);


				ACPI_MOVE_32_TO_32(&temp32,
				ACPI_MOVE_32_TO_32(&temp32,
						   &buffer[(acpi_size)i + j +
						   &buffer[(acpi_size)i + j +
							   4]);
							   4]);
				acpi_ut_file_printf(file, "%08X ", temp32);
				fprintf(file, "%08X ", temp32);
				break;
				break;
			}
			}


@@ -311,24 +309,24 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file,
		 * Print the ASCII equivalent characters but watch out for the bad
		 * Print the ASCII equivalent characters but watch out for the bad
		 * unprintable ones (printable chars are 0x20 through 0x7E)
		 * unprintable ones (printable chars are 0x20 through 0x7E)
		 */
		 */
		acpi_ut_file_printf(file, " ");
		fprintf(file, " ");
		for (j = 0; j < 16; j++) {
		for (j = 0; j < 16; j++) {
			if (i + j >= count) {
			if (i + j >= count) {
				acpi_ut_file_printf(file, "\n");
				fprintf(file, "\n");
				return;
				return;
			}
			}


			buf_char = buffer[(acpi_size)i + j];
			buf_char = buffer[(acpi_size)i + j];
			if (isprint(buf_char)) {
			if (isprint(buf_char)) {
				acpi_ut_file_printf(file, "%c", buf_char);
				fprintf(file, "%c", buf_char);
			} else {
			} else {
				acpi_ut_file_printf(file, ".");
				fprintf(file, ".");
			}
			}
		}
		}


		/* Done with that line. */
		/* Done with that line. */


		acpi_ut_file_printf(file, "\n");
		fprintf(file, "\n");
		i += 16;
		i += 16;
	}
	}


+1 −1
Original line number Original line Diff line number Diff line
@@ -646,7 +646,7 @@ void ACPI_INTERNAL_VAR_XFACE acpi_log_error(const char *format, ...)
	va_list args;
	va_list args;


	va_start(args, format);
	va_start(args, format);
	(void)acpi_ut_file_vprintf(ACPI_FILE_ERR, format, args);
	(void)vfprintf(ACPI_FILE_ERR, format, args);
	va_end(args);
	va_end(args);
}
}


+90 −14
Original line number Original line Diff line number Diff line
@@ -336,7 +336,7 @@ static char *acpi_ut_format_number(char *string,


/*******************************************************************************
/*******************************************************************************
 *
 *
 * FUNCTION:    acpi_ut_vsnprintf
 * FUNCTION:    vsnprintf
 *
 *
 * PARAMETERS:  string              - String with boundary
 * PARAMETERS:  string              - String with boundary
 *              size                - Boundary of the string
 *              size                - Boundary of the string
@@ -349,9 +349,7 @@ static char *acpi_ut_format_number(char *string,
 *
 *
 ******************************************************************************/
 ******************************************************************************/


int
int vsnprintf(char *string, acpi_size size, const char *format, va_list args)
acpi_ut_vsnprintf(char *string,
		  acpi_size size, const char *format, va_list args)
{
{
	u8 base;
	u8 base;
	u8 type;
	u8 type;
@@ -586,7 +584,7 @@ acpi_ut_vsnprintf(char *string,


/*******************************************************************************
/*******************************************************************************
 *
 *
 * FUNCTION:    acpi_ut_snprintf
 * FUNCTION:    snprintf
 *
 *
 * PARAMETERS:  string              - String with boundary
 * PARAMETERS:  string              - String with boundary
 *              size                - Boundary of the string
 *              size                - Boundary of the string
@@ -598,13 +596,38 @@ acpi_ut_vsnprintf(char *string,
 *
 *
 ******************************************************************************/
 ******************************************************************************/


int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...)
int snprintf(char *string, acpi_size size, const char *format, ...)
{
{
	va_list args;
	va_list args;
	int length;
	int length;


	va_start(args, format);
	va_start(args, format);
	length = acpi_ut_vsnprintf(string, size, format, args);
	length = vsnprintf(string, size, format, args);
	va_end(args);

	return (length);
}

/*******************************************************************************
 *
 * FUNCTION:    sprintf
 *
 * PARAMETERS:  string              - String with boundary
 *              Format, ...         - Standard printf format
 *
 * RETURN:      Number of bytes actually written.
 *
 * DESCRIPTION: Formatted output to a string.
 *
 ******************************************************************************/

int sprintf(char *string, const char *format, ...)
{
	va_list args;
	int length;

	va_start(args, format);
	length = vsnprintf(string, ACPI_UINT32_MAX, format, args);
	va_end(args);
	va_end(args);


	return (length);
	return (length);
@@ -613,7 +636,60 @@ int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...)
#ifdef ACPI_APPLICATION
#ifdef ACPI_APPLICATION
/*******************************************************************************
/*******************************************************************************
 *
 *
 * FUNCTION:    acpi_ut_file_vprintf
 * FUNCTION:    vprintf
 *
 * PARAMETERS:  format              - Standard printf format
 *              args                - Argument list
 *
 * RETURN:      Number of bytes actually written.
 *
 * DESCRIPTION: Formatted output to stdout using argument list pointer.
 *
 ******************************************************************************/

int vprintf(const char *format, va_list args)
{
	acpi_cpu_flags flags;
	int length;

	flags = acpi_os_acquire_lock(acpi_gbl_print_lock);
	length = vsnprintf(acpi_gbl_print_buffer,
			   sizeof(acpi_gbl_print_buffer), format, args);

	(void)acpi_os_write_file(ACPI_FILE_OUT, acpi_gbl_print_buffer, length,
				 1);
	acpi_os_release_lock(acpi_gbl_print_lock, flags);

	return (length);
}

/*******************************************************************************
 *
 * FUNCTION:    printf
 *
 * PARAMETERS:  Format, ...         - Standard printf format
 *
 * RETURN:      Number of bytes actually written.
 *
 * DESCRIPTION: Formatted output to stdout.
 *
 ******************************************************************************/

int printf(const char *format, ...)
{
	va_list args;
	int length;

	va_start(args, format);
	length = vprintf(format, args);
	va_end(args);

	return (length);
}

/*******************************************************************************
 *
 * FUNCTION:    vfprintf
 *
 *
 * PARAMETERS:  file                - File descriptor
 * PARAMETERS:  file                - File descriptor
 *              format              - Standard printf format
 *              format              - Standard printf format
@@ -625,13 +701,13 @@ int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...)
 *
 *
 ******************************************************************************/
 ******************************************************************************/


int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args)
int vfprintf(FILE * file, const char *format, va_list args)
{
{
	acpi_cpu_flags flags;
	acpi_cpu_flags flags;
	int length;
	int length;


	flags = acpi_os_acquire_lock(acpi_gbl_print_lock);
	flags = acpi_os_acquire_lock(acpi_gbl_print_lock);
	length = acpi_ut_vsnprintf(acpi_gbl_print_buffer,
	length = vsnprintf(acpi_gbl_print_buffer,
			   sizeof(acpi_gbl_print_buffer), format, args);
			   sizeof(acpi_gbl_print_buffer), format, args);


	(void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1);
	(void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1);
@@ -642,7 +718,7 @@ int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args)


/*******************************************************************************
/*******************************************************************************
 *
 *
 * FUNCTION:    acpi_ut_file_printf
 * FUNCTION:    fprintf
 *
 *
 * PARAMETERS:  file                - File descriptor
 * PARAMETERS:  file                - File descriptor
 *              Format, ...         - Standard printf format
 *              Format, ...         - Standard printf format
@@ -653,13 +729,13 @@ 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, ...)
int fprintf(FILE * file, const char *format, ...)
{
{
	va_list args;
	va_list args;
	int length;
	int length;


	va_start(args, format);
	va_start(args, format);
	length = acpi_ut_file_vprintf(file, format, args);
	length = vfprintf(file, format, args);
	va_end(args);
	va_end(args);


	return (length);
	return (length);
+3 −3
Original line number Original line Diff line number Diff line
@@ -195,13 +195,13 @@ ap_dump_table_buffer(struct acpi_table_header *table,
	 * Note: simplest to just always emit a 64-bit address. acpi_xtract
	 * Note: simplest to just always emit a 64-bit address. acpi_xtract
	 * utility can handle this.
	 * utility can handle this.
	 */
	 */
	acpi_ut_file_printf(gbl_output_file, "%4.4s @ 0x%8.8X%8.8X\n",
	fprintf(gbl_output_file, "%4.4s @ 0x%8.8X%8.8X\n",
		table->signature, ACPI_FORMAT_UINT64(address));
		table->signature, ACPI_FORMAT_UINT64(address));


	acpi_ut_dump_buffer_to_file(gbl_output_file,
	acpi_ut_dump_buffer_to_file(gbl_output_file,
				    ACPI_CAST_PTR(u8, table), table_length,
				    ACPI_CAST_PTR(u8, table), table_length,
				    DB_BYTE_DISPLAY, 0);
				    DB_BYTE_DISPLAY, 0);
	acpi_ut_file_printf(gbl_output_file, "\n");
	fprintf(gbl_output_file, "\n");
	return (0);
	return (0);
}
}


Loading