From 3a81e13d1640464df04a0454a9b5bb12abd101f4 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:52 +0800 Subject: EFI: Add a missing object file which is split recently This patch adds utnonansi.o linkage to EFI builds. Lv Zheng. Signed-off-by: Lv Zheng --- generate/efi/acpidump/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generate/efi/acpidump/Makefile b/generate/efi/acpidump/Makefile index 16bd52a81..d7d5f48f8 100644 --- a/generate/efi/acpidump/Makefile +++ b/generate/efi/acpidump/Makefile @@ -36,12 +36,14 @@ OBJECTS = \ $(OBJDIR)/osefixf.o\ $(OBJDIR)/tbprint.o\ $(OBJDIR)/tbxfroot.o\ + $(OBJDIR)/utascii.o\ $(OBJDIR)/utbuffer.o\ $(OBJDIR)/utdebug.o\ $(OBJDIR)/utclib.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ $(OBJDIR)/utmath.o\ + $(OBJDIR)/utnonansi.o\ $(OBJDIR)/utprint.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/utxferror.o -- cgit v1.2.1 From 9fcf90766f26bef08ae06d0aefa975ad18b64ba7 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Thu, 26 May 2016 08:44:31 +0800 Subject: EFI/acpidump: Remove Gbl_DumpCustomizedTables awareness EFI environment doesn't support any table customization mechanism, and acpidump defaults to use "-c on", it then is a problem that in UEFI environment, user can obtain nothing by just type "acpidump.efi". This patch removes Gbl_DumpCustomizedTables awaness to fix this issue. Lv Zheng. Signed-off-by: Lv Zheng --- source/os_specific/service_layers/osefitbl.c | 80 +++++++++++----------------- 1 file changed, 30 insertions(+), 50 deletions(-) diff --git a/source/os_specific/service_layers/osefitbl.c b/source/os_specific/service_layers/osefitbl.c index ec2161915..42924053d 100644 --- a/source/os_specific/service_layers/osefitbl.c +++ b/source/os_specific/service_layers/osefitbl.c @@ -305,18 +305,7 @@ AcpiOsGetTableByName ( /* Not a main ACPI table, attempt to extract it from the RSDT/XSDT */ - if (!Gbl_DumpCustomizedTables) - { - /* Attempt to get the table from the memory */ - - Status = OslGetTable (Signature, Instance, Table, Address); - } - else - { - /* Attempt to get the table from the static directory */ - - Status = AE_SUPPORT; - } + Status = OslGetTable (Signature, Instance, Table, Address); return (Status); } @@ -650,56 +639,47 @@ OslTableInitialize ( return (Status); } - if (!Gbl_DumpCustomizedTables) + /* Add mandatory tables to global table list first */ + + Status = OslAddTableToList (ACPI_RSDP_NAME, 0); + if (ACPI_FAILURE (Status)) { - /* Add mandatory tables to global table list first */ + return (Status); + } - Status = OslAddTableToList (ACPI_RSDP_NAME, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + Status = OslAddTableToList (ACPI_SIG_RSDT, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - Status = OslAddTableToList (ACPI_SIG_RSDT, 0); + if (Gbl_Revision == 2) + { + Status = OslAddTableToList (ACPI_SIG_XSDT, 0); if (ACPI_FAILURE (Status)) { return (Status); } + } - if (Gbl_Revision == 2) - { - Status = OslAddTableToList (ACPI_SIG_XSDT, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - - Status = OslAddTableToList (ACPI_SIG_DSDT, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + Status = OslAddTableToList (ACPI_SIG_DSDT, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - Status = OslAddTableToList (ACPI_SIG_FACS, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + Status = OslAddTableToList (ACPI_SIG_FACS, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - /* Add all tables found in the memory */ + /* Add all tables found in the memory */ - Status = OslListTables (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - else + Status = OslListTables (); + if (ACPI_FAILURE (Status)) { - /* Add all tables found in the static directory */ - - Status = AE_SUPPORT; + return (Status); } Gbl_TableListInitialized = TRUE; -- cgit v1.2.1 From 8825041d5ebe9d75680cba96bf00efc0754b9683 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:53 +0800 Subject: OSL: Add correct AcpiGbl_DebugTimeout export to allow acpiexec to link The AcpiGbl_DebugTimeout which is used by acpiexec -et option now is only implemented in oswinxf.c and used for WIN32 builds. This makes it very difficult to remember to add this variable to other os specificy layer files in order to link. This patch makes it a global option so that it can always be linked. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/acpixf.h | 2 ++ source/os_specific/service_layers/osunixxf.c | 3 --- source/os_specific/service_layers/oswinxf.c | 3 --- source/tools/acpiexec/aemain.c | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/source/include/acpixf.h b/source/include/acpixf.h index 6ced00db7..4f3f74791 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -357,6 +357,8 @@ ACPI_GLOBAL (ACPI_TABLE_FADT, AcpiGbl_FADT); ACPI_GLOBAL (UINT32, AcpiCurrentGpeCount); ACPI_GLOBAL (BOOLEAN, AcpiGbl_SystemAwakeAndRunning); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DebugTimeout, FALSE); + /***************************************************************************** * diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c index c3a66d7b3..f04b59e65 100644 --- a/source/os_specific/service_layers/osunixxf.c +++ b/source/os_specific/service_layers/osunixxf.c @@ -136,9 +136,6 @@ ACPI_MODULE_NAME ("osunixxf") -BOOLEAN AcpiGbl_DebugTimeout = FALSE; - - /* Upcalls to AcpiExec */ void diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c index 78a0526c4..07f284492 100644 --- a/source/os_specific/service_layers/oswinxf.c +++ b/source/os_specific/service_layers/oswinxf.c @@ -172,9 +172,6 @@ ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES]; #endif /* ACPI_SINGLE_THREADED */ -BOOLEAN AcpiGbl_DebugTimeout = FALSE; - - /****************************************************************************** * * FUNCTION: AcpiOsTerminate diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index a645ffa27..90b6cfc5b 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -131,7 +131,6 @@ * Windows: The setargv.obj module must be linked in to automatically * expand wildcards. */ -extern BOOLEAN AcpiGbl_DebugTimeout; /* Local prototypes */ -- cgit v1.2.1 From 831b85c7b5e72e12dbc30df2b04e255e1accddb8 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:53 +0800 Subject: Applications: Enable USE_NATIVE_ALLOCATE_ZEROED environment for all applications We now safe to enable USE_NATIVE_ALLOCATE_ZEROED for all applications as there are implementations in oswinxf.c, osunixxf.c and osefixf.c. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/platform/acenv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index 7a7245624..41022a7e4 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -151,6 +151,7 @@ (defined ACPI_EXAMPLE_APP) #define ACPI_APPLICATION #define ACPI_SINGLE_THREADED +#define USE_NATIVE_ALLOCATE_ZEROED #endif /* iASL configuration */ @@ -197,7 +198,6 @@ #ifdef ACPI_DUMP_APP #define ACPI_USE_NATIVE_MEMORY_MAPPING -#define USE_NATIVE_ALLOCATE_ZEROED #endif /* AcpiNames/Example configuration. Hardware disabled */ -- cgit v1.2.1 From 70e41616567106527e9302496ec03a5e70d8cc53 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:54 +0800 Subject: Clib: Add -nostdinc support for EFI layer 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. This patch also converts the entire EFI porting layer to use the standard system Clibrary and implements GNU EFI specific standard Clibrary stdio operations. -fno-builtin is required for GCC to avoid optimization performed printf(). This optimization cannot be automatically disabled by specifying -nostdlib. Please refer to the Link 1 for the details. -iwithprefix include is required to include which contains compiler specific implementation of vargs. It is unclear why there is the vargs macros defined for OSPMs that do not have ACPI_USE_SYSTEM_CLIBRARY defined. After applying this patch, this special vargs implementation should also get deleted. Standard C header files shouldn't be included here and there throughout the entire ACPICA code base. This patch corrects some of them. Lv Zheng. Link 1: http://www.ciselant.de/projects/gcc_printf/gcc_printf.html Signed-off-by: Lv Zheng --- generate/efi/Makefile.config | 6 ++ generate/efi/acpidump/Makefile | 2 +- source/common/acfileio.c | 5 +- source/common/acgetline.c | 2 - source/common/cmfsize.c | 1 - source/components/debugger/dbfileio.c | 1 - source/components/utilities/utbuffer.c | 26 +++--- source/components/utilities/utclib.c | 4 +- source/components/utilities/utdebug.c | 2 +- source/components/utilities/utpredef.c | 2 - source/components/utilities/utprint.c | 122 +++++++++++++++++++++++++--- source/include/acapps.h | 6 -- source/include/acclib.h | 57 +++++++++++++ source/include/accommon.h | 4 +- source/include/acutils.h | 42 ---------- source/include/platform/acefi.h | 34 ++------ source/include/platform/acenv.h | 57 +++++++++++-- source/include/platform/acgcc.h | 4 + source/include/platform/aclinux.h | 6 +- source/include/platform/acmsvc.h | 4 + source/os_specific/service_layers/osefixf.c | 2 +- source/tools/acpidump/acpidump.h | 6 -- source/tools/acpidump/apdump.c | 4 +- source/tools/acpidump/apfiles.c | 6 +- 24 files changed, 269 insertions(+), 136 deletions(-) diff --git a/generate/efi/Makefile.config b/generate/efi/Makefile.config index d7872c8ac..6c7c5950b 100644 --- a/generate/efi/Makefile.config +++ b/generate/efi/Makefile.config @@ -95,17 +95,23 @@ LD = ld OBJCOPY = objcopy CFLAGS = \ + --save-temps\ + -nostdinc\ + -nostdlib\ -std=c99\ -U__linux__\ -U_LINUX\ -D_GNU_EFI\ -D_GNU_SOURCE\ + -fno-builtin\ + -iwithprefix include\ -fno-stack-protector\ -fno-strict-aliasing\ -fpic\ -fshort-wchar\ -I$(ACPICA_INCLUDE) LDFLAGS = \ + -nostdinc\ -nostdlib\ -znocombreloc\ -Bsymbolic diff --git a/generate/efi/acpidump/Makefile b/generate/efi/acpidump/Makefile index d7d5f48f8..672421d6e 100644 --- a/generate/efi/acpidump/Makefile +++ b/generate/efi/acpidump/Makefile @@ -38,8 +38,8 @@ OBJECTS = \ $(OBJDIR)/tbxfroot.o\ $(OBJDIR)/utascii.o\ $(OBJDIR)/utbuffer.o\ - $(OBJDIR)/utdebug.o\ $(OBJDIR)/utclib.o\ + $(OBJDIR)/utdebug.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ $(OBJDIR)/utmath.o\ diff --git a/source/common/acfileio.c b/source/common/acfileio.c index c00580fc7..8b7d28360 100644 --- a/source/common/acfileio.c +++ b/source/common/acfileio.c @@ -118,7 +118,6 @@ #include "acapps.h" #include "actables.h" #include "acutils.h" -#include #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("acfileio") @@ -352,7 +351,7 @@ AcGetOneTableFromFile ( /* Allocate a buffer for the entire table */ - Table = AcpiOsAllocate ((size_t) TableHeader.Length); + Table = AcpiOsAllocate ((ACPI_SIZE) TableHeader.Length); if (!Table) { return (AE_NO_MEMORY); @@ -460,7 +459,7 @@ AcValidateTableHeader ( long TableOffset) { ACPI_TABLE_HEADER TableHeader; - size_t Actual; + ACPI_SIZE Actual; long OriginalOffset; UINT32 FileSize; UINT32 i; diff --git a/source/common/acgetline.c b/source/common/acgetline.c index dfc065389..a28aaf78d 100644 --- a/source/common/acgetline.c +++ b/source/common/acgetline.c @@ -119,8 +119,6 @@ #include "acparser.h" #include "acdebug.h" -#include - /* * This is an os-independent implementation of line-editing services needed * by the AcpiExec utility. It uses getchar() and putchar() and the existing diff --git a/source/common/cmfsize.c b/source/common/cmfsize.c index accdf225b..4d35105cb 100644 --- a/source/common/cmfsize.c +++ b/source/common/cmfsize.c @@ -116,7 +116,6 @@ #include "acpi.h" #include "accommon.h" #include "acapps.h" -#include #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("cmfsize") diff --git a/source/components/debugger/dbfileio.c b/source/components/debugger/dbfileio.c index d7942b745..78e06eb86 100644 --- a/source/components/debugger/dbfileio.c +++ b/source/components/debugger/dbfileio.c @@ -118,7 +118,6 @@ #include "accommon.h" #include "acdebug.h" #include "actables.h" -#include #ifdef ACPI_APPLICATION #include "acapps.h" #endif diff --git a/source/components/utilities/utbuffer.c b/source/components/utilities/utbuffer.c index 4a50e9e06..fe5c7d505 100644 --- a/source/components/utilities/utbuffer.c +++ b/source/components/utilities/utbuffer.c @@ -336,7 +336,7 @@ AcpiUtDumpBufferToFile ( if (!Buffer) { - AcpiUtFilePrintf (File, "Null Buffer Pointer in DumpBuffer!\n"); + fprintf (File, "Null Buffer Pointer in DumpBuffer!\n"); return; } @@ -351,7 +351,7 @@ AcpiUtDumpBufferToFile ( { /* Print current offset */ - AcpiUtFilePrintf (File, "%6.4X: ", (BaseOffset + i)); + fprintf (File, "%6.4X: ", (BaseOffset + i)); /* Print 16 hex chars */ @@ -361,7 +361,7 @@ AcpiUtDumpBufferToFile ( { /* Dump fill spaces */ - AcpiUtFilePrintf (File, "%*s", ((Display * 2) + 1), " "); + fprintf (File, "%*s", ((Display * 2) + 1), " "); j += Display; continue; } @@ -371,28 +371,28 @@ AcpiUtDumpBufferToFile ( case DB_BYTE_DISPLAY: default: /* Default is BYTE display */ - AcpiUtFilePrintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]); + fprintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]); break; case DB_WORD_DISPLAY: ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); - AcpiUtFilePrintf (File, "%04X ", Temp32); + fprintf (File, "%04X ", Temp32); break; case DB_DWORD_DISPLAY: ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); - AcpiUtFilePrintf (File, "%08X ", Temp32); + fprintf (File, "%08X ", Temp32); break; case DB_QWORD_DISPLAY: ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); - AcpiUtFilePrintf (File, "%08X", Temp32); + fprintf (File, "%08X", Temp32); ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]); - AcpiUtFilePrintf (File, "%08X ", Temp32); + fprintf (File, "%08X ", Temp32); break; } @@ -403,29 +403,29 @@ AcpiUtDumpBufferToFile ( * Print the ASCII equivalent characters but watch out for the bad * unprintable ones (printable chars are 0x20 through 0x7E) */ - AcpiUtFilePrintf (File, " "); + fprintf (File, " "); for (j = 0; j < 16; j++) { if (i + j >= Count) { - AcpiUtFilePrintf (File, "\n"); + fprintf (File, "\n"); return; } BufChar = Buffer[(ACPI_SIZE) i + j]; if (isprint (BufChar)) { - AcpiUtFilePrintf (File, "%c", BufChar); + fprintf (File, "%c", BufChar); } else { - AcpiUtFilePrintf (File, "."); + fprintf (File, "."); } } /* Done with that line. */ - AcpiUtFilePrintf (File, "\n"); + fprintf (File, "\n"); i += 16; } diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c index 26fbaf958..7e61b980a 100644 --- a/source/components/utilities/utclib.c +++ b/source/components/utilities/utclib.c @@ -163,7 +163,7 @@ ACPI_MODULE_NAME ("utclib") -#ifndef ACPI_USE_SYSTEM_CLIBRARY /* Entire module */ +#if defined(ACPI_USE_SYSTEM_CLIBRARY) && !defined(ACPI_USE_STANDARD_HEADERS) /******************************************************************************* @@ -987,4 +987,4 @@ const UINT8 AcpiGbl_Ctypes[257] = { }; -#endif /* ACPI_USE_SYSTEM_CLIBRARY */ +#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */ diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c index 4d2b306a0..d13c0974e 100644 --- a/source/components/utilities/utdebug.c +++ b/source/components/utilities/utdebug.c @@ -804,7 +804,7 @@ AcpiLogError ( va_list Args; va_start (Args, Format); - (void) AcpiUtFileVprintf (ACPI_FILE_ERR, Format, Args); + (void) vfprintf (ACPI_FILE_ERR, Format, Args); va_end (Args); } diff --git a/source/components/utilities/utpredef.c b/source/components/utilities/utpredef.c index 01196bb03..a97064c7a 100644 --- a/source/components/utilities/utpredef.c +++ b/source/components/utilities/utpredef.c @@ -268,8 +268,6 @@ AcpiUtGetExpectedReturnTypes ( ******************************************************************************/ #if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP) -#include -#include /* Local prototypes */ diff --git a/source/components/utilities/utprint.c b/source/components/utilities/utprint.c index 5ca859ec4..ec7c0cce4 100644 --- a/source/components/utilities/utprint.c +++ b/source/components/utilities/utprint.c @@ -120,6 +120,8 @@ ACPI_MODULE_NAME ("utprint") +#if defined(ACPI_USE_SYSTEM_CLIBRARY) && !defined(ACPI_USE_STANDARD_HEADERS) + #define ACPI_FORMAT_SIGN 0x01 #define ACPI_FORMAT_SIGN_PLUS 0x02 #define ACPI_FORMAT_SIGN_PLUS_SPACE 0x04 @@ -488,7 +490,7 @@ AcpiUtFormatNumber ( /******************************************************************************* * - * FUNCTION: AcpiUtVsnprintf + * FUNCTION: vsnprintf * * PARAMETERS: String - String with boundary * Size - Boundary of the string @@ -502,7 +504,7 @@ AcpiUtFormatNumber ( ******************************************************************************/ int -AcpiUtVsnprintf ( +vsnprintf ( char *String, ACPI_SIZE Size, const char *Format, @@ -785,7 +787,7 @@ AcpiUtVsnprintf ( /******************************************************************************* * - * FUNCTION: AcpiUtSnprintf + * FUNCTION: snprintf * * PARAMETERS: String - String with boundary * Size - Boundary of the string @@ -798,7 +800,7 @@ AcpiUtVsnprintf ( ******************************************************************************/ int -AcpiUtSnprintf ( +snprintf ( char *String, ACPI_SIZE Size, const char *Format, @@ -809,7 +811,38 @@ AcpiUtSnprintf ( va_start (Args, Format); - Length = AcpiUtVsnprintf (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); return (Length); @@ -819,7 +852,69 @@ AcpiUtSnprintf ( #ifdef ACPI_APPLICATION /******************************************************************************* * - * FUNCTION: AcpiUtFileVprintf + * 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 = AcpiOsAcquireLock (AcpiGbl_PrintLock); + Length = vsnprintf (AcpiGbl_PrintBuffer, + sizeof (AcpiGbl_PrintBuffer), Format, Args); + + (void) AcpiOsWriteFile (ACPI_FILE_OUT, AcpiGbl_PrintBuffer, Length, 1); + AcpiOsReleaseLock (AcpiGbl_PrintLock, 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 * Format - Standard printf format @@ -832,8 +927,8 @@ AcpiUtSnprintf ( ******************************************************************************/ int -AcpiUtFileVprintf ( - ACPI_FILE File, +vfprintf ( + FILE *File, const char *Format, va_list Args) { @@ -842,7 +937,7 @@ AcpiUtFileVprintf ( Flags = AcpiOsAcquireLock (AcpiGbl_PrintLock); - Length = AcpiUtVsnprintf (AcpiGbl_PrintBuffer, + Length = vsnprintf (AcpiGbl_PrintBuffer, sizeof (AcpiGbl_PrintBuffer), Format, Args); (void) AcpiOsWriteFile (File, AcpiGbl_PrintBuffer, Length, 1); @@ -854,7 +949,7 @@ AcpiUtFileVprintf ( /******************************************************************************* * - * FUNCTION: AcpiUtFilePrintf + * FUNCTION: fprintf * * PARAMETERS: File - File descriptor * Format, ... - Standard printf format @@ -866,8 +961,8 @@ AcpiUtFileVprintf ( ******************************************************************************/ int -AcpiUtFilePrintf ( - ACPI_FILE File, +fprintf ( + FILE *File, const char *Format, ...) { @@ -876,9 +971,10 @@ AcpiUtFilePrintf ( va_start (Args, Format); - Length = AcpiUtFileVprintf (File, Format, Args); + Length = vfprintf (File, Format, Args); va_end (Args); return (Length); } #endif +#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */ diff --git a/source/include/acapps.h b/source/include/acapps.h index b8ab5a3c6..8699dcbba 100644 --- a/source/include/acapps.h +++ b/source/include/acapps.h @@ -116,12 +116,6 @@ #ifndef _ACAPPS #define _ACAPPS -#include - -#ifdef _MSC_VER /* disable some level-4 warnings */ -#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ -#endif - /* Common info for tool signons */ #define ACPICA_NAME "Intel ACPI Component Architecture" diff --git a/source/include/acclib.h b/source/include/acclib.h index 267c73d25..46919656b 100644 --- a/source/include/acclib.h +++ b/source/include/acclib.h @@ -236,4 +236,61 @@ int toupper ( int c); +/* + * utprint - printf/vprintf output functions + */ +const char * +AcpiUtScanNumber ( + const char *String, + UINT64 *NumberPtr); + +const char * +AcpiUtPrintNumber ( + char *String, + UINT64 Number); + +int +vsnprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + va_list Args); + +int +snprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + ...); + +int +sprintf ( + char *String, + const char *Format, + ...); + +#ifdef ACPI_APPLICATION +int +vprintf ( + const char *Format, + va_list Args); + +int +printf ( + const char *Format, + ...); + +int +vfprintf ( + FILE *File, + const char *Format, + va_list Args); + +int +fprintf ( + FILE *File, + const char *Format, + ...); +#endif + #endif /* _ACCLIB_H */ diff --git a/source/include/accommon.h b/source/include/accommon.h index 76f76d62f..7e398b590 100644 --- a/source/include/accommon.h +++ b/source/include/accommon.h @@ -131,9 +131,9 @@ #include "acglobal.h" /* All global variables */ #include "achware.h" /* Hardware defines and interfaces */ #include "acutils.h" /* Utility interfaces */ -#ifndef ACPI_USE_SYSTEM_CLIBRARY +#if defined(ACPI_USE_SYSTEM_CLIBRARY) && !defined(ACPI_USE_STANDARD_HEADERS) #include "acclib.h" /* C library interfaces */ -#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ +#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */ #endif /* __ACCOMMON_H__ */ diff --git a/source/include/acutils.h b/source/include/acutils.h index 3fdca4599..358d1c8b7 100644 --- a/source/include/acutils.h +++ b/source/include/acutils.h @@ -1139,48 +1139,6 @@ AcpiAhMatchUuid ( UINT8 *Data); -/* - * utprint - printf/vprintf output functions - */ -const char * -AcpiUtScanNumber ( - const char *String, - UINT64 *NumberPtr); - -const char * -AcpiUtPrintNumber ( - char *String, - UINT64 Number); - -int -AcpiUtVsnprintf ( - char *String, - ACPI_SIZE Size, - const char *Format, - va_list Args); - -int -AcpiUtSnprintf ( - char *String, - ACPI_SIZE Size, - const char *Format, - ...); - -#ifdef ACPI_APPLICATION -int -AcpiUtFileVprintf ( - ACPI_FILE File, - const char *Format, - va_list Args); - -int -AcpiUtFilePrintf ( - ACPI_FILE File, - const char *Format, - ...); -#endif - - /* * utuuid -- UUID support functions */ diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h index a252b2cd9..b251c1504 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -116,12 +116,6 @@ #ifndef __ACEFI_H__ #define __ACEFI_H__ -#include -#if defined(_GNU_EFI) -#include -#include -#endif - #if defined(__x86_64__) #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) #define USE_MS_ABI 1 @@ -136,16 +130,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__) @@ -166,8 +150,8 @@ 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) @@ -176,13 +160,14 @@ typedef int64_t INTN; #define ACPI_MACHINE_WIDTH 32 #define ACPI_USE_NATIVE_DIVIDE -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__(...) \ @@ -306,10 +291,9 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, #include "acgcc.h" -#undef ACPI_USE_SYSTEM_CLIBRARY #undef ACPI_USE_STANDARD_HEADERS #undef ACPI_USE_NATIVE_DIVIDE -#define ACPI_USE_SYSTEM_INTTYPES +#undef ACPI_USE_SYSTEM_INTTYPES /* * Math helpers @@ -340,8 +324,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__ */ diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index 41022a7e4..878be8c12 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -422,12 +422,47 @@ #include #include #include +#ifdef ACPI_APPLICATION +#include +#include +#include +#include +#endif -#endif /* ACPI_USE_STANDARD_HEADERS */ +#else /* ACPI_USE_STANDARD_HEADERS */ -/* We will be linking to the standard Clib functions */ +#ifdef ACPI_USE_COMPILER_VA -#else +/* + * We will be linking to the standard Clib functions, but stdarg.h is + * compiler specific, this works for linux kernel. + */ +#include + +#else /* ACPI_USE_COMPILER_VA */ + +#ifndef va_arg + +#ifndef _VALIST +#define _VALIST +typedef char *va_list; +#endif /* _VALIST */ + +/* Storage alignment properties */ + +#define _AUPBND (sizeof (ACPI_NATIVE_INT) - 1) +#define _ADNBND (sizeof (ACPI_NATIVE_INT) - 1) + +/* Variable argument list macro definitions */ + +#define _Bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) +#define va_arg(ap, T) (*(T *)(((ap) += (_Bnd (T, _AUPBND))) - (_Bnd (T,_ADNBND)))) +#define va_end(ap) (ap = (va_list) NULL) +#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_Bnd (A,_AUPBND)))) + +#endif /* va_arg */ + +#endif /* ACPI_USE_COMPILER_VA */ /****************************************************************************** * @@ -435,6 +470,19 @@ * *****************************************************************************/ +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_STANDARD_HEADERS */ + +#else /* ACPI_USE_SYSTEM_CLIBRARY */ + /* * Use local definitions of C library macros and functions. These function * implementations may not be as efficient as an inline or assembly code @@ -466,9 +514,7 @@ typedef char *va_list; #endif /* ACPI_USE_SYSTEM_CLIBRARY */ -#ifndef ACPI_FILE #ifdef ACPI_APPLICATION -#include #define ACPI_FILE FILE * #define ACPI_FILE_OUT stdout #define ACPI_FILE_ERR stderr @@ -477,6 +523,5 @@ typedef char *va_list; #define ACPI_FILE_OUT NULL #define ACPI_FILE_ERR NULL #endif /* ACPI_APPLICATION */ -#endif /* ACPI_FILE */ #endif /* __ACENV_H__ */ diff --git a/source/include/platform/acgcc.h b/source/include/platform/acgcc.h index 3d36a38a3..773bd8959 100644 --- a/source/include/platform/acgcc.h +++ b/source/include/platform/acgcc.h @@ -116,6 +116,10 @@ #ifndef __ACGCC_H__ #define __ACGCC_H__ +/* Allow inclusion of stdarg.h */ + +#define ACPI_USE_COMPILER_VA + #define ACPI_INLINE __inline__ /* Function name is used for debug output. Non-ANSI, compiler-dependent */ diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h index 912773593..c948f6900 100644 --- a/source/include/platform/aclinux.h +++ b/source/include/platform/aclinux.h @@ -245,11 +245,9 @@ #else /* !__KERNEL__ */ -#include -#include -#include -#include #include +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_STANDARD_HEADERS /* Define/disable kernel-specific declarators */ diff --git a/source/include/platform/acmsvc.h b/source/include/platform/acmsvc.h index 133f449ef..c7cf21bc7 100644 --- a/source/include/platform/acmsvc.h +++ b/source/include/platform/acmsvc.h @@ -225,6 +225,10 @@ #pragma warning( disable : 4295 ) /* needed for acpredef.h array */ #endif +#ifdef _MSC_VER /* disable some level-4 warnings */ +#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ +#endif + /* Debug support. */ diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index fa111b508..1947197e1 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -827,7 +827,7 @@ AcpiOsVprintf ( va_list Args) { - (void) AcpiUtFileVprintf (ACPI_FILE_OUT, Format, Args); + (void) vfprintf (ACPI_FILE_OUT, Format, Args); } diff --git a/source/tools/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h index 76843da28..b15de1d86 100644 --- a/source/tools/acpidump/acpidump.h +++ b/source/tools/acpidump/acpidump.h @@ -128,12 +128,6 @@ #include "accommon.h" #include "actables.h" -#include -#include -#include -#include - - /* Globals */ EXTERN BOOLEAN INIT_GLOBAL (Gbl_SummaryMode, FALSE); diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c index 783060080..bb5bd545b 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -295,13 +295,13 @@ ApDumpTableBuffer ( * Note: simplest to just always emit a 64-bit address. AcpiXtract * utility can handle this. */ - AcpiUtFilePrintf (Gbl_OutputFile, "%4.4s @ 0x%8.8X%8.8X\n", + fprintf (Gbl_OutputFile, "%4.4s @ 0x%8.8X%8.8X\n", Table->Signature, ACPI_FORMAT_UINT64 (Address)); AcpiUtDumpBufferToFile (Gbl_OutputFile, ACPI_CAST_PTR (UINT8, Table), TableLength, DB_BYTE_DISPLAY, 0); - AcpiUtFilePrintf (Gbl_OutputFile, "\n"); + fprintf (Gbl_OutputFile, "\n"); return (0); } diff --git a/source/tools/acpidump/apfiles.c b/source/tools/acpidump/apfiles.c index 9394e98cf..04d9cf250 100644 --- a/source/tools/acpidump/apfiles.c +++ b/source/tools/acpidump/apfiles.c @@ -225,7 +225,7 @@ ApWriteToBinaryFile ( char Filename[ACPI_NAME_SIZE + 16]; char InstanceStr [16]; ACPI_FILE File; - size_t Actual; + ACPI_SIZE Actual; UINT32 TableLength; @@ -254,7 +254,7 @@ ApWriteToBinaryFile ( if (Instance > 0) { - AcpiUtSnprintf (InstanceStr, sizeof (InstanceStr), "%u", Instance); + snprintf (InstanceStr, sizeof (InstanceStr), "%u", Instance); strcat (Filename, InstanceStr); } @@ -311,7 +311,7 @@ ApGetTableFromFile ( ACPI_TABLE_HEADER *Buffer = NULL; ACPI_FILE File; UINT32 FileSize; - size_t Actual; + ACPI_SIZE Actual; /* Must use binary mode */ -- cgit v1.2.1 From a33ba9f8564bf7524941a6762800b207d0a3a15a Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:54 +0800 Subject: Clib: Eliminate AcpiOsXXXFile()/AcpiLogError and link clibrary fxxx()/errno/perror() instead This patch follows new ACPICA design, eliminates old portable OSLs, and implements fopen/fread/fwrite/fclose/fseek/ftell for GNU EFI environment. This patch also eliminates AcpiLogError(), convering them into fprintf(stderr)/perror(). Lv Zheng. Signed-off-by: Lv Zheng --- generate/efi/acpidump/Makefile | 1 + generate/unix/acpibin/Makefile | 1 - generate/unix/acpidump/Makefile | 1 - generate/unix/acpiexamples/Makefile | 1 - generate/unix/acpiexec/Makefile | 1 - generate/unix/acpihelp/Makefile | 1 - generate/unix/acpinames/Makefile | 1 - generate/unix/acpisrc/Makefile | 5 +- generate/unix/acpixtract/Makefile | 1 - generate/unix/iasl/Makefile | 1 - source/common/acfileio.c | 2 +- source/common/cmfsize.c | 12 +- source/common/getopt.c | 2 +- source/components/utilities/utdebug.c | 30 - source/components/utilities/utprint.c | 4 +- source/include/acclib.h | 61 ++ source/include/acpiosxf.h | 67 +- source/include/acpixf.h | 7 - source/include/actypes.h | 10 - source/os_specific/service_layers/oseficlib.c | 880 ++++++++++++++++++++++++++ source/os_specific/service_layers/osefitbl.c | 6 +- source/os_specific/service_layers/osefixf.c | 696 +------------------- source/os_specific/service_layers/oslibcfs.c | 330 ---------- source/tools/acpidump/apdump.c | 24 +- source/tools/acpidump/apfiles.c | 36 +- source/tools/acpidump/apmain.c | 14 +- source/tools/acpiexec/aeinitfile.c | 3 +- 27 files changed, 1006 insertions(+), 1192 deletions(-) create mode 100644 source/os_specific/service_layers/oseficlib.c delete mode 100644 source/os_specific/service_layers/oslibcfs.c diff --git a/generate/efi/acpidump/Makefile b/generate/efi/acpidump/Makefile index 672421d6e..39fa364d0 100644 --- a/generate/efi/acpidump/Makefile +++ b/generate/efi/acpidump/Makefile @@ -32,6 +32,7 @@ OBJECTS = \ $(OBJDIR)/apmain.o\ $(OBJDIR)/cmfsize.o\ $(OBJDIR)/getopt.o\ + $(OBJDIR)/oseficlib.o\ $(OBJDIR)/osefitbl.o\ $(OBJDIR)/osefixf.o\ $(OBJDIR)/tbprint.o\ diff --git a/generate/unix/acpibin/Makefile b/generate/unix/acpibin/Makefile index e856499a5..511d71091 100644 --- a/generate/unix/acpibin/Makefile +++ b/generate/unix/acpibin/Makefile @@ -47,7 +47,6 @@ OBJECTS = \ $(OBJDIR)/utstate.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/utxferror.o\ - $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o # diff --git a/generate/unix/acpidump/Makefile b/generate/unix/acpidump/Makefile index d6e19644c..bc3430613 100644 --- a/generate/unix/acpidump/Makefile +++ b/generate/unix/acpidump/Makefile @@ -33,7 +33,6 @@ OBJECTS = \ $(OBJDIR)/apmain.o\ $(OBJDIR)/cmfsize.o\ $(OBJDIR)/getopt.o\ - $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixdir.o\ $(OBJDIR)/osunixmap.o\ $(OBJDIR)/osunixxf.o\ diff --git a/generate/unix/acpiexamples/Makefile b/generate/unix/acpiexamples/Makefile index 54d74739e..b22b84883 100644 --- a/generate/unix/acpiexamples/Makefile +++ b/generate/unix/acpiexamples/Makefile @@ -107,7 +107,6 @@ OBJECTS = \ $(OBJDIR)/nsxfeval.o\ $(OBJDIR)/nsxfname.o\ $(OBJDIR)/nsxfobj.o\ - $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/psargs.o\ $(OBJDIR)/psloop.o\ diff --git a/generate/unix/acpiexec/Makefile b/generate/unix/acpiexec/Makefile index 7f8befabb..33e516caf 100644 --- a/generate/unix/acpiexec/Makefile +++ b/generate/unix/acpiexec/Makefile @@ -163,7 +163,6 @@ OBJECTS = \ $(OBJDIR)/nsxfeval.o\ $(OBJDIR)/nsxfname.o\ $(OBJDIR)/nsxfobj.o\ - $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/psargs.o\ $(OBJDIR)/psloop.o\ diff --git a/generate/unix/acpihelp/Makefile b/generate/unix/acpihelp/Makefile index d50e416c8..4290a153f 100644 --- a/generate/unix/acpihelp/Makefile +++ b/generate/unix/acpihelp/Makefile @@ -38,7 +38,6 @@ OBJECTS = \ $(OBJDIR)/ahtable.o\ $(OBJDIR)/ahuuids.o\ $(OBJDIR)/getopt.o\ - $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/utdebug.o\ $(OBJDIR)/utexcep.o\ diff --git a/generate/unix/acpinames/Makefile b/generate/unix/acpinames/Makefile index 4ff5558f0..a7dd6a9ee 100644 --- a/generate/unix/acpinames/Makefile +++ b/generate/unix/acpinames/Makefile @@ -72,7 +72,6 @@ OBJECTS = \ $(OBJDIR)/nsxfeval.o\ $(OBJDIR)/nsxfname.o\ $(OBJDIR)/nsxfobj.o\ - $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/psargs.o\ $(OBJDIR)/psloop.o\ diff --git a/generate/unix/acpisrc/Makefile b/generate/unix/acpisrc/Makefile index 93a9868cf..931b33d71 100644 --- a/generate/unix/acpisrc/Makefile +++ b/generate/unix/acpisrc/Makefile @@ -36,15 +36,14 @@ OBJECTS = \ $(OBJDIR)/asutils.o\ $(OBJDIR)/cmfsize.o\ $(OBJDIR)/getopt.o \ - $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixdir.o\ $(OBJDIR)/osunixxf.o\ - $(OBJDIR)/utascii.o\ + $(OBJDIR)/utascii.o\ $(OBJDIR)/utdebug.o\ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utglobal.o\ $(OBJDIR)/utmath.o\ - $(OBJDIR)/utnonansi.o\ + $(OBJDIR)/utnonansi.o\ $(OBJDIR)/utprint.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/utxferror.o diff --git a/generate/unix/acpixtract/Makefile b/generate/unix/acpixtract/Makefile index 272cbd091..22b3294ee 100644 --- a/generate/unix/acpixtract/Makefile +++ b/generate/unix/acpixtract/Makefile @@ -31,7 +31,6 @@ OBJECTS = \ $(OBJDIR)/axmain.o\ $(OBJDIR)/axutils.o\ $(OBJDIR)/getopt.o\ - $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/utascii.o\ $(OBJDIR)/utdebug.o\ diff --git a/generate/unix/iasl/Makefile b/generate/unix/iasl/Makefile index 73682f801..747059539 100644 --- a/generate/unix/iasl/Makefile +++ b/generate/unix/iasl/Makefile @@ -177,7 +177,6 @@ OBJECTS = \ $(OBJDIR)/nswalk.o\ $(OBJDIR)/nsxfobj.o\ $(OBJDIR)/osunixxf.o\ - $(OBJDIR)/oslibcfs.o\ $(OBJDIR)/prexpress.o\ $(OBJDIR)/prmacros.o\ $(OBJDIR)/prscan.o\ diff --git a/source/common/acfileio.c b/source/common/acfileio.c index 8b7d28360..e53b825a7 100644 --- a/source/common/acfileio.c +++ b/source/common/acfileio.c @@ -169,7 +169,7 @@ AcGetAllTablesFromFile ( File = fopen (Filename, "rb"); if (!File) { - perror ("Could not open input file"); + fprintf (stderr, "Could not open input file: %s\n", Filename); if (errno == ENOENT) { return (AE_NOT_EXIST); diff --git a/source/common/cmfsize.c b/source/common/cmfsize.c index 4d35105cb..2139e4b26 100644 --- a/source/common/cmfsize.c +++ b/source/common/cmfsize.c @@ -145,19 +145,19 @@ CmGetFileSize ( /* Save the current file pointer, seek to EOF to obtain file size */ - CurrentOffset = AcpiOsGetFileOffset (File); + CurrentOffset = ftell (File); if (CurrentOffset < 0) { goto OffsetError; } - Status = AcpiOsSetFileOffset (File, 0, ACPI_FILE_END); + Status = fseek (File, 0, SEEK_END); if (ACPI_FAILURE (Status)) { goto SeekError; } - FileSize = AcpiOsGetFileOffset (File); + FileSize = ftell (File); if (FileSize < 0) { goto OffsetError; @@ -165,7 +165,7 @@ CmGetFileSize ( /* Restore original file pointer */ - Status = AcpiOsSetFileOffset (File, CurrentOffset, ACPI_FILE_BEGIN); + Status = fseek (File, CurrentOffset, SEEK_SET); if (ACPI_FAILURE (Status)) { goto SeekError; @@ -175,10 +175,10 @@ CmGetFileSize ( OffsetError: - AcpiLogError ("Could not get file offset"); + fprintf (stderr, "Could not get file offset\n"); return (ACPI_UINT32_MAX); SeekError: - AcpiLogError ("Could not set file offset"); + fprintf (stderr, "Could not set file offset\n"); return (ACPI_UINT32_MAX); } diff --git a/source/common/getopt.c b/source/common/getopt.c index 15eadc259..cf4375dd8 100644 --- a/source/common/getopt.c +++ b/source/common/getopt.c @@ -129,7 +129,7 @@ #include "acapps.h" #define ACPI_OPTION_ERROR(msg, badchar) \ - if (AcpiGbl_Opterr) {AcpiLogError ("%s%c\n", msg, badchar);} + if (AcpiGbl_Opterr) {fprintf (stderr, "%s%c\n", msg, badchar);} int AcpiGbl_Opterr = 1; diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c index d13c0974e..995d45cc3 100644 --- a/source/components/utilities/utdebug.c +++ b/source/components/utilities/utdebug.c @@ -780,33 +780,3 @@ AcpiTracePoint ( ACPI_EXPORT_SYMBOL (AcpiTracePoint) #endif - - -#ifdef ACPI_APPLICATION -/******************************************************************************* - * - * FUNCTION: AcpiLogError - * - * 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 -AcpiLogError ( - const char *Format, - ...) -{ - va_list Args; - - va_start (Args, Format); - (void) vfprintf (ACPI_FILE_ERR, Format, Args); - va_end (Args); -} - -ACPI_EXPORT_SYMBOL (AcpiLogError) -#endif diff --git a/source/components/utilities/utprint.c b/source/components/utilities/utprint.c index ec7c0cce4..ee52453fd 100644 --- a/source/components/utilities/utprint.c +++ b/source/components/utilities/utprint.c @@ -876,7 +876,7 @@ vprintf ( Length = vsnprintf (AcpiGbl_PrintBuffer, sizeof (AcpiGbl_PrintBuffer), Format, Args); - (void) AcpiOsWriteFile (ACPI_FILE_OUT, AcpiGbl_PrintBuffer, Length, 1); + (void) fwrite (AcpiGbl_PrintBuffer, Length, 1, ACPI_FILE_OUT); AcpiOsReleaseLock (AcpiGbl_PrintLock, Flags); return (Length); @@ -940,7 +940,7 @@ vfprintf ( Length = vsnprintf (AcpiGbl_PrintBuffer, sizeof (AcpiGbl_PrintBuffer), Format, Args); - (void) AcpiOsWriteFile (File, AcpiGbl_PrintBuffer, Length, 1); + (void) fwrite (AcpiGbl_PrintBuffer, Length, 1, File); AcpiOsReleaseLock (AcpiGbl_PrintLock, Flags); return (Length); diff --git a/source/include/acclib.h b/source/include/acclib.h index 46919656b..67c05bf36 100644 --- a/source/include/acclib.h +++ b/source/include/acclib.h @@ -145,6 +145,23 @@ extern const UINT8 AcpiGbl_Ctypes[]; #define isprint(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU)) #define isalpha(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) +/* Error code */ + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define EBADF 9 /* Bad file number */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define ENODEV 19 /* No such device */ +#define EINVAL 22 /* Invalid argument */ +#define EPIPE 32 /* Broken pipe */ +#define ERANGE 34 /* Math result not representable */ /* Strings */ @@ -270,6 +287,17 @@ sprintf ( ...); #ifdef ACPI_APPLICATION +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +/* + * NOTE: Currently we only need to update errno for file IOs. Other + * Clibrary invocations in ACPICA do not make descisions according to + * the errno. + */ +extern int errno; + int vprintf ( const char *Format, @@ -291,6 +319,39 @@ fprintf ( FILE *File, const char *Format, ...); + +FILE * +fopen ( + const char *Path, + const char *Modes); + +void +fclose ( + FILE *File); + +int +fread ( + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count, + FILE *File); + +int +fwrite ( + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count, + FILE *File); + +int +fseek ( + FILE *File, + long Offset, + int From); + +long +ftell ( + FILE *File); #endif #endif /* _ACCLIB_H */ diff --git a/source/include/acpiosxf.h b/source/include/acpiosxf.h index 550e264bd..60d61f119 100644 --- a/source/include/acpiosxf.h +++ b/source/include/acpiosxf.h @@ -564,6 +564,15 @@ AcpiOsGetLine ( UINT32 *BytesRead); #endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint +void +AcpiOsTracePoint ( + ACPI_TRACE_EVENT_TYPE Type, + BOOLEAN Begin, + UINT8 *Aml, + char *Pathname); +#endif + /* * Obtain ACPI table(s) @@ -624,62 +633,4 @@ AcpiOsCloseDirectory ( #endif -/* - * File I/O and related support - */ -#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenFile -ACPI_FILE -AcpiOsOpenFile ( - const char *Path, - UINT8 Modes); -#endif - -#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseFile -void -AcpiOsCloseFile ( - ACPI_FILE File); -#endif - -#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadFile -int -AcpiOsReadFile ( - ACPI_FILE File, - void *Buffer, - ACPI_SIZE Size, - ACPI_SIZE Count); -#endif - -#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteFile -int -AcpiOsWriteFile ( - ACPI_FILE File, - void *Buffer, - ACPI_SIZE Size, - ACPI_SIZE Count); -#endif - -#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetFileOffset -long -AcpiOsGetFileOffset ( - ACPI_FILE File); -#endif - -#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSetFileOffset -ACPI_STATUS -AcpiOsSetFileOffset ( - ACPI_FILE File, - long Offset, - UINT8 From); -#endif - -#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint -void -AcpiOsTracePoint ( - ACPI_TRACE_EVENT_TYPE Type, - BOOLEAN Begin, - UINT8 *Aml, - char *Pathname); -#endif - - #endif /* __ACPIOSXF_H__ */ diff --git a/source/include/acpixf.h b/source/include/acpixf.h index 4f3f74791..18ac73993 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -1306,13 +1306,6 @@ AcpiTracePoint ( UINT8 *Aml, char *Pathname)) -ACPI_APP_DEPENDENT_RETURN_VOID ( -ACPI_PRINTF_LIKE(1) -void ACPI_INTERNAL_VAR_XFACE -AcpiLogError ( - const char *Format, - ...)) - ACPI_STATUS AcpiInitializeDebugger ( void); diff --git a/source/include/actypes.h b/source/include/actypes.h index 039d71a5a..abc4f7b4c 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -1459,16 +1459,6 @@ typedef enum #define ACPI_OSI_WIN_10 0x0D -/* 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 - - /* Definitions of getopt */ #define ACPI_OPT_END -1 diff --git a/source/os_specific/service_layers/oseficlib.c b/source/os_specific/service_layers/oseficlib.c new file mode 100644 index 000000000..629e99d00 --- /dev/null +++ b/source/os_specific/service_layers/oseficlib.c @@ -0,0 +1,880 @@ +/****************************************************************************** + * + * Module Name: oseficlib - EFI specific CLibrary interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acapps.h" + +#define _COMPONENT ACPI_OS_SERVICES + ACPI_MODULE_NAME ("oseficlib") + + +/* Local definitions */ + +#define ACPI_EFI_PRINT_LENGTH 256 + + +/* Local prototypes */ + +static int +AcpiEfiArgify ( + char *String, + int *ArgcPtr, + char ***ArgvPtr); + +static int +AcpiEfiConvertArgcv ( + CHAR16 *LoadOpt, + UINT32 LoadOptSize, + int *ArgcPtr, + char ***ArgvPtr, + char **BufferPtr); + +static CHAR16 * +AcpiEfiFlushFile ( + FILE *File, + CHAR16 *Begin, + CHAR16 *End, + CHAR16 *Pos, + BOOLEAN FlushAll); + + +/* Local variables */ + +static EFI_FILE_HANDLE AcpiGbl_EfiCurrentVolume = NULL; +EFI_GUID AcpiGbl_LoadedImageProtocol = LOADED_IMAGE_PROTOCOL; +EFI_GUID AcpiGbl_TextInProtocol = SIMPLE_TEXT_INPUT_PROTOCOL; +EFI_GUID AcpiGbl_TextOutProtocol = SIMPLE_TEXT_OUTPUT_PROTOCOL; +EFI_GUID AcpiGbl_FileSystemProtocol = SIMPLE_FILE_SYSTEM_PROTOCOL; + +int errno = 0; + + +/******************************************************************************* + * + * FUNCTION: fopen + * + * PARAMETERS: Path - File path + * Modes - File operation type + * + * RETURN: File descriptor + * + * DESCRIPTION: Open a file for reading or/and writing. + * + ******************************************************************************/ + +FILE * +fopen ( + const char *Path, + const char *Modes) +{ + EFI_STATUS EfiStatus = EFI_SUCCESS; + UINT64 OpenModes; + EFI_FILE_HANDLE EfiFile = NULL; + CHAR16 *Path16 = NULL; + CHAR16 *Pos16; + const char *Pos; + INTN Count, i; + BOOLEAN IsAppend = FALSE; + FILE *File = NULL; + + + if (!Path) + { + errno = EINVAL; + return (NULL); + } + + /* + * Convert modes, EFI says the only 2 read/write modes are read-only, + * read+write. Thus set default mode as read-only. + */ + OpenModes = EFI_FILE_MODE_READ; + switch (*Modes++) + { + case 'r': + + break; + + case 'w': + + OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); + break; + + case 'a': + + OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); + IsAppend = TRUE; + break; + + default: + + errno = EINVAL; + return (NULL); + } + + for (; *Modes; Modes++) + { + switch (*Modes) + { + case '+': + + OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); + break; + + case 'b': + case 't': + + break; + + case 'f': + default: + + break; + } + } + + /* Allocate path buffer */ + + Count = strlen (Path); + Path16 = ACPI_ALLOCATE_ZEROED ((Count + 1) * sizeof (CHAR16)); + if (!Path16) + { + EfiStatus = EFI_BAD_BUFFER_SIZE; + errno = ENOMEM; + goto ErrorExit; + } + Pos = Path; + Pos16 = Path16; + while (*Pos == '/' || *Pos == '\\') + { + Pos++; + Count--; + } + for (i = 0; i < Count; i++) + { + if (*Pos == '/') + { + *Pos16++ = '\\'; + Pos++; + } + else + { + *Pos16++ = *Pos++; + } + } + *Pos16 = '\0'; + + EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Open, 5, + AcpiGbl_EfiCurrentVolume, &EfiFile, Path16, OpenModes, 0); + if (EFI_ERROR (EfiStatus)) + { + fprintf (stderr, "EFI_FILE_HANDLE->Open() failure.\n"); + errno = ENOENT; + goto ErrorExit; + } + + File = (FILE *) EfiFile; + if (IsAppend) + { + fseek (File, 0, SEEK_END); + } + +ErrorExit: + + if (Path16) + { + ACPI_FREE (Path16); + } + + return (File); +} + + +/******************************************************************************* + * + * FUNCTION: fclose + * + * PARAMETERS: File - File descriptor + * + * RETURN: None. + * + * DESCRIPTION: Close a file. + * + ******************************************************************************/ + +void +fclose ( + FILE *File) +{ + EFI_FILE_HANDLE EfiFile; + + + if (File == stdout || File == stderr) + { + return; + } + EfiFile = (EFI_FILE_HANDLE) File; + (void) uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Close, 1, EfiFile); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: fread + * + * PARAMETERS: Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks + * File - File descriptor + * + * RETURN: Size of successfully read buffer + * + * DESCRIPTION: Read from a file. + * + ******************************************************************************/ + +int +fread ( + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count, + FILE *File) +{ + int Length = -1; + EFI_FILE_HANDLE EfiFile; + UINTN ReadSize; + EFI_STATUS EfiStatus; + + + if (File == stdout || File == stderr) + { + } + else + { + EfiFile = (EFI_FILE_HANDLE) File; + if (!EfiFile) + { + errno = EINVAL; + goto ErrorExit; + } + ReadSize = Size * Count; + + EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Read, 3, + EfiFile, &ReadSize, Buffer); + if (EFI_ERROR (EfiStatus)) + { + fprintf (stderr, "EFI_FILE_HANDLE->Read() failure.\n"); + errno = EIO; + goto ErrorExit; + } + Length = ReadSize; + } + +ErrorExit: + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEfiFlushFile + * + * PARAMETERS: File - File descriptor + * Begin - String with boundary + * End - Boundary of the string + * Pos - Current position + * FlushAll - Whether checking boundary before flushing + * + * RETURN: Updated position + * + * DESCRIPTION: Flush cached buffer to the file. + * + ******************************************************************************/ + +static CHAR16 * +AcpiEfiFlushFile ( + FILE *File, + CHAR16 *Begin, + CHAR16 *End, + CHAR16 *Pos, + BOOLEAN FlushAll) +{ + + if (FlushAll || Pos >= (End - 1)) + { + *Pos = 0; + uefi_call_wrapper (File->OutputString, 2, File, Begin); + Pos = Begin; + } + + return (Pos); +} + + +/******************************************************************************* + * + * FUNCTION: fwrite + * + * PARAMETERS: Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks + * File - File descriptor + * + * RETURN: Size of successfully written buffer + * + * DESCRIPTION: Write to a file. + * + ******************************************************************************/ + +int +fwrite ( + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count, + FILE *File) +{ + int Length = -1; + CHAR16 String[ACPI_EFI_PRINT_LENGTH]; + const char *Ascii; + CHAR16 *End; + CHAR16 *Pos; + int i, j; + EFI_FILE_HANDLE EfiFile; + UINTN WriteSize; + EFI_STATUS EfiStatus; + + + if (File == stdout || File == stderr) + { + Pos = String; + End = String + ACPI_EFI_PRINT_LENGTH - 1; + Ascii = ACPI_CAST_PTR (const char, Buffer); + Length = 0; + + for (j = 0; j < Count; j++) + { + for (i = 0; i < Size; i++) + { + if (*Ascii == '\n') + { + *Pos++ = '\r'; + Pos = AcpiEfiFlushFile (File, String, + End, Pos, FALSE); + } + *Pos++ = *Ascii++; + Length++; + Pos = AcpiEfiFlushFile (File, String, + End, Pos, FALSE); + } + } + Pos = AcpiEfiFlushFile (File, String, End, Pos, TRUE); + } + else + { + EfiFile = (EFI_FILE_HANDLE) File; + if (!EfiFile) + { + errno = EINVAL; + goto ErrorExit; + } + WriteSize = Size * Count; + + EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Write, 3, + EfiFile, &WriteSize, Buffer); + if (EFI_ERROR (EfiStatus)) + { + fprintf (stderr, "EFI_FILE_HANDLE->Write() failure.\n"); + errno = EIO; + goto ErrorExit; + } + Length = WriteSize; + } + +ErrorExit: + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: ftell + * + * PARAMETERS: File - File descriptor + * + * RETURN: Size of current position + * + * DESCRIPTION: Get current file offset. + * + ******************************************************************************/ + +long +ftell ( + FILE *File) +{ + long Offset = -1; + + + return (Offset); +} + + +/******************************************************************************* + * + * FUNCTION: fseek + * + * PARAMETERS: File - File descriptor + * Offset - File offset + * From - From begin/end of file + * + * RETURN: Status + * + * DESCRIPTION: Set current file offset. + * + ******************************************************************************/ + +int +fseek ( + FILE *File, + long Offset, + int From) +{ + + return (-1); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEfiArgify + * + * PARAMETERS: String - Pointer to command line argument strings + * which are seperated with spaces + * ArgcPtr - Return number of the arguments + * ArgvPtr - Return vector of the arguments + * + * RETURN: Clibraray error code + * -EINVAL: invalid parameter + * EAGAIN: try again + * + * DESCRIPTION: Convert EFI arguments into C arguments. + * + *****************************************************************************/ + +static int +AcpiEfiArgify ( + char *String, + int *ArgcPtr, + char ***ArgvPtr) +{ + char *CopyBuffer; + int MaxArgc = *ArgcPtr; + int Argc = 0; + char **Argv = *ArgvPtr; + char *Arg; + BOOLEAN IsSingleQuote = FALSE; + BOOLEAN IsDoubleQuote = FALSE; + BOOLEAN IsEscape = FALSE; + + + if (String == NULL) + { + errno = EINVAL; + return (-EINVAL); + } + + CopyBuffer = String; + + while (*String != '\0') + { + while (isspace (*String)) + { + *String++ = '\0'; + } + Arg = CopyBuffer; + while (*String != '\0') + { + if (isspace (*String) && + !IsSingleQuote && !IsDoubleQuote && !IsEscape) + { + *Arg++ = '\0'; + String++; + break; + } + if (IsEscape) + { + IsEscape = FALSE; + *Arg++ = *String; + } + else if (*String == '\\') + { + IsEscape = TRUE; + } + else if (IsSingleQuote) + { + if (*String == '\'') + { + IsSingleQuote = FALSE; + *Arg++ = '\0'; + } + else + { + *Arg++ = *String; + } + } + else if (IsDoubleQuote) + { + if (*String == '"') + { + IsDoubleQuote = FALSE; + *Arg = '\0'; + } + else + { + *Arg++ = *String; + } + } + else + { + if (*String == '\'') + { + IsSingleQuote = TRUE; + } + else if (*String == '"') + { + IsDoubleQuote = TRUE; + } + else + { + *Arg++ = *String; + } + } + String++; + } + if (Argv && Argc < MaxArgc) + { + Argv[Argc] = CopyBuffer; + } + Argc++; + CopyBuffer = Arg; + } + if (Argv && Argc < MaxArgc) + { + Argv[Argc] = NULL; + } + + *ArgcPtr = Argc; + *ArgvPtr = Argv; + + if (MaxArgc < Argc) + { + errno = EAGAIN; + return (-ENOMEM); + } + return (0); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEfiConvertArgcv + * + * PARAMETERS: LoadOptions - Pointer to the EFI options buffer, which + * is NULL terminated + * LoadOptionsSize - Size of the EFI options buffer + * ArgcPtr - Return number of the arguments + * ArgvPtr - Return vector of the arguments + * BufferPtr - Buffer to contain the argument strings + * + * RETURN: Clibrary error code + * + * DESCRIPTION: Convert EFI arguments into C arguments. + * + *****************************************************************************/ + +static int +AcpiEfiConvertArgcv ( + CHAR16 *LoadOptions, + UINT32 LoadOptionsSize, + int *ArgcPtr, + char ***ArgvPtr, + char **BufferPtr) +{ + int Error = 0; + UINT32 Count = LoadOptionsSize / sizeof (CHAR16); + UINT32 i; + CHAR16 *From; + char *To; + int Argc = 0; + char **Argv = NULL; + char *Buffer; + + + /* Prepare a buffer to contain the argument strings */ + + Buffer = ACPI_ALLOCATE_ZEROED (Count); + if (!Buffer) + { + errno = ENOMEM; + Error = -ENOMEM; + goto ErrorExit; + } + +TryAgain: + + /* Extend the argument vector */ + + if (Argv) + { + ACPI_FREE (Argv); + Argv = NULL; + } + if (Argc > 0) + { + Argv = ACPI_ALLOCATE_ZEROED (sizeof (char *) * (Argc + 1)); + if (!Argv) + { + errno = ENOMEM; + Error = -ENOMEM; + goto ErrorExit; + } + } + + /* + * Note: As AcpiEfiArgify() will modify the content of the buffer, so + * we need to restore it each time before invoking + * AcpiEfiArgify(). + */ + From = LoadOptions; + To = ACPI_CAST_PTR (char, Buffer); + for (i = 0; i < Count; i++) + { + *To++ = (char) *From++; + } + + /* + * The "Buffer" will contain NULL terminated strings after invoking + * AcpiEfiArgify(). The number of the strings are saved in Argc and the + * pointers of the strings are saved in Argv. + */ + Error = AcpiEfiArgify (Buffer, &Argc, &Argv); + if (Error && errno == EAGAIN) + { + goto TryAgain; + } + +ErrorExit: + + if (Error) + { + ACPI_FREE (Buffer); + ACPI_FREE (Argv); + } + else + { + *ArgcPtr = Argc; + *ArgvPtr = Argv; + *BufferPtr = Buffer; + } + return (Error); +} + + +/****************************************************************************** + * + * FUNCTION: efi_main + * + * PARAMETERS: Image - EFI image handle + * SystemTab - EFI system table + * + * RETURN: EFI Status + * + * DESCRIPTION: Entry point of EFI executable + * + *****************************************************************************/ + +EFI_STATUS +efi_main ( + EFI_HANDLE Image, + EFI_SYSTEM_TABLE *SystemTab) +{ + EFI_LOADED_IMAGE *Info; + EFI_STATUS EfiStatus = EFI_SUCCESS; + int Error; + int argc; + char **argv = NULL; + char *OptBuffer = NULL; + EFI_FILE_IO_INTERFACE *Volume = NULL; + + + /* Initialize global variables */ + + ST = SystemTab; + BS = SystemTab->BootServices; + + /* Retrieve image information */ + + EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, + Image, &AcpiGbl_LoadedImageProtocol, ACPI_CAST_PTR (VOID, &Info)); + if (EFI_ERROR (EfiStatus)) + { + fprintf (stderr, + "EFI_BOOT_SERVICES->HandleProtocol(LoadedImageProtocol) failure.\n"); + return (EfiStatus); + } + + EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, + Info->DeviceHandle, &AcpiGbl_FileSystemProtocol, (void **) &Volume); + if (EFI_ERROR (EfiStatus)) + { + fprintf (stderr, + "EFI_BOOT_SERVICES->HandleProtocol(FileSystemProtocol) failure.\n"); + return (EfiStatus); + } + EfiStatus = uefi_call_wrapper (Volume->OpenVolume, 2, + Volume, &AcpiGbl_EfiCurrentVolume); + if (EFI_ERROR (EfiStatus)) + { + fprintf (stderr, "EFI_FILE_IO_INTERFACE->OpenVolume() failure.\n"); + return (EfiStatus); + } + + Error = AcpiEfiConvertArgcv (Info->LoadOptions, + Info->LoadOptionsSize, &argc, &argv, &OptBuffer); + if (Error) + { + EfiStatus = EFI_DEVICE_ERROR; + goto ErrorAlloc; + } + + acpi_main (argc, argv); + +ErrorAlloc: + + if (argv) + { + ACPI_FREE (argv); + } + if (OptBuffer) + { + ACPI_FREE (OptBuffer); + } + + return (EfiStatus); +} diff --git a/source/os_specific/service_layers/osefitbl.c b/source/os_specific/service_layers/osefitbl.c index 42924053d..81bbdc76b 100644 --- a/source/os_specific/service_layers/osefitbl.c +++ b/source/os_specific/service_layers/osefitbl.c @@ -378,7 +378,7 @@ OslAddTableToList ( { if (Instance) { - AcpiLogError ( + fprintf (stderr, "%4.4s: Warning unmatched table instance %d, expected %d\n", Signature, Instance, NextInstance); } @@ -1014,7 +1014,7 @@ OslMapTable ( MappedTable = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); if (!MappedTable) { - AcpiLogError ("Could not map table header at 0x%8.8X%8.8X\n", + fprintf (stderr, "Could not map table header at 0x%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Address)); return (AE_BAD_ADDRESS); } @@ -1050,7 +1050,7 @@ OslMapTable ( MappedTable = AcpiOsMapMemory (Address, Length); if (!MappedTable) { - AcpiLogError ("Could not map table at 0x%8.8X%8.8X length %8.8X\n", + fprintf (stderr, "Could not map table at 0x%8.8X%8.8X length %8.8X\n", ACPI_FORMAT_UINT64 (Address), Length); return (AE_INVALID_TABLE_LENGTH); } diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index 1947197e1..b3da80b8f 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -121,53 +121,17 @@ ACPI_MODULE_NAME ("osefixf") -/* Local definitions */ - -#define ACPI_EFI_PRINT_LENGTH 256 - - /* Local prototypes */ -static ACPI_STATUS -AcpiEfiArgify ( - char *String, - int *ArgcPtr, - char ***ArgvPtr); - static BOOLEAN AcpiEfiCompareGuid ( EFI_GUID *Guid1, EFI_GUID *Guid2); -static ACPI_STATUS -AcpiEfiConvertArgcv ( - CHAR16 *LoadOpt, - UINT32 LoadOptSize, - int *ArgcPtr, - char ***ArgvPtr, - char **BufferPtr); - static ACPI_PHYSICAL_ADDRESS AcpiEfiGetRsdpViaGuid ( EFI_GUID *Guid); -static CHAR16 * -AcpiEfiFlushFile ( - ACPI_FILE File, - CHAR16 *Begin, - CHAR16 *End, - CHAR16 *Pos, - BOOLEAN FlushAll); - - -/* Local variables */ - -static EFI_FILE_HANDLE AcpiGbl_EfiCurrentVolume = NULL; -EFI_GUID AcpiGbl_LoadedImageProtocol = LOADED_IMAGE_PROTOCOL; -EFI_GUID AcpiGbl_TextInProtocol = SIMPLE_TEXT_INPUT_PROTOCOL; -EFI_GUID AcpiGbl_TextOutProtocol = SIMPLE_TEXT_OUTPUT_PROTOCOL; -EFI_GUID AcpiGbl_FileSystemProtocol = SIMPLE_FILE_SYSTEM_PROTOCOL; - /****************************************************************************** * @@ -376,7 +340,8 @@ AcpiOsAllocate ( EfiLoaderData, Size, &Mem); if (EFI_ERROR (EfiStatus)) { - AcpiLogError ("EFI_BOOT_SERVICES->AllocatePool(EfiLoaderData) failure.\n"); + fprintf (stderr, + "EFI_BOOT_SERVICES->AllocatePool(EfiLoaderData) failure.\n"); return (NULL); } @@ -436,352 +401,6 @@ AcpiOsFree ( } -/******************************************************************************* - * - * FUNCTION: AcpiOsOpenFile - * - * PARAMETERS: Path - File path - * Modes - File operation type - * - * RETURN: File descriptor - * - * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing - * (ACPI_FILE_WRITING). - * - ******************************************************************************/ - -ACPI_FILE -AcpiOsOpenFile ( - const char *Path, - UINT8 Modes) -{ - EFI_STATUS EfiStatus = EFI_SUCCESS; - UINT64 OpenModes; - EFI_FILE_HANDLE EfiFile = NULL; - CHAR16 *Path16 = NULL; - CHAR16 *Pos16; - const char *Pos; - INTN Count, i; - - - if (!Path) - { - return (NULL); - } - - /* Convert modes */ - - OpenModes = EFI_FILE_MODE_READ; - if (Modes & ACPI_FILE_WRITING) - { - OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); - } - - /* Allocate path buffer */ - - Count = strlen (Path); - Path16 = ACPI_ALLOCATE_ZEROED ((Count + 1) * sizeof (CHAR16)); - if (!Path16) - { - EfiStatus = EFI_BAD_BUFFER_SIZE; - goto ErrorExit; - } - Pos = Path; - Pos16 = Path16; - while (*Pos == '/' || *Pos == '\\') - { - Pos++; - Count--; - } - for (i = 0; i < Count; i++) - { - if (*Pos == '/') - { - *Pos16++ = '\\'; - Pos++; - } - else - { - *Pos16++ = *Pos++; - } - } - *Pos16 = '\0'; - - EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Open, 5, - AcpiGbl_EfiCurrentVolume, &EfiFile, Path16, OpenModes, 0); - if (EFI_ERROR (EfiStatus)) - { - AcpiLogError ("EFI_FILE_HANDLE->Open() failure.\n"); - goto ErrorExit; - } - -ErrorExit: - - if (Path16) - { - ACPI_FREE (Path16); - } - - return ((ACPI_FILE) EfiFile); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsCloseFile - * - * PARAMETERS: File - File descriptor - * - * RETURN: None. - * - * DESCRIPTION: Close a file. - * - ******************************************************************************/ - -void -AcpiOsCloseFile ( - ACPI_FILE File) -{ - EFI_FILE_HANDLE EfiFile; - - - if (File == ACPI_FILE_OUT || - File == ACPI_FILE_ERR) - { - return; - } - EfiFile = (EFI_FILE_HANDLE) File; - (void) uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Close, 1, EfiFile); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsReadFile - * - * PARAMETERS: File - File descriptor - * Buffer - Data buffer - * Size - Data block size - * Count - Number of data blocks - * - * RETURN: Size of successfully read buffer - * - * DESCRIPTION: Read from a file. - * - ******************************************************************************/ - -int -AcpiOsReadFile ( - ACPI_FILE File, - void *Buffer, - ACPI_SIZE Size, - ACPI_SIZE Count) -{ - int Length = -1; - EFI_FILE_HANDLE EfiFile; - UINTN ReadSize; - EFI_STATUS EfiStatus; - - - if (File == ACPI_FILE_OUT || - File == ACPI_FILE_ERR) - { - } - else - { - EfiFile = (EFI_FILE_HANDLE) File; - if (!EfiFile) - { - goto ErrorExit; - } - ReadSize = Size * Count; - - EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Read, 3, - EfiFile, &ReadSize, Buffer); - if (EFI_ERROR (EfiStatus)) - { - AcpiLogError ("EFI_FILE_HANDLE->Read() failure.\n"); - goto ErrorExit; - } - Length = ReadSize; - } - -ErrorExit: - - return (Length); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEfiFlushFile - * - * PARAMETERS: File - File descriptor - * Begin - String with boundary - * End - Boundary of the string - * Pos - Current position - * FlushAll - Whether checking boundary before flushing - * - * RETURN: Updated position - * - * DESCRIPTION: Flush cached buffer to the file. - * - ******************************************************************************/ - -static CHAR16 * -AcpiEfiFlushFile ( - ACPI_FILE File, - CHAR16 *Begin, - CHAR16 *End, - CHAR16 *Pos, - BOOLEAN FlushAll) -{ - - if (FlushAll || Pos >= (End - 1)) - { - *Pos = 0; - uefi_call_wrapper (File->OutputString, 2, File, Begin); - Pos = Begin; - } - - return (Pos); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsWriteFile - * - * PARAMETERS: File - File descriptor - * Buffer - Data buffer - * Size - Data block size - * Count - Number of data blocks - * - * RETURN: Size of successfully written buffer - * - * DESCRIPTION: Write to a file. - * - ******************************************************************************/ - -int -AcpiOsWriteFile ( - ACPI_FILE File, - void *Buffer, - ACPI_SIZE Size, - ACPI_SIZE Count) -{ - int Length = -1; - CHAR16 String[ACPI_EFI_PRINT_LENGTH]; - const char *Ascii; - CHAR16 *End; - CHAR16 *Pos; - int i, j; - EFI_FILE_HANDLE EfiFile; - UINTN WriteSize; - EFI_STATUS EfiStatus; - - - if (File == ACPI_FILE_OUT || - File == ACPI_FILE_ERR) - { - Pos = String; - End = String + ACPI_EFI_PRINT_LENGTH - 1; - Ascii = ACPI_CAST_PTR (const char, Buffer); - Length = 0; - - for (j = 0; j < Count; j++) - { - for (i = 0; i < Size; i++) - { - if (*Ascii == '\n') - { - *Pos++ = '\r'; - Pos = AcpiEfiFlushFile (File, String, - End, Pos, FALSE); - } - *Pos++ = *Ascii++; - Length++; - Pos = AcpiEfiFlushFile (File, String, - End, Pos, FALSE); - } - } - Pos = AcpiEfiFlushFile (File, String, End, Pos, TRUE); - } - else - { - EfiFile = (EFI_FILE_HANDLE) File; - if (!EfiFile) - { - goto ErrorExit; - } - WriteSize = Size * Count; - - EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Write, 3, - EfiFile, &WriteSize, Buffer); - if (EFI_ERROR (EfiStatus)) - { - AcpiLogError ("EFI_FILE_HANDLE->Write() failure.\n"); - goto ErrorExit; - } - Length = WriteSize; - } - -ErrorExit: - - return (Length); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsGetFileOffset - * - * PARAMETERS: File - File descriptor - * - * RETURN: Size of current position - * - * DESCRIPTION: Get current file offset. - * - ******************************************************************************/ - -long -AcpiOsGetFileOffset ( - ACPI_FILE File) -{ - long Offset = -1; - - - return (Offset); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsSetFileOffset - * - * PARAMETERS: File - File descriptor - * Offset - File offset - * From - From begin/end of file - * - * RETURN: Status - * - * DESCRIPTION: Set current file offset. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiOsSetFileOffset ( - ACPI_FILE File, - long Offset, - UINT8 From) -{ - - return (AE_SUPPORT); -} - - /****************************************************************************** * * FUNCTION: AcpiOsPrintf @@ -850,314 +469,3 @@ AcpiOsInitialize ( return (AE_OK); } - - -/****************************************************************************** - * - * FUNCTION: AcpiEfiArgify - * - * PARAMETERS: String - Pointer to command line argument strings - * which are seperated with spaces - * ArgcPtr - Return number of the arguments - * ArgvPtr - Return vector of the arguments - * - * RETURN: Status - * - * DESCRIPTION: Convert EFI arguments into C arguments. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiEfiArgify ( - char *String, - int *ArgcPtr, - char ***ArgvPtr) -{ - char *CopyBuffer; - int MaxArgc = *ArgcPtr; - int Argc = 0; - char **Argv = *ArgvPtr; - char *Arg; - BOOLEAN IsSingleQuote = FALSE; - BOOLEAN IsDoubleQuote = FALSE; - BOOLEAN IsEscape = FALSE; - - - if (String == NULL) - { - return (AE_BAD_PARAMETER); - } - - CopyBuffer = String; - - while (*String != '\0') - { - while (isspace (*String)) - { - *String++ = '\0'; - } - Arg = CopyBuffer; - while (*String != '\0') - { - if (isspace (*String) && - !IsSingleQuote && !IsDoubleQuote && !IsEscape) - { - *Arg++ = '\0'; - String++; - break; - } - if (IsEscape) - { - IsEscape = FALSE; - *Arg++ = *String; - } - else if (*String == '\\') - { - IsEscape = TRUE; - } - else if (IsSingleQuote) - { - if (*String == '\'') - { - IsSingleQuote = FALSE; - *Arg++ = '\0'; - } - else - { - *Arg++ = *String; - } - } - else if (IsDoubleQuote) - { - if (*String == '"') - { - IsDoubleQuote = FALSE; - *Arg = '\0'; - } - else - { - *Arg++ = *String; - } - } - else - { - if (*String == '\'') - { - IsSingleQuote = TRUE; - } - else if (*String == '"') - { - IsDoubleQuote = TRUE; - } - else - { - *Arg++ = *String; - } - } - String++; - } - if (Argv && Argc < MaxArgc) - { - Argv[Argc] = CopyBuffer; - } - Argc++; - CopyBuffer = Arg; - } - if (Argv && Argc < MaxArgc) - { - Argv[Argc] = NULL; - } - - *ArgcPtr = Argc; - *ArgvPtr = Argv; - - return ((MaxArgc < Argc) ? AE_NO_MEMORY : AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEfiConvertArgcv - * - * PARAMETERS: LoadOptions - Pointer to the EFI options buffer, which - * is NULL terminated - * LoadOptionsSize - Size of the EFI options buffer - * ArgcPtr - Return number of the arguments - * ArgvPtr - Return vector of the arguments - * BufferPtr - Buffer to contain the argument strings - * - * RETURN: Status - * - * DESCRIPTION: Convert EFI arguments into C arguments. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiEfiConvertArgcv ( - CHAR16 *LoadOptions, - UINT32 LoadOptionsSize, - int *ArgcPtr, - char ***ArgvPtr, - char **BufferPtr) -{ - ACPI_STATUS Status = AE_OK; - UINT32 Count = LoadOptionsSize / sizeof (CHAR16); - UINT32 i; - CHAR16 *From; - char *To; - int Argc = 0; - char **Argv = NULL; - char *Buffer; - - - /* Prepare a buffer to contain the argument strings */ - - Buffer = ACPI_ALLOCATE_ZEROED (Count); - if (!Buffer) - { - Status = AE_NO_MEMORY; - goto ErrorExit; - } - -TryAgain: - - /* Extend the argument vector */ - - if (Argv) - { - ACPI_FREE (Argv); - Argv = NULL; - } - if (Argc > 0) - { - Argv = ACPI_ALLOCATE_ZEROED (sizeof (char *) * (Argc + 1)); - if (!Argv) - { - Status = AE_NO_MEMORY; - goto ErrorExit; - } - } - - /* - * Note: As AcpiEfiArgify() will modify the content of the buffer, so - * we need to restore it each time before invoking - * AcpiEfiArgify(). - */ - From = LoadOptions; - To = ACPI_CAST_PTR (char, Buffer); - for (i = 0; i < Count; i++) - { - *To++ = (char) *From++; - } - - /* - * The "Buffer" will contain NULL terminated strings after invoking - * AcpiEfiArgify(). The number of the strings are saved in Argc and the - * pointers of the strings are saved in Argv. - */ - Status = AcpiEfiArgify (Buffer, &Argc, &Argv); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_NO_MEMORY) - { - goto TryAgain; - } - } - -ErrorExit: - - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (Buffer); - ACPI_FREE (Argv); - } - else - { - *ArgcPtr = Argc; - *ArgvPtr = Argv; - *BufferPtr = Buffer; - } - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: efi_main - * - * PARAMETERS: Image - EFI image handle - * SystemTab - EFI system table - * - * RETURN: EFI Status - * - * DESCRIPTION: Entry point of EFI executable - * - *****************************************************************************/ - -EFI_STATUS -efi_main ( - EFI_HANDLE Image, - EFI_SYSTEM_TABLE *SystemTab) -{ - EFI_LOADED_IMAGE *Info; - EFI_STATUS EfiStatus = EFI_SUCCESS; - ACPI_STATUS Status; - int argc; - char **argv = NULL; - char *OptBuffer = NULL; - EFI_FILE_IO_INTERFACE *Volume = NULL; - - - /* Initialize global variables */ - - ST = SystemTab; - BS = SystemTab->BootServices; - - /* Retrieve image information */ - - EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, - Image, &AcpiGbl_LoadedImageProtocol, ACPI_CAST_PTR (VOID, &Info)); - if (EFI_ERROR (EfiStatus)) - { - AcpiLogError ("EFI_BOOT_SERVICES->HandleProtocol(LoadedImageProtocol) failure.\n"); - return (EfiStatus); - } - - EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, - Info->DeviceHandle, &AcpiGbl_FileSystemProtocol, (void **) &Volume); - if (EFI_ERROR (EfiStatus)) - { - AcpiLogError ("EFI_BOOT_SERVICES->HandleProtocol(FileSystemProtocol) failure.\n"); - return (EfiStatus); - } - EfiStatus = uefi_call_wrapper (Volume->OpenVolume, 2, - Volume, &AcpiGbl_EfiCurrentVolume); - if (EFI_ERROR (EfiStatus)) - { - AcpiLogError ("EFI_FILE_IO_INTERFACE->OpenVolume() failure.\n"); - return (EfiStatus); - } - - Status = AcpiEfiConvertArgcv (Info->LoadOptions, - Info->LoadOptionsSize, &argc, &argv, &OptBuffer); - if (ACPI_FAILURE (Status)) - { - EfiStatus = EFI_DEVICE_ERROR; - goto ErrorAlloc; - } - - acpi_main (argc, argv); - -ErrorAlloc: - - if (argv) - { - ACPI_FREE (argv); - } - if (OptBuffer) - { - ACPI_FREE (OptBuffer); - } - - return (EfiStatus); -} diff --git a/source/os_specific/service_layers/oslibcfs.c b/source/os_specific/service_layers/oslibcfs.c deleted file mode 100644 index 26c1a8fed..000000000 --- a/source/os_specific/service_layers/oslibcfs.c +++ /dev/null @@ -1,330 +0,0 @@ -/****************************************************************************** - * - * Module Name: oslibcfs - C library OSL for file I/O - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#include "acpi.h" -#include -#include - -#define _COMPONENT ACPI_OS_SERVICES - ACPI_MODULE_NAME ("oslibcfs") - - -/******************************************************************************* - * - * FUNCTION: AcpiOsOpenFile - * - * PARAMETERS: Path - File path - * Modes - File operation type - * - * RETURN: File descriptor. - * - * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing - * (ACPI_FILE_WRITING). - * - ******************************************************************************/ - -ACPI_FILE -AcpiOsOpenFile ( - const char *Path, - UINT8 Modes) -{ - ACPI_FILE File; - UINT32 i = 0; - char ModesStr[4]; - - - if (Modes & ACPI_FILE_READING) - { - ModesStr[i++] = 'r'; - } - if (Modes & ACPI_FILE_WRITING) - { - ModesStr[i++] = 'w'; - } - - if (Modes & ACPI_FILE_BINARY) - { - ModesStr[i++] = 'b'; - } - - ModesStr[i++] = '\0'; - - File = fopen (Path, ModesStr); - if (!File) - { - perror ("Could not open file"); - } - - return (File); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsCloseFile - * - * PARAMETERS: File - An open file descriptor - * - * RETURN: None. - * - * DESCRIPTION: Close a file opened via AcpiOsOpenFile. - * - ******************************************************************************/ - -void -AcpiOsCloseFile ( - ACPI_FILE File) -{ - - fclose (File); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsReadFile - * - * PARAMETERS: File - An open file descriptor - * Buffer - Data buffer - * Size - Data block size - * Count - Number of data blocks - * - * RETURN: Number of bytes actually read. - * - * DESCRIPTION: Read from a file. - * - ******************************************************************************/ - -int -AcpiOsReadFile ( - ACPI_FILE File, - void *Buffer, - ACPI_SIZE Size, - ACPI_SIZE Count) -{ - int Length; - - - Length = fread (Buffer, Size, Count, File); - if (Length < 0) - { - perror ("Error reading file"); - } - - return (Length); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsWriteFile - * - * PARAMETERS: File - An open file descriptor - * Buffer - Data buffer - * Size - Data block size - * Count - Number of data blocks - * - * RETURN: Number of bytes actually written. - * - * DESCRIPTION: Write to a file. - * - ******************************************************************************/ - -int -AcpiOsWriteFile ( - ACPI_FILE File, - void *Buffer, - ACPI_SIZE Size, - ACPI_SIZE Count) -{ - int Length; - - - Length = fwrite (Buffer, Size, Count, File); - if (Length < 0) - { - perror ("Error writing file"); - } - - return (Length); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsGetFileOffset - * - * PARAMETERS: File - An open file descriptor - * - * RETURN: Current file pointer position. - * - * DESCRIPTION: Get current file offset. - * - ******************************************************************************/ - -long -AcpiOsGetFileOffset ( - ACPI_FILE File) -{ - long Offset; - - - Offset = ftell (File); - return (Offset); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiOsSetFileOffset - * - * PARAMETERS: File - An open file descriptor - * Offset - New file offset - * From - From begin/end of file - * - * RETURN: Status - * - * DESCRIPTION: Set current file offset. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiOsSetFileOffset ( - ACPI_FILE File, - long Offset, - UINT8 From) -{ - int Ret = 0; - - - if (From == ACPI_FILE_BEGIN) - { - Ret = fseek (File, Offset, SEEK_SET); - } - - if (From == ACPI_FILE_END) - { - Ret = fseek (File, Offset, SEEK_END); - } - - if (Ret < 0) - { - return (AE_ERROR); - } - else - { - return (AE_OK); - } -} diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c index bb5bd545b..68065d733 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -148,7 +148,7 @@ ApIsValidHeader ( if (!AcpiUtValidNameseg (Table->Signature)) { - AcpiLogError ("Table signature (0x%8.8X) is invalid\n", + fprintf (stderr, "Table signature (0x%8.8X) is invalid\n", *(UINT32 *) Table->Signature); return (FALSE); } @@ -157,7 +157,7 @@ ApIsValidHeader ( if (Table->Length < sizeof (ACPI_TABLE_HEADER)) { - AcpiLogError ("Table length (0x%8.8X) is invalid\n", + fprintf (stderr, "Table length (0x%8.8X) is invalid\n", Table->Length); return (FALSE); } @@ -203,7 +203,7 @@ ApIsValidChecksum ( if (ACPI_FAILURE (Status)) { - AcpiLogError ("%4.4s: Warning: wrong checksum in table\n", + fprintf (stderr, "%4.4s: Warning: wrong checksum in table\n", Table->Signature); } @@ -346,13 +346,13 @@ ApDumpAllTables ( } else if (i == 0) { - AcpiLogError ("Could not get ACPI tables, %s\n", + fprintf (stderr, "Could not get ACPI tables, %s\n", AcpiFormatException (Status)); return (-1); } else { - AcpiLogError ("Could not get ACPI table at index %u, %s\n", + fprintf (stderr, "Could not get ACPI table at index %u, %s\n", i, AcpiFormatException (Status)); continue; } @@ -402,7 +402,7 @@ ApDumpTableByAddress ( ACPI_MAX64_BYTE_WIDTH, &LongAddress); if (ACPI_FAILURE (Status)) { - AcpiLogError ("%s: Could not convert to a physical address\n", + fprintf (stderr, "%s: Could not convert to a physical address\n", AsciiAddress); return (-1); } @@ -411,7 +411,7 @@ ApDumpTableByAddress ( Status = AcpiOsGetTableByAddress (Address, &Table); if (ACPI_FAILURE (Status)) { - AcpiLogError ("Could not get table at 0x%8.8X%8.8X, %s\n", + fprintf (stderr, "Could not get table at 0x%8.8X%8.8X, %s\n", ACPI_FORMAT_UINT64 (Address), AcpiFormatException (Status)); return (-1); @@ -450,7 +450,7 @@ ApDumpTableByName ( if (strlen (Signature) != ACPI_NAME_SIZE) { - AcpiLogError ( + fprintf (stderr, "Invalid table signature [%s]: must be exactly 4 characters\n", Signature); return (-1); @@ -487,7 +487,7 @@ ApDumpTableByName ( return (0); } - AcpiLogError ( + fprintf (stderr, "Could not get ACPI table with signature [%s], %s\n", LocalSignature, AcpiFormatException (Status)); return (-1); @@ -539,7 +539,7 @@ ApDumpTableFromFile ( if (!AcpiUtValidNameseg (Table->Signature)) { - AcpiLogError ( + fprintf (stderr, "No valid ACPI signature was found in input file %s\n", Pathname); } @@ -548,7 +548,7 @@ ApDumpTableFromFile ( if (Table->Length > FileSize) { - AcpiLogError ( + fprintf (stderr, "Table length (0x%X) is too large for input file (0x%X) %s\n", Table->Length, FileSize, Pathname); goto Exit; @@ -556,7 +556,7 @@ ApDumpTableFromFile ( if (Gbl_VerboseMode) { - AcpiLogError ( + fprintf (stderr, "Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n", Pathname, Table->Signature, FileSize, FileSize); } diff --git a/source/tools/acpidump/apfiles.c b/source/tools/acpidump/apfiles.c index 04d9cf250..ad02f6d03 100644 --- a/source/tools/acpidump/apfiles.c +++ b/source/tools/acpidump/apfiles.c @@ -146,7 +146,7 @@ ApIsExistingFile ( if (!stat (Pathname, &StatInfo)) { - AcpiLogError ("Target path already exists, overwrite? [y|n] "); + fprintf (stderr, "Target path already exists, overwrite? [y|n] "); if (getchar () != 'y') { @@ -188,10 +188,10 @@ ApOpenOutputFile ( /* Point stdout to the file */ - File = AcpiOsOpenFile (Pathname, ACPI_FILE_WRITING); + File = fopen (Pathname, "w"); if (!File) { - AcpiLogError ("Could not open output file: %s\n", Pathname); + fprintf (stderr, "Could not open output file: %s\n", Pathname); return (-1); } @@ -262,30 +262,29 @@ ApWriteToBinaryFile ( if (Gbl_VerboseMode) { - AcpiLogError ( + fprintf (stderr, "Writing [%4.4s] to binary file: %s 0x%X (%u) bytes\n", Table->Signature, Filename, Table->Length, Table->Length); } /* Open the file and dump the entire table in binary mode */ - File = AcpiOsOpenFile (Filename, - ACPI_FILE_WRITING | ACPI_FILE_BINARY); + File = fopen (Filename, "wb"); if (!File) { - AcpiLogError ("Could not open output file: %s\n", Filename); + fprintf (stderr, "Could not open output file: %s\n", Filename); return (-1); } - Actual = AcpiOsWriteFile (File, Table, 1, TableLength); + Actual = fwrite (Table, 1, TableLength, File); if (Actual != TableLength) { - AcpiLogError ("Error writing binary output file: %s\n", Filename); - AcpiOsCloseFile (File); + fprintf (stderr, "Error writing binary output file: %s\n", Filename); + fclose (File); return (-1); } - AcpiOsCloseFile (File); + fclose (File); return (0); } @@ -316,10 +315,10 @@ ApGetTableFromFile ( /* Must use binary mode */ - File = AcpiOsOpenFile (Pathname, ACPI_FILE_READING | ACPI_FILE_BINARY); + File = fopen (Pathname, "rb"); if (!File) { - AcpiLogError ("Could not open input file: %s\n", Pathname); + fprintf (stderr, "Could not open input file: %s\n", Pathname); return (NULL); } @@ -328,7 +327,7 @@ ApGetTableFromFile ( FileSize = CmGetFileSize (File); if (FileSize == ACPI_UINT32_MAX) { - AcpiLogError ( + fprintf (stderr, "Could not get input file size: %s\n", Pathname); goto Cleanup; } @@ -338,18 +337,17 @@ ApGetTableFromFile ( Buffer = ACPI_ALLOCATE_ZEROED (FileSize); if (!Buffer) { - AcpiLogError ( + fprintf (stderr, "Could not allocate file buffer of size: %u\n", FileSize); goto Cleanup; } /* Read the entire file */ - Actual = AcpiOsReadFile (File, Buffer, 1, FileSize); + Actual = fread (Buffer, 1, FileSize, File); if (Actual != FileSize) { - AcpiLogError ( - "Could not read input file: %s\n", Pathname); + fprintf (stderr, "Could not read input file: %s\n", Pathname); ACPI_FREE (Buffer); Buffer = NULL; goto Cleanup; @@ -358,6 +356,6 @@ ApGetTableFromFile ( *OutFileSize = FileSize; Cleanup: - AcpiOsCloseFile (File); + fclose (File); return (Buffer); } diff --git a/source/tools/acpidump/apmain.c b/source/tools/acpidump/apmain.c index cfe0c3261..355155359 100644 --- a/source/tools/acpidump/apmain.c +++ b/source/tools/acpidump/apmain.c @@ -233,7 +233,7 @@ ApInsertAction ( CurrentAction++; if (CurrentAction > AP_MAX_ACTIONS) { - AcpiLogError ("Too many table options (max %u)\n", AP_MAX_ACTIONS); + fprintf (stderr, "Too many table options (max %u)\n", AP_MAX_ACTIONS); return (-1); } @@ -287,7 +287,7 @@ ApDoOptions ( } else { - AcpiLogError ("%s: Cannot handle this switch, please use on|off\n", + fprintf (stderr, "%s: Cannot handle this switch, please use on|off\n", AcpiGbl_Optarg); return (-1); } @@ -313,7 +313,7 @@ ApDoOptions ( ACPI_MAX64_BYTE_WIDTH, &Gbl_RsdpBase); if (ACPI_FAILURE (Status)) { - AcpiLogError ("%s: Could not convert to a physical address\n", + fprintf (stderr, "%s: Could not convert to a physical address\n", AcpiGbl_Optarg); return (-1); } @@ -344,7 +344,7 @@ ApDoOptions ( case 'z': /* Verbose mode */ Gbl_VerboseMode = TRUE; - AcpiLogError (ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); + fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); continue; /* @@ -469,7 +469,7 @@ acpi_main ( default: - AcpiLogError ("Internal error, invalid action: 0x%X\n", + fprintf (stderr, "Internal error, invalid action: 0x%X\n", Action->ToBeDone); return (-1); } @@ -487,11 +487,11 @@ acpi_main ( /* Summary for the output file */ FileSize = CmGetFileSize (Gbl_OutputFile); - AcpiLogError ("Output file %s contains 0x%X (%u) bytes\n\n", + fprintf (stderr, "Output file %s contains 0x%X (%u) bytes\n\n", Gbl_OutputFilename, FileSize, FileSize); } - AcpiOsCloseFile (Gbl_OutputFile); + fclose (Gbl_OutputFile); } return (Status); diff --git a/source/tools/acpiexec/aeinitfile.c b/source/tools/acpiexec/aeinitfile.c index 57c20dce0..b1b60cd0c 100644 --- a/source/tools/acpiexec/aeinitfile.c +++ b/source/tools/acpiexec/aeinitfile.c @@ -158,7 +158,8 @@ AeOpenInitializationFile ( InitFile = fopen (Filename, "r"); if (!InitFile) { - perror ("Could not open initialization file"); + fprintf (stderr, + "Could not open initialization file: %s\n", Filename); return (-1); } -- cgit v1.2.1 From fe92a821a09e91035b27c30cfdaf8e54d846594f Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:54 +0800 Subject: acpidump: Fix a duplicate variable definition AcpiGbl_IntegerByteWidth has already been instantiated by ACPI_GLOBAL() in acglobal.h. Lv Zheng. Signed-off-by: Lv Zheng --- source/tools/acpidump/acpidump.h | 6 ------ source/tools/acpidump/apmain.c | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/source/tools/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h index b15de1d86..5d6ed795c 100644 --- a/source/tools/acpidump/acpidump.h +++ b/source/tools/acpidump/acpidump.h @@ -139,12 +139,6 @@ EXTERN ACPI_FILE INIT_GLOBAL (Gbl_OutputFile, NULL); EXTERN char INIT_GLOBAL (*Gbl_OutputFilename, NULL); EXTERN UINT64 INIT_GLOBAL (Gbl_RsdpBase, 0); -/* Globals required for use with ACPICA modules */ - -#ifdef _DECLARE_GLOBALS -UINT8 AcpiGbl_IntegerByteWidth = 8; -#endif - /* Action table used to defer requested options */ typedef struct ap_dump_action diff --git a/source/tools/acpidump/apmain.c b/source/tools/acpidump/apmain.c index 355155359..0e0e5b218 100644 --- a/source/tools/acpidump/apmain.c +++ b/source/tools/acpidump/apmain.c @@ -427,6 +427,7 @@ acpi_main ( ACPI_DEBUG_INITIALIZE (); /* For debug version only */ AcpiOsInitialize (); Gbl_OutputFile = ACPI_FILE_OUT; + AcpiGbl_IntegerByteWidth = 8; /* Process command line options */ -- cgit v1.2.1 From 33f019a5bf9901048822f7cc1701603d4087cf99 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:54 +0800 Subject: Applications: Fix a potential issue that help messages may be dumped to AcpiGbl_DebugFile There is an issue for usage macros, if an command line option changed AcpiGbl_DebugFile, then the follow up usage may errornously dumped to the debug file. This is just a bug in theory, because currently AcpiGbl_DebugFile can only be modified by acpibin and acpiexec. Currently this will not trigger such issue because: 1. For acpibin, AcpiGbl_DebugFile will be modified by "-t" option and the program exit after processing this option without dumping help message or other error options. 2. For acpiexec, AcpiGbl_DebugFile will only be modified by the open command, which happens after parsing the command line options, so no help message will be dumped into the debug file. But maintaining this logic is difficult, so this patch modifies AcpiOsPrintf() into printf() for usage macros so that the help messages are ensured to be dumped to the stdout. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/acapps.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/include/acapps.h b/source/include/acapps.h index 8699dcbba..f8b7bd0b3 100644 --- a/source/include/acapps.h +++ b/source/include/acapps.h @@ -151,13 +151,13 @@ /* Macros for usage messages */ #define ACPI_USAGE_HEADER(Usage) \ - AcpiOsPrintf ("Usage: %s\nOptions:\n", Usage); + printf ("Usage: %s\nOptions:\n", Usage); #define ACPI_USAGE_TEXT(Description) \ - AcpiOsPrintf (Description); + printf (Description); #define ACPI_OPTION(Name, Description) \ - AcpiOsPrintf (" %-20s%s\n", Name, Description); + printf (" %-20s%s\n", Name, Description); /* Check for unexpected exceptions */ -- cgit v1.2.1 From 17d2c00994f3e04d0b25dccb00220e69dc8bb443 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:55 +0800 Subject: Clib: Add memmove() to improve portability This patch implements memmove(). Lv Zheng. Signed-off-by: Lv Zheng --- source/components/utilities/utclib.c | 55 ++++++++++++++++++++++++++++++++++++ source/include/acclib.h | 6 ++++ 2 files changed, 61 insertions(+) diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c index 7e61b980a..0bc9215fd 100644 --- a/source/components/utilities/utclib.c +++ b/source/components/utilities/utclib.c @@ -199,6 +199,61 @@ memcmp ( } +/******************************************************************************* + * + * FUNCTION: memmove + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory with respect to the overlapping + * + ******************************************************************************/ + +void * +memmove ( + void *Dest, + const void *Src, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + char *Old = (char *) Src; + + + if (Old > New) + { + /* Copy from the beginning */ + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + } + else if (Old < New) + { + /* Copy from the end */ + + New = New + Count - 1; + Old = Old + Count - 1; + while (Count) + { + *New = *Old; + New--; + Old--; + Count--; + } + } + + return (Dest); +} + + /******************************************************************************* * * FUNCTION: memcpy diff --git a/source/include/acclib.h b/source/include/acclib.h index 67c05bf36..9f5853596 100644 --- a/source/include/acclib.h +++ b/source/include/acclib.h @@ -236,6 +236,12 @@ memcpy ( const void *Src, ACPI_SIZE Count); +void * +memmove ( + void *Dest, + const void *Src, + ACPI_SIZE Count); + void * memset ( void *Dest, -- cgit v1.2.1 From 973f73ca34c168d62bcc84bb71ea3ea194001f0a Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:55 +0800 Subject: Clib/EFI: Add fgetc()/fputc() to improve portability This patch added two new Clibrary functions: fgetc()/fputc() for EFI environment, they are implemented using fread()/fwrite(). Note in this patch, stdin is simply defined as NULL for EFI environment. Its EFI support should be implemented by further patches. Signed-off-by: Lv Zheng --- source/include/acclib.h | 19 ++++++++ source/include/platform/acefi.h | 1 + source/include/platform/acenv.h | 2 + source/os_specific/service_layers/oseficlib.c | 70 +++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) diff --git a/source/include/acclib.h b/source/include/acclib.h index 9f5853596..deaed5a5e 100644 --- a/source/include/acclib.h +++ b/source/include/acclib.h @@ -304,6 +304,10 @@ sprintf ( */ extern int errno; +#ifndef EOF +#define EOF (-1) +#endif + int vprintf ( const char *Format, @@ -358,6 +362,21 @@ fseek ( long ftell ( FILE *File); + +int +fgetc ( + FILE *File); + +int +fputc ( + FILE *File, + char c); + +char * +fgets ( + char *s, + ACPI_SIZE Size, + FILE *File); #endif #endif /* _ACCLIB_H */ diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h index b251c1504..172fac47a 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -327,5 +327,6 @@ extern struct _EFI_BOOT_SERVICES *BS; #define FILE struct _SIMPLE_TEXT_OUTPUT_INTERFACE #define stdout ST->ConOut #define stderr ST->ConOut +#define stdin NULL #endif /* __ACEFI_H__ */ diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index 878be8c12..ead8a9af0 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -518,10 +518,12 @@ typedef char *va_list; #define ACPI_FILE FILE * #define ACPI_FILE_OUT stdout #define ACPI_FILE_ERR stderr +#define ACPI_FILE_IN stdin #else #define ACPI_FILE void * #define ACPI_FILE_OUT NULL #define ACPI_FILE_ERR NULL +#define ACPI_FILE_IN NULL #endif /* ACPI_APPLICATION */ #endif /* __ACENV_H__ */ diff --git a/source/os_specific/service_layers/oseficlib.c b/source/os_specific/service_layers/oseficlib.c index 629e99d00..00b787447 100644 --- a/source/os_specific/service_layers/oseficlib.c +++ b/source/os_specific/service_layers/oseficlib.c @@ -333,6 +333,76 @@ fclose ( } +/******************************************************************************* + * + * FUNCTION: fgetc + * + * PARAMETERS: File - File descriptor + * + * RETURN: The character read or EOF on the end of the file or error + * + * DESCRIPTION: Read a character from the file. + * + ******************************************************************************/ + +int +fgetc ( + FILE *File) +{ + UINT8 Byte; + int Length; + + + Length = fread (ACPI_CAST_PTR (void, &Byte), 1, 1, File); + if (Length == 0) + { + Length = EOF; + } + else if (Length == 1) + { + Length = (int) Byte; + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: fputc + * + * PARAMETERS: File - File descriptor + * c - Character byte + * + * RETURN: The character written or EOF on the end of the file or error + * + * DESCRIPTION: Write a character to the file. + * + ******************************************************************************/ + +int +fputc ( + FILE *File, + char c) +{ + UINT8 Byte = (UINT8) c; + int Length; + + + Length = fwrite (ACPI_CAST_PTR (void, &Byte), 1, 1, File); + if (Length == 0) + { + Length = EOF; + } + else if (Length == 1) + { + Length = (int) Byte; + } + + return (Length); +} + + /******************************************************************************* * * FUNCTION: fread -- cgit v1.2.1 From 9bba284f4de0268356af8c004bf8482e079eb842 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:55 +0800 Subject: Clib/EFI: Add standard input descriptor support This patch implements stdin for EFI environment using SIMPLE_INPUT_INTERFACE. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/platform/acefi.h | 10 ++- source/include/platform/acefiex.h | 21 ++++- source/os_specific/service_layers/oseficlib.c | 118 ++++++++++++++++++++++++-- 3 files changed, 134 insertions(+), 15 deletions(-) diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h index 172fac47a..567df9ff1 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -324,9 +324,11 @@ struct _EFI_SYSTEM_TABLE; extern struct _EFI_SYSTEM_TABLE *ST; extern struct _EFI_BOOT_SERVICES *BS; -#define FILE struct _SIMPLE_TEXT_OUTPUT_INTERFACE -#define stdout ST->ConOut -#define stderr ST->ConOut -#define stdin NULL +typedef union acpi_efi_file ACPI_EFI_FILE; + +#define FILE ACPI_EFI_FILE +#define stdout ((FILE *) (ST)->ConOut) +#define stderr ((FILE *) (ST)->ConOut) +#define stdin ((FILE *) (ST)->ConIn) #endif /* __ACEFI_H__ */ diff --git a/source/include/platform/acefiex.h b/source/include/platform/acefiex.h index 1fc58f752..17f347221 100644 --- a/source/include/platform/acefiex.h +++ b/source/include/platform/acefiex.h @@ -516,6 +516,15 @@ EFI_STATUS EFI_HANDLE ImageHandle); +typedef +EFI_STATUS +(EFIAPI *EFI_SET_WATCHDOG_TIMER) ( + UINTN Timeout, + UINT64 WatchdogCode, + UINTN DataSize, + CHAR16 *WatchdogData); + + #define EFI_IMAGE_INFORMATION_REVISION 0x1000 typedef struct { UINT32 Revision; @@ -803,13 +812,12 @@ typedef struct _EFI_BOOT_SERVICES { EFI_EXIT_BOOT_SERVICES ExitBootServices; EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; EFI_STALL Stall; - EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; #else EFI_UNKNOWN_INTERFACE ExitBootServices; EFI_UNKNOWN_INTERFACE GetNextMonotonicCount; EFI_UNKNOWN_INTERFACE Stall; - EFI_UNKNOWN_INTERFACE SetWatchdogTimer; #endif + EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; #if 0 EFI_CONNECT_CONTROLLER ConnectController; @@ -890,6 +898,15 @@ typedef struct _EFI_SYSTEM_TABLE { } EFI_SYSTEM_TABLE; +/* FILE abstraction */ + +union acpi_efi_file { + struct _EFI_FILE_IO_INTERFACE File; + struct _SIMPLE_TEXT_OUTPUT_INTERFACE ConOut; + struct _SIMPLE_INPUT_INTERFACE ConIn; +}; + + /* GNU EFI definitions */ #if defined(_GNU_EFI) diff --git a/source/os_specific/service_layers/oseficlib.c b/source/os_specific/service_layers/oseficlib.c index 00b787447..5d6b1a7f4 100644 --- a/source/os_specific/service_layers/oseficlib.c +++ b/source/os_specific/service_layers/oseficlib.c @@ -125,6 +125,17 @@ #define ACPI_EFI_PRINT_LENGTH 256 +#define ACPI_EFI_KEY_ESC 0x0000 +#define ACPI_EFI_KEY_BACKSPACE 0x0008 +#define ACPI_EFI_KEY_ENTER 0x000D +#define ACPI_EFI_KEY_CTRL_C 0x0003 + +#define ACPI_EFI_ASCII_NULL 0x00 +#define ACPI_EFI_ASCII_DEL 0x7F +#define ACPI_EFI_ASCII_ESC 0x1B +#define ACPI_EFI_ASCII_CR '\r' +#define ACPI_EFI_ASCII_NL '\n' + /* Local prototypes */ @@ -322,7 +333,8 @@ fclose ( EFI_FILE_HANDLE EfiFile; - if (File == stdout || File == stderr) + if (File == stdin || File == stdout || + File == stderr) { return; } @@ -425,14 +437,87 @@ fread ( ACPI_SIZE Count, FILE *File) { - int Length = -1; + int Length = -EINVAL; EFI_FILE_HANDLE EfiFile; + SIMPLE_INPUT_INTERFACE *In; UINTN ReadSize; EFI_STATUS EfiStatus; + EFI_INPUT_KEY Key; + ACPI_SIZE Pos = 0; + if (!Buffer) + { + errno = EINVAL; + goto ErrorExit; + } + + ReadSize = Size * Count; + if (File == stdout || File == stderr) { + /* Do not support read operations on output console */ + } + else if (File == stdin) + { + In = ACPI_CAST_PTR (SIMPLE_INPUT_INTERFACE, File); + + while (Pos < ReadSize) + { +WaitKey: + EfiStatus = uefi_call_wrapper (In->ReadKeyStroke, 2, In, &Key); + if (EFI_ERROR (EfiStatus)) + { + if (EfiStatus == EFI_NOT_READY) + { + goto WaitKey; + } + errno = EIO; + Length = -EIO; + fprintf (stderr, + "SIMPLE_INPUT_INTERFACE->ReadKeyStroke() failure.\n"); + goto ErrorExit; + } + + switch (Key.UnicodeChar) + { + case ACPI_EFI_KEY_CTRL_C: + + break; + + case ACPI_EFI_KEY_ENTER: + + *(ACPI_ADD_PTR (UINT8, Buffer, Pos)) = (UINT8) ACPI_EFI_ASCII_CR; + if (Pos < ReadSize - 1) + { + /* Drop CR in case we don't have sufficient buffer */ + + Pos++; + } + *(ACPI_ADD_PTR (UINT8, Buffer, Pos)) = (UINT8) ACPI_EFI_ASCII_NL; + Pos++; + break; + + case ACPI_EFI_KEY_BACKSPACE: + + *(ACPI_ADD_PTR (UINT8, Buffer, Pos)) = (UINT8) ACPI_EFI_ASCII_DEL; + Pos++; + break; + + case ACPI_EFI_KEY_ESC: + + *(ACPI_ADD_PTR (UINT8, Buffer, Pos)) = (UINT8) ACPI_EFI_ASCII_ESC; + Pos++; + break; + + default: + + *(ACPI_ADD_PTR (UINT8, Buffer, Pos)) = (UINT8) Key.UnicodeChar; + Pos++; + break; + } + } + Length = Pos; } else { @@ -442,7 +527,6 @@ fread ( errno = EINVAL; goto ErrorExit; } - ReadSize = Size * Count; EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Read, 3, EfiFile, &ReadSize, Buffer); @@ -450,6 +534,7 @@ fread ( { fprintf (stderr, "EFI_FILE_HANDLE->Read() failure.\n"); errno = EIO; + Length = -EIO; goto ErrorExit; } Length = ReadSize; @@ -485,12 +570,19 @@ AcpiEfiFlushFile ( CHAR16 *Pos, BOOLEAN FlushAll) { + SIMPLE_TEXT_OUTPUT_INTERFACE *Out; + - if (FlushAll || Pos >= (End - 1)) + if (File == stdout || File == stderr) { - *Pos = 0; - uefi_call_wrapper (File->OutputString, 2, File, Begin); - Pos = Begin; + Out = ACPI_CAST_PTR (SIMPLE_TEXT_OUTPUT_INTERFACE, File); + + if (FlushAll || Pos >= (End - 1)) + { + *Pos = 0; + uefi_call_wrapper (Out->OutputString, 2, Out, Begin); + Pos = Begin; + } } return (Pos); @@ -519,7 +611,7 @@ fwrite ( ACPI_SIZE Count, FILE *File) { - int Length = -1; + int Length = -EINVAL; CHAR16 String[ACPI_EFI_PRINT_LENGTH]; const char *Ascii; CHAR16 *End; @@ -530,7 +622,11 @@ fwrite ( EFI_STATUS EfiStatus; - if (File == stdout || File == stderr) + if (File == stdin) + { + /* Do not support write operations on input console */ + } + else if (File == stdout || File == stderr) { Pos = String; End = String + ACPI_EFI_PRINT_LENGTH - 1; @@ -898,6 +994,10 @@ efi_main ( ST = SystemTab; BS = SystemTab->BootServices; + /* Disable the platform watchdog timer if we go interactive */ + + uefi_call_wrapper(BS->SetWatchdogTimer, 4, 0, 0x0, 0, NULL); + /* Retrieve image information */ EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, -- cgit v1.2.1 From fa8cacd85745e3aa7d454c299e8cd2dd4bfa3771 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:56 +0800 Subject: Clib/EFI: Add file position seeking/telling support This patch adds file position seeking/telling support. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/platform/acefiex.h | 31 ++++++ source/os_specific/service_layers/oseficlib.c | 142 +++++++++++++++++++++++++- 2 files changed, 171 insertions(+), 2 deletions(-) diff --git a/source/include/platform/acefiex.h b/source/include/platform/acefiex.h index 17f347221..f78f034ad 100644 --- a/source/include/platform/acefiex.h +++ b/source/include/platform/acefiex.h @@ -154,6 +154,20 @@ typedef struct { UINT8 Data4[8]; } EFI_GUID; +typedef struct { + UINT16 Year; /* 1998 - 20XX */ + UINT8 Month; /* 1 - 12 */ + UINT8 Day; /* 1 - 31 */ + UINT8 Hour; /* 0 - 23 */ + UINT8 Minute; /* 0 - 59 */ + UINT8 Second; /* 0 - 59 */ + UINT8 Pad1; + UINT32 Nanosecond; /* 0 - 999,999,999 */ + INT16 TimeZone; /* -1440 to 1440 or 2047 */ + UINT8 Daylight; + UINT8 Pad2; +} EFI_TIME; + typedef struct _EFI_DEVICE_PATH { UINT8 Type; UINT8 SubType; @@ -434,6 +448,22 @@ EFI_STATUS struct _EFI_FILE_HANDLE *File, UINT64 *Position); +#define EFI_FILE_INFO_ID \ + { 0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } + +typedef struct { + UINT64 Size; + UINT64 FileSize; + UINT64 PhysicalSize; + EFI_TIME CreateTime; + EFI_TIME LastAccessTime; + EFI_TIME ModificationTime; + UINT64 Attribute; + CHAR16 FileName[1]; +} EFI_FILE_INFO; + +#define SIZE_OF_EFI_FILE_INFO ACPI_OFFSET(EFI_FILE_INFO, FileName) + typedef EFI_STATUS (EFIAPI *EFI_FILE_GET_INFO) ( @@ -940,5 +970,6 @@ extern EFI_GUID AcpiGbl_LoadedImageProtocol; extern EFI_GUID AcpiGbl_TextInProtocol; extern EFI_GUID AcpiGbl_TextOutProtocol; extern EFI_GUID AcpiGbl_FileSystemProtocol; +extern EFI_GUID AcpiGbl_GenericFileInfo; #endif /* __ACEFIEX_H__ */ diff --git a/source/os_specific/service_layers/oseficlib.c b/source/os_specific/service_layers/oseficlib.c index 5d6b1a7f4..7839f2a0c 100644 --- a/source/os_specific/service_layers/oseficlib.c +++ b/source/os_specific/service_layers/oseficlib.c @@ -153,6 +153,11 @@ AcpiEfiConvertArgcv ( char ***ArgvPtr, char **BufferPtr); +static int +AcpiEfiGetFileInfo ( + FILE *File, + EFI_FILE_INFO **InfoPtr); + static CHAR16 * AcpiEfiFlushFile ( FILE *File, @@ -169,6 +174,7 @@ EFI_GUID AcpiGbl_LoadedImageProtocol = LOADED_IMAGE_PROTOCOL; EFI_GUID AcpiGbl_TextInProtocol = SIMPLE_TEXT_INPUT_PROTOCOL; EFI_GUID AcpiGbl_TextOutProtocol = SIMPLE_TEXT_OUTPUT_PROTOCOL; EFI_GUID AcpiGbl_FileSystemProtocol = SIMPLE_FILE_SYSTEM_PROTOCOL; +EFI_GUID AcpiGbl_GenericFileInfo = EFI_FILE_INFO_ID; int errno = 0; @@ -678,13 +684,70 @@ ErrorExit: } +/******************************************************************************* + * + * FUNCTION: AcpiEfiGetFileInfo + * + * PARAMETERS: File - File descriptor + * InfoPtr - Pointer to contain file information + * + * RETURN: Clibrary error code + * + * DESCRIPTION: Get file information. + * + ******************************************************************************/ + +static int +AcpiEfiGetFileInfo ( + FILE *File, + EFI_FILE_INFO **InfoPtr) +{ + EFI_STATUS EfiStatus = EFI_BUFFER_TOO_SMALL; + EFI_FILE_INFO *Buffer = NULL; + UINTN BufferSize = SIZE_OF_EFI_FILE_INFO + 200; + EFI_FILE_HANDLE EfiFile; + + + if (!InfoPtr) + { + errno = EINVAL; + return (-EINVAL); + } + + while (EfiStatus == EFI_BUFFER_TOO_SMALL) + { + EfiFile = ACPI_CAST_PTR (EFI_FILE, File); + Buffer = AcpiOsAllocate (BufferSize); + if (!Buffer) + { + errno = ENOMEM; + return (-ENOMEM); + } + EfiStatus = uefi_call_wrapper (EfiFile->GetInfo, 4, EfiFile, + &AcpiGbl_GenericFileInfo, &BufferSize, Buffer); + if (EFI_ERROR (EfiStatus)) + { + AcpiOsFree (Buffer); + if (EfiStatus != EFI_BUFFER_TOO_SMALL) + { + errno = EIO; + return (-EIO); + } + } + } + + *InfoPtr = Buffer; + return (0); +} + + /******************************************************************************* * * FUNCTION: ftell * * PARAMETERS: File - File descriptor * - * RETURN: Size of current position + * RETURN: current position * * DESCRIPTION: Get current file offset. * @@ -695,8 +758,32 @@ ftell ( FILE *File) { long Offset = -1; + UINT64 Current; + EFI_STATUS EfiStatus; + EFI_FILE_HANDLE EfiFile; + if (File == stdin || File == stdout || File == stderr) + { + Offset = 0; + } + else + { + EfiFile = ACPI_CAST_PTR (EFI_FILE, File); + + EfiStatus = uefi_call_wrapper (EfiFile->GetPosition, 2, + EfiFile, &Current); + if (EFI_ERROR (EfiStatus)) + { + goto ErrorExit; + } + else + { + Offset = (long) Current; + } + } + +ErrorExit: return (Offset); } @@ -721,8 +808,59 @@ fseek ( long Offset, int From) { + EFI_FILE_INFO *Info; + int Error; + ACPI_SIZE Size; + UINT64 Current; + EFI_STATUS EfiStatus; + EFI_FILE_HANDLE EfiFile; + + + if (File == stdin || File == stdout || File == stderr) + { + return (0); + } + else + { + EfiFile = ACPI_CAST_PTR (EFI_FILE, File); + Error = AcpiEfiGetFileInfo (File, &Info); + if (Error) + { + return (Error); + } + Size = Info->FileSize; + AcpiOsFree (Info); - return (-1); + if (From == SEEK_CUR) + { + EfiStatus = uefi_call_wrapper (EfiFile->GetPosition, 2, + EfiFile, &Current); + if (EFI_ERROR (EfiStatus)) + { + errno = ERANGE; + return (-ERANGE); + } + Current += Offset; + } + else if (From == SEEK_END) + { + Current = Size - Offset; + } + else + { + Current = Offset; + } + + EfiStatus = uefi_call_wrapper (EfiFile->SetPosition, 2, + EfiFile, Current); + if (EFI_ERROR (EfiStatus)) + { + errno = ERANGE; + return (-ERANGE); + } + } + + return (0); } -- cgit v1.2.1 From 452f283aa516d78437d65c4c3af9723225d109cd Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:56 +0800 Subject: Clib/EFI: Add fgets() to improve portability This patch adds fgets(). Lv Zheng. Signed-off-by: Lv Zheng --- source/os_specific/service_layers/oseficlib.c | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/source/os_specific/service_layers/oseficlib.c b/source/os_specific/service_layers/oseficlib.c index 7839f2a0c..062d1912d 100644 --- a/source/os_specific/service_layers/oseficlib.c +++ b/source/os_specific/service_layers/oseficlib.c @@ -421,6 +421,65 @@ fputc ( } +/******************************************************************************* + * + * FUNCTION: fgets + * + * PARAMETERS: File - File descriptor + * + * RETURN: The string read + * + * DESCRIPTION: Read a string from the file. + * + ******************************************************************************/ + +char * +fgets ( + char *s, + ACPI_SIZE Size, + FILE *File) +{ + ACPI_SIZE ReadBytes = 0; + int Ret; + + + if (Size <= 1) + { + errno = EINVAL; + return (NULL); + } + while (ReadBytes < (Size - 1)) + { + Ret = fgetc (File); + if (Ret == EOF) + { + if (ReadBytes == 0) + { + return (NULL); + } + break; + } + else if (Ret < 0) + { + errno = EIO; + return (NULL); + } + else if (Ret == '\n') + { + s[ReadBytes++] = (char) Ret; + break; + } + else + { + s[ReadBytes++] = (char) Ret; + } + } + + s[ReadBytes] = '\0'; + return (s); +} + + /******************************************************************************* * * FUNCTION: fread -- cgit v1.2.1 From 01f6a32f55a7d77eb3ef02ba4fc02215f5a9e5e2 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:56 +0800 Subject: Clib: Add generic strpbrk() and strtok() to improve portability This patch implements the native string APIs of strpbrk()/strtok(). Unit tests have been done to these two functions in unix environment and no bugs have been found. Lv Zheng. Signed-off-by: Lv Zheng --- source/components/utilities/utclib.c | 87 ++++++++++++++++++++++++++++++++++++ source/include/acclib.h | 10 +++++ 2 files changed, 97 insertions(+) diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c index 0bc9215fd..2f4f4ffdb 100644 --- a/source/components/utilities/utclib.c +++ b/source/components/utilities/utclib.c @@ -356,6 +356,93 @@ strlen ( } +/******************************************************************************* + * + * FUNCTION: strpbrk + * + * PARAMETERS: String - Null terminated string + * Delimiters - Delimiters to match + * + * RETURN: The first occurance in the string of any of the bytes in the + * delimiters + * + * DESCRIPTION: Search a string for any of a set of the delimiters + * + ******************************************************************************/ + +char * +strpbrk ( + const char *String, + const char *Delimiters) +{ + const char *Delimiter; + + + for ( ; *String != '\0'; ++String) + { + for (Delimiter = Delimiters; *Delimiter != '\0'; Delimiter++) + { + if (*String == *Delimiter) + { + return (ACPI_CAST_PTR (char, String)); + } + } + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: strtok + * + * PARAMETERS: String - Null terminated string + * Delimiters - Delimiters to match + * + * RETURN: Pointer to the next token + * + * DESCRIPTION: Split string into tokens + * + ******************************************************************************/ + +char* +strtok ( + char *String, + const char *Delimiters) +{ + char *Begin = String; + static char *SavedPtr; + + + if (Begin == NULL) + { + if (SavedPtr == NULL) + { + return (NULL); + } + Begin = SavedPtr; + } + + SavedPtr = strpbrk (Begin, Delimiters); + while (SavedPtr == Begin) + { + *Begin++ = '\0'; + SavedPtr = strpbrk (Begin, Delimiters); + } + + if (SavedPtr) + { + *SavedPtr++ = '\0'; + return (Begin); + } + else + { + return (NULL); + } +} + + /******************************************************************************* * * FUNCTION: strcpy diff --git a/source/include/acclib.h b/source/include/acclib.h index deaed5a5e..10f5e69b9 100644 --- a/source/include/acclib.h +++ b/source/include/acclib.h @@ -175,6 +175,16 @@ strchr ( const char *String, int ch); +char * +strpbrk ( + const char *String, + const char *Delimiters); + +char * +strtok ( + char *String, + const char *Delimiters); + char * strcpy ( char *DstString, -- cgit v1.2.1 From 52cca74dadcf5ba93f0591215342c6e2dfbb3a9c Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:06:57 +0800 Subject: Clib: Add putchar()/getchar() to improve portability This patch implements putchar()/getchar() invoked in AcpiOsGetLine() to improve the portability. No functional changes for Unix/Windows environments. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/acclib.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/include/acclib.h b/source/include/acclib.h index 10f5e69b9..bf32373dc 100644 --- a/source/include/acclib.h +++ b/source/include/acclib.h @@ -318,6 +318,9 @@ extern int errno; #define EOF (-1) #endif +#define putchar(c) fputc(stdout, c) +#define getchar(c) fgetc(stdin) + int vprintf ( const char *Format, -- cgit v1.2.1 From d91961818753632ebb5eb356d7b3560bfa74edf9 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:54:41 +0800 Subject: EFI: Add OSL supports for those can be empty This patch adds OSLs that can be empty under EFI environment. Lv Zheng. Signed-off-by: Lv Zheng --- source/os_specific/service_layers/osefixf.c | 126 +++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 2 deletions(-) diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index b3da80b8f..54e3e5df8 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -233,6 +233,36 @@ AcpiOsGetRootPointer ( } +/****************************************************************************** + * + * FUNCTION: AcpiOsPredefinedOverride + * + * PARAMETERS: InitVal - Initial value of the predefined object + * NewVal - The new value for the object + * + * RETURN: Status, pointer to value. Null pointer returned if not + * overriding. + * + * DESCRIPTION: Allow the OS to override predefined names + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsPredefinedOverride ( + const ACPI_PREDEFINED_NAMES *InitVal, + ACPI_STRING *NewVal) +{ + + if (!InitVal || !NewVal) + { + return (AE_BAD_PARAMETER); + } + + *NewVal = NULL; + return (AE_OK); +} + + /****************************************************************************** * * FUNCTION: AcpiOsMapMemory @@ -452,13 +482,13 @@ AcpiOsVprintf ( /****************************************************************************** * - * FUNCTION: AcpiOsInitialize + * FUNCTION: AcpiOsInitialize, AcpiOsTerminate * * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Initialize this module. + * DESCRIPTION: Initialize/terminate this module. * *****************************************************************************/ @@ -469,3 +499,95 @@ AcpiOsInitialize ( return (AE_OK); } + +ACPI_STATUS +AcpiOsTerminate ( + void) +{ + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsSignal + * + * PARAMETERS: Function - ACPI A signal function code + * Info - Pointer to function-dependent structure + * + * RETURN: Status + * + * DESCRIPTION: Miscellaneous functions. Example implementation only. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info) +{ + + switch (Function) + { + case ACPI_SIGNAL_FATAL: + + break; + + case ACPI_SIGNAL_BREAKPOINT: + + break; + + default: + + break; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsReadable + * + * PARAMETERS: Pointer - Area to be verified + * Length - Size of area + * + * RETURN: TRUE if readable for entire length + * + * DESCRIPTION: Verify that a pointer is valid for reading + * + *****************************************************************************/ + +BOOLEAN +AcpiOsReadable ( + void *Pointer, + ACPI_SIZE Length) +{ + + return (TRUE); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsWritable + * + * PARAMETERS: Pointer - Area to be verified + * Length - Size of area + * + * RETURN: TRUE if writable for entire length + * + * DESCRIPTION: Verify that a pointer is valid for writing + * + *****************************************************************************/ + +BOOLEAN +AcpiOsWritable ( + void *Pointer, + ACPI_SIZE Length) +{ + + return (TRUE); +} -- cgit v1.2.1 From 24b89b61acfc69d5edfc59a1798ccc43f28446b0 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:54:42 +0800 Subject: EFI: Add stubs for multi-threading OSLs to make EFI ported applications running This patch only adds stub supports for multi-threading OSLs to make EFI ported application running. In order to fully support acpiexec in a non multi-threading environment, ACPICA core itself need to be upgraded to contain full asynchrnous support. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/platform/acefi.h | 6 +++ source/os_specific/service_layers/osefixf.c | 59 ++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h index 567df9ff1..4e1bca132 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -291,6 +291,12 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, #include "acgcc.h" +#ifdef DEBUGGER_THREADING +#undef DEBUGGER_THREADING +#endif /* DEBUGGER_THREADING */ + +#define DEBUGGER_THREADING 0 /* integrated with DDB */ + #undef ACPI_USE_STANDARD_HEADERS #undef ACPI_USE_NATIVE_DIVIDE #undef ACPI_USE_SYSTEM_INTTYPES diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index 54e3e5df8..7d61e85aa 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -312,7 +312,7 @@ AcpiOsUnmapMemory ( /****************************************************************************** * - * FUNCTION: Spinlock interfaces + * FUNCTION: Single threaded stub interfaces * * DESCRIPTION: No-op on single threaded BIOS * @@ -345,6 +345,63 @@ AcpiOsReleaseLock ( { } +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_HANDLE *OutHandle) +{ + *OutHandle = (ACPI_HANDLE) 1; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_HANDLE Handle) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units, + UINT16 Timeout) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + return (AE_OK); +} + +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (1); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + return (AE_OK); +} + +void +AcpiOsWaitEventsComplete ( + void) +{ + return; +} + /****************************************************************************** * -- cgit v1.2.1 From 370047064ca35f6b46a17c31e83560fb9d615e0d Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:54:42 +0800 Subject: EFI: Add stubs for hardware access OSLs to make EFI ported applications running This patch only adds stub supports for hardware access OSLs to make EFI ported application running. This patch adds the following OSLs for efi: 1. AcpiOsInstallInterruptHandler()/RemoveInterruptHandler(). 2. AcpiOsReadPort()/AcpiOsWritePort(). 3. AcpiOsReadMemory()/AcpiOsWriteMemory(). 3. AcpiOsReadPciConfigration()/AcpiOsWritePciConfiguration(). Currently we will not support real hardware accesses in the EFI environment, so they can stay stubs. Lv Zheng. Signed-off-by: Lv Zheng --- source/os_specific/service_layers/osefixf.c | 241 ++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index 7d61e85aa..2ab8683db 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -403,6 +403,247 @@ AcpiOsWaitEventsComplete ( } +/****************************************************************************** + * + * FUNCTION: AcpiOsInstallInterruptHandler + * + * PARAMETERS: InterruptNumber - Level handler should respond to. + * ServiceRoutine - Address of the ACPI interrupt handler + * Context - Where status is returned + * + * RETURN: Handle to the newly installed handler. + * + * DESCRIPTION: Install an interrupt handler. Used to install the ACPI + * OS-independent handler. + * + *****************************************************************************/ + +UINT32 +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine, + void *Context) +{ + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsRemoveInterruptHandler + * + * PARAMETERS: InterruptNumber - Level handler should respond to. + * ServiceRoutine - Address of the ACPI interrupt handler + * + * RETURN: Status + * + * DESCRIPTION: Uninstalls an interrupt handler. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine) +{ + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsReadPciConfiguration + * + * PARAMETERS: PciId - Seg/Bus/Dev + * PciRegister - Device Register + * Value - Buffer where value is placed + * Width - Number of bits + * + * RETURN: Status + * + * DESCRIPTION: Read data from PCI configuration space + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsReadPciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 PciRegister, + UINT64 *Value, + UINT32 Width) +{ + + *Value = 0; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsWritePciConfiguration + * + * PARAMETERS: PciId - Seg/Bus/Dev + * PciRegister - Device Register + * Value - Value to be written + * Width - Number of bits + * + * RETURN: Status. + * + * DESCRIPTION: Write data to PCI configuration space + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsWritePciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 PciRegister, + UINT64 Value, + UINT32 Width) +{ + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsReadPort + * + * PARAMETERS: Address - Address of I/O port/register to read + * Value - Where value is placed + * Width - Number of bits + * + * RETURN: Value read from port + * + * DESCRIPTION: Read data from an I/O port or register + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + + switch (Width) + { + case 8: + + *Value = 0xFF; + break; + + case 16: + + *Value = 0xFFFF; + break; + + case 32: + + *Value = 0xFFFFFFFF; + break; + + default: + + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsWritePort + * + * PARAMETERS: Address - Address of I/O port/register to write + * Value - Value to write + * Width - Number of bits + * + * RETURN: None + * + * DESCRIPTION: Write data to an I/O port or register + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsReadMemory + * + * PARAMETERS: Address - Physical Memory Address to read + * Value - Where value is placed + * Width - Number of bits (8,16,32, or 64) + * + * RETURN: Value read from physical memory address. Always returned + * as a 64-bit integer, regardless of the read width. + * + * DESCRIPTION: Read data from a physical memory address + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsReadMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT64 *Value, + UINT32 Width) +{ + + switch (Width) + { + case 8: + case 16: + case 32: + case 64: + + *Value = 0; + break; + + default: + + return (AE_BAD_PARAMETER); + } + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsWriteMemory + * + * PARAMETERS: Address - Physical Memory Address to write + * Value - Value to write + * Width - Number of bits (8,16,32, or 64) + * + * RETURN: None + * + * DESCRIPTION: Write data to a physical memory address + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsWriteMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT64 Value, + UINT32 Width) +{ + + return (AE_OK); +} + + /****************************************************************************** * * FUNCTION: AcpiOsAllocate -- cgit v1.2.1 From 27a9dec7e5d613e1be7419a362676609a8a92cc6 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:54:43 +0800 Subject: EFI: Add AcpiOsGetTimer() support This patch adds AcpiOsGetTimer() support for EFI environment. Note that currently we don't support timezone. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/platform/acefi.h | 2 + source/include/platform/acefiex.h | 73 +++++++++++++++++++++++++-- source/os_specific/service_layers/oseficlib.c | 1 + source/os_specific/service_layers/osefixf.c | 61 ++++++++++++++++++++++ 4 files changed, 133 insertions(+), 4 deletions(-) diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h index 4e1bca132..c24b3058c 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -325,10 +325,12 @@ struct _SIMPLE_INPUT_INTERFACE; struct _EFI_FILE_IO_INTERFACE; struct _EFI_FILE_HANDLE; struct _EFI_BOOT_SERVICES; +struct _EFI_RUNTIME_SERVICES; struct _EFI_SYSTEM_TABLE; extern struct _EFI_SYSTEM_TABLE *ST; extern struct _EFI_BOOT_SERVICES *BS; +extern struct _EFI_RUNTIME_SERVICES *RT; typedef union acpi_efi_file ACPI_EFI_FILE; diff --git a/source/include/platform/acefiex.h b/source/include/platform/acefiex.h index f78f034ad..fc1438738 100644 --- a/source/include/platform/acefiex.h +++ b/source/include/platform/acefiex.h @@ -615,6 +615,27 @@ EFI_STATUS VOID *Buffer); +/* + * EFI Time + */ +typedef struct { + UINT32 Resolution; + UINT32 Accuracy; + BOOLEAN SetsToZero; +} EFI_TIME_CAPABILITIES; + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_TIME) ( + EFI_TIME *Time, + EFI_TIME_CAPABILITIES *Capabilities); + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_TIME) ( + EFI_TIME *Time); + + /* * Protocol handler functions */ @@ -879,6 +900,54 @@ typedef struct _EFI_BOOT_SERVICES { } EFI_BOOT_SERVICES; +/* + * EFI Runtime Services Table + */ +#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 +#define EFI_RUNTIME_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) + +typedef struct _EFI_RUNTIME_SERVICES { + EFI_TABLE_HEADER Hdr; + + EFI_GET_TIME GetTime; + EFI_SET_TIME SetTime; +#if 0 + EFI_GET_WAKEUP_TIME GetWakeupTime; + EFI_SET_WAKEUP_TIME SetWakeupTime; +#else + EFI_UNKNOWN_INTERFACE GetWakeupTime; + EFI_UNKNOWN_INTERFACE SetWakeupTime; +#endif + +#if 0 + EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap; + EFI_CONVERT_POINTER ConvertPointer; +#else + EFI_UNKNOWN_INTERFACE SetVirtualAddressMap; + EFI_UNKNOWN_INTERFACE ConvertPointer; +#endif + +#if 0 + EFI_GET_VARIABLE GetVariable; + EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName; + EFI_SET_VARIABLE SetVariable; +#else + EFI_UNKNOWN_INTERFACE GetVariable; + EFI_UNKNOWN_INTERFACE GetNextVariableName; + EFI_UNKNOWN_INTERFACE SetVariable; +#endif + +#if 0 + EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount; + EFI_RESET_SYSTEM ResetSystem; +#else + EFI_UNKNOWN_INTERFACE GetNextHighMonotonicCount; + EFI_UNKNOWN_INTERFACE ResetSystem; +#endif + +} EFI_RUNTIME_SERVICES; + + /* * EFI System Table */ @@ -915,11 +984,7 @@ typedef struct _EFI_SYSTEM_TABLE { EFI_HANDLE StandardErrorHandle; SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr; -#if 0 EFI_RUNTIME_SERVICES *RuntimeServices; -#else - EFI_HANDLE *RuntimeServices; -#endif EFI_BOOT_SERVICES *BootServices; UINTN NumberOfTableEntries; diff --git a/source/os_specific/service_layers/oseficlib.c b/source/os_specific/service_layers/oseficlib.c index 062d1912d..69f92b6d1 100644 --- a/source/os_specific/service_layers/oseficlib.c +++ b/source/os_specific/service_layers/oseficlib.c @@ -1190,6 +1190,7 @@ efi_main ( ST = SystemTab; BS = SystemTab->BootServices; + RT = SystemTab->RuntimeServices; /* Disable the platform watchdog timer if we go interactive */ diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index 2ab8683db..439494cbc 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -644,6 +644,67 @@ AcpiOsWriteMemory ( } +/****************************************************************************** + * + * FUNCTION: AcpiOsGetTimer + * + * PARAMETERS: None + * + * RETURN: Current time in 100 nanosecond units + * + * DESCRIPTION: Get the current system time + * + *****************************************************************************/ + +UINT64 +AcpiOsGetTimer ( + void) +{ + EFI_STATUS EfiStatus; + EFI_TIME EfiTime; + int Year, Month, Day; + int Hour, Minute, Second; + UINT64 Timer; + + + EfiStatus = uefi_call_wrapper (RT->GetTime, 2, &EfiTime, NULL); + if (EFI_ERROR (EfiStatus)) + { + return (-1); + } + + Year = EfiTime.Year; + Month = EfiTime.Month; + Day = EfiTime.Day; + Hour = EfiTime.Hour; + Minute = EfiTime.Minute; + Second = EfiTime.Second; + + /* 1..12 -> 11,12,1..10 */ + + if (0 >= (int) (Month -= 2)) + { + /* Feb has leap days */ + + Month += 12; + Year -= 1; + } + + /* Calculate days */ + + Timer = ((UINT64) (Year/4 - Year/100 + Year/400 + 367*Month/12 + Day) + + Year*365 - 719499); + + /* Calculate seconds */ + + Timer = ((Timer*24 + Hour) * 60 + Minute) * 60 + Second; + + /* Calculate 100 nanoseconds */ + + return ((Timer * ACPI_100NSEC_PER_SEC) + (EfiTime.Nanosecond / 100)); +} + + /****************************************************************************** * * FUNCTION: AcpiOsAllocate -- cgit v1.2.1 From feba919da450b9cf6a3caad0b5260b19d1ad9e41 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:54:43 +0800 Subject: EFI: Add AcpiOsStall()/AcpiOsSleep() support This patch adds AcpiOsStall() and AcpiOsSleep() support. Currently we do not support asynchronous polling of key stroke and timer, so AcpiOsSleep() is simply an invocation of AcpiOsStall(). Lv Zheng. Signed-off-by: Lv Zheng --- source/include/platform/acefiex.h | 8 +++-- source/os_specific/service_layers/osefixf.c | 45 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/source/include/platform/acefiex.h b/source/include/platform/acefiex.h index fc1438738..1b74b545b 100644 --- a/source/include/platform/acefiex.h +++ b/source/include/platform/acefiex.h @@ -546,6 +546,11 @@ EFI_STATUS EFI_HANDLE ImageHandle); +typedef +EFI_STATUS +(EFIAPI *EFI_STALL) ( + UINTN Microseconds); + typedef EFI_STATUS (EFIAPI *EFI_SET_WATCHDOG_TIMER) ( @@ -862,12 +867,11 @@ typedef struct _EFI_BOOT_SERVICES { #if 0 EFI_EXIT_BOOT_SERVICES ExitBootServices; EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; - EFI_STALL Stall; #else EFI_UNKNOWN_INTERFACE ExitBootServices; EFI_UNKNOWN_INTERFACE GetNextMonotonicCount; - EFI_UNKNOWN_INTERFACE Stall; #endif + EFI_STALL Stall; EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; #if 0 diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index 439494cbc..193381d00 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -705,6 +705,51 @@ AcpiOsGetTimer ( } +/****************************************************************************** + * + * FUNCTION: AcpiOsStall + * + * PARAMETERS: microseconds - Time to sleep + * + * RETURN: Blocks until sleep is completed. + * + * DESCRIPTION: Sleep at microsecond granularity + * + *****************************************************************************/ + +void +AcpiOsStall ( + UINT32 microseconds) +{ + + if (microseconds) + { + uefi_call_wrapper (BS->Stall, 1, microseconds); + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsSleep + * + * PARAMETERS: milliseconds - Time to sleep + * + * RETURN: Blocks until sleep is completed. + * + * DESCRIPTION: Sleep at millisecond granularity + * + *****************************************************************************/ + +void +AcpiOsSleep ( + UINT64 milliseconds) +{ + + AcpiOsStall (milliseconds * ACPI_USEC_PER_MSEC); +} + + /****************************************************************************** * * FUNCTION: AcpiOsAllocate -- cgit v1.2.1 From 43cb45b8e190959e1a519df9a1b73122b3b69d16 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:54:43 +0800 Subject: EFI: Add table OSL supports for acpiexec This patch implements table OSLs for acpiexec in EFI environment: 1. Adds AcpiOsTableOverride() to use acpiexec loaded xSDT tables. 2. Adds a stub AcpiOsPhysicalTableOverride(). Note that currently we only support emulator mode acpiexec in EFI environment, thus all table overrides, RSDP location are implemented in the same way as its windows/unix versions. Lv Zheng. Signed-off-by: Lv Zheng --- source/os_specific/service_layers/osefixf.c | 77 +++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index 193381d00..6ba45bb21 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -121,8 +121,17 @@ ACPI_MODULE_NAME ("osefixf") +/* Upcalls to AcpiExec */ + +void +AeTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable); + /* Local prototypes */ +#ifndef ACPI_USE_NATIVE_RSDP_POINTER + static BOOLEAN AcpiEfiCompareGuid ( EFI_GUID *Guid1, @@ -232,6 +241,74 @@ AcpiOsGetRootPointer ( return (Address); } +#endif + + +/****************************************************************************** + * + * FUNCTION: AcpiOsTableOverride + * + * PARAMETERS: ExistingTable - Header of current table (probably + * firmware) + * NewTable - Where an entire new table is returned. + * + * RETURN: Status, pointer to new table. Null pointer returned if no + * table is available to override + * + * DESCRIPTION: Return a different version of a table if one is available + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable) +{ + + if (!ExistingTable || !NewTable) + { + return (AE_BAD_PARAMETER); + } + + *NewTable = NULL; + +#ifdef ACPI_EXEC_APP + + AeTableOverride (ExistingTable, NewTable); + return (AE_OK); +#else + + return (AE_NO_ACPI_TABLES); +#endif +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsPhysicalTableOverride + * + * PARAMETERS: ExistingTable - Header of current table (probably firmware) + * NewAddress - Where new table address is returned + * (Physical address) + * NewTableLength - Where new table length is returned + * + * RETURN: Status, address/length of new table. Null pointer returned + * if no table is available to override. + * + * DESCRIPTION: Returns AE_SUPPORT, function not used in user space. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsPhysicalTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_PHYSICAL_ADDRESS *NewAddress, + UINT32 *NewTableLength) +{ + + return (AE_SUPPORT); +} + /****************************************************************************** * -- cgit v1.2.1 From def0dcd048716e293fd187e6f3e4d65d4e1e9e37 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:54:44 +0800 Subject: EFI/acpiexec: Add stubs for Ctrl+C signal handling Currently we do not support console termination caused by Ctrl+C for EFI environment. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/platform/acenv.h | 1 + source/tools/acpiexec/aecommon.h | 2 ++ source/tools/acpiexec/aehandlers.c | 5 ++++- source/tools/acpiexec/aemain.c | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index ead8a9af0..723979ff7 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -426,6 +426,7 @@ #include #include #include +#include #include #endif diff --git a/source/tools/acpiexec/aecommon.h b/source/tools/acpiexec/aecommon.h index 12199b04c..502717584 100644 --- a/source/tools/acpiexec/aecommon.h +++ b/source/tools/acpiexec/aecommon.h @@ -173,9 +173,11 @@ extern ACPI_CONNECTION_INFO AeMyContext; #define OSD_PRINT(lvl,fp) TEST_OUTPUT_LEVEL(lvl) {\ AcpiOsPrintf PARAM_LIST(fp);} +#ifndef _GNU_EFI void ACPI_SYSTEM_XFACE AeCtrlCHandler ( int Sig); +#endif ACPI_STATUS AeBuildLocalTables ( diff --git a/source/tools/acpiexec/aehandlers.c b/source/tools/acpiexec/aehandlers.c index f08ffbe8e..c3d0a7db8 100644 --- a/source/tools/acpiexec/aehandlers.c +++ b/source/tools/acpiexec/aehandlers.c @@ -192,10 +192,12 @@ static char *TableEvents[] = #endif /* !ACPI_REDUCED_HARDWARE */ -static UINT32 SigintCount = 0; static AE_DEBUG_REGIONS AeRegions; +#ifndef _GNU_EFI +static UINT32 SigintCount = 0; + /****************************************************************************** * * FUNCTION: AeCtrlCHandler @@ -232,6 +234,7 @@ AeCtrlCHandler ( (void) AcpiOsTerminate (); exit (0); } +#endif /****************************************************************************** diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index 90b6cfc5b..f6929e191 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -530,7 +530,9 @@ main ( ACPI_DEBUG_INITIALIZE (); /* For debug version only */ +#ifndef _GNU_EFI signal (SIGINT, AeCtrlCHandler); +#endif /* Init debug globals */ -- cgit v1.2.1 From 6bbbef88118f08723c9dc82349ee92505476d762 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:54:44 +0800 Subject: EFI/acpiexec: Disable object override mechanism This mechanism requires sscanf to be implemented for almost no significant benefit for EFI environment, so disables it. Lv Zheng. Signed-off-by: Lv Zheng --- source/components/utilities/utxfinit.c | 4 ++++ source/include/platform/acefi.h | 6 ++++++ source/tools/acpiexec/aeinitfile.c | 4 ++++ source/tools/acpiexec/aemain.c | 2 ++ 4 files changed, 16 insertions(+) diff --git a/source/components/utilities/utxfinit.c b/source/components/utilities/utxfinit.c index c6a26d992..66834ac77 100644 --- a/source/components/utilities/utxfinit.c +++ b/source/components/utilities/utxfinit.c @@ -126,9 +126,11 @@ ACPI_MODULE_NAME ("utxfinit") /* For AcpiExec only */ +#ifndef ACPI_DISABLE_OBJECT_OVERRIDE void AeDoObjectOverrides ( void); +#endif /******************************************************************************* @@ -346,11 +348,13 @@ AcpiInitializeObjects ( #ifdef ACPI_EXEC_APP +#ifndef ACPI_DISABLE_OBJECT_OVERRIDE /* * This call implements the "initialization file" option for AcpiExec. * This is the precise point that we want to perform the overrides. */ AeDoObjectOverrides (); +#endif #endif /* diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h index c24b3058c..a545fb95a 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -301,6 +301,12 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, #undef ACPI_USE_NATIVE_DIVIDE #undef ACPI_USE_SYSTEM_INTTYPES +/* AcpiExec configuration */ + +#ifdef ACPI_EXEC_APP +#define ACPI_DISABLE_OBJECT_OVERRIDE +#endif + /* * Math helpers */ diff --git a/source/tools/acpiexec/aeinitfile.c b/source/tools/acpiexec/aeinitfile.c index b1b60cd0c..996cc8e9c 100644 --- a/source/tools/acpiexec/aeinitfile.c +++ b/source/tools/acpiexec/aeinitfile.c @@ -122,6 +122,8 @@ /* Local prototypes */ +#ifndef ACPI_DISABLE_OBJECT_OVERRIDE + static void AeDoOneOverride ( char *Pathname, @@ -304,3 +306,5 @@ AeDoOneOverride ( AcpiOsPrintf ("New value: 0x%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Value)); } + +#endif diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index f6929e191..7e60a1233 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -397,10 +397,12 @@ AeDoOptions ( return (-1); } +#ifndef ACPI_DISABLE_OBJECT_OVERRIDE if (AeOpenInitializationFile (AcpiGbl_Optarg)) { return (-1); } +#endif break; default: -- cgit v1.2.1 From 4de4519bb6c236115a4277917a6fc56facd45fb3 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 23 May 2016 23:54:44 +0800 Subject: EFI/acpiexec: Add EFI support for acpiexec This patch enables acpiexec for EFI environment. Lv Zheng. Signed-off-by: Lv Zheng --- generate/efi/Makefile.config | 3 +- generate/efi/acpiexec/Makefile | 255 +++++++++++++++++++++++++++++++++++++++ source/tools/acpiexec/aecommon.h | 5 - source/tools/acpiexec/aemain.c | 10 +- 4 files changed, 265 insertions(+), 8 deletions(-) create mode 100644 generate/efi/acpiexec/Makefile diff --git a/generate/efi/Makefile.config b/generate/efi/Makefile.config index 6c7c5950b..1f3aa74d4 100644 --- a/generate/efi/Makefile.config +++ b/generate/efi/Makefile.config @@ -47,7 +47,7 @@ # # Common defines # -PROGS = acpidump +PROGS = acpidump acpiexec HOST = $(shell uname -m | sed s,i[3456789]86,ia32,) TARGET = $(shell uname -m | sed s,i[3456789]86,ia32,) SHARED ?= true @@ -79,6 +79,7 @@ ACPICA_UTILITIES = $(ACPICA_CORE)/utilities # ACPICA tool and utility source directories # ACPIDUMP = $(ACPICA_TOOLS)/acpidump +ACPIEXEC = $(ACPICA_TOOLS)/acpiexec # # Common ACPICA header files diff --git a/generate/efi/acpiexec/Makefile b/generate/efi/acpiexec/Makefile new file mode 100644 index 000000000..aedcb6b14 --- /dev/null +++ b/generate/efi/acpiexec/Makefile @@ -0,0 +1,255 @@ + +# +# acpiexec: ACPI execution simulator. Runs ACPICA code in user +# space. Loads ACPI tables, displays the namespace, and allows +# execution of control methods. +# + +# +# Note: This makefile is intended to be used from within the native +# ACPICA directory structure, from under generate/unix. It specifically +# places all object files in a generate/unix subdirectory, not within +# the various ACPICA source directories. This prevents collisions +# between different compilations of the same source file with different +# compile options, and prevents pollution of the source code. +# +include ../Makefile.config +FINAL_PROG = ../$(BINDIR)/acpiexec +PROG = $(OBJDIR)/acpiexec + +# +# Search paths for source files +# +vpath %.c \ + $(ACPIEXEC)\ + $(ACPICA_DEBUGGER)\ + $(ACPICA_DISASSEMBLER)\ + $(ACPICA_DISPATCHER)\ + $(ACPICA_EVENTS)\ + $(ACPICA_EXECUTER)\ + $(ACPICA_HARDWARE)\ + $(ACPICA_NAMESPACE)\ + $(ACPICA_PARSER)\ + $(ACPICA_RESOURCES)\ + $(ACPICA_TABLES)\ + $(ACPICA_UTILITIES)\ + $(ACPICA_COMMON)\ + $(ACPICA_OSL) + +HEADERS = \ + $(wildcard $(ACPIEXEC)/*.h) + +OBJECTS = \ + $(OBJDIR)/acfileio.o\ + $(OBJDIR)/acgetline.o\ + $(OBJDIR)/aeexec.o\ + $(OBJDIR)/aehandlers.o\ + $(OBJDIR)/aeinitfile.o\ + $(OBJDIR)/aemain.o\ + $(OBJDIR)/aeregion.o\ + $(OBJDIR)/aetables.o\ + $(OBJDIR)/ahids.o\ + $(OBJDIR)/ahuuids.o\ + $(OBJDIR)/cmfsize.o\ + $(OBJDIR)/dbcmds.o\ + $(OBJDIR)/dbconvert.o\ + $(OBJDIR)/dbdisply.o\ + $(OBJDIR)/dbexec.o\ + $(OBJDIR)/dbfileio.o\ + $(OBJDIR)/dbhistry.o\ + $(OBJDIR)/dbinput.o\ + $(OBJDIR)/dbmethod.o\ + $(OBJDIR)/dbnames.o\ + $(OBJDIR)/dbobject.o\ + $(OBJDIR)/dbstats.o\ + $(OBJDIR)/dbtest.o\ + $(OBJDIR)/dbutils.o\ + $(OBJDIR)/dbxface.o\ + $(OBJDIR)/dmbuffer.o\ + $(OBJDIR)/dmcstyle.o\ + $(OBJDIR)/dmdeferred.o\ + $(OBJDIR)/dmnames.o\ + $(OBJDIR)/dmopcode.o\ + $(OBJDIR)/dmresrc.o\ + $(OBJDIR)/dmresrcl.o\ + $(OBJDIR)/dmresrcl2.o\ + $(OBJDIR)/dmresrcs.o\ + $(OBJDIR)/dmutils.o\ + $(OBJDIR)/dmwalk.o\ + $(OBJDIR)/dsargs.o\ + $(OBJDIR)/dscontrol.o\ + $(OBJDIR)/dsdebug.o\ + $(OBJDIR)/dsfield.o\ + $(OBJDIR)/dsinit.o\ + $(OBJDIR)/dsmethod.o\ + $(OBJDIR)/dsmthdat.o\ + $(OBJDIR)/dsobject.o\ + $(OBJDIR)/dsopcode.o\ + $(OBJDIR)/dsutils.o\ + $(OBJDIR)/dswexec.o\ + $(OBJDIR)/dswload.o\ + $(OBJDIR)/dswload2.o\ + $(OBJDIR)/dswscope.o\ + $(OBJDIR)/dswstate.o\ + $(OBJDIR)/evevent.o\ + $(OBJDIR)/evglock.o\ + $(OBJDIR)/evgpe.o\ + $(OBJDIR)/evgpeblk.o\ + $(OBJDIR)/evgpeinit.o\ + $(OBJDIR)/evgpeutil.o\ + $(OBJDIR)/evhandler.o\ + $(OBJDIR)/evmisc.o\ + $(OBJDIR)/evregion.o\ + $(OBJDIR)/evrgnini.o\ + $(OBJDIR)/evsci.o\ + $(OBJDIR)/evxface.o\ + $(OBJDIR)/evxfevnt.o\ + $(OBJDIR)/evxfgpe.o\ + $(OBJDIR)/evxfregn.o\ + $(OBJDIR)/exconcat.o\ + $(OBJDIR)/exconfig.o\ + $(OBJDIR)/exconvrt.o\ + $(OBJDIR)/excreate.o\ + $(OBJDIR)/exdebug.o\ + $(OBJDIR)/exdump.o\ + $(OBJDIR)/exfield.o\ + $(OBJDIR)/exfldio.o\ + $(OBJDIR)/exmisc.o\ + $(OBJDIR)/exmutex.o\ + $(OBJDIR)/exnames.o\ + $(OBJDIR)/exoparg1.o\ + $(OBJDIR)/exoparg2.o\ + $(OBJDIR)/exoparg3.o\ + $(OBJDIR)/exoparg6.o\ + $(OBJDIR)/exprep.o\ + $(OBJDIR)/exregion.o\ + $(OBJDIR)/exresnte.o\ + $(OBJDIR)/exresolv.o\ + $(OBJDIR)/exresop.o\ + $(OBJDIR)/exstore.o\ + $(OBJDIR)/exstoren.o\ + $(OBJDIR)/exstorob.o\ + $(OBJDIR)/exsystem.o\ + $(OBJDIR)/extrace.o\ + $(OBJDIR)/exutils.o\ + $(OBJDIR)/getopt.o\ + $(OBJDIR)/hwacpi.o\ + $(OBJDIR)/hwesleep.o\ + $(OBJDIR)/hwgpe.o\ + $(OBJDIR)/hwpci.o\ + $(OBJDIR)/hwregs.o\ + $(OBJDIR)/hwsleep.o\ + $(OBJDIR)/hwvalid.o\ + $(OBJDIR)/hwxface.o\ + $(OBJDIR)/hwxfsleep.o\ + $(OBJDIR)/nsaccess.o\ + $(OBJDIR)/nsalloc.o\ + $(OBJDIR)/nsarguments.o\ + $(OBJDIR)/nsconvert.o\ + $(OBJDIR)/nsdump.o\ + $(OBJDIR)/nsdumpdv.o\ + $(OBJDIR)/nseval.o\ + $(OBJDIR)/nsinit.o\ + $(OBJDIR)/nsload.o\ + $(OBJDIR)/nsnames.o\ + $(OBJDIR)/nsobject.o\ + $(OBJDIR)/nsparse.o\ + $(OBJDIR)/nspredef.o\ + $(OBJDIR)/nsprepkg.o\ + $(OBJDIR)/nsrepair.o\ + $(OBJDIR)/nsrepair2.o\ + $(OBJDIR)/nssearch.o\ + $(OBJDIR)/nsutils.o\ + $(OBJDIR)/nswalk.o\ + $(OBJDIR)/nsxfeval.o\ + $(OBJDIR)/nsxfname.o\ + $(OBJDIR)/nsxfobj.o\ + $(OBJDIR)/psargs.o\ + $(OBJDIR)/psloop.o\ + $(OBJDIR)/psobject.o\ + $(OBJDIR)/psopcode.o\ + $(OBJDIR)/psopinfo.o\ + $(OBJDIR)/psparse.o\ + $(OBJDIR)/psscope.o\ + $(OBJDIR)/pstree.o\ + $(OBJDIR)/psutils.o\ + $(OBJDIR)/pswalk.o\ + $(OBJDIR)/psxface.o\ + $(OBJDIR)/rsaddr.o\ + $(OBJDIR)/rscalc.o\ + $(OBJDIR)/rscreate.o\ + $(OBJDIR)/rsdump.o\ + $(OBJDIR)/rsdumpinfo.o\ + $(OBJDIR)/rsinfo.o\ + $(OBJDIR)/rsio.o\ + $(OBJDIR)/rsirq.o\ + $(OBJDIR)/rslist.o\ + $(OBJDIR)/rsmemory.o\ + $(OBJDIR)/rsmisc.o\ + $(OBJDIR)/rsserial.o\ + $(OBJDIR)/rsutils.o\ + $(OBJDIR)/rsxface.o\ + $(OBJDIR)/tbdata.o\ + $(OBJDIR)/tbfadt.o\ + $(OBJDIR)/tbfind.o\ + $(OBJDIR)/tbinstal.o\ + $(OBJDIR)/tbprint.o\ + $(OBJDIR)/tbutils.o\ + $(OBJDIR)/tbxface.o\ + $(OBJDIR)/tbxfload.o\ + $(OBJDIR)/tbxfroot.o\ + $(OBJDIR)/utaddress.o\ + $(OBJDIR)/utalloc.o\ + $(OBJDIR)/utascii.o\ + $(OBJDIR)/utbuffer.o\ + $(OBJDIR)/utcache.o\ + $(OBJDIR)/utclib.o\ + $(OBJDIR)/utcopy.o\ + $(OBJDIR)/utdebug.o\ + $(OBJDIR)/utdecode.o\ + $(OBJDIR)/utdelete.o\ + $(OBJDIR)/uterror.o\ + $(OBJDIR)/uteval.o\ + $(OBJDIR)/utexcep.o\ + $(OBJDIR)/utglobal.o\ + $(OBJDIR)/uthex.o\ + $(OBJDIR)/utids.o\ + $(OBJDIR)/utinit.o\ + $(OBJDIR)/utlock.o\ + $(OBJDIR)/utmath.o\ + $(OBJDIR)/utmisc.o\ + $(OBJDIR)/utmutex.o\ + $(OBJDIR)/utnonansi.o\ + $(OBJDIR)/utobject.o\ + $(OBJDIR)/utosi.o\ + $(OBJDIR)/utownerid.o\ + $(OBJDIR)/utpredef.o\ + $(OBJDIR)/utprint.o\ + $(OBJDIR)/utresrc.o\ + $(OBJDIR)/utstate.o\ + $(OBJDIR)/utstring.o\ + $(OBJDIR)/uttrack.o\ + $(OBJDIR)/utuuid.o\ + $(OBJDIR)/utxface.o\ + $(OBJDIR)/utxferror.o\ + $(OBJDIR)/utxfinit.o\ + $(OBJDIR)/oseficlib.o\ + $(OBJDIR)/osefixf.o\ + $(OBJDIR)/utxfmutex.o + +# +# Flags specific to acpiexec utility +# +CFLAGS += \ + -DACPI_EXEC_APP\ + -I$(ACPIEXEC) + +ifeq ($(ASLTS),TRUE) +CFLAGS += \ + -DACPI_CHECKSUM_ABORT=TRUE +endif + +# +# Common Rules +# +include ../Makefile.rules diff --git a/source/tools/acpiexec/aecommon.h b/source/tools/acpiexec/aecommon.h index 502717584..aaa7f9099 100644 --- a/source/tools/acpiexec/aecommon.h +++ b/source/tools/acpiexec/aecommon.h @@ -131,11 +131,6 @@ #include "amlresrc.h" #include "acapps.h" -#include -#include -#include -#include - /* * Debug Regions diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index 7e60a1233..b153121fe 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -114,7 +114,6 @@ *****************************************************************************/ #include "aecommon.h" -#include "errno.h" #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("aemain") @@ -520,10 +519,17 @@ AeDoOptions ( * *****************************************************************************/ +#ifndef _GNU_EFI int ACPI_SYSTEM_XFACE main ( int argc, - char **argv) + char *argv[]) +#else +int ACPI_SYSTEM_XFACE +acpi_main ( + int argc, + char *argv[]) +#endif { ACPI_NEW_TABLE_DESC *ListHead = NULL; ACPI_STATUS Status; -- cgit v1.2.1 From 904347fbea8281411d8defd761e4015c61a008d6 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 30 May 2016 17:45:30 +0800 Subject: EFI: Rename EFI stuff to ACPI_EFI to improve portability This patch renames the EFI stuffs to ACPI_EFI stuffs so that there won't be namespace conflicts when this code is ported to the different EFI development environment. No functional changes. Lv Zheng. Signed-off-by: Lv Zheng --- source/include/platform/acefi.h | 32 +- source/include/platform/acefiex.h | 961 +++++++++++++------------- source/os_specific/service_layers/oseficlib.c | 122 ++-- source/os_specific/service_layers/osefixf.c | 28 +- 4 files changed, 572 insertions(+), 571 deletions(-) diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h index a545fb95a..859e7554d 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -123,11 +123,11 @@ #endif #ifdef _MSC_EXTENSIONS -#define EFIAPI __cdecl +#define ACPI_EFI_API __cdecl #elif USE_MS_ABI -#define EFIAPI __attribute__((ms_abi)) +#define ACPI_EFI_API __attribute__((ms_abi)) #else -#define EFIAPI +#define ACPI_EFI_API #endif #define VOID void @@ -153,7 +153,7 @@ #define UINTN uint64_t #define INTN int64_t -#define EFIERR(a) (0x8000000000000000 | a) +#define ACPI_EFI_ERR(a) (0x8000000000000000 | a) #else @@ -163,7 +163,7 @@ #define UINTN uint32_t #define INTN int32_t -#define EFIERR(a) (0x80000000 | a) +#define ACPI_EFI_ERR(a) (0x80000000 | a) #endif @@ -326,17 +326,17 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, #endif -struct _SIMPLE_TEXT_OUTPUT_INTERFACE; -struct _SIMPLE_INPUT_INTERFACE; -struct _EFI_FILE_IO_INTERFACE; -struct _EFI_FILE_HANDLE; -struct _EFI_BOOT_SERVICES; -struct _EFI_RUNTIME_SERVICES; -struct _EFI_SYSTEM_TABLE; - -extern struct _EFI_SYSTEM_TABLE *ST; -extern struct _EFI_BOOT_SERVICES *BS; -extern struct _EFI_RUNTIME_SERVICES *RT; +struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE; +struct _ACPI_SIMPLE_INPUT_INTERFACE; +struct _ACPI_EFI_FILE_IO_INTERFACE; +struct _ACPI_EFI_FILE_HANDLE; +struct _ACPI_EFI_BOOT_SERVICES; +struct _ACPI_EFI_RUNTIME_SERVICES; +struct _ACPI_EFI_SYSTEM_TABLE; + +extern struct _ACPI_EFI_SYSTEM_TABLE *ST; +extern struct _ACPI_EFI_BOOT_SERVICES *BS; +extern struct _ACPI_EFI_RUNTIME_SERVICES *RT; typedef union acpi_efi_file ACPI_EFI_FILE; diff --git a/source/include/platform/acefiex.h b/source/include/platform/acefiex.h index 1b74b545b..aecb38e6c 100644 --- a/source/include/platform/acefiex.h +++ b/source/include/platform/acefiex.h @@ -117,42 +117,42 @@ #define __ACEFIEX_H__ -#define EFI_ERROR(a) (((INTN) a) < 0) -#define EFI_SUCCESS 0 -#define EFI_LOAD_ERROR EFIERR(1) -#define EFI_INVALID_PARAMETER EFIERR(2) -#define EFI_UNSUPPORTED EFIERR(3) -#define EFI_BAD_BUFFER_SIZE EFIERR(4) -#define EFI_BUFFER_TOO_SMALL EFIERR(5) -#define EFI_NOT_READY EFIERR(6) -#define EFI_DEVICE_ERROR EFIERR(7) -#define EFI_WRITE_PROTECTED EFIERR(8) -#define EFI_OUT_OF_RESOURCES EFIERR(9) -#define EFI_VOLUME_CORRUPTED EFIERR(10) -#define EFI_VOLUME_FULL EFIERR(11) -#define EFI_NO_MEDIA EFIERR(12) -#define EFI_MEDIA_CHANGED EFIERR(13) -#define EFI_NOT_FOUND EFIERR(14) -#define EFI_ACCESS_DENIED EFIERR(15) -#define EFI_NO_RESPONSE EFIERR(16) -#define EFI_NO_MAPPING EFIERR(17) -#define EFI_TIMEOUT EFIERR(18) -#define EFI_NOT_STARTED EFIERR(19) -#define EFI_ALREADY_STARTED EFIERR(20) -#define EFI_ABORTED EFIERR(21) -#define EFI_PROTOCOL_ERROR EFIERR(24) - - -typedef UINTN EFI_STATUS; -typedef VOID *EFI_HANDLE; -typedef VOID *EFI_EVENT; +#define ACPI_EFI_ERROR(a) (((INTN) a) < 0) +#define ACPI_EFI_SUCCESS 0 +#define ACPI_EFI_LOAD_ERROR ACPI_EFI_ERR(1) +#define ACPI_EFI_INVALID_PARAMETER ACPI_EFI_ERR(2) +#define ACPI_EFI_UNSUPPORTED ACPI_EFI_ERR(3) +#define ACPI_EFI_BAD_BUFFER_SIZE ACPI_EFI_ERR(4) +#define ACPI_EFI_BUFFER_TOO_SMALL ACPI_EFI_ERR(5) +#define ACPI_EFI_NOT_READY ACPI_EFI_ERR(6) +#define ACPI_EFI_DEVICE_ERROR ACPI_EFI_ERR(7) +#define ACPI_EFI_WRITE_PROTECTED ACPI_EFI_ERR(8) +#define ACPI_EFI_OUT_OF_RESOURCES ACPI_EFI_ERR(9) +#define ACPI_EFI_VOLUME_CORRUPTED ACPI_EFI_ERR(10) +#define ACPI_EFI_VOLUME_FULL ACPI_EFI_ERR(11) +#define ACPI_EFI_NO_MEDIA ACPI_EFI_ERR(12) +#define ACPI_EFI_MEDIA_CHANGED ACPI_EFI_ERR(13) +#define ACPI_EFI_NOT_FOUND ACPI_EFI_ERR(14) +#define ACPI_EFI_ACCESS_DENIED ACPI_EFI_ERR(15) +#define ACPI_EFI_NO_RESPONSE ACPI_EFI_ERR(16) +#define ACPI_EFI_NO_MAPPING ACPI_EFI_ERR(17) +#define ACPI_EFI_TIMEOUT ACPI_EFI_ERR(18) +#define ACPI_EFI_NOT_STARTED ACPI_EFI_ERR(19) +#define ACPI_EFI_ALREADY_STARTED ACPI_EFI_ERR(20) +#define ACPI_EFI_ABORTED ACPI_EFI_ERR(21) +#define ACPI_EFI_PROTOCOL_ERROR ACPI_EFI_ERR(24) + + +typedef UINTN ACPI_EFI_STATUS; +typedef VOID *ACPI_EFI_HANDLE; +typedef VOID *ACPI_EFI_EVENT; typedef struct { UINT32 Data1; UINT16 Data2; UINT16 Data3; UINT8 Data4[8]; -} EFI_GUID; +} ACPI_EFI_GUID; typedef struct { UINT16 Year; /* 1998 - 20XX */ @@ -166,142 +166,142 @@ typedef struct { INT16 TimeZone; /* -1440 to 1440 or 2047 */ UINT8 Daylight; UINT8 Pad2; -} EFI_TIME; +} ACPI_EFI_TIME; -typedef struct _EFI_DEVICE_PATH { +typedef struct _ACPI_EFI_DEVICE_PATH { UINT8 Type; UINT8 SubType; UINT8 Length[2]; -} EFI_DEVICE_PATH; +} ACPI_EFI_DEVICE_PATH; -typedef UINT64 EFI_PHYSICAL_ADDRESS; -typedef UINT64 EFI_VIRTUAL_ADDRESS; +typedef UINT64 ACPI_EFI_PHYSICAL_ADDRESS; +typedef UINT64 ACPI_EFI_VIRTUAL_ADDRESS; typedef enum { - AllocateAnyPages, - AllocateMaxAddress, - AllocateAddress, - MaxAllocateType -} EFI_ALLOCATE_TYPE; + AcpiEfiAllocateAnyPages, + AcpiEfiAllocateMaxAddress, + AcpiEfiAllocateAddress, + AcpiEfiMaxAllocateType +} ACPI_EFI_ALLOCATE_TYPE; typedef enum { - EfiReservedMemoryType, - EfiLoaderCode, - EfiLoaderData, - EfiBootServicesCode, - EfiBootServicesData, - EfiRuntimeServicesCode, - EfiRuntimeServicesData, - EfiConventionalMemory, - EfiUnusableMemory, - EfiACPIReclaimMemory, - EfiACPIMemoryNVS, - EfiMemoryMappedIO, - EfiMemoryMappedIOPortSpace, - EfiPalCode, - EfiMaxMemoryType -} EFI_MEMORY_TYPE; + AcpiEfiReservedMemoryType, + AcpiEfiLoaderCode, + AcpiEfiLoaderData, + AcpiEfiBootServicesCode, + AcpiEfiBootServicesData, + AcpiEfiRuntimeServicesCode, + AcpiEfiRuntimeServicesData, + AcpiEfiConventionalMemory, + AcpiEfiUnusableMemory, + AcpiEfiACPIReclaimMemory, + AcpiEfiACPIMemoryNVS, + AcpiEfiMemoryMappedIO, + AcpiEfiMemoryMappedIOPortSpace, + AcpiEfiPalCode, + AcpiEfiMaxMemoryType +} ACPI_EFI_MEMORY_TYPE; /* possible caching types for the memory range */ -#define EFI_MEMORY_UC 0x0000000000000001 -#define EFI_MEMORY_WC 0x0000000000000002 -#define EFI_MEMORY_WT 0x0000000000000004 -#define EFI_MEMORY_WB 0x0000000000000008 -#define EFI_MEMORY_UCE 0x0000000000000010 +#define ACPI_EFI_MEMORY_UC 0x0000000000000001 +#define ACPI_EFI_MEMORY_WC 0x0000000000000002 +#define ACPI_EFI_MEMORY_WT 0x0000000000000004 +#define ACPI_EFI_MEMORY_WB 0x0000000000000008 +#define ACPI_EFI_MEMORY_UCE 0x0000000000000010 /* physical memory protection on range */ -#define EFI_MEMORY_WP 0x0000000000001000 -#define EFI_MEMORY_RP 0x0000000000002000 -#define EFI_MEMORY_XP 0x0000000000004000 +#define ACPI_EFI_MEMORY_WP 0x0000000000001000 +#define ACPI_EFI_MEMORY_RP 0x0000000000002000 +#define ACPI_EFI_MEMORY_XP 0x0000000000004000 /* range requires a runtime mapping */ -#define EFI_MEMORY_RUNTIME 0x8000000000000000 +#define ACPI_EFI_MEMORY_RUNTIME 0x8000000000000000 -#define EFI_MEMORY_DESCRIPTOR_VERSION 1 +#define ACPI_EFI_MEMORY_DESCRIPTOR_VERSION 1 typedef struct { UINT32 Type; UINT32 Pad; - EFI_PHYSICAL_ADDRESS PhysicalStart; - EFI_VIRTUAL_ADDRESS VirtualStart; + ACPI_EFI_PHYSICAL_ADDRESS PhysicalStart; + ACPI_EFI_VIRTUAL_ADDRESS VirtualStart; UINT64 NumberOfPages; UINT64 Attribute; -} EFI_MEMORY_DESCRIPTOR; +} ACPI_EFI_MEMORY_DESCRIPTOR; -typedef struct _EFI_TABLE_HEARDER { +typedef struct _ACPI_EFI_TABLE_HEARDER { UINT64 Signature; UINT32 Revision; UINT32 HeaderSize; UINT32 CRC32; UINT32 Reserved; -} EFI_TABLE_HEADER; +} ACPI_EFI_TABLE_HEADER; typedef -EFI_STATUS -(EFIAPI *EFI_UNKNOWN_INTERFACE) ( +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_UNKNOWN_INTERFACE) ( void); /* * Text output protocol */ -#define SIMPLE_TEXT_OUTPUT_PROTOCOL \ +#define ACPI_SIMPLE_TEXT_OUTPUT_PROTOCOL \ { 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } typedef -EFI_STATUS -(EFIAPI *EFI_TEXT_RESET) ( - struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, - BOOLEAN ExtendedVerification); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_TEXT_RESET) ( + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, + BOOLEAN ExtendedVerification); typedef -EFI_STATUS -(EFIAPI *EFI_TEXT_OUTPUT_STRING) ( - struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, - CHAR16 *String); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_TEXT_OUTPUT_STRING) ( + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, + CHAR16 *String); typedef -EFI_STATUS -(EFIAPI *EFI_TEXT_TEST_STRING) ( - struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, - CHAR16 *String); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_TEXT_TEST_STRING) ( + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, + CHAR16 *String); typedef -EFI_STATUS -(EFIAPI *EFI_TEXT_QUERY_MODE) ( - struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, - UINTN ModeNumber, - UINTN *Columns, - UINTN *Rows); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_TEXT_QUERY_MODE) ( + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, + UINTN ModeNumber, + UINTN *Columns, + UINTN *Rows); typedef -EFI_STATUS -(EFIAPI *EFI_TEXT_SET_MODE) ( - struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, - UINTN ModeNumber); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_TEXT_SET_MODE) ( + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, + UINTN ModeNumber); typedef -EFI_STATUS -(EFIAPI *EFI_TEXT_SET_ATTRIBUTE) ( - struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, - UINTN Attribute); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_TEXT_SET_ATTRIBUTE) ( + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, + UINTN Attribute); typedef -EFI_STATUS -(EFIAPI *EFI_TEXT_CLEAR_SCREEN) ( - struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_TEXT_CLEAR_SCREEN) ( + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This); typedef -EFI_STATUS -(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) ( - struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, - UINTN Column, - UINTN Row); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_TEXT_SET_CURSOR_POSITION) ( + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, + UINTN Column, + UINTN Row); typedef -EFI_STATUS -(EFIAPI *EFI_TEXT_ENABLE_CURSOR) ( - struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, - BOOLEAN Enable); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_TEXT_ENABLE_CURSOR) ( + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, + BOOLEAN Enable); typedef struct { INT32 MaxMode; @@ -310,35 +310,35 @@ typedef struct { INT32 CursorColumn; INT32 CursorRow; BOOLEAN CursorVisible; -} SIMPLE_TEXT_OUTPUT_MODE; +} ACPI_SIMPLE_TEXT_OUTPUT_MODE; -typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE { - EFI_TEXT_RESET Reset; +typedef struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE { + ACPI_EFI_TEXT_RESET Reset; - EFI_TEXT_OUTPUT_STRING OutputString; - EFI_TEXT_TEST_STRING TestString; + ACPI_EFI_TEXT_OUTPUT_STRING OutputString; + ACPI_EFI_TEXT_TEST_STRING TestString; - EFI_TEXT_QUERY_MODE QueryMode; - EFI_TEXT_SET_MODE SetMode; - EFI_TEXT_SET_ATTRIBUTE SetAttribute; + ACPI_EFI_TEXT_QUERY_MODE QueryMode; + ACPI_EFI_TEXT_SET_MODE SetMode; + ACPI_EFI_TEXT_SET_ATTRIBUTE SetAttribute; - EFI_TEXT_CLEAR_SCREEN ClearScreen; - EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition; - EFI_TEXT_ENABLE_CURSOR EnableCursor; + ACPI_EFI_TEXT_CLEAR_SCREEN ClearScreen; + ACPI_EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition; + ACPI_EFI_TEXT_ENABLE_CURSOR EnableCursor; - SIMPLE_TEXT_OUTPUT_MODE *Mode; -} SIMPLE_TEXT_OUTPUT_INTERFACE; + ACPI_SIMPLE_TEXT_OUTPUT_MODE *Mode; +} ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE; /* * Text input protocol */ -#define SIMPLE_TEXT_INPUT_PROTOCOL \ +#define ACPI_SIMPLE_TEXT_INPUT_PROTOCOL \ { 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } typedef struct { UINT16 ScanCode; CHAR16 UnicodeChar; -} EFI_INPUT_KEY; +} ACPI_EFI_INPUT_KEY; /* * Baseline unicode control chars @@ -350,210 +350,211 @@ typedef struct { #define CHAR_CARRIAGE_RETURN 0x000D typedef -EFI_STATUS -(EFIAPI *EFI_INPUT_RESET) ( - struct _SIMPLE_INPUT_INTERFACE *This, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_INPUT_RESET) ( + struct _ACPI_SIMPLE_INPUT_INTERFACE *This, BOOLEAN ExtendedVerification); typedef -EFI_STATUS -(EFIAPI *EFI_INPUT_READ_KEY) ( - struct _SIMPLE_INPUT_INTERFACE *This, - EFI_INPUT_KEY *Key); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_INPUT_READ_KEY) ( + struct _ACPI_SIMPLE_INPUT_INTERFACE *This, + ACPI_EFI_INPUT_KEY *Key); -typedef struct _SIMPLE_INPUT_INTERFACE { - EFI_INPUT_RESET Reset; - EFI_INPUT_READ_KEY ReadKeyStroke; - EFI_EVENT WaitForKey; -} SIMPLE_INPUT_INTERFACE; +typedef struct _ACPI_SIMPLE_INPUT_INTERFACE { + ACPI_EFI_INPUT_RESET Reset; + ACPI_EFI_INPUT_READ_KEY ReadKeyStroke; + ACPI_EFI_EVENT WaitForKey; +} ACPI_SIMPLE_INPUT_INTERFACE; /* * Simple file system protocol */ -#define SIMPLE_FILE_SYSTEM_PROTOCOL \ +#define ACPI_SIMPLE_FILE_SYSTEM_PROTOCOL \ { 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } typedef -EFI_STATUS -(EFIAPI *EFI_VOLUME_OPEN) ( - struct _EFI_FILE_IO_INTERFACE *This, - struct _EFI_FILE_HANDLE **Root); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_VOLUME_OPEN) ( + struct _ACPI_EFI_FILE_IO_INTERFACE *This, + struct _ACPI_EFI_FILE_HANDLE **Root); -#define EFI_FILE_IO_INTERFACE_REVISION 0x00010000 +#define ACPI_EFI_FILE_IO_INTERFACE_REVISION 0x00010000 -typedef struct _EFI_FILE_IO_INTERFACE { +typedef struct _ACPI_EFI_FILE_IO_INTERFACE { UINT64 Revision; - EFI_VOLUME_OPEN OpenVolume; -} EFI_FILE_IO_INTERFACE; + ACPI_EFI_VOLUME_OPEN OpenVolume; +} ACPI_EFI_FILE_IO_INTERFACE; typedef -EFI_STATUS -(EFIAPI *EFI_FILE_OPEN) ( - struct _EFI_FILE_HANDLE *File, - struct _EFI_FILE_HANDLE **NewHandle, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_OPEN) ( + struct _ACPI_EFI_FILE_HANDLE *File, + struct _ACPI_EFI_FILE_HANDLE **NewHandle, CHAR16 *FileName, UINT64 OpenMode, UINT64 Attributes); /* Values for OpenMode used above */ -#define EFI_FILE_MODE_READ 0x0000000000000001 -#define EFI_FILE_MODE_WRITE 0x0000000000000002 -#define EFI_FILE_MODE_CREATE 0x8000000000000000 +#define ACPI_EFI_FILE_MODE_READ 0x0000000000000001 +#define ACPI_EFI_FILE_MODE_WRITE 0x0000000000000002 +#define ACPI_EFI_FILE_MODE_CREATE 0x8000000000000000 /* Values for Attribute used above */ -#define EFI_FILE_READ_ONLY 0x0000000000000001 -#define EFI_FILE_HIDDEN 0x0000000000000002 -#define EFI_FILE_SYSTEM 0x0000000000000004 -#define EFI_FILE_RESERVIED 0x0000000000000008 -#define EFI_FILE_DIRECTORY 0x0000000000000010 -#define EFI_FILE_ARCHIVE 0x0000000000000020 -#define EFI_FILE_VALID_ATTR 0x0000000000000037 +#define ACPI_EFI_FILE_READ_ONLY 0x0000000000000001 +#define ACPI_EFI_FILE_HIDDEN 0x0000000000000002 +#define ACPI_EFI_FILE_SYSTEM 0x0000000000000004 +#define ACPI_EFI_FILE_RESERVIED 0x0000000000000008 +#define ACPI_EFI_FILE_DIRECTORY 0x0000000000000010 +#define ACPI_EFI_FILE_ARCHIVE 0x0000000000000020 +#define ACPI_EFI_FILE_VALID_ATTR 0x0000000000000037 typedef -EFI_STATUS -(EFIAPI *EFI_FILE_CLOSE) ( - struct _EFI_FILE_HANDLE *File); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_CLOSE) ( + struct _ACPI_EFI_FILE_HANDLE *File); typedef -EFI_STATUS -(EFIAPI *EFI_FILE_DELETE) ( - struct _EFI_FILE_HANDLE *File); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_DELETE) ( + struct _ACPI_EFI_FILE_HANDLE *File); typedef -EFI_STATUS -(EFIAPI *EFI_FILE_READ) ( - struct _EFI_FILE_HANDLE *File, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_READ) ( + struct _ACPI_EFI_FILE_HANDLE *File, UINTN *BufferSize, VOID *Buffer); typedef -EFI_STATUS -(EFIAPI *EFI_FILE_WRITE) ( - struct _EFI_FILE_HANDLE *File, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_WRITE) ( + struct _ACPI_EFI_FILE_HANDLE *File, UINTN *BufferSize, VOID *Buffer); typedef -EFI_STATUS -(EFIAPI *EFI_FILE_SET_POSITION) ( - struct _EFI_FILE_HANDLE *File, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_SET_POSITION) ( + struct _ACPI_EFI_FILE_HANDLE *File, UINT64 Position); typedef -EFI_STATUS -(EFIAPI *EFI_FILE_GET_POSITION) ( - struct _EFI_FILE_HANDLE *File, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_GET_POSITION) ( + struct _ACPI_EFI_FILE_HANDLE *File, UINT64 *Position); -#define EFI_FILE_INFO_ID \ +#define ACPI_EFI_FILE_INFO_ID \ { 0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } typedef struct { UINT64 Size; UINT64 FileSize; UINT64 PhysicalSize; - EFI_TIME CreateTime; - EFI_TIME LastAccessTime; - EFI_TIME ModificationTime; + ACPI_EFI_TIME CreateTime; + ACPI_EFI_TIME LastAccessTime; + ACPI_EFI_TIME ModificationTime; UINT64 Attribute; CHAR16 FileName[1]; -} EFI_FILE_INFO; +} ACPI_EFI_FILE_INFO; -#define SIZE_OF_EFI_FILE_INFO ACPI_OFFSET(EFI_FILE_INFO, FileName) +#define ACPI_EFI_FILE_INFO_SIZE \ + ACPI_OFFSET(ACPI_EFI_FILE_INFO, FileName) typedef -EFI_STATUS -(EFIAPI *EFI_FILE_GET_INFO) ( - struct _EFI_FILE_HANDLE *File, - EFI_GUID *InformationType, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_GET_INFO) ( + struct _ACPI_EFI_FILE_HANDLE *File, + ACPI_EFI_GUID *InformationType, UINTN *BufferSize, VOID *Buffer); typedef -EFI_STATUS -(EFIAPI *EFI_FILE_SET_INFO) ( - struct _EFI_FILE_HANDLE *File, - EFI_GUID *InformationType, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_SET_INFO) ( + struct _ACPI_EFI_FILE_HANDLE *File, + ACPI_EFI_GUID *InformationType, UINTN BufferSize, VOID *Buffer); typedef -EFI_STATUS -(EFIAPI *EFI_FILE_FLUSH) ( - struct _EFI_FILE_HANDLE *File); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FILE_FLUSH) ( + struct _ACPI_EFI_FILE_HANDLE *File); -#define EFI_FILE_HANDLE_REVISION 0x00010000 +#define ACPI_EFI_FILE_HANDLE_REVISION 0x00010000 -typedef struct _EFI_FILE_HANDLE { - UINT64 Revision; - EFI_FILE_OPEN Open; - EFI_FILE_CLOSE Close; - EFI_FILE_DELETE Delete; - EFI_FILE_READ Read; - EFI_FILE_WRITE Write; - EFI_FILE_GET_POSITION GetPosition; - EFI_FILE_SET_POSITION SetPosition; - EFI_FILE_GET_INFO GetInfo; - EFI_FILE_SET_INFO SetInfo; - EFI_FILE_FLUSH Flush; -} EFI_FILE, *EFI_FILE_HANDLE; +typedef struct _ACPI_EFI_FILE_HANDLE { + UINT64 Revision; + ACPI_EFI_FILE_OPEN Open; + ACPI_EFI_FILE_CLOSE Close; + ACPI_EFI_FILE_DELETE Delete; + ACPI_EFI_FILE_READ Read; + ACPI_EFI_FILE_WRITE Write; + ACPI_EFI_FILE_GET_POSITION GetPosition; + ACPI_EFI_FILE_SET_POSITION SetPosition; + ACPI_EFI_FILE_GET_INFO GetInfo; + ACPI_EFI_FILE_SET_INFO SetInfo; + ACPI_EFI_FILE_FLUSH Flush; +} ACPI_EFI_FILE_STRUCT, *ACPI_EFI_FILE_HANDLE; /* * Loaded image protocol */ -#define LOADED_IMAGE_PROTOCOL \ +#define ACPI_EFI_LOADED_IMAGE_PROTOCOL \ { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } typedef -EFI_STATUS -(EFIAPI *EFI_IMAGE_ENTRY_POINT) ( - EFI_HANDLE ImageHandle, - struct _EFI_SYSTEM_TABLE *SystemTable); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_IMAGE_ENTRY_POINT) ( + ACPI_EFI_HANDLE ImageHandle, + struct _ACPI_EFI_SYSTEM_TABLE *SystemTable); typedef -EFI_STATUS -(EFIAPI *EFI_IMAGE_LOAD) ( +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_IMAGE_LOAD) ( BOOLEAN BootPolicy, - EFI_HANDLE ParentImageHandle, - EFI_DEVICE_PATH *FilePath, + ACPI_EFI_HANDLE ParentImageHandle, + ACPI_EFI_DEVICE_PATH *FilePath, VOID *SourceBuffer, UINTN SourceSize, - EFI_HANDLE *ImageHandle); + ACPI_EFI_HANDLE *ImageHandle); typedef -EFI_STATUS -(EFIAPI *EFI_IMAGE_START) ( - EFI_HANDLE ImageHandle, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_IMAGE_START) ( + ACPI_EFI_HANDLE ImageHandle, UINTN *ExitDataSize, CHAR16 **ExitData); typedef -EFI_STATUS -(EFIAPI *EFI_EXIT) ( - EFI_HANDLE ImageHandle, - EFI_STATUS ExitStatus, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_EXIT) ( + ACPI_EFI_HANDLE ImageHandle, + ACPI_EFI_STATUS ExitStatus, UINTN ExitDataSize, CHAR16 *ExitData); typedef -EFI_STATUS -(EFIAPI *EFI_IMAGE_UNLOAD) ( - EFI_HANDLE ImageHandle); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_IMAGE_UNLOAD) ( + ACPI_EFI_HANDLE ImageHandle); typedef -EFI_STATUS -(EFIAPI *EFI_STALL) ( +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_STALL) ( UINTN Microseconds); typedef -EFI_STATUS -(EFIAPI *EFI_SET_WATCHDOG_TIMER) ( +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_SET_WATCHDOG_TIMER) ( UINTN Timeout, UINT64 WatchdogCode, UINTN DataSize, @@ -563,60 +564,60 @@ EFI_STATUS #define EFI_IMAGE_INFORMATION_REVISION 0x1000 typedef struct { UINT32 Revision; - EFI_HANDLE ParentHandle; - struct _EFI_SYSTEM_TABLE *SystemTable; - EFI_HANDLE DeviceHandle; - EFI_DEVICE_PATH *FilePath; + ACPI_EFI_HANDLE ParentHandle; + struct _ACPI_EFI_SYSTEM_TABLE *SystemTable; + ACPI_EFI_HANDLE DeviceHandle; + ACPI_EFI_DEVICE_PATH *FilePath; VOID *Reserved; UINT32 LoadOptionsSize; VOID *LoadOptions; VOID *ImageBase; UINT64 ImageSize; - EFI_MEMORY_TYPE ImageCodeType; - EFI_MEMORY_TYPE ImageDataType; - EFI_IMAGE_UNLOAD Unload; + ACPI_EFI_MEMORY_TYPE ImageCodeType; + ACPI_EFI_MEMORY_TYPE ImageDataType; + ACPI_EFI_IMAGE_UNLOAD Unload; -} EFI_LOADED_IMAGE; +} ACPI_EFI_LOADED_IMAGE; /* * EFI Memory */ typedef -EFI_STATUS -(EFIAPI *EFI_ALLOCATE_PAGES) ( - EFI_ALLOCATE_TYPE Type, - EFI_MEMORY_TYPE MemoryType, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_ALLOCATE_PAGES) ( + ACPI_EFI_ALLOCATE_TYPE Type, + ACPI_EFI_MEMORY_TYPE MemoryType, UINTN NoPages, - EFI_PHYSICAL_ADDRESS *Memory); + ACPI_EFI_PHYSICAL_ADDRESS *Memory); typedef -EFI_STATUS -(EFIAPI *EFI_FREE_PAGES) ( - EFI_PHYSICAL_ADDRESS Memory, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FREE_PAGES) ( + ACPI_EFI_PHYSICAL_ADDRESS Memory, UINTN NoPages); typedef -EFI_STATUS -(EFIAPI *EFI_GET_MEMORY_MAP) ( +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_GET_MEMORY_MAP) ( UINTN *MemoryMapSize, - EFI_MEMORY_DESCRIPTOR *MemoryMap, + ACPI_EFI_MEMORY_DESCRIPTOR *MemoryMap, UINTN *MapKey, UINTN *DescriptorSize, UINT32 *DescriptorVersion); -#define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size)) +#define NextMemoryDescriptor(Ptr,Size) ((ACPI_EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size)) typedef -EFI_STATUS -(EFIAPI *EFI_ALLOCATE_POOL) ( - EFI_MEMORY_TYPE PoolType, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_ALLOCATE_POOL) ( + ACPI_EFI_MEMORY_TYPE PoolType, UINTN Size, VOID **Buffer); typedef -EFI_STATUS -(EFIAPI *EFI_FREE_POOL) ( +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_FREE_POOL) ( VOID *Buffer); @@ -627,185 +628,185 @@ typedef struct { UINT32 Resolution; UINT32 Accuracy; BOOLEAN SetsToZero; -} EFI_TIME_CAPABILITIES; +} ACPI_EFI_TIME_CAPABILITIES; typedef -EFI_STATUS -(EFIAPI *EFI_GET_TIME) ( - EFI_TIME *Time, - EFI_TIME_CAPABILITIES *Capabilities); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_GET_TIME) ( + ACPI_EFI_TIME *Time, + ACPI_EFI_TIME_CAPABILITIES *Capabilities); typedef -EFI_STATUS -(EFIAPI *EFI_SET_TIME) ( - EFI_TIME *Time); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_SET_TIME) ( + ACPI_EFI_TIME *Time); /* * Protocol handler functions */ typedef enum { - EFI_NATIVE_INTERFACE, - EFI_PCODE_INTERFACE -} EFI_INTERFACE_TYPE; + ACPI_EFI_NATIVE_INTERFACE, + ACPI_EFI_PCODE_INTERFACE +} ACPI_EFI_INTERFACE_TYPE; typedef enum { - AllHandles, - ByRegisterNotify, - ByProtocol -} EFI_LOCATE_SEARCH_TYPE; + AcpiEfiAllHandles, + AcpiEfiByRegisterNotify, + AcpiEfiByProtocol +} ACPI_EFI_LOCATE_SEARCH_TYPE; typedef -EFI_STATUS -(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) ( - EFI_HANDLE *Handle, - EFI_GUID *Protocol, - EFI_INTERFACE_TYPE InterfaceType, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_INSTALL_PROTOCOL_INTERFACE) ( + ACPI_EFI_HANDLE *Handle, + ACPI_EFI_GUID *Protocol, + ACPI_EFI_INTERFACE_TYPE InterfaceType, VOID *Interface); typedef -EFI_STATUS -(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) ( - EFI_HANDLE Handle, - EFI_GUID *Protocol, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_REINSTALL_PROTOCOL_INTERFACE) ( + ACPI_EFI_HANDLE Handle, + ACPI_EFI_GUID *Protocol, VOID *OldInterface, VOID *NewInterface); typedef -EFI_STATUS -(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) ( - EFI_HANDLE Handle, - EFI_GUID *Protocol, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_UNINSTALL_PROTOCOL_INTERFACE) ( + ACPI_EFI_HANDLE Handle, + ACPI_EFI_GUID *Protocol, VOID *Interface); typedef -EFI_STATUS -(EFIAPI *EFI_HANDLE_PROTOCOL) ( - EFI_HANDLE Handle, - EFI_GUID *Protocol, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_HANDLE_PROTOCOL) ( + ACPI_EFI_HANDLE Handle, + ACPI_EFI_GUID *Protocol, VOID **Interface); typedef -EFI_STATUS -(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) ( - EFI_GUID *Protocol, - EFI_EVENT Event, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_REGISTER_PROTOCOL_NOTIFY) ( + ACPI_EFI_GUID *Protocol, + ACPI_EFI_EVENT Event, VOID **Registration); typedef -EFI_STATUS -(EFIAPI *EFI_LOCATE_HANDLE) ( - EFI_LOCATE_SEARCH_TYPE SearchType, - EFI_GUID *Protocol, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_LOCATE_HANDLE) ( + ACPI_EFI_LOCATE_SEARCH_TYPE SearchType, + ACPI_EFI_GUID *Protocol, VOID *SearchKey, UINTN *BufferSize, - EFI_HANDLE *Buffer); + ACPI_EFI_HANDLE *Buffer); typedef -EFI_STATUS -(EFIAPI *EFI_LOCATE_DEVICE_PATH) ( - EFI_GUID *Protocol, - EFI_DEVICE_PATH **DevicePath, - EFI_HANDLE *Device); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_LOCATE_DEVICE_PATH) ( + ACPI_EFI_GUID *Protocol, + ACPI_EFI_DEVICE_PATH **DevicePath, + ACPI_EFI_HANDLE *Device); typedef -EFI_STATUS -(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) ( - EFI_GUID *Guid, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_INSTALL_CONFIGURATION_TABLE) ( + ACPI_EFI_GUID *Guid, VOID *Table); -#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 -#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 -#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 -#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 -#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 -#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 +#define ACPI_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 +#define ACPI_EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 +#define ACPI_EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 +#define ACPI_EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 +#define ACPI_EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 +#define ACPI_EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 typedef -EFI_STATUS -(EFIAPI *EFI_OPEN_PROTOCOL) ( - EFI_HANDLE Handle, - EFI_GUID *Protocol, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_OPEN_PROTOCOL) ( + ACPI_EFI_HANDLE Handle, + ACPI_EFI_GUID *Protocol, VOID **Interface, - EFI_HANDLE AgentHandle, - EFI_HANDLE ControllerHandle, + ACPI_EFI_HANDLE AgentHandle, + ACPI_EFI_HANDLE ControllerHandle, UINT32 Attributes); typedef -EFI_STATUS -(EFIAPI *EFI_CLOSE_PROTOCOL) ( - EFI_HANDLE Handle, - EFI_GUID *Protocol, - EFI_HANDLE AgentHandle, - EFI_HANDLE ControllerHandle); +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_CLOSE_PROTOCOL) ( + ACPI_EFI_HANDLE Handle, + ACPI_EFI_GUID *Protocol, + ACPI_EFI_HANDLE AgentHandle, + ACPI_EFI_HANDLE ControllerHandle); typedef struct { - EFI_HANDLE AgentHandle; - EFI_HANDLE ControllerHandle; - UINT32 Attributes; - UINT32 OpenCount; -} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY; + ACPI_EFI_HANDLE AgentHandle; + ACPI_EFI_HANDLE ControllerHandle; + UINT32 Attributes; + UINT32 OpenCount; +} ACPI_EFI_OPEN_PROTOCOL_INFORMATION_ENTRY; typedef -EFI_STATUS -(EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) ( - EFI_HANDLE Handle, - EFI_GUID *Protocol, - EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_OPEN_PROTOCOL_INFORMATION) ( + ACPI_EFI_HANDLE Handle, + ACPI_EFI_GUID *Protocol, + ACPI_EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer, UINTN *EntryCount); typedef -EFI_STATUS -(EFIAPI *EFI_PROTOCOLS_PER_HANDLE) ( - EFI_HANDLE Handle, - EFI_GUID ***ProtocolBuffer, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_PROTOCOLS_PER_HANDLE) ( + ACPI_EFI_HANDLE Handle, + ACPI_EFI_GUID ***ProtocolBuffer, UINTN *ProtocolBufferCount); typedef -EFI_STATUS -(EFIAPI *EFI_LOCATE_HANDLE_BUFFER) ( - EFI_LOCATE_SEARCH_TYPE SearchType, - EFI_GUID *Protocol, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_LOCATE_HANDLE_BUFFER) ( + ACPI_EFI_LOCATE_SEARCH_TYPE SearchType, + ACPI_EFI_GUID *Protocol, VOID *SearchKey, UINTN *NoHandles, - EFI_HANDLE **Buffer); + ACPI_EFI_HANDLE **Buffer); typedef -EFI_STATUS -(EFIAPI *EFI_LOCATE_PROTOCOL) ( - EFI_GUID *Protocol, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_LOCATE_PROTOCOL) ( + ACPI_EFI_GUID *Protocol, VOID *Registration, VOID **Interface); typedef -EFI_STATUS -(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( - EFI_HANDLE *Handle, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( + ACPI_EFI_HANDLE *Handle, ...); typedef -EFI_STATUS -(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( - EFI_HANDLE Handle, +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( + ACPI_EFI_HANDLE Handle, ...); typedef -EFI_STATUS -(EFIAPI *EFI_CALCULATE_CRC32) ( +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_CALCULATE_CRC32) ( VOID *Data, UINTN DataSize, UINT32 *Crc32); typedef VOID -(EFIAPI *EFI_COPY_MEM) ( +(ACPI_EFI_API *ACPI_EFI_COPY_MEM) ( VOID *Destination, VOID *Source, UINTN Length); typedef VOID -(EFIAPI *EFI_SET_MEM) ( +(ACPI_EFI_API *ACPI_EFI_SET_MEM) ( VOID *Buffer, UINTN Size, UINT8 Value); @@ -813,143 +814,143 @@ VOID /* * EFI Boot Services Table */ -#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 -#define EFI_BOOT_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) +#define ACPI_EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 +#define ACPI_EFI_BOOT_SERVICES_REVISION (ACPI_EFI_SPECIFICATION_MAJOR_REVISION<<16) | (ACPI_EFI_SPECIFICATION_MINOR_REVISION) -typedef struct _EFI_BOOT_SERVICES { - EFI_TABLE_HEADER Hdr; +typedef struct _ACPI_EFI_BOOT_SERVICES { + ACPI_EFI_TABLE_HEADER Hdr; #if 0 - EFI_RAISE_TPL RaiseTPL; - EFI_RESTORE_TPL RestoreTPL; + ACPI_EFI_RAISE_TPL RaiseTPL; + ACPI_EFI_RESTORE_TPL RestoreTPL; #else - EFI_UNKNOWN_INTERFACE RaiseTPL; - EFI_UNKNOWN_INTERFACE RestoreTPL; + ACPI_EFI_UNKNOWN_INTERFACE RaiseTPL; + ACPI_EFI_UNKNOWN_INTERFACE RestoreTPL; #endif - EFI_ALLOCATE_PAGES AllocatePages; - EFI_FREE_PAGES FreePages; - EFI_GET_MEMORY_MAP GetMemoryMap; - EFI_ALLOCATE_POOL AllocatePool; - EFI_FREE_POOL FreePool; + ACPI_EFI_ALLOCATE_PAGES AllocatePages; + ACPI_EFI_FREE_PAGES FreePages; + ACPI_EFI_GET_MEMORY_MAP GetMemoryMap; + ACPI_EFI_ALLOCATE_POOL AllocatePool; + ACPI_EFI_FREE_POOL FreePool; #if 0 - EFI_CREATE_EVENT CreateEvent; - EFI_SET_TIMER SetTimer; - EFI_WAIT_FOR_EVENT WaitForEvent; - EFI_SIGNAL_EVENT SignalEvent; - EFI_CLOSE_EVENT CloseEvent; - EFI_CHECK_EVENT CheckEvent; + ACPI_EFI_CREATE_EVENT CreateEvent; + ACPI_EFI_SET_TIMER SetTimer; + ACPI_EFI_WAIT_FOR_EVENT WaitForEvent; + ACPI_EFI_SIGNAL_EVENT SignalEvent; + ACPI_EFI_CLOSE_EVENT CloseEvent; + ACPI_EFI_CHECK_EVENT CheckEvent; #else - EFI_UNKNOWN_INTERFACE CreateEvent; - EFI_UNKNOWN_INTERFACE SetTimer; - EFI_UNKNOWN_INTERFACE WaitForEvent; - EFI_UNKNOWN_INTERFACE SignalEvent; - EFI_UNKNOWN_INTERFACE CloseEvent; - EFI_UNKNOWN_INTERFACE CheckEvent; + ACPI_EFI_UNKNOWN_INTERFACE CreateEvent; + ACPI_EFI_UNKNOWN_INTERFACE SetTimer; + ACPI_EFI_UNKNOWN_INTERFACE WaitForEvent; + ACPI_EFI_UNKNOWN_INTERFACE SignalEvent; + ACPI_EFI_UNKNOWN_INTERFACE CloseEvent; + ACPI_EFI_UNKNOWN_INTERFACE CheckEvent; #endif - EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface; - EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface; - EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface; - EFI_HANDLE_PROTOCOL HandleProtocol; - EFI_HANDLE_PROTOCOL PCHandleProtocol; - EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify; - EFI_LOCATE_HANDLE LocateHandle; - EFI_LOCATE_DEVICE_PATH LocateDevicePath; - EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable; - - EFI_IMAGE_LOAD LoadImage; - EFI_IMAGE_START StartImage; - EFI_EXIT Exit; - EFI_IMAGE_UNLOAD UnloadImage; + ACPI_EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface; + ACPI_EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface; + ACPI_EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface; + ACPI_EFI_HANDLE_PROTOCOL HandleProtocol; + ACPI_EFI_HANDLE_PROTOCOL PCHandleProtocol; + ACPI_EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify; + ACPI_EFI_LOCATE_HANDLE LocateHandle; + ACPI_EFI_LOCATE_DEVICE_PATH LocateDevicePath; + ACPI_EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable; + + ACPI_EFI_IMAGE_LOAD LoadImage; + ACPI_EFI_IMAGE_START StartImage; + ACPI_EFI_EXIT Exit; + ACPI_EFI_IMAGE_UNLOAD UnloadImage; #if 0 - EFI_EXIT_BOOT_SERVICES ExitBootServices; - EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; + ACPI_EFI_EXIT_BOOT_SERVICES ExitBootServices; + ACPI_EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; #else - EFI_UNKNOWN_INTERFACE ExitBootServices; - EFI_UNKNOWN_INTERFACE GetNextMonotonicCount; + ACPI_EFI_UNKNOWN_INTERFACE ExitBootServices; + ACPI_EFI_UNKNOWN_INTERFACE GetNextMonotonicCount; #endif - EFI_STALL Stall; - EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; + ACPI_EFI_STALL Stall; + ACPI_EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; #if 0 - EFI_CONNECT_CONTROLLER ConnectController; - EFI_DISCONNECT_CONTROLLER DisconnectController; + ACPI_EFI_CONNECT_CONTROLLER ConnectController; + ACPI_EFI_DISCONNECT_CONTROLLER DisconnectController; #else - EFI_UNKNOWN_INTERFACE ConnectController; - EFI_UNKNOWN_INTERFACE DisconnectController; + ACPI_EFI_UNKNOWN_INTERFACE ConnectController; + ACPI_EFI_UNKNOWN_INTERFACE DisconnectController; #endif - EFI_OPEN_PROTOCOL OpenProtocol; - EFI_CLOSE_PROTOCOL CloseProtocol; - EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation; - EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle; - EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer; - EFI_LOCATE_PROTOCOL LocateProtocol; - EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces; - EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces; + ACPI_EFI_OPEN_PROTOCOL OpenProtocol; + ACPI_EFI_CLOSE_PROTOCOL CloseProtocol; + ACPI_EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation; + ACPI_EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle; + ACPI_EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer; + ACPI_EFI_LOCATE_PROTOCOL LocateProtocol; + ACPI_EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces; + ACPI_EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces; - EFI_CALCULATE_CRC32 CalculateCrc32; + ACPI_EFI_CALCULATE_CRC32 CalculateCrc32; - EFI_COPY_MEM CopyMem; - EFI_SET_MEM SetMem; + ACPI_EFI_COPY_MEM CopyMem; + ACPI_EFI_SET_MEM SetMem; #if 0 - EFI_CREATE_EVENT_EX CreateEventEx; + ACPI_EFI_CREATE_EVENT_EX CreateEventEx; #else - EFI_UNKNOWN_INTERFACE CreateEventEx; + ACPI_EFI_UNKNOWN_INTERFACE CreateEventEx; #endif -} EFI_BOOT_SERVICES; +} ACPI_EFI_BOOT_SERVICES; /* * EFI Runtime Services Table */ -#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 -#define EFI_RUNTIME_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) +#define ACPI_EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 +#define ACPI_EFI_RUNTIME_SERVICES_REVISION (ACPI_EFI_SPECIFICATION_MAJOR_REVISION<<16) | (ACPI_EFI_SPECIFICATION_MINOR_REVISION) -typedef struct _EFI_RUNTIME_SERVICES { - EFI_TABLE_HEADER Hdr; +typedef struct _ACPI_EFI_RUNTIME_SERVICES { + ACPI_EFI_TABLE_HEADER Hdr; - EFI_GET_TIME GetTime; - EFI_SET_TIME SetTime; + ACPI_EFI_GET_TIME GetTime; + ACPI_EFI_SET_TIME SetTime; #if 0 - EFI_GET_WAKEUP_TIME GetWakeupTime; - EFI_SET_WAKEUP_TIME SetWakeupTime; + ACPI_EFI_GET_WAKEUP_TIME GetWakeupTime; + ACPI_EFI_SET_WAKEUP_TIME SetWakeupTime; #else - EFI_UNKNOWN_INTERFACE GetWakeupTime; - EFI_UNKNOWN_INTERFACE SetWakeupTime; + ACPI_EFI_UNKNOWN_INTERFACE GetWakeupTime; + ACPI_EFI_UNKNOWN_INTERFACE SetWakeupTime; #endif #if 0 - EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap; - EFI_CONVERT_POINTER ConvertPointer; + ACPI_EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap; + ACPI_EFI_CONVERT_POINTER ConvertPointer; #else - EFI_UNKNOWN_INTERFACE SetVirtualAddressMap; - EFI_UNKNOWN_INTERFACE ConvertPointer; + ACPI_EFI_UNKNOWN_INTERFACE SetVirtualAddressMap; + ACPI_EFI_UNKNOWN_INTERFACE ConvertPointer; #endif #if 0 - EFI_GET_VARIABLE GetVariable; - EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName; - EFI_SET_VARIABLE SetVariable; + ACPI_EFI_GET_VARIABLE GetVariable; + ACPI_EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName; + ACPI_EFI_SET_VARIABLE SetVariable; #else - EFI_UNKNOWN_INTERFACE GetVariable; - EFI_UNKNOWN_INTERFACE GetNextVariableName; - EFI_UNKNOWN_INTERFACE SetVariable; + ACPI_EFI_UNKNOWN_INTERFACE GetVariable; + ACPI_EFI_UNKNOWN_INTERFACE GetNextVariableName; + ACPI_EFI_UNKNOWN_INTERFACE SetVariable; #endif #if 0 - EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount; - EFI_RESET_SYSTEM ResetSystem; + ACPI_EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount; + ACPI_EFI_RESET_SYSTEM ResetSystem; #else - EFI_UNKNOWN_INTERFACE GetNextHighMonotonicCount; - EFI_UNKNOWN_INTERFACE ResetSystem; + ACPI_EFI_UNKNOWN_INTERFACE GetNextHighMonotonicCount; + ACPI_EFI_UNKNOWN_INTERFACE ResetSystem; #endif -} EFI_RUNTIME_SERVICES; +} ACPI_EFI_RUNTIME_SERVICES; /* @@ -959,50 +960,50 @@ typedef struct _EFI_RUNTIME_SERVICES { /* * EFI Configuration Table and GUID definitions */ -#define ACPI_TABLE_GUID \ +#define ACPI_TABLE_GUID \ { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } -#define ACPI_20_TABLE_GUID \ +#define ACPI_20_TABLE_GUID \ { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } -typedef struct _EFI_CONFIGURATION_TABLE { - EFI_GUID VendorGuid; +typedef struct _ACPI_EFI_CONFIGURATION_TABLE { + ACPI_EFI_GUID VendorGuid; VOID *VendorTable; -} EFI_CONFIGURATION_TABLE; +} ACPI_EFI_CONFIGURATION_TABLE; -#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 -#define EFI_SYSTEM_TABLE_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) +#define ACPI_EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 +#define ACPI_EFI_SYSTEM_TABLE_REVISION (ACPI_EFI_SPECIFICATION_MAJOR_REVISION<<16) | (ACPI_EFI_SPECIFICATION_MINOR_REVISION) -typedef struct _EFI_SYSTEM_TABLE { - EFI_TABLE_HEADER Hdr; +typedef struct _ACPI_EFI_SYSTEM_TABLE { + ACPI_EFI_TABLE_HEADER Hdr; - CHAR16 *FirmwareVendor; - UINT32 FirmwareRevision; + CHAR16 *FirmwareVendor; + UINT32 FirmwareRevision; - EFI_HANDLE ConsoleInHandle; - SIMPLE_INPUT_INTERFACE *ConIn; + ACPI_EFI_HANDLE ConsoleInHandle; + ACPI_SIMPLE_INPUT_INTERFACE *ConIn; - EFI_HANDLE ConsoleOutHandle; - SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut; + ACPI_EFI_HANDLE ConsoleOutHandle; + ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut; - EFI_HANDLE StandardErrorHandle; - SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr; + ACPI_EFI_HANDLE StandardErrorHandle; + ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr; - EFI_RUNTIME_SERVICES *RuntimeServices; - EFI_BOOT_SERVICES *BootServices; + ACPI_EFI_RUNTIME_SERVICES *RuntimeServices; + ACPI_EFI_BOOT_SERVICES *BootServices; - UINTN NumberOfTableEntries; - EFI_CONFIGURATION_TABLE *ConfigurationTable; + UINTN NumberOfTableEntries; + ACPI_EFI_CONFIGURATION_TABLE *ConfigurationTable; -} EFI_SYSTEM_TABLE; +} ACPI_EFI_SYSTEM_TABLE; /* FILE abstraction */ union acpi_efi_file { - struct _EFI_FILE_IO_INTERFACE File; - struct _SIMPLE_TEXT_OUTPUT_INTERFACE ConOut; - struct _SIMPLE_INPUT_INTERFACE ConIn; + struct _ACPI_EFI_FILE_IO_INTERFACE File; + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE ConOut; + struct _ACPI_SIMPLE_INPUT_INTERFACE ConIn; }; @@ -1022,10 +1023,10 @@ DivU64x32 ( /* * EFI specific prototypes */ -EFI_STATUS +ACPI_EFI_STATUS efi_main ( - EFI_HANDLE Image, - EFI_SYSTEM_TABLE *SystemTab); + ACPI_EFI_HANDLE Image, + ACPI_EFI_SYSTEM_TABLE *SystemTab); int acpi_main ( @@ -1035,10 +1036,10 @@ acpi_main ( #endif -extern EFI_GUID AcpiGbl_LoadedImageProtocol; -extern EFI_GUID AcpiGbl_TextInProtocol; -extern EFI_GUID AcpiGbl_TextOutProtocol; -extern EFI_GUID AcpiGbl_FileSystemProtocol; -extern EFI_GUID AcpiGbl_GenericFileInfo; +extern ACPI_EFI_GUID AcpiGbl_LoadedImageProtocol; +extern ACPI_EFI_GUID AcpiGbl_TextInProtocol; +extern ACPI_EFI_GUID AcpiGbl_TextOutProtocol; +extern ACPI_EFI_GUID AcpiGbl_FileSystemProtocol; +extern ACPI_EFI_GUID AcpiGbl_GenericFileInfo; #endif /* __ACEFIEX_H__ */ diff --git a/source/os_specific/service_layers/oseficlib.c b/source/os_specific/service_layers/oseficlib.c index 69f92b6d1..43337c838 100644 --- a/source/os_specific/service_layers/oseficlib.c +++ b/source/os_specific/service_layers/oseficlib.c @@ -156,7 +156,7 @@ AcpiEfiConvertArgcv ( static int AcpiEfiGetFileInfo ( FILE *File, - EFI_FILE_INFO **InfoPtr); + ACPI_EFI_FILE_INFO **InfoPtr); static CHAR16 * AcpiEfiFlushFile ( @@ -169,12 +169,12 @@ AcpiEfiFlushFile ( /* Local variables */ -static EFI_FILE_HANDLE AcpiGbl_EfiCurrentVolume = NULL; -EFI_GUID AcpiGbl_LoadedImageProtocol = LOADED_IMAGE_PROTOCOL; -EFI_GUID AcpiGbl_TextInProtocol = SIMPLE_TEXT_INPUT_PROTOCOL; -EFI_GUID AcpiGbl_TextOutProtocol = SIMPLE_TEXT_OUTPUT_PROTOCOL; -EFI_GUID AcpiGbl_FileSystemProtocol = SIMPLE_FILE_SYSTEM_PROTOCOL; -EFI_GUID AcpiGbl_GenericFileInfo = EFI_FILE_INFO_ID; +static ACPI_EFI_FILE_HANDLE AcpiGbl_EfiCurrentVolume = NULL; +ACPI_EFI_GUID AcpiGbl_LoadedImageProtocol = ACPI_EFI_LOADED_IMAGE_PROTOCOL; +ACPI_EFI_GUID AcpiGbl_TextInProtocol = ACPI_SIMPLE_TEXT_INPUT_PROTOCOL; +ACPI_EFI_GUID AcpiGbl_TextOutProtocol = ACPI_SIMPLE_TEXT_OUTPUT_PROTOCOL; +ACPI_EFI_GUID AcpiGbl_FileSystemProtocol = ACPI_SIMPLE_FILE_SYSTEM_PROTOCOL; +ACPI_EFI_GUID AcpiGbl_GenericFileInfo = ACPI_EFI_FILE_INFO_ID; int errno = 0; @@ -197,9 +197,9 @@ fopen ( const char *Path, const char *Modes) { - EFI_STATUS EfiStatus = EFI_SUCCESS; + ACPI_EFI_STATUS EfiStatus = ACPI_EFI_SUCCESS; UINT64 OpenModes; - EFI_FILE_HANDLE EfiFile = NULL; + ACPI_EFI_FILE_HANDLE EfiFile = NULL; CHAR16 *Path16 = NULL; CHAR16 *Pos16; const char *Pos; @@ -218,7 +218,7 @@ fopen ( * Convert modes, EFI says the only 2 read/write modes are read-only, * read+write. Thus set default mode as read-only. */ - OpenModes = EFI_FILE_MODE_READ; + OpenModes = ACPI_EFI_FILE_MODE_READ; switch (*Modes++) { case 'r': @@ -227,12 +227,12 @@ fopen ( case 'w': - OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); + OpenModes |= (ACPI_EFI_FILE_MODE_WRITE | ACPI_EFI_FILE_MODE_CREATE); break; case 'a': - OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); + OpenModes |= (ACPI_EFI_FILE_MODE_WRITE | ACPI_EFI_FILE_MODE_CREATE); IsAppend = TRUE; break; @@ -248,7 +248,7 @@ fopen ( { case '+': - OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); + OpenModes |= (ACPI_EFI_FILE_MODE_WRITE | ACPI_EFI_FILE_MODE_CREATE); break; case 'b': @@ -269,7 +269,7 @@ fopen ( Path16 = ACPI_ALLOCATE_ZEROED ((Count + 1) * sizeof (CHAR16)); if (!Path16) { - EfiStatus = EFI_BAD_BUFFER_SIZE; + EfiStatus = ACPI_EFI_BAD_BUFFER_SIZE; errno = ENOMEM; goto ErrorExit; } @@ -296,7 +296,7 @@ fopen ( EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Open, 5, AcpiGbl_EfiCurrentVolume, &EfiFile, Path16, OpenModes, 0); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { fprintf (stderr, "EFI_FILE_HANDLE->Open() failure.\n"); errno = ENOENT; @@ -336,7 +336,7 @@ void fclose ( FILE *File) { - EFI_FILE_HANDLE EfiFile; + ACPI_EFI_FILE_HANDLE EfiFile; if (File == stdin || File == stdout || @@ -344,7 +344,7 @@ fclose ( { return; } - EfiFile = (EFI_FILE_HANDLE) File; + EfiFile = (ACPI_EFI_FILE_HANDLE) File; (void) uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Close, 1, EfiFile); return; @@ -503,11 +503,11 @@ fread ( FILE *File) { int Length = -EINVAL; - EFI_FILE_HANDLE EfiFile; - SIMPLE_INPUT_INTERFACE *In; + ACPI_EFI_FILE_HANDLE EfiFile; + ACPI_SIMPLE_INPUT_INTERFACE *In; UINTN ReadSize; - EFI_STATUS EfiStatus; - EFI_INPUT_KEY Key; + ACPI_EFI_STATUS EfiStatus; + ACPI_EFI_INPUT_KEY Key; ACPI_SIZE Pos = 0; @@ -525,15 +525,15 @@ fread ( } else if (File == stdin) { - In = ACPI_CAST_PTR (SIMPLE_INPUT_INTERFACE, File); + In = ACPI_CAST_PTR (ACPI_SIMPLE_INPUT_INTERFACE, File); while (Pos < ReadSize) { WaitKey: EfiStatus = uefi_call_wrapper (In->ReadKeyStroke, 2, In, &Key); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { - if (EfiStatus == EFI_NOT_READY) + if (EfiStatus == ACPI_EFI_NOT_READY) { goto WaitKey; } @@ -586,7 +586,7 @@ WaitKey: } else { - EfiFile = (EFI_FILE_HANDLE) File; + EfiFile = (ACPI_EFI_FILE_HANDLE) File; if (!EfiFile) { errno = EINVAL; @@ -595,7 +595,7 @@ WaitKey: EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Read, 3, EfiFile, &ReadSize, Buffer); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { fprintf (stderr, "EFI_FILE_HANDLE->Read() failure.\n"); errno = EIO; @@ -635,12 +635,12 @@ AcpiEfiFlushFile ( CHAR16 *Pos, BOOLEAN FlushAll) { - SIMPLE_TEXT_OUTPUT_INTERFACE *Out; + ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *Out; if (File == stdout || File == stderr) { - Out = ACPI_CAST_PTR (SIMPLE_TEXT_OUTPUT_INTERFACE, File); + Out = ACPI_CAST_PTR (ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE, File); if (FlushAll || Pos >= (End - 1)) { @@ -682,9 +682,9 @@ fwrite ( CHAR16 *End; CHAR16 *Pos; int i, j; - EFI_FILE_HANDLE EfiFile; + ACPI_EFI_FILE_HANDLE EfiFile; UINTN WriteSize; - EFI_STATUS EfiStatus; + ACPI_EFI_STATUS EfiStatus; if (File == stdin) @@ -718,7 +718,7 @@ fwrite ( } else { - EfiFile = (EFI_FILE_HANDLE) File; + EfiFile = (ACPI_EFI_FILE_HANDLE) File; if (!EfiFile) { errno = EINVAL; @@ -728,7 +728,7 @@ fwrite ( EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Write, 3, EfiFile, &WriteSize, Buffer); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { fprintf (stderr, "EFI_FILE_HANDLE->Write() failure.\n"); errno = EIO; @@ -759,12 +759,12 @@ ErrorExit: static int AcpiEfiGetFileInfo ( FILE *File, - EFI_FILE_INFO **InfoPtr) + ACPI_EFI_FILE_INFO **InfoPtr) { - EFI_STATUS EfiStatus = EFI_BUFFER_TOO_SMALL; - EFI_FILE_INFO *Buffer = NULL; - UINTN BufferSize = SIZE_OF_EFI_FILE_INFO + 200; - EFI_FILE_HANDLE EfiFile; + ACPI_EFI_STATUS EfiStatus = ACPI_EFI_BUFFER_TOO_SMALL; + ACPI_EFI_FILE_INFO *Buffer = NULL; + UINTN BufferSize = ACPI_EFI_FILE_INFO_SIZE + 200; + ACPI_EFI_FILE_HANDLE EfiFile; if (!InfoPtr) @@ -773,9 +773,9 @@ AcpiEfiGetFileInfo ( return (-EINVAL); } - while (EfiStatus == EFI_BUFFER_TOO_SMALL) + while (EfiStatus == ACPI_EFI_BUFFER_TOO_SMALL) { - EfiFile = ACPI_CAST_PTR (EFI_FILE, File); + EfiFile = ACPI_CAST_PTR (ACPI_EFI_FILE_STRUCT, File); Buffer = AcpiOsAllocate (BufferSize); if (!Buffer) { @@ -784,10 +784,10 @@ AcpiEfiGetFileInfo ( } EfiStatus = uefi_call_wrapper (EfiFile->GetInfo, 4, EfiFile, &AcpiGbl_GenericFileInfo, &BufferSize, Buffer); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { AcpiOsFree (Buffer); - if (EfiStatus != EFI_BUFFER_TOO_SMALL) + if (EfiStatus != ACPI_EFI_BUFFER_TOO_SMALL) { errno = EIO; return (-EIO); @@ -818,8 +818,8 @@ ftell ( { long Offset = -1; UINT64 Current; - EFI_STATUS EfiStatus; - EFI_FILE_HANDLE EfiFile; + ACPI_EFI_STATUS EfiStatus; + ACPI_EFI_FILE_HANDLE EfiFile; if (File == stdin || File == stdout || File == stderr) @@ -828,11 +828,11 @@ ftell ( } else { - EfiFile = ACPI_CAST_PTR (EFI_FILE, File); + EfiFile = ACPI_CAST_PTR (ACPI_EFI_FILE_STRUCT, File); EfiStatus = uefi_call_wrapper (EfiFile->GetPosition, 2, EfiFile, &Current); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { goto ErrorExit; } @@ -867,12 +867,12 @@ fseek ( long Offset, int From) { - EFI_FILE_INFO *Info; + ACPI_EFI_FILE_INFO *Info; int Error; ACPI_SIZE Size; UINT64 Current; - EFI_STATUS EfiStatus; - EFI_FILE_HANDLE EfiFile; + ACPI_EFI_STATUS EfiStatus; + ACPI_EFI_FILE_HANDLE EfiFile; if (File == stdin || File == stdout || File == stderr) @@ -881,7 +881,7 @@ fseek ( } else { - EfiFile = ACPI_CAST_PTR (EFI_FILE, File); + EfiFile = ACPI_CAST_PTR (ACPI_EFI_FILE_STRUCT, File); Error = AcpiEfiGetFileInfo (File, &Info); if (Error) { @@ -894,7 +894,7 @@ fseek ( { EfiStatus = uefi_call_wrapper (EfiFile->GetPosition, 2, EfiFile, &Current); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { errno = ERANGE; return (-ERANGE); @@ -912,7 +912,7 @@ fseek ( EfiStatus = uefi_call_wrapper (EfiFile->SetPosition, 2, EfiFile, Current); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { errno = ERANGE; return (-ERANGE); @@ -1172,18 +1172,18 @@ ErrorExit: * *****************************************************************************/ -EFI_STATUS +ACPI_EFI_STATUS efi_main ( - EFI_HANDLE Image, - EFI_SYSTEM_TABLE *SystemTab) + ACPI_EFI_HANDLE Image, + ACPI_EFI_SYSTEM_TABLE *SystemTab) { - EFI_LOADED_IMAGE *Info; - EFI_STATUS EfiStatus = EFI_SUCCESS; + ACPI_EFI_LOADED_IMAGE *Info; + ACPI_EFI_STATUS EfiStatus = ACPI_EFI_SUCCESS; int Error; int argc; char **argv = NULL; char *OptBuffer = NULL; - EFI_FILE_IO_INTERFACE *Volume = NULL; + ACPI_EFI_FILE_IO_INTERFACE *Volume = NULL; /* Initialize global variables */ @@ -1200,7 +1200,7 @@ efi_main ( EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, Image, &AcpiGbl_LoadedImageProtocol, ACPI_CAST_PTR (VOID, &Info)); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { fprintf (stderr, "EFI_BOOT_SERVICES->HandleProtocol(LoadedImageProtocol) failure.\n"); @@ -1209,7 +1209,7 @@ efi_main ( EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3, Info->DeviceHandle, &AcpiGbl_FileSystemProtocol, (void **) &Volume); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { fprintf (stderr, "EFI_BOOT_SERVICES->HandleProtocol(FileSystemProtocol) failure.\n"); @@ -1217,7 +1217,7 @@ efi_main ( } EfiStatus = uefi_call_wrapper (Volume->OpenVolume, 2, Volume, &AcpiGbl_EfiCurrentVolume); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { fprintf (stderr, "EFI_FILE_IO_INTERFACE->OpenVolume() failure.\n"); return (EfiStatus); @@ -1227,7 +1227,7 @@ efi_main ( Info->LoadOptionsSize, &argc, &argv, &OptBuffer); if (Error) { - EfiStatus = EFI_DEVICE_ERROR; + EfiStatus = ACPI_EFI_DEVICE_ERROR; goto ErrorAlloc; } diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c index 6ba45bb21..bc6c99f85 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -134,12 +134,12 @@ AeTableOverride ( static BOOLEAN AcpiEfiCompareGuid ( - EFI_GUID *Guid1, - EFI_GUID *Guid2); + ACPI_EFI_GUID *Guid1, + ACPI_EFI_GUID *Guid2); static ACPI_PHYSICAL_ADDRESS AcpiEfiGetRsdpViaGuid ( - EFI_GUID *Guid); + ACPI_EFI_GUID *Guid); /****************************************************************************** @@ -157,8 +157,8 @@ AcpiEfiGetRsdpViaGuid ( static BOOLEAN AcpiEfiCompareGuid ( - EFI_GUID *Guid1, - EFI_GUID *Guid2) + ACPI_EFI_GUID *Guid1, + ACPI_EFI_GUID *Guid2) { INT32 *g1; INT32 *g2; @@ -191,7 +191,7 @@ AcpiEfiCompareGuid ( static ACPI_PHYSICAL_ADDRESS AcpiEfiGetRsdpViaGuid ( - EFI_GUID *Guid) + ACPI_EFI_GUID *Guid) { ACPI_PHYSICAL_ADDRESS Address = 0; int i; @@ -228,8 +228,8 @@ AcpiOsGetRootPointer ( void) { ACPI_PHYSICAL_ADDRESS Address; - EFI_GUID Guid10 = ACPI_TABLE_GUID; - EFI_GUID Guid20 = ACPI_20_TABLE_GUID; + ACPI_EFI_GUID Guid10 = ACPI_TABLE_GUID; + ACPI_EFI_GUID Guid20 = ACPI_20_TABLE_GUID; Address = AcpiEfiGetRsdpViaGuid (&Guid20); @@ -737,15 +737,15 @@ UINT64 AcpiOsGetTimer ( void) { - EFI_STATUS EfiStatus; - EFI_TIME EfiTime; + ACPI_EFI_STATUS EfiStatus; + ACPI_EFI_TIME EfiTime; int Year, Month, Day; int Hour, Minute, Second; UINT64 Timer; EfiStatus = uefi_call_wrapper (RT->GetTime, 2, &EfiTime, NULL); - if (EFI_ERROR (EfiStatus)) + if (ACPI_EFI_ERROR (EfiStatus)) { return (-1); } @@ -843,13 +843,13 @@ void * AcpiOsAllocate ( ACPI_SIZE Size) { - EFI_STATUS EfiStatus; + ACPI_EFI_STATUS EfiStatus; void *Mem; EfiStatus = uefi_call_wrapper (BS->AllocatePool, 3, - EfiLoaderData, Size, &Mem); - if (EFI_ERROR (EfiStatus)) + AcpiEfiLoaderData, Size, &Mem); + if (ACPI_EFI_ERROR (EfiStatus)) { fprintf (stderr, "EFI_BOOT_SERVICES->AllocatePool(EfiLoaderData) failure.\n"); -- cgit v1.2.1 From cc7c7ebe27537840b6e0109d8ef1435c306669bc Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Mon, 6 Jun 2016 09:39:20 +0800 Subject: EFI: Port acpiexec/acpidump to EDK2 environment This patch adds necessary build files for EDK2 environment to build ACPICA tools. The command steps of building edk2 binaries are (if you are using gcc4.7): # cd edk2 # . ./edksetup.sh # ln -s AcpiPkg # build -p AcpiPkg/AcpiPkg.dsc -t GCC47 -a X64 -a IA32 Note the above test was done in Linux, and the Windows hasn't been tested when this patch is generated. For building edk2 binaries in the MSVC environment, you need to modify acpidump.inf/acpiexec.inf, adding necessary options when they cannot pass the build in the following configure items: MSFT:*_*_IA32_CC_FLAGS/MSFT:*_*_X64_CC_FLAGS. Lv Zheng. Signed-off-by: Lv Zheng --- AcpiPkg.dec | 25 +++ AcpiPkg.dsc | 47 ++++++ source/acpidump.inf | 59 +++++++ source/acpiexec.inf | 234 ++++++++++++++++++++++++++ source/include/platform/acefi.h | 22 ++- source/include/platform/acenv.h | 3 + source/include/platform/acmsvc.h | 5 + source/os_specific/service_layers/oseficlib.c | 20 +++ 8 files changed, 411 insertions(+), 4 deletions(-) create mode 100644 AcpiPkg.dec create mode 100644 AcpiPkg.dsc create mode 100644 source/acpidump.inf create mode 100644 source/acpiexec.inf diff --git a/AcpiPkg.dec b/AcpiPkg.dec new file mode 100644 index 000000000..13cf1029c --- /dev/null +++ b/AcpiPkg.dec @@ -0,0 +1,25 @@ +## @file +# Build description file to ACPICA applications. +# +# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + PACKAGE_NAME = AcpiPkg + PACKAGE_GUID = 3ee43d98-2941-11e6-a597-0024e8c6d30e + PACKAGE_VERSION = 0.01 + DEC_SPECIFICATION = 0x00010005 + +[Includes] + source/include + +[Guids] + gAcpiPkgTokenSpaceGuid = { 0x81c5af5c, 0x2941, 0x11e6, { 0xa5, 0x3d, 0x00, 0x24, 0xe8, 0xc6, 0xd3, 0x0e }} diff --git a/AcpiPkg.dsc b/AcpiPkg.dsc new file mode 100644 index 000000000..24f4aa135 --- /dev/null +++ b/AcpiPkg.dsc @@ -0,0 +1,47 @@ +#/** @file +# Build discription file to generate ACPICA applications. +# +# Copyright (c) 2009 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +# **/ + +[Defines] + PLATFORM_NAME = Acpi + PLATFORM_GUID = b03fdec4-2942-11e6-a416-0024e8c6d30e + PLATFORM_VERSION = 1.0 + DSC_SPECIFICATION = 0x00010005 + OUTPUT_DIRECTORY = Build/Acpi + SUPPORTED_ARCHITECTURES = IA32|X64 + BUILD_TARGETS = DEBUG|RELEASE + SKUID_IDENTIFIER = DEFAULT + +[LibraryClasses] + # + # Entry Point Libraries + # + UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf + # + # Common Libraries + # + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + !if $(DEBUG_ENABLE_OUTPUT) + DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf + !else ## DEBUG_ENABLE_OUTPUT + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + !endif ## DEBUG_ENABLE_OUTPUT + +[Components.common] + AcpiPkg/source/acpidump.inf + AcpiPkg/source/acpiexec.inf diff --git a/source/acpidump.inf b/source/acpidump.inf new file mode 100644 index 000000000..499d1999b --- /dev/null +++ b/source/acpidump.inf @@ -0,0 +1,59 @@ +## @file +# acpidump.inf +# +# Copyright (c) 2016, Intel Corporation. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = acpidump + FILE_GUID = bf942c9a-2942-11e6-9a64-0024e8c6d30e + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = UefiMain + +[Sources] + tools/acpidump/apdump.c + tools/acpidump/apfiles.c + tools/acpidump/apmain.c + common/cmfsize.c + common/getopt.c + os_specific/service_layers/oseficlib.c + os_specific/service_layers/osefitbl.c + os_specific/service_layers/osefixf.c + components/tables/tbprint.c + components/tables/tbxfroot.c + components/utilities/utascii.c + components/utilities/utbuffer.c + components/utilities/utclib.c + components/utilities/utdebug.c + components/utilities/utexcep.c + components/utilities/utglobal.c + components/utilities/utmath.c + components/utilities/utnonansi.c + components/utilities/utprint.c + components/utilities/utstring.c + components/utilities/utxferror.c + +[Packages] + AcpiPkg/AcpiPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + UefiApplicationEntryPoint + BaseLib + +[BuildOptions] + MSFT:*_*_IA32_CC_FLAGS = /Oi- /WX- /D_EDK2_EFI /DACPI_DUMP_APP + MSFT:*_*_X64_CC_FLAGS = /Oi- /WX- /D_EDK2_EFI /DACPI_DUMP_APP + GCC:*_*_IA32_CC_FLAGS = -U__linux__ -U_LINUX -D_EDK2_EFI -DACPI_DUMP_APP -fno-builtin -iwithprefix include + GCC:*_*_X64_CC_FLAGS = -U__linux__ -U_LINUX -D_EDK2_EFI -DACPI_DUMP_APP -fno-builtin -iwithprefix include diff --git a/source/acpiexec.inf b/source/acpiexec.inf new file mode 100644 index 000000000..a6566e7bb --- /dev/null +++ b/source/acpiexec.inf @@ -0,0 +1,234 @@ +## @file +# acpiexec.inf +# +# Copyright (c) 2016, Intel Corporation. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = acpiexec + FILE_GUID = 485464fc-2946-11e6-85c7-0024e8c6d30e + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = UefiMain + +[Sources] + tools/acpiexec/aeexec.c + tools/acpiexec/aehandlers.c + tools/acpiexec/aeinitfile.c + tools/acpiexec/aemain.c + tools/acpiexec/aeregion.c + tools/acpiexec/aetables.c + common/acfileio.c + common/acgetline.c + common/ahids.c + common/ahuuids.c + common/cmfsize.c + common/getopt.c + components/debugger/dbcmds.c + components/debugger/dbconvert.c + components/debugger/dbdisply.c + components/debugger/dbexec.c + components/debugger/dbfileio.c + components/debugger/dbhistry.c + components/debugger/dbinput.c + components/debugger/dbmethod.c + components/debugger/dbnames.c + components/debugger/dbobject.c + components/debugger/dbstats.c + components/debugger/dbtest.c + components/debugger/dbutils.c + components/debugger/dbxface.c + components/disassembler/dmbuffer.c + components/disassembler/dmcstyle.c + components/disassembler/dmdeferred.c + components/disassembler/dmnames.c + components/disassembler/dmopcode.c + components/disassembler/dmresrc.c + components/disassembler/dmresrcl.c + components/disassembler/dmresrcl2.c + components/disassembler/dmresrcs.c + components/disassembler/dmutils.c + components/disassembler/dmwalk.c + components/dispatcher/dsargs.c + components/dispatcher/dscontrol.c + components/dispatcher/dsdebug.c + components/dispatcher/dsfield.c + components/dispatcher/dsinit.c + components/dispatcher/dsmethod.c + components/dispatcher/dsmthdat.c + components/dispatcher/dsobject.c + components/dispatcher/dsopcode.c + components/dispatcher/dsutils.c + components/dispatcher/dswexec.c + components/dispatcher/dswload.c + components/dispatcher/dswload2.c + components/dispatcher/dswscope.c + components/dispatcher/dswstate.c + components/events/evevent.c + components/events/evglock.c + components/events/evgpe.c + components/events/evgpeblk.c + components/events/evgpeinit.c + components/events/evgpeutil.c + components/events/evhandler.c + components/events/evmisc.c + components/events/evregion.c + components/events/evrgnini.c + components/events/evsci.c + components/events/evxface.c + components/events/evxfevnt.c + components/events/evxfgpe.c + components/events/evxfregn.c + components/executer/exconcat.c + components/executer/exconfig.c + components/executer/exconvrt.c + components/executer/excreate.c + components/executer/exdebug.c + components/executer/exdump.c + components/executer/exfield.c + components/executer/exfldio.c + components/executer/exmisc.c + components/executer/exmutex.c + components/executer/exnames.c + components/executer/exoparg1.c + components/executer/exoparg2.c + components/executer/exoparg3.c + components/executer/exoparg6.c + components/executer/exprep.c + components/executer/exregion.c + components/executer/exresnte.c + components/executer/exresolv.c + components/executer/exresop.c + components/executer/exstore.c + components/executer/exstoren.c + components/executer/exstorob.c + components/executer/exsystem.c + components/executer/extrace.c + components/executer/exutils.c + components/hardware/hwacpi.c + components/hardware/hwesleep.c + components/hardware/hwgpe.c + components/hardware/hwpci.c + components/hardware/hwregs.c + components/hardware/hwsleep.c + components/hardware/hwvalid.c + components/hardware/hwxface.c + components/hardware/hwxfsleep.c + components/namespace/nsaccess.c + components/namespace/nsalloc.c + components/namespace/nsarguments.c + components/namespace/nsconvert.c + components/namespace/nsdump.c + components/namespace/nsdumpdv.c + components/namespace/nseval.c + components/namespace/nsinit.c + components/namespace/nsload.c + components/namespace/nsnames.c + components/namespace/nsobject.c + components/namespace/nsparse.c + components/namespace/nspredef.c + components/namespace/nsprepkg.c + components/namespace/nsrepair.c + components/namespace/nsrepair2.c + components/namespace/nssearch.c + components/namespace/nsutils.c + components/namespace/nswalk.c + components/namespace/nsxfeval.c + components/namespace/nsxfname.c + components/namespace/nsxfobj.c + components/parser/psargs.c + components/parser/psloop.c + components/parser/psobject.c + components/parser/psopcode.c + components/parser/psopinfo.c + components/parser/psparse.c + components/parser/psscope.c + components/parser/pstree.c + components/parser/psutils.c + components/parser/pswalk.c + components/parser/psxface.c + components/resources/rsaddr.c + components/resources/rscalc.c + components/resources/rscreate.c + components/resources/rsdump.c + components/resources/rsdumpinfo.c + components/resources/rsinfo.c + components/resources/rsio.c + components/resources/rsirq.c + components/resources/rslist.c + components/resources/rsmemory.c + components/resources/rsmisc.c + components/resources/rsserial.c + components/resources/rsutils.c + components/resources/rsxface.c + components/tables/tbdata.c + components/tables/tbfadt.c + components/tables/tbfind.c + components/tables/tbinstal.c + components/tables/tbprint.c + components/tables/tbutils.c + components/tables/tbxface.c + components/tables/tbxfload.c + components/tables/tbxfroot.c + components/utilities/utaddress.c + components/utilities/utalloc.c + components/utilities/utascii.c + components/utilities/utbuffer.c + components/utilities/utcache.c + components/utilities/utclib.c + components/utilities/utcopy.c + components/utilities/utdebug.c + components/utilities/utdecode.c + components/utilities/utdelete.c + components/utilities/uterror.c + components/utilities/uteval.c + components/utilities/utexcep.c + components/utilities/utglobal.c + components/utilities/uthex.c + components/utilities/utids.c + components/utilities/utinit.c + components/utilities/utlock.c + components/utilities/utmath.c + components/utilities/utmisc.c + components/utilities/utmutex.c + components/utilities/utnonansi.c + components/utilities/utobject.c + components/utilities/utosi.c + components/utilities/utownerid.c + components/utilities/utpredef.c + components/utilities/utprint.c + components/utilities/utresrc.c + components/utilities/utstate.c + components/utilities/utstring.c + components/utilities/uttrack.c + components/utilities/utuuid.c + components/utilities/utxface.c + components/utilities/utxferror.c + components/utilities/utxfinit.c + components/utilities/utxfmutex.c + os_specific/service_layers/oseficlib.c + os_specific/service_layers/osefixf.c + +[Packages] + AcpiPkg/AcpiPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + UefiApplicationEntryPoint + BaseLib + +[BuildOptions] + MSFT:*_*_IA32_CC_FLAGS = /Oi- /WX- /D_EDK2_EFI /DACPI_EXEC_APP + MSFT:*_*_X64_CC_FLAGS = /Oi- /WX- /D_EDK2_EFI /DACPI_EXEC_APP + GCC:*_*_IA32_CC_FLAGS = -U__linux__ -U_LINUX -D_EDK2_EFI -DACPI_EXEC_APP -fno-builtin -iwithprefix include + GCC:*_*_X64_CC_FLAGS = -U__linux__ -U_LINUX -D_EDK2_EFI -DACPI_EXEC_APP -fno-builtin -iwithprefix include diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h index 859e7554d..4de3607b8 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -116,6 +116,14 @@ #ifndef __ACEFI_H__ #define __ACEFI_H__ +#ifdef __GNUC__ +#include "acgcc.h" +#endif + +#ifdef _MSC_VER +#include "acmsvc.h" +#endif + #if defined(__x86_64__) #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) #define USE_MS_ABI 1 @@ -254,6 +262,16 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, #endif + +/* EDK2 EFI definitions */ + +#if defined(_EDK2_EFI) + +#define _GNU_EFI + +#endif + + /* AED EFI definitions */ #if defined(_AED_EFI) @@ -287,10 +305,6 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, #if defined(_GNU_EFI) -/* Using GCC for GNU EFI */ - -#include "acgcc.h" - #ifdef DEBUGGER_THREADING #undef DEBUGGER_THREADING #endif /* DEBUGGER_THREADING */ diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index 723979ff7..b5268b4e6 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -288,6 +288,9 @@ #elif defined(_GNU_EFI) #include "acefi.h" +#elif defined(_EDK2_EFI) +#include "acefi.h" + #elif defined(__HAIKU__) #include "achaiku.h" diff --git a/source/include/platform/acmsvc.h b/source/include/platform/acmsvc.h index c7cf21bc7..a154c6745 100644 --- a/source/include/platform/acmsvc.h +++ b/source/include/platform/acmsvc.h @@ -174,6 +174,10 @@ #define ACPI_INTERNAL_XFACE #define ACPI_INTERNAL_VAR_XFACE __cdecl + +/* Do not maintain the architecture specific stuffs for the EFI ports */ + +#if !defined(_EDK2_EFI) && !defined(_GNU_EFI) #ifndef _LINT /* * Math helper functions @@ -208,6 +212,7 @@ n_lo >>= 1; \ } #endif +#endif /* warn C4100: unreferenced formal parameter */ #pragma warning(disable:4100) diff --git a/source/os_specific/service_layers/oseficlib.c b/source/os_specific/service_layers/oseficlib.c index 43337c838..acc5f7b8d 100644 --- a/source/os_specific/service_layers/oseficlib.c +++ b/source/os_specific/service_layers/oseficlib.c @@ -1246,3 +1246,23 @@ ErrorAlloc: return (EfiStatus); } + +#ifdef _EDK2_EFI +struct _ACPI_EFI_SYSTEM_TABLE *ST; +struct _ACPI_EFI_BOOT_SERVICES *BS; +struct _ACPI_EFI_RUNTIME_SERVICES *RT; + +EFI_STATUS +EFIAPI +UefiMain ( + EFI_HANDLE Image, + EFI_SYSTEM_TABLE *SystemTab) +{ + EFI_STATUS EfiStatus; + + + EfiStatus = (EFI_STATUS) efi_main ( + (ACPI_EFI_HANDLE) Image, (ACPI_EFI_SYSTEM_TABLE *) SystemTab); + return (EfiStatus); +} +#endif -- cgit v1.2.1