Skip to content

Commit

Permalink
Clib/EFI: Fix wrong order of standard integer types/IO handles
Browse files Browse the repository at this point in the history
EFI header should use standard C library stuffs (integer types and IO
handles) rather than implementing such standard stuffs.
This patch fixes this issue by:
1. Implementing standard integer types for ACPI_USE_STANDARD_HADERS=n;
2. Defining EFI types using standard integer types and standard IO handles;
3. Tuning header inclusion order and environment definition order;
4. Removing wrong standard header inclusion from ACPICA core files;
5. Moving several application headers from acpidump.h to acenv.h.
This patch corrects some of them. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Jul 22, 2016
1 parent 6c6d573 commit 7f9b359
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 58 deletions.
1 change: 0 additions & 1 deletion source/common/acfileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
#include "acapps.h"
#include "actables.h"
#include "acutils.h"
#include <errno.h>

#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("acfileio")
Expand Down
2 changes: 0 additions & 2 deletions source/common/acgetline.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@
#include "acparser.h"
#include "acdebug.h"

#include <stdio.h>

/*
* This is an os-independent implementation of line-editing services needed
* by the AcpiExec utility. It uses getchar() and putchar() and the existing
Expand Down
1 change: 0 additions & 1 deletion source/common/cmfsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
#include <stdio.h>

#define _COMPONENT ACPI_TOOLS
ACPI_MODULE_NAME ("cmfsize")
Expand Down
2 changes: 0 additions & 2 deletions source/components/utilities/utpredef.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ AcpiUtGetExpectedReturnTypes (
******************************************************************************/

#if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP)
#include <stdio.h>
#include <string.h>

/* Local prototypes */

Expand Down
2 changes: 0 additions & 2 deletions source/include/acapps.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@
#ifndef _ACAPPS
#define _ACAPPS

#include <stdio.h>

/* Common info for tool signons */

#define ACPICA_NAME "Intel ACPI Component Architecture"
Expand Down
43 changes: 14 additions & 29 deletions source/include/platform/acefi.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@
#ifndef __ACEFI_H__
#define __ACEFI_H__

#include <stdarg.h>
#if defined(_GNU_EFI)
#include <stdint.h>
#include <unistd.h>
#ifdef __GNUC__
#include "acgcc.h"
#endif

#ifdef _MSC_VER
#include "acmsvc.h"
#endif

#if defined(__x86_64__)
Expand All @@ -136,16 +138,6 @@
#define EFIAPI
#endif

typedef uint8_t UINT8;
typedef uint16_t UINT16;
typedef int16_t INT16;
typedef uint32_t UINT32;
typedef int32_t INT32;
typedef uint64_t UINT64;
typedef int64_t INT64;
typedef uint8_t BOOLEAN;
typedef uint16_t CHAR16;

#define VOID void

#if defined(__ia64__) || defined(__x86_64__)
Expand All @@ -166,22 +158,23 @@ typedef uint16_t CHAR16;

#endif

typedef uint64_t UINTN;
typedef int64_t INTN;
#define UINTN uint64_t
#define INTN int64_t

#define EFIERR(a) (0x8000000000000000 | a)

#else

#define ACPI_MACHINE_WIDTH 32

typedef uint32_t UINTN;
typedef int32_t INTN;
#define UINTN uint32_t
#define INTN int32_t

#define EFIERR(a) (0x80000000 | a)

#endif

#define CHAR16 uint16_t

#ifdef USE_EFI_FUNCTION_WRAPPER
#define __VA_NARG__(...) \
Expand Down Expand Up @@ -301,14 +294,6 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,

#if defined(_GNU_EFI)

/* Using GCC for GNU EFI */

#include "acgcc.h"

#undef ACPI_USE_SYSTEM_CLIBRARY
#undef ACPI_USE_STANDARD_HEADERS
#define ACPI_USE_SYSTEM_INTTYPES

/*
* Math helpers
*/
Expand Down Expand Up @@ -337,8 +322,8 @@ struct _EFI_SYSTEM_TABLE;
extern struct _EFI_SYSTEM_TABLE *ST;
extern struct _EFI_BOOT_SERVICES *BS;

#define ACPI_FILE struct _SIMPLE_TEXT_OUTPUT_INTERFACE *
#define ACPI_FILE_OUT ST->ConOut
#define ACPI_FILE_ERR ST->ConOut
#define FILE struct _SIMPLE_TEXT_OUTPUT_INTERFACE
#define stdout ST->ConOut
#define stderr ST->ConOut

#endif /* __ACEFI_H__ */
13 changes: 13 additions & 0 deletions source/include/platform/acefiex.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@
#define __ACEFIEX_H__


#ifndef ACPI_USE_SYSTEM_CLIBRARY

typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef COMPILER_DEPENDENT_INT64 int64_t;
typedef COMPILER_DEPENDENT_UINT64 uint64_t;

#endif /* ACPI_USE_SYSTEM_CLIBRARY */

#define EFI_ERROR(a) (((INTN) a) < 0)
#define EFI_SUCCESS 0
#define EFI_LOAD_ERROR EFIERR(1)
Expand Down
23 changes: 14 additions & 9 deletions source/include/platform/acenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,20 @@
#elif defined(__OS2__)
#include "acos2.h"

#elif defined(_AED_EFI)
#include "acefi.h"

#elif defined(_GNU_EFI)
#include "acefi.h"

#elif defined(__HAIKU__)
#include "achaiku.h"

#elif defined(__QNX__)
#include "acqnx.h"

/*
* EFI applications can be built with -nostdlib, in this case, it must be
* included after including all other host environmental definitions, in
* order to override the definitions.
*/
#elif defined(_AED_EFI) || defined(_GNU_EFI)
#include "acefi.h"

#else

/* Unknown environment */
Expand Down Expand Up @@ -420,12 +422,16 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef ACPI_APPLICATION
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
#endif

#endif /* ACPI_USE_STANDARD_HEADERS */

#ifndef ACPI_FILE
#ifdef ACPI_APPLICATION
#include <stdio.h>
#define ACPI_FILE FILE *
#define ACPI_FILE_OUT stdout
#define ACPI_FILE_ERR stderr
Expand All @@ -434,6 +440,5 @@
#define ACPI_FILE_OUT NULL
#define ACPI_FILE_ERR NULL
#endif /* ACPI_APPLICATION */
#endif /* ACPI_FILE */

#endif /* __ACENV_H__ */
14 changes: 8 additions & 6 deletions source/include/platform/acenvex.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@
#elif defined(WIN32)
#include "acwinex.h"

#elif defined(_AED_EFI)
#include "acefiex.h"

#elif defined(_GNU_EFI)
#include "acefiex.h"

#elif defined(__DragonFly__)
#include "acdragonflyex.h"

/*
* EFI applications can be built with -nostdlib, in this case, it must be
* included after including all other host environmental definitions, in
* order to override the definitions.
*/
#elif defined(_AED_EFI) || defined(_GNU_EFI)
#include "acefiex.h"

#endif

/*! [End] no source code translation !*/
Expand Down
6 changes: 0 additions & 6 deletions source/tools/acpidump/acpidump.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@
#include "accommon.h"
#include "actables.h"

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>


/* Globals */

EXTERN BOOLEAN INIT_GLOBAL (Gbl_SummaryMode, FALSE);
Expand Down

0 comments on commit 7f9b359

Please sign in to comment.