From d776c9ee6e67f3b7a186d809763558ca7a358710 Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Wed, 15 Jun 2016 10:51:12 -0700 Subject: Revert "Efi edk2" --- AcpiPkg.dec | 25 - AcpiPkg.dsc | 47 - generate/efi/Makefile.config | 9 +- generate/efi/acpidump/Makefile | 5 +- generate/efi/acpiexec/Makefile | 255 ----- 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/acpidump.inf | 59 -- source/acpiexec.inf | 234 ----- source/common/acfileio.c | 7 +- source/common/acgetline.c | 2 + source/common/cmfsize.c | 13 +- source/common/getopt.c | 2 +- source/components/debugger/dbfileio.c | 1 + source/components/utilities/utbuffer.c | 26 +- source/components/utilities/utclib.c | 146 +-- source/components/utilities/utdebug.c | 30 + source/components/utilities/utpredef.c | 2 + source/components/utilities/utprint.c | 124 +-- source/components/utilities/utxfinit.c | 4 - source/include/acapps.h | 12 +- source/include/acclib.h | 156 --- source/include/accommon.h | 4 +- source/include/acpiosxf.h | 67 +- source/include/acpixf.h | 9 +- source/include/actypes.h | 10 + source/include/acutils.h | 42 + source/include/platform/acefi.h | 91 +- source/include/platform/acefiex.h | 998 +++++++++---------- source/include/platform/acenv.h | 65 +- source/include/platform/acgcc.h | 4 - source/include/platform/aclinux.h | 6 +- source/include/platform/acmsvc.h | 9 - source/os_specific/service_layers/oseficlib.c | 1268 ------------------------- source/os_specific/service_layers/osefitbl.c | 86 +- source/os_specific/service_layers/osefixf.c | 1099 +++++++++++---------- source/os_specific/service_layers/oslibcfs.c | 330 +++++++ source/os_specific/service_layers/osunixxf.c | 3 + source/os_specific/service_layers/oswinxf.c | 3 + source/tools/acpidump/acpidump.h | 12 + source/tools/acpidump/apdump.c | 28 +- source/tools/acpidump/apfiles.c | 42 +- source/tools/acpidump/apmain.c | 15 +- source/tools/acpiexec/aecommon.h | 7 +- source/tools/acpiexec/aehandlers.c | 5 +- source/tools/acpiexec/aeinitfile.c | 7 +- source/tools/acpiexec/aemain.c | 15 +- 54 files changed, 1754 insertions(+), 3643 deletions(-) delete mode 100644 AcpiPkg.dec delete mode 100644 AcpiPkg.dsc delete mode 100644 generate/efi/acpiexec/Makefile delete mode 100644 source/acpidump.inf delete mode 100644 source/acpiexec.inf delete mode 100644 source/os_specific/service_layers/oseficlib.c create mode 100644 source/os_specific/service_layers/oslibcfs.c diff --git a/AcpiPkg.dec b/AcpiPkg.dec deleted file mode 100644 index 13cf1029c..000000000 --- a/AcpiPkg.dec +++ /dev/null @@ -1,25 +0,0 @@ -## @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 deleted file mode 100644 index 24f4aa135..000000000 --- a/AcpiPkg.dsc +++ /dev/null @@ -1,47 +0,0 @@ -#/** @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/generate/efi/Makefile.config b/generate/efi/Makefile.config index 1f3aa74d4..d7872c8ac 100644 --- a/generate/efi/Makefile.config +++ b/generate/efi/Makefile.config @@ -47,7 +47,7 @@ # # Common defines # -PROGS = acpidump acpiexec +PROGS = acpidump HOST = $(shell uname -m | sed s,i[3456789]86,ia32,) TARGET = $(shell uname -m | sed s,i[3456789]86,ia32,) SHARED ?= true @@ -79,7 +79,6 @@ ACPICA_UTILITIES = $(ACPICA_CORE)/utilities # ACPICA tool and utility source directories # ACPIDUMP = $(ACPICA_TOOLS)/acpidump -ACPIEXEC = $(ACPICA_TOOLS)/acpiexec # # Common ACPICA header files @@ -96,23 +95,17 @@ 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 39fa364d0..16bd52a81 100644 --- a/generate/efi/acpidump/Makefile +++ b/generate/efi/acpidump/Makefile @@ -32,19 +32,16 @@ OBJECTS = \ $(OBJDIR)/apmain.o\ $(OBJDIR)/cmfsize.o\ $(OBJDIR)/getopt.o\ - $(OBJDIR)/oseficlib.o\ $(OBJDIR)/osefitbl.o\ $(OBJDIR)/osefixf.o\ $(OBJDIR)/tbprint.o\ $(OBJDIR)/tbxfroot.o\ - $(OBJDIR)/utascii.o\ $(OBJDIR)/utbuffer.o\ - $(OBJDIR)/utclib.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 diff --git a/generate/efi/acpiexec/Makefile b/generate/efi/acpiexec/Makefile deleted file mode 100644 index aedcb6b14..000000000 --- a/generate/efi/acpiexec/Makefile +++ /dev/null @@ -1,255 +0,0 @@ - -# -# 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/generate/unix/acpibin/Makefile b/generate/unix/acpibin/Makefile index 511d71091..e856499a5 100644 --- a/generate/unix/acpibin/Makefile +++ b/generate/unix/acpibin/Makefile @@ -47,6 +47,7 @@ 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 bc3430613..d6e19644c 100644 --- a/generate/unix/acpidump/Makefile +++ b/generate/unix/acpidump/Makefile @@ -33,6 +33,7 @@ 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 b22b84883..54d74739e 100644 --- a/generate/unix/acpiexamples/Makefile +++ b/generate/unix/acpiexamples/Makefile @@ -107,6 +107,7 @@ 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 33e516caf..7f8befabb 100644 --- a/generate/unix/acpiexec/Makefile +++ b/generate/unix/acpiexec/Makefile @@ -163,6 +163,7 @@ 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 4290a153f..d50e416c8 100644 --- a/generate/unix/acpihelp/Makefile +++ b/generate/unix/acpihelp/Makefile @@ -38,6 +38,7 @@ 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 a7dd6a9ee..4ff5558f0 100644 --- a/generate/unix/acpinames/Makefile +++ b/generate/unix/acpinames/Makefile @@ -72,6 +72,7 @@ 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 931b33d71..93a9868cf 100644 --- a/generate/unix/acpisrc/Makefile +++ b/generate/unix/acpisrc/Makefile @@ -36,14 +36,15 @@ 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 22b3294ee..272cbd091 100644 --- a/generate/unix/acpixtract/Makefile +++ b/generate/unix/acpixtract/Makefile @@ -31,6 +31,7 @@ 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 949dd180a..a3759cc85 100644 --- a/generate/unix/iasl/Makefile +++ b/generate/unix/iasl/Makefile @@ -177,6 +177,7 @@ 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/acpidump.inf b/source/acpidump.inf deleted file mode 100644 index 499d1999b..000000000 --- a/source/acpidump.inf +++ /dev/null @@ -1,59 +0,0 @@ -## @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 deleted file mode 100644 index a6566e7bb..000000000 --- a/source/acpiexec.inf +++ /dev/null @@ -1,234 +0,0 @@ -## @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/common/acfileio.c b/source/common/acfileio.c index e53b825a7..c00580fc7 100644 --- a/source/common/acfileio.c +++ b/source/common/acfileio.c @@ -118,6 +118,7 @@ #include "acapps.h" #include "actables.h" #include "acutils.h" +#include #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("acfileio") @@ -169,7 +170,7 @@ AcGetAllTablesFromFile ( File = fopen (Filename, "rb"); if (!File) { - fprintf (stderr, "Could not open input file: %s\n", Filename); + perror ("Could not open input file"); if (errno == ENOENT) { return (AE_NOT_EXIST); @@ -351,7 +352,7 @@ AcGetOneTableFromFile ( /* Allocate a buffer for the entire table */ - Table = AcpiOsAllocate ((ACPI_SIZE) TableHeader.Length); + Table = AcpiOsAllocate ((size_t) TableHeader.Length); if (!Table) { return (AE_NO_MEMORY); @@ -459,7 +460,7 @@ AcValidateTableHeader ( long TableOffset) { ACPI_TABLE_HEADER TableHeader; - ACPI_SIZE Actual; + size_t Actual; long OriginalOffset; UINT32 FileSize; UINT32 i; diff --git a/source/common/acgetline.c b/source/common/acgetline.c index a28aaf78d..dfc065389 100644 --- a/source/common/acgetline.c +++ b/source/common/acgetline.c @@ -119,6 +119,8 @@ #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 2139e4b26..accdf225b 100644 --- a/source/common/cmfsize.c +++ b/source/common/cmfsize.c @@ -116,6 +116,7 @@ #include "acpi.h" #include "accommon.h" #include "acapps.h" +#include #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("cmfsize") @@ -145,19 +146,19 @@ CmGetFileSize ( /* Save the current file pointer, seek to EOF to obtain file size */ - CurrentOffset = ftell (File); + CurrentOffset = AcpiOsGetFileOffset (File); if (CurrentOffset < 0) { goto OffsetError; } - Status = fseek (File, 0, SEEK_END); + Status = AcpiOsSetFileOffset (File, 0, ACPI_FILE_END); if (ACPI_FAILURE (Status)) { goto SeekError; } - FileSize = ftell (File); + FileSize = AcpiOsGetFileOffset (File); if (FileSize < 0) { goto OffsetError; @@ -165,7 +166,7 @@ CmGetFileSize ( /* Restore original file pointer */ - Status = fseek (File, CurrentOffset, SEEK_SET); + Status = AcpiOsSetFileOffset (File, CurrentOffset, ACPI_FILE_BEGIN); if (ACPI_FAILURE (Status)) { goto SeekError; @@ -175,10 +176,10 @@ CmGetFileSize ( OffsetError: - fprintf (stderr, "Could not get file offset\n"); + AcpiLogError ("Could not get file offset"); return (ACPI_UINT32_MAX); SeekError: - fprintf (stderr, "Could not set file offset\n"); + AcpiLogError ("Could not set file offset"); return (ACPI_UINT32_MAX); } diff --git a/source/common/getopt.c b/source/common/getopt.c index d309789c3..07e98a92e 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) {fprintf (stderr, "%s%c\n", msg, badchar);} + if (AcpiGbl_Opterr) {AcpiLogError ("%s%c\n", msg, badchar);} int AcpiGbl_Opterr = 1; diff --git a/source/components/debugger/dbfileio.c b/source/components/debugger/dbfileio.c index 78e06eb86..d7942b745 100644 --- a/source/components/debugger/dbfileio.c +++ b/source/components/debugger/dbfileio.c @@ -118,6 +118,7 @@ #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 fe5c7d505..4a50e9e06 100644 --- a/source/components/utilities/utbuffer.c +++ b/source/components/utilities/utbuffer.c @@ -336,7 +336,7 @@ AcpiUtDumpBufferToFile ( if (!Buffer) { - fprintf (File, "Null Buffer Pointer in DumpBuffer!\n"); + AcpiUtFilePrintf (File, "Null Buffer Pointer in DumpBuffer!\n"); return; } @@ -351,7 +351,7 @@ AcpiUtDumpBufferToFile ( { /* Print current offset */ - fprintf (File, "%6.4X: ", (BaseOffset + i)); + AcpiUtFilePrintf (File, "%6.4X: ", (BaseOffset + i)); /* Print 16 hex chars */ @@ -361,7 +361,7 @@ AcpiUtDumpBufferToFile ( { /* Dump fill spaces */ - fprintf (File, "%*s", ((Display * 2) + 1), " "); + AcpiUtFilePrintf (File, "%*s", ((Display * 2) + 1), " "); j += Display; continue; } @@ -371,28 +371,28 @@ AcpiUtDumpBufferToFile ( case DB_BYTE_DISPLAY: default: /* Default is BYTE display */ - fprintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]); + AcpiUtFilePrintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]); break; case DB_WORD_DISPLAY: ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); - fprintf (File, "%04X ", Temp32); + AcpiUtFilePrintf (File, "%04X ", Temp32); break; case DB_DWORD_DISPLAY: ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); - fprintf (File, "%08X ", Temp32); + AcpiUtFilePrintf (File, "%08X ", Temp32); break; case DB_QWORD_DISPLAY: ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); - fprintf (File, "%08X", Temp32); + AcpiUtFilePrintf (File, "%08X", Temp32); ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]); - fprintf (File, "%08X ", Temp32); + AcpiUtFilePrintf (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) */ - fprintf (File, " "); + AcpiUtFilePrintf (File, " "); for (j = 0; j < 16; j++) { if (i + j >= Count) { - fprintf (File, "\n"); + AcpiUtFilePrintf (File, "\n"); return; } BufChar = Buffer[(ACPI_SIZE) i + j]; if (isprint (BufChar)) { - fprintf (File, "%c", BufChar); + AcpiUtFilePrintf (File, "%c", BufChar); } else { - fprintf (File, "."); + AcpiUtFilePrintf (File, "."); } } /* Done with that line. */ - fprintf (File, "\n"); + AcpiUtFilePrintf (File, "\n"); i += 16; } diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c index 2f4f4ffdb..26fbaf958 100644 --- a/source/components/utilities/utclib.c +++ b/source/components/utilities/utclib.c @@ -163,7 +163,7 @@ ACPI_MODULE_NAME ("utclib") -#if defined(ACPI_USE_SYSTEM_CLIBRARY) && !defined(ACPI_USE_STANDARD_HEADERS) +#ifndef ACPI_USE_SYSTEM_CLIBRARY /* Entire module */ /******************************************************************************* @@ -199,61 +199,6 @@ 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 @@ -356,93 +301,6 @@ 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 @@ -1129,4 +987,4 @@ const UINT8 AcpiGbl_Ctypes[257] = { }; -#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */ +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c index 995d45cc3..4d2b306a0 100644 --- a/source/components/utilities/utdebug.c +++ b/source/components/utilities/utdebug.c @@ -780,3 +780,33 @@ 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) AcpiUtFileVprintf (ACPI_FILE_ERR, Format, Args); + va_end (Args); +} + +ACPI_EXPORT_SYMBOL (AcpiLogError) +#endif diff --git a/source/components/utilities/utpredef.c b/source/components/utilities/utpredef.c index a97064c7a..01196bb03 100644 --- a/source/components/utilities/utpredef.c +++ b/source/components/utilities/utpredef.c @@ -268,6 +268,8 @@ 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 ee52453fd..5ca859ec4 100644 --- a/source/components/utilities/utprint.c +++ b/source/components/utilities/utprint.c @@ -120,8 +120,6 @@ 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 @@ -490,7 +488,7 @@ AcpiUtFormatNumber ( /******************************************************************************* * - * FUNCTION: vsnprintf + * FUNCTION: AcpiUtVsnprintf * * PARAMETERS: String - String with boundary * Size - Boundary of the string @@ -504,7 +502,7 @@ AcpiUtFormatNumber ( ******************************************************************************/ int -vsnprintf ( +AcpiUtVsnprintf ( char *String, ACPI_SIZE Size, const char *Format, @@ -787,7 +785,7 @@ vsnprintf ( /******************************************************************************* * - * FUNCTION: snprintf + * FUNCTION: AcpiUtSnprintf * * PARAMETERS: String - String with boundary * Size - Boundary of the string @@ -800,7 +798,7 @@ vsnprintf ( ******************************************************************************/ int -snprintf ( +AcpiUtSnprintf ( char *String, ACPI_SIZE Size, const char *Format, @@ -811,38 +809,7 @@ snprintf ( va_start (Args, Format); - 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); + Length = AcpiUtVsnprintf (String, Size, Format, Args); va_end (Args); return (Length); @@ -852,69 +819,7 @@ sprintf ( #ifdef ACPI_APPLICATION /******************************************************************************* * - * 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) fwrite (AcpiGbl_PrintBuffer, Length, 1, ACPI_FILE_OUT); - 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 + * FUNCTION: AcpiUtFileVprintf * * PARAMETERS: File - File descriptor * Format - Standard printf format @@ -927,8 +832,8 @@ printf ( ******************************************************************************/ int -vfprintf ( - FILE *File, +AcpiUtFileVprintf ( + ACPI_FILE File, const char *Format, va_list Args) { @@ -937,10 +842,10 @@ vfprintf ( Flags = AcpiOsAcquireLock (AcpiGbl_PrintLock); - Length = vsnprintf (AcpiGbl_PrintBuffer, + Length = AcpiUtVsnprintf (AcpiGbl_PrintBuffer, sizeof (AcpiGbl_PrintBuffer), Format, Args); - (void) fwrite (AcpiGbl_PrintBuffer, Length, 1, File); + (void) AcpiOsWriteFile (File, AcpiGbl_PrintBuffer, Length, 1); AcpiOsReleaseLock (AcpiGbl_PrintLock, Flags); return (Length); @@ -949,7 +854,7 @@ vfprintf ( /******************************************************************************* * - * FUNCTION: fprintf + * FUNCTION: AcpiUtFilePrintf * * PARAMETERS: File - File descriptor * Format, ... - Standard printf format @@ -961,8 +866,8 @@ vfprintf ( ******************************************************************************/ int -fprintf ( - FILE *File, +AcpiUtFilePrintf ( + ACPI_FILE File, const char *Format, ...) { @@ -971,10 +876,9 @@ fprintf ( va_start (Args, Format); - Length = vfprintf (File, Format, Args); + Length = AcpiUtFileVprintf (File, Format, Args); va_end (Args); return (Length); } #endif -#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */ diff --git a/source/components/utilities/utxfinit.c b/source/components/utilities/utxfinit.c index 66834ac77..c6a26d992 100644 --- a/source/components/utilities/utxfinit.c +++ b/source/components/utilities/utxfinit.c @@ -126,11 +126,9 @@ ACPI_MODULE_NAME ("utxfinit") /* For AcpiExec only */ -#ifndef ACPI_DISABLE_OBJECT_OVERRIDE void AeDoObjectOverrides ( void); -#endif /******************************************************************************* @@ -348,13 +346,11 @@ 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/acapps.h b/source/include/acapps.h index f8b7bd0b3..b8ab5a3c6 100644 --- a/source/include/acapps.h +++ b/source/include/acapps.h @@ -116,6 +116,12 @@ #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" @@ -151,13 +157,13 @@ /* Macros for usage messages */ #define ACPI_USAGE_HEADER(Usage) \ - printf ("Usage: %s\nOptions:\n", Usage); + AcpiOsPrintf ("Usage: %s\nOptions:\n", Usage); #define ACPI_USAGE_TEXT(Description) \ - printf (Description); + AcpiOsPrintf (Description); #define ACPI_OPTION(Name, Description) \ - printf (" %-20s%s\n", Name, Description); + AcpiOsPrintf (" %-20s%s\n", Name, Description); /* Check for unexpected exceptions */ diff --git a/source/include/acclib.h b/source/include/acclib.h index bf32373dc..267c73d25 100644 --- a/source/include/acclib.h +++ b/source/include/acclib.h @@ -145,23 +145,6 @@ 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 */ @@ -175,16 +158,6 @@ 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, @@ -246,12 +219,6 @@ memcpy ( const void *Src, ACPI_SIZE Count); -void * -memmove ( - void *Dest, - const void *Src, - ACPI_SIZE Count); - void * memset ( void *Dest, @@ -269,127 +236,4 @@ 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 -#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; - -#ifndef EOF -#define EOF (-1) -#endif - -#define putchar(c) fputc(stdout, c) -#define getchar(c) fgetc(stdin) - -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, - ...); - -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); - -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/accommon.h b/source/include/accommon.h index 7e398b590..76f76d62f 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 */ -#if defined(ACPI_USE_SYSTEM_CLIBRARY) && !defined(ACPI_USE_STANDARD_HEADERS) +#ifndef ACPI_USE_SYSTEM_CLIBRARY #include "acclib.h" /* C library interfaces */ -#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */ +#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ #endif /* __ACCOMMON_H__ */ diff --git a/source/include/acpiosxf.h b/source/include/acpiosxf.h index 60d61f119..550e264bd 100644 --- a/source/include/acpiosxf.h +++ b/source/include/acpiosxf.h @@ -564,15 +564,6 @@ 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) @@ -633,4 +624,62 @@ 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 a641c4e2c..2f939b1f5 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -357,8 +357,6 @@ ACPI_GLOBAL (ACPI_TABLE_FADT, AcpiGbl_FADT); ACPI_GLOBAL (UINT32, AcpiCurrentGpeCount); ACPI_GLOBAL (BOOLEAN, AcpiGbl_SystemAwakeAndRunning); -ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DebugTimeout, FALSE); - /***************************************************************************** * @@ -1306,6 +1304,13 @@ 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 abc4f7b4c..039d71a5a 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -1459,6 +1459,16 @@ 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/include/acutils.h b/source/include/acutils.h index 358d1c8b7..3fdca4599 100644 --- a/source/include/acutils.h +++ b/source/include/acutils.h @@ -1139,6 +1139,48 @@ 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 4de3607b8..a252b2cd9 100644 --- a/source/include/platform/acefi.h +++ b/source/include/platform/acefi.h @@ -116,12 +116,10 @@ #ifndef __ACEFI_H__ #define __ACEFI_H__ -#ifdef __GNUC__ -#include "acgcc.h" -#endif - -#ifdef _MSC_VER -#include "acmsvc.h" +#include +#if defined(_GNU_EFI) +#include +#include #endif #if defined(__x86_64__) @@ -131,13 +129,23 @@ #endif #ifdef _MSC_EXTENSIONS -#define ACPI_EFI_API __cdecl +#define EFIAPI __cdecl #elif USE_MS_ABI -#define ACPI_EFI_API __attribute__((ms_abi)) +#define EFIAPI __attribute__((ms_abi)) #else -#define ACPI_EFI_API +#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__) @@ -158,24 +166,23 @@ #endif -#define UINTN uint64_t -#define INTN int64_t +typedef uint64_t UINTN; +typedef int64_t INTN; -#define ACPI_EFI_ERR(a) (0x8000000000000000 | a) +#define EFIERR(a) (0x8000000000000000 | a) #else #define ACPI_MACHINE_WIDTH 32 #define ACPI_USE_NATIVE_DIVIDE -#define UINTN uint32_t -#define INTN int32_t +typedef uint32_t UINTN; +typedef int32_t INTN; -#define ACPI_EFI_ERR(a) (0x80000000 | a) +#define EFIERR(a) (0x80000000 | a) #endif -#define CHAR16 uint16_t #ifdef USE_EFI_FUNCTION_WRAPPER #define __VA_NARG__(...) \ @@ -262,16 +269,6 @@ 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) @@ -305,21 +302,14 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, #if defined(_GNU_EFI) -#ifdef DEBUGGER_THREADING -#undef DEBUGGER_THREADING -#endif /* DEBUGGER_THREADING */ +/* Using GCC for GNU EFI */ -#define DEBUGGER_THREADING 0 /* integrated with DDB */ +#include "acgcc.h" +#undef ACPI_USE_SYSTEM_CLIBRARY #undef ACPI_USE_STANDARD_HEADERS #undef ACPI_USE_NATIVE_DIVIDE -#undef ACPI_USE_SYSTEM_INTTYPES - -/* AcpiExec configuration */ - -#ifdef ACPI_EXEC_APP -#define ACPI_DISABLE_OBJECT_OVERRIDE -#endif +#define ACPI_USE_SYSTEM_INTTYPES /* * Math helpers @@ -340,23 +330,18 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, #endif -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; +struct _SIMPLE_TEXT_OUTPUT_INTERFACE; +struct _SIMPLE_INPUT_INTERFACE; +struct _EFI_FILE_IO_INTERFACE; +struct _EFI_FILE_HANDLE; +struct _EFI_BOOT_SERVICES; +struct _EFI_SYSTEM_TABLE; -typedef union acpi_efi_file ACPI_EFI_FILE; +extern struct _EFI_SYSTEM_TABLE *ST; +extern struct _EFI_BOOT_SERVICES *BS; -#define FILE ACPI_EFI_FILE -#define stdout ((FILE *) (ST)->ConOut) -#define stderr ((FILE *) (ST)->ConOut) -#define stdin ((FILE *) (ST)->ConIn) +#define ACPI_FILE struct _SIMPLE_TEXT_OUTPUT_INTERFACE * +#define ACPI_FILE_OUT ST->ConOut +#define ACPI_FILE_ERR ST->ConOut #endif /* __ACEFI_H__ */ diff --git a/source/include/platform/acefiex.h b/source/include/platform/acefiex.h index aecb38e6c..1fc58f752 100644 --- a/source/include/platform/acefiex.h +++ b/source/include/platform/acefiex.h @@ -117,191 +117,177 @@ #define __ACEFIEX_H__ -#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; +#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; typedef struct { UINT32 Data1; UINT16 Data2; UINT16 Data3; UINT8 Data4[8]; -} ACPI_EFI_GUID; +} 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; -} ACPI_EFI_TIME; - -typedef struct _ACPI_EFI_DEVICE_PATH { +typedef struct _EFI_DEVICE_PATH { UINT8 Type; UINT8 SubType; UINT8 Length[2]; -} ACPI_EFI_DEVICE_PATH; +} EFI_DEVICE_PATH; -typedef UINT64 ACPI_EFI_PHYSICAL_ADDRESS; -typedef UINT64 ACPI_EFI_VIRTUAL_ADDRESS; +typedef UINT64 EFI_PHYSICAL_ADDRESS; +typedef UINT64 EFI_VIRTUAL_ADDRESS; typedef enum { - AcpiEfiAllocateAnyPages, - AcpiEfiAllocateMaxAddress, - AcpiEfiAllocateAddress, - AcpiEfiMaxAllocateType -} ACPI_EFI_ALLOCATE_TYPE; + AllocateAnyPages, + AllocateMaxAddress, + AllocateAddress, + MaxAllocateType +} EFI_ALLOCATE_TYPE; typedef enum { - AcpiEfiReservedMemoryType, - AcpiEfiLoaderCode, - AcpiEfiLoaderData, - AcpiEfiBootServicesCode, - AcpiEfiBootServicesData, - AcpiEfiRuntimeServicesCode, - AcpiEfiRuntimeServicesData, - AcpiEfiConventionalMemory, - AcpiEfiUnusableMemory, - AcpiEfiACPIReclaimMemory, - AcpiEfiACPIMemoryNVS, - AcpiEfiMemoryMappedIO, - AcpiEfiMemoryMappedIOPortSpace, - AcpiEfiPalCode, - AcpiEfiMaxMemoryType -} ACPI_EFI_MEMORY_TYPE; + EfiReservedMemoryType, + EfiLoaderCode, + EfiLoaderData, + EfiBootServicesCode, + EfiBootServicesData, + EfiRuntimeServicesCode, + EfiRuntimeServicesData, + EfiConventionalMemory, + EfiUnusableMemory, + EfiACPIReclaimMemory, + EfiACPIMemoryNVS, + EfiMemoryMappedIO, + EfiMemoryMappedIOPortSpace, + EfiPalCode, + EfiMaxMemoryType +} EFI_MEMORY_TYPE; /* possible caching types for the memory range */ -#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 +#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 /* physical memory protection on range */ -#define ACPI_EFI_MEMORY_WP 0x0000000000001000 -#define ACPI_EFI_MEMORY_RP 0x0000000000002000 -#define ACPI_EFI_MEMORY_XP 0x0000000000004000 +#define EFI_MEMORY_WP 0x0000000000001000 +#define EFI_MEMORY_RP 0x0000000000002000 +#define EFI_MEMORY_XP 0x0000000000004000 /* range requires a runtime mapping */ -#define ACPI_EFI_MEMORY_RUNTIME 0x8000000000000000 +#define EFI_MEMORY_RUNTIME 0x8000000000000000 -#define ACPI_EFI_MEMORY_DESCRIPTOR_VERSION 1 +#define EFI_MEMORY_DESCRIPTOR_VERSION 1 typedef struct { UINT32 Type; UINT32 Pad; - ACPI_EFI_PHYSICAL_ADDRESS PhysicalStart; - ACPI_EFI_VIRTUAL_ADDRESS VirtualStart; + EFI_PHYSICAL_ADDRESS PhysicalStart; + EFI_VIRTUAL_ADDRESS VirtualStart; UINT64 NumberOfPages; UINT64 Attribute; -} ACPI_EFI_MEMORY_DESCRIPTOR; +} EFI_MEMORY_DESCRIPTOR; -typedef struct _ACPI_EFI_TABLE_HEARDER { +typedef struct _EFI_TABLE_HEARDER { UINT64 Signature; UINT32 Revision; UINT32 HeaderSize; UINT32 CRC32; UINT32 Reserved; -} ACPI_EFI_TABLE_HEADER; +} EFI_TABLE_HEADER; typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_UNKNOWN_INTERFACE) ( +EFI_STATUS +(EFIAPI *EFI_UNKNOWN_INTERFACE) ( void); /* * Text output protocol */ -#define ACPI_SIMPLE_TEXT_OUTPUT_PROTOCOL \ +#define SIMPLE_TEXT_OUTPUT_PROTOCOL \ { 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_TEXT_RESET) ( - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, - BOOLEAN ExtendedVerification); +EFI_STATUS +(EFIAPI *EFI_TEXT_RESET) ( + struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + BOOLEAN ExtendedVerification); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_TEXT_OUTPUT_STRING) ( - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, - CHAR16 *String); +EFI_STATUS +(EFIAPI *EFI_TEXT_OUTPUT_STRING) ( + struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + CHAR16 *String); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_TEXT_TEST_STRING) ( - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, - CHAR16 *String); +EFI_STATUS +(EFIAPI *EFI_TEXT_TEST_STRING) ( + struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + CHAR16 *String); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_TEXT_QUERY_MODE) ( - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, - UINTN ModeNumber, - UINTN *Columns, - UINTN *Rows); +EFI_STATUS +(EFIAPI *EFI_TEXT_QUERY_MODE) ( + struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + UINTN ModeNumber, + UINTN *Columns, + UINTN *Rows); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_TEXT_SET_MODE) ( - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, - UINTN ModeNumber); +EFI_STATUS +(EFIAPI *EFI_TEXT_SET_MODE) ( + struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + UINTN ModeNumber); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_TEXT_SET_ATTRIBUTE) ( - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, - UINTN Attribute); +EFI_STATUS +(EFIAPI *EFI_TEXT_SET_ATTRIBUTE) ( + struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + UINTN Attribute); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_TEXT_CLEAR_SCREEN) ( - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This); +EFI_STATUS +(EFIAPI *EFI_TEXT_CLEAR_SCREEN) ( + struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_TEXT_SET_CURSOR_POSITION) ( - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, - UINTN Column, - UINTN Row); +EFI_STATUS +(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) ( + struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + UINTN Column, + UINTN Row); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_TEXT_ENABLE_CURSOR) ( - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This, - BOOLEAN Enable); +EFI_STATUS +(EFIAPI *EFI_TEXT_ENABLE_CURSOR) ( + struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This, + BOOLEAN Enable); typedef struct { INT32 MaxMode; @@ -310,35 +296,35 @@ typedef struct { INT32 CursorColumn; INT32 CursorRow; BOOLEAN CursorVisible; -} ACPI_SIMPLE_TEXT_OUTPUT_MODE; +} SIMPLE_TEXT_OUTPUT_MODE; -typedef struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE { - ACPI_EFI_TEXT_RESET Reset; +typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE { + EFI_TEXT_RESET Reset; - ACPI_EFI_TEXT_OUTPUT_STRING OutputString; - ACPI_EFI_TEXT_TEST_STRING TestString; + EFI_TEXT_OUTPUT_STRING OutputString; + EFI_TEXT_TEST_STRING TestString; - ACPI_EFI_TEXT_QUERY_MODE QueryMode; - ACPI_EFI_TEXT_SET_MODE SetMode; - ACPI_EFI_TEXT_SET_ATTRIBUTE SetAttribute; + EFI_TEXT_QUERY_MODE QueryMode; + EFI_TEXT_SET_MODE SetMode; + EFI_TEXT_SET_ATTRIBUTE SetAttribute; - ACPI_EFI_TEXT_CLEAR_SCREEN ClearScreen; - ACPI_EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition; - ACPI_EFI_TEXT_ENABLE_CURSOR EnableCursor; + EFI_TEXT_CLEAR_SCREEN ClearScreen; + EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition; + EFI_TEXT_ENABLE_CURSOR EnableCursor; - ACPI_SIMPLE_TEXT_OUTPUT_MODE *Mode; -} ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE; + SIMPLE_TEXT_OUTPUT_MODE *Mode; +} SIMPLE_TEXT_OUTPUT_INTERFACE; /* * Text input protocol */ -#define ACPI_SIMPLE_TEXT_INPUT_PROTOCOL \ +#define SIMPLE_TEXT_INPUT_PROTOCOL \ { 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } typedef struct { UINT16 ScanCode; CHAR16 UnicodeChar; -} ACPI_EFI_INPUT_KEY; +} EFI_INPUT_KEY; /* * Baseline unicode control chars @@ -350,463 +336,411 @@ typedef struct { #define CHAR_CARRIAGE_RETURN 0x000D typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_INPUT_RESET) ( - struct _ACPI_SIMPLE_INPUT_INTERFACE *This, +EFI_STATUS +(EFIAPI *EFI_INPUT_RESET) ( + struct _SIMPLE_INPUT_INTERFACE *This, BOOLEAN ExtendedVerification); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_INPUT_READ_KEY) ( - struct _ACPI_SIMPLE_INPUT_INTERFACE *This, - ACPI_EFI_INPUT_KEY *Key); +EFI_STATUS +(EFIAPI *EFI_INPUT_READ_KEY) ( + struct _SIMPLE_INPUT_INTERFACE *This, + EFI_INPUT_KEY *Key); -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; +typedef struct _SIMPLE_INPUT_INTERFACE { + EFI_INPUT_RESET Reset; + EFI_INPUT_READ_KEY ReadKeyStroke; + EFI_EVENT WaitForKey; +} SIMPLE_INPUT_INTERFACE; /* * Simple file system protocol */ -#define ACPI_SIMPLE_FILE_SYSTEM_PROTOCOL \ +#define SIMPLE_FILE_SYSTEM_PROTOCOL \ { 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_VOLUME_OPEN) ( - struct _ACPI_EFI_FILE_IO_INTERFACE *This, - struct _ACPI_EFI_FILE_HANDLE **Root); +EFI_STATUS +(EFIAPI *EFI_VOLUME_OPEN) ( + struct _EFI_FILE_IO_INTERFACE *This, + struct _EFI_FILE_HANDLE **Root); -#define ACPI_EFI_FILE_IO_INTERFACE_REVISION 0x00010000 +#define EFI_FILE_IO_INTERFACE_REVISION 0x00010000 -typedef struct _ACPI_EFI_FILE_IO_INTERFACE { +typedef struct _EFI_FILE_IO_INTERFACE { UINT64 Revision; - ACPI_EFI_VOLUME_OPEN OpenVolume; -} ACPI_EFI_FILE_IO_INTERFACE; + EFI_VOLUME_OPEN OpenVolume; +} EFI_FILE_IO_INTERFACE; typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_OPEN) ( - struct _ACPI_EFI_FILE_HANDLE *File, - struct _ACPI_EFI_FILE_HANDLE **NewHandle, +EFI_STATUS +(EFIAPI *EFI_FILE_OPEN) ( + struct _EFI_FILE_HANDLE *File, + struct _EFI_FILE_HANDLE **NewHandle, CHAR16 *FileName, UINT64 OpenMode, UINT64 Attributes); /* Values for OpenMode used above */ -#define ACPI_EFI_FILE_MODE_READ 0x0000000000000001 -#define ACPI_EFI_FILE_MODE_WRITE 0x0000000000000002 -#define ACPI_EFI_FILE_MODE_CREATE 0x8000000000000000 +#define EFI_FILE_MODE_READ 0x0000000000000001 +#define EFI_FILE_MODE_WRITE 0x0000000000000002 +#define EFI_FILE_MODE_CREATE 0x8000000000000000 /* Values for Attribute used above */ -#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 +#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 typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_CLOSE) ( - struct _ACPI_EFI_FILE_HANDLE *File); +EFI_STATUS +(EFIAPI *EFI_FILE_CLOSE) ( + struct _EFI_FILE_HANDLE *File); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_DELETE) ( - struct _ACPI_EFI_FILE_HANDLE *File); +EFI_STATUS +(EFIAPI *EFI_FILE_DELETE) ( + struct _EFI_FILE_HANDLE *File); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_READ) ( - struct _ACPI_EFI_FILE_HANDLE *File, +EFI_STATUS +(EFIAPI *EFI_FILE_READ) ( + struct _EFI_FILE_HANDLE *File, UINTN *BufferSize, VOID *Buffer); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_WRITE) ( - struct _ACPI_EFI_FILE_HANDLE *File, +EFI_STATUS +(EFIAPI *EFI_FILE_WRITE) ( + struct _EFI_FILE_HANDLE *File, UINTN *BufferSize, VOID *Buffer); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_SET_POSITION) ( - struct _ACPI_EFI_FILE_HANDLE *File, +EFI_STATUS +(EFIAPI *EFI_FILE_SET_POSITION) ( + struct _EFI_FILE_HANDLE *File, UINT64 Position); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_GET_POSITION) ( - struct _ACPI_EFI_FILE_HANDLE *File, +EFI_STATUS +(EFIAPI *EFI_FILE_GET_POSITION) ( + struct _EFI_FILE_HANDLE *File, UINT64 *Position); -#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; - ACPI_EFI_TIME CreateTime; - ACPI_EFI_TIME LastAccessTime; - ACPI_EFI_TIME ModificationTime; - UINT64 Attribute; - CHAR16 FileName[1]; -} ACPI_EFI_FILE_INFO; - -#define ACPI_EFI_FILE_INFO_SIZE \ - ACPI_OFFSET(ACPI_EFI_FILE_INFO, FileName) - typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_GET_INFO) ( - struct _ACPI_EFI_FILE_HANDLE *File, - ACPI_EFI_GUID *InformationType, +EFI_STATUS +(EFIAPI *EFI_FILE_GET_INFO) ( + struct _EFI_FILE_HANDLE *File, + EFI_GUID *InformationType, UINTN *BufferSize, VOID *Buffer); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_SET_INFO) ( - struct _ACPI_EFI_FILE_HANDLE *File, - ACPI_EFI_GUID *InformationType, +EFI_STATUS +(EFIAPI *EFI_FILE_SET_INFO) ( + struct _EFI_FILE_HANDLE *File, + EFI_GUID *InformationType, UINTN BufferSize, VOID *Buffer); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FILE_FLUSH) ( - struct _ACPI_EFI_FILE_HANDLE *File); +EFI_STATUS +(EFIAPI *EFI_FILE_FLUSH) ( + struct _EFI_FILE_HANDLE *File); -#define ACPI_EFI_FILE_HANDLE_REVISION 0x00010000 +#define EFI_FILE_HANDLE_REVISION 0x00010000 -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; +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; /* * Loaded image protocol */ -#define ACPI_EFI_LOADED_IMAGE_PROTOCOL \ +#define LOADED_IMAGE_PROTOCOL \ { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_IMAGE_ENTRY_POINT) ( - ACPI_EFI_HANDLE ImageHandle, - struct _ACPI_EFI_SYSTEM_TABLE *SystemTable); +EFI_STATUS +(EFIAPI *EFI_IMAGE_ENTRY_POINT) ( + EFI_HANDLE ImageHandle, + struct _EFI_SYSTEM_TABLE *SystemTable); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_IMAGE_LOAD) ( +EFI_STATUS +(EFIAPI *EFI_IMAGE_LOAD) ( BOOLEAN BootPolicy, - ACPI_EFI_HANDLE ParentImageHandle, - ACPI_EFI_DEVICE_PATH *FilePath, + EFI_HANDLE ParentImageHandle, + EFI_DEVICE_PATH *FilePath, VOID *SourceBuffer, UINTN SourceSize, - ACPI_EFI_HANDLE *ImageHandle); + EFI_HANDLE *ImageHandle); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_IMAGE_START) ( - ACPI_EFI_HANDLE ImageHandle, +EFI_STATUS +(EFIAPI *EFI_IMAGE_START) ( + EFI_HANDLE ImageHandle, UINTN *ExitDataSize, CHAR16 **ExitData); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_EXIT) ( - ACPI_EFI_HANDLE ImageHandle, - ACPI_EFI_STATUS ExitStatus, +EFI_STATUS +(EFIAPI *EFI_EXIT) ( + EFI_HANDLE ImageHandle, + EFI_STATUS ExitStatus, UINTN ExitDataSize, CHAR16 *ExitData); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_IMAGE_UNLOAD) ( - ACPI_EFI_HANDLE ImageHandle); - - -typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_STALL) ( - UINTN Microseconds); - -typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_SET_WATCHDOG_TIMER) ( - UINTN Timeout, - UINT64 WatchdogCode, - UINTN DataSize, - CHAR16 *WatchdogData); +EFI_STATUS +(EFIAPI *EFI_IMAGE_UNLOAD) ( + EFI_HANDLE ImageHandle); #define EFI_IMAGE_INFORMATION_REVISION 0x1000 typedef struct { UINT32 Revision; - ACPI_EFI_HANDLE ParentHandle; - struct _ACPI_EFI_SYSTEM_TABLE *SystemTable; - ACPI_EFI_HANDLE DeviceHandle; - ACPI_EFI_DEVICE_PATH *FilePath; + EFI_HANDLE ParentHandle; + struct _EFI_SYSTEM_TABLE *SystemTable; + EFI_HANDLE DeviceHandle; + EFI_DEVICE_PATH *FilePath; VOID *Reserved; UINT32 LoadOptionsSize; VOID *LoadOptions; VOID *ImageBase; UINT64 ImageSize; - ACPI_EFI_MEMORY_TYPE ImageCodeType; - ACPI_EFI_MEMORY_TYPE ImageDataType; - ACPI_EFI_IMAGE_UNLOAD Unload; + EFI_MEMORY_TYPE ImageCodeType; + EFI_MEMORY_TYPE ImageDataType; + EFI_IMAGE_UNLOAD Unload; -} ACPI_EFI_LOADED_IMAGE; +} EFI_LOADED_IMAGE; /* * EFI Memory */ typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_ALLOCATE_PAGES) ( - ACPI_EFI_ALLOCATE_TYPE Type, - ACPI_EFI_MEMORY_TYPE MemoryType, +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_PAGES) ( + EFI_ALLOCATE_TYPE Type, + EFI_MEMORY_TYPE MemoryType, UINTN NoPages, - ACPI_EFI_PHYSICAL_ADDRESS *Memory); + EFI_PHYSICAL_ADDRESS *Memory); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FREE_PAGES) ( - ACPI_EFI_PHYSICAL_ADDRESS Memory, +EFI_STATUS +(EFIAPI *EFI_FREE_PAGES) ( + EFI_PHYSICAL_ADDRESS Memory, UINTN NoPages); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_GET_MEMORY_MAP) ( +EFI_STATUS +(EFIAPI *EFI_GET_MEMORY_MAP) ( UINTN *MemoryMapSize, - ACPI_EFI_MEMORY_DESCRIPTOR *MemoryMap, + EFI_MEMORY_DESCRIPTOR *MemoryMap, UINTN *MapKey, UINTN *DescriptorSize, UINT32 *DescriptorVersion); -#define NextMemoryDescriptor(Ptr,Size) ((ACPI_EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size)) +#define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size)) typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_ALLOCATE_POOL) ( - ACPI_EFI_MEMORY_TYPE PoolType, +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_POOL) ( + EFI_MEMORY_TYPE PoolType, UINTN Size, VOID **Buffer); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_FREE_POOL) ( +EFI_STATUS +(EFIAPI *EFI_FREE_POOL) ( VOID *Buffer); -/* - * EFI Time - */ -typedef struct { - UINT32 Resolution; - UINT32 Accuracy; - BOOLEAN SetsToZero; -} ACPI_EFI_TIME_CAPABILITIES; - -typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_GET_TIME) ( - ACPI_EFI_TIME *Time, - ACPI_EFI_TIME_CAPABILITIES *Capabilities); - -typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_SET_TIME) ( - ACPI_EFI_TIME *Time); - - /* * Protocol handler functions */ typedef enum { - ACPI_EFI_NATIVE_INTERFACE, - ACPI_EFI_PCODE_INTERFACE -} ACPI_EFI_INTERFACE_TYPE; + EFI_NATIVE_INTERFACE, + EFI_PCODE_INTERFACE +} EFI_INTERFACE_TYPE; typedef enum { - AcpiEfiAllHandles, - AcpiEfiByRegisterNotify, - AcpiEfiByProtocol -} ACPI_EFI_LOCATE_SEARCH_TYPE; + AllHandles, + ByRegisterNotify, + ByProtocol +} EFI_LOCATE_SEARCH_TYPE; typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_INSTALL_PROTOCOL_INTERFACE) ( - ACPI_EFI_HANDLE *Handle, - ACPI_EFI_GUID *Protocol, - ACPI_EFI_INTERFACE_TYPE InterfaceType, +EFI_STATUS +(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) ( + EFI_HANDLE *Handle, + EFI_GUID *Protocol, + EFI_INTERFACE_TYPE InterfaceType, VOID *Interface); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_REINSTALL_PROTOCOL_INTERFACE) ( - ACPI_EFI_HANDLE Handle, - ACPI_EFI_GUID *Protocol, +EFI_STATUS +(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) ( + EFI_HANDLE Handle, + EFI_GUID *Protocol, VOID *OldInterface, VOID *NewInterface); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_UNINSTALL_PROTOCOL_INTERFACE) ( - ACPI_EFI_HANDLE Handle, - ACPI_EFI_GUID *Protocol, +EFI_STATUS +(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) ( + EFI_HANDLE Handle, + EFI_GUID *Protocol, VOID *Interface); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_HANDLE_PROTOCOL) ( - ACPI_EFI_HANDLE Handle, - ACPI_EFI_GUID *Protocol, +EFI_STATUS +(EFIAPI *EFI_HANDLE_PROTOCOL) ( + EFI_HANDLE Handle, + EFI_GUID *Protocol, VOID **Interface); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_REGISTER_PROTOCOL_NOTIFY) ( - ACPI_EFI_GUID *Protocol, - ACPI_EFI_EVENT Event, +EFI_STATUS +(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) ( + EFI_GUID *Protocol, + EFI_EVENT Event, VOID **Registration); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_LOCATE_HANDLE) ( - ACPI_EFI_LOCATE_SEARCH_TYPE SearchType, - ACPI_EFI_GUID *Protocol, +EFI_STATUS +(EFIAPI *EFI_LOCATE_HANDLE) ( + EFI_LOCATE_SEARCH_TYPE SearchType, + EFI_GUID *Protocol, VOID *SearchKey, UINTN *BufferSize, - ACPI_EFI_HANDLE *Buffer); + EFI_HANDLE *Buffer); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_LOCATE_DEVICE_PATH) ( - ACPI_EFI_GUID *Protocol, - ACPI_EFI_DEVICE_PATH **DevicePath, - ACPI_EFI_HANDLE *Device); +EFI_STATUS +(EFIAPI *EFI_LOCATE_DEVICE_PATH) ( + EFI_GUID *Protocol, + EFI_DEVICE_PATH **DevicePath, + EFI_HANDLE *Device); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_INSTALL_CONFIGURATION_TABLE) ( - ACPI_EFI_GUID *Guid, +EFI_STATUS +(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) ( + EFI_GUID *Guid, VOID *Table); -#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 +#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 typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_OPEN_PROTOCOL) ( - ACPI_EFI_HANDLE Handle, - ACPI_EFI_GUID *Protocol, +EFI_STATUS +(EFIAPI *EFI_OPEN_PROTOCOL) ( + EFI_HANDLE Handle, + EFI_GUID *Protocol, VOID **Interface, - ACPI_EFI_HANDLE AgentHandle, - ACPI_EFI_HANDLE ControllerHandle, + EFI_HANDLE AgentHandle, + EFI_HANDLE ControllerHandle, UINT32 Attributes); typedef -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); +EFI_STATUS +(EFIAPI *EFI_CLOSE_PROTOCOL) ( + EFI_HANDLE Handle, + EFI_GUID *Protocol, + EFI_HANDLE AgentHandle, + EFI_HANDLE ControllerHandle); typedef struct { - ACPI_EFI_HANDLE AgentHandle; - ACPI_EFI_HANDLE ControllerHandle; - UINT32 Attributes; - UINT32 OpenCount; -} ACPI_EFI_OPEN_PROTOCOL_INFORMATION_ENTRY; - -typedef -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, + EFI_HANDLE AgentHandle; + EFI_HANDLE ControllerHandle; + UINT32 Attributes; + UINT32 OpenCount; +} 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, UINTN *EntryCount); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_PROTOCOLS_PER_HANDLE) ( - ACPI_EFI_HANDLE Handle, - ACPI_EFI_GUID ***ProtocolBuffer, +EFI_STATUS +(EFIAPI *EFI_PROTOCOLS_PER_HANDLE) ( + EFI_HANDLE Handle, + EFI_GUID ***ProtocolBuffer, UINTN *ProtocolBufferCount); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_LOCATE_HANDLE_BUFFER) ( - ACPI_EFI_LOCATE_SEARCH_TYPE SearchType, - ACPI_EFI_GUID *Protocol, +EFI_STATUS +(EFIAPI *EFI_LOCATE_HANDLE_BUFFER) ( + EFI_LOCATE_SEARCH_TYPE SearchType, + EFI_GUID *Protocol, VOID *SearchKey, UINTN *NoHandles, - ACPI_EFI_HANDLE **Buffer); + EFI_HANDLE **Buffer); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_LOCATE_PROTOCOL) ( - ACPI_EFI_GUID *Protocol, +EFI_STATUS +(EFIAPI *EFI_LOCATE_PROTOCOL) ( + EFI_GUID *Protocol, VOID *Registration, VOID **Interface); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( - ACPI_EFI_HANDLE *Handle, +EFI_STATUS +(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( + EFI_HANDLE *Handle, ...); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( - ACPI_EFI_HANDLE Handle, +EFI_STATUS +(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( + EFI_HANDLE Handle, ...); typedef -ACPI_EFI_STATUS -(ACPI_EFI_API *ACPI_EFI_CALCULATE_CRC32) ( +EFI_STATUS +(EFIAPI *EFI_CALCULATE_CRC32) ( VOID *Data, UINTN DataSize, UINT32 *Crc32); typedef VOID -(ACPI_EFI_API *ACPI_EFI_COPY_MEM) ( +(EFIAPI *EFI_COPY_MEM) ( VOID *Destination, VOID *Source, UINTN Length); typedef VOID -(ACPI_EFI_API *ACPI_EFI_SET_MEM) ( +(EFIAPI *EFI_SET_MEM) ( VOID *Buffer, UINTN Size, UINT8 Value); @@ -814,143 +748,97 @@ VOID /* * EFI Boot Services Table */ -#define ACPI_EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 -#define ACPI_EFI_BOOT_SERVICES_REVISION (ACPI_EFI_SPECIFICATION_MAJOR_REVISION<<16) | (ACPI_EFI_SPECIFICATION_MINOR_REVISION) +#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 +#define EFI_BOOT_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) -typedef struct _ACPI_EFI_BOOT_SERVICES { - ACPI_EFI_TABLE_HEADER Hdr; +typedef struct _EFI_BOOT_SERVICES { + EFI_TABLE_HEADER Hdr; #if 0 - ACPI_EFI_RAISE_TPL RaiseTPL; - ACPI_EFI_RESTORE_TPL RestoreTPL; + EFI_RAISE_TPL RaiseTPL; + EFI_RESTORE_TPL RestoreTPL; #else - ACPI_EFI_UNKNOWN_INTERFACE RaiseTPL; - ACPI_EFI_UNKNOWN_INTERFACE RestoreTPL; + EFI_UNKNOWN_INTERFACE RaiseTPL; + EFI_UNKNOWN_INTERFACE RestoreTPL; #endif - 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; + EFI_ALLOCATE_PAGES AllocatePages; + EFI_FREE_PAGES FreePages; + EFI_GET_MEMORY_MAP GetMemoryMap; + EFI_ALLOCATE_POOL AllocatePool; + EFI_FREE_POOL FreePool; #if 0 - 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; + 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; #else - 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; + EFI_UNKNOWN_INTERFACE CreateEvent; + EFI_UNKNOWN_INTERFACE SetTimer; + EFI_UNKNOWN_INTERFACE WaitForEvent; + EFI_UNKNOWN_INTERFACE SignalEvent; + EFI_UNKNOWN_INTERFACE CloseEvent; + EFI_UNKNOWN_INTERFACE CheckEvent; #endif - 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; + 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; #if 0 - ACPI_EFI_EXIT_BOOT_SERVICES ExitBootServices; - ACPI_EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; + EFI_EXIT_BOOT_SERVICES ExitBootServices; + EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; + EFI_STALL Stall; + EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; #else - ACPI_EFI_UNKNOWN_INTERFACE ExitBootServices; - ACPI_EFI_UNKNOWN_INTERFACE GetNextMonotonicCount; + EFI_UNKNOWN_INTERFACE ExitBootServices; + EFI_UNKNOWN_INTERFACE GetNextMonotonicCount; + EFI_UNKNOWN_INTERFACE Stall; + EFI_UNKNOWN_INTERFACE SetWatchdogTimer; #endif - ACPI_EFI_STALL Stall; - ACPI_EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; #if 0 - ACPI_EFI_CONNECT_CONTROLLER ConnectController; - ACPI_EFI_DISCONNECT_CONTROLLER DisconnectController; + EFI_CONNECT_CONTROLLER ConnectController; + EFI_DISCONNECT_CONTROLLER DisconnectController; #else - ACPI_EFI_UNKNOWN_INTERFACE ConnectController; - ACPI_EFI_UNKNOWN_INTERFACE DisconnectController; + EFI_UNKNOWN_INTERFACE ConnectController; + EFI_UNKNOWN_INTERFACE DisconnectController; #endif - 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_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_CALCULATE_CRC32 CalculateCrc32; + EFI_CALCULATE_CRC32 CalculateCrc32; - ACPI_EFI_COPY_MEM CopyMem; - ACPI_EFI_SET_MEM SetMem; + EFI_COPY_MEM CopyMem; + EFI_SET_MEM SetMem; #if 0 - ACPI_EFI_CREATE_EVENT_EX CreateEventEx; + EFI_CREATE_EVENT_EX CreateEventEx; #else - ACPI_EFI_UNKNOWN_INTERFACE CreateEventEx; + EFI_UNKNOWN_INTERFACE CreateEventEx; #endif -} ACPI_EFI_BOOT_SERVICES; - - -/* - * EFI Runtime Services Table - */ -#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 _ACPI_EFI_RUNTIME_SERVICES { - ACPI_EFI_TABLE_HEADER Hdr; - - ACPI_EFI_GET_TIME GetTime; - ACPI_EFI_SET_TIME SetTime; -#if 0 - ACPI_EFI_GET_WAKEUP_TIME GetWakeupTime; - ACPI_EFI_SET_WAKEUP_TIME SetWakeupTime; -#else - ACPI_EFI_UNKNOWN_INTERFACE GetWakeupTime; - ACPI_EFI_UNKNOWN_INTERFACE SetWakeupTime; -#endif - -#if 0 - ACPI_EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap; - ACPI_EFI_CONVERT_POINTER ConvertPointer; -#else - ACPI_EFI_UNKNOWN_INTERFACE SetVirtualAddressMap; - ACPI_EFI_UNKNOWN_INTERFACE ConvertPointer; -#endif - -#if 0 - ACPI_EFI_GET_VARIABLE GetVariable; - ACPI_EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName; - ACPI_EFI_SET_VARIABLE SetVariable; -#else - ACPI_EFI_UNKNOWN_INTERFACE GetVariable; - ACPI_EFI_UNKNOWN_INTERFACE GetNextVariableName; - ACPI_EFI_UNKNOWN_INTERFACE SetVariable; -#endif - -#if 0 - ACPI_EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount; - ACPI_EFI_RESET_SYSTEM ResetSystem; -#else - ACPI_EFI_UNKNOWN_INTERFACE GetNextHighMonotonicCount; - ACPI_EFI_UNKNOWN_INTERFACE ResetSystem; -#endif - -} ACPI_EFI_RUNTIME_SERVICES; +} EFI_BOOT_SERVICES; /* @@ -960,51 +848,46 @@ typedef struct _ACPI_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 _ACPI_EFI_CONFIGURATION_TABLE { - ACPI_EFI_GUID VendorGuid; +typedef struct _EFI_CONFIGURATION_TABLE { + EFI_GUID VendorGuid; VOID *VendorTable; -} ACPI_EFI_CONFIGURATION_TABLE; +} EFI_CONFIGURATION_TABLE; -#define ACPI_EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 -#define ACPI_EFI_SYSTEM_TABLE_REVISION (ACPI_EFI_SPECIFICATION_MAJOR_REVISION<<16) | (ACPI_EFI_SPECIFICATION_MINOR_REVISION) +#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 +#define EFI_SYSTEM_TABLE_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) -typedef struct _ACPI_EFI_SYSTEM_TABLE { - ACPI_EFI_TABLE_HEADER Hdr; +typedef struct _EFI_SYSTEM_TABLE { + EFI_TABLE_HEADER Hdr; - CHAR16 *FirmwareVendor; - UINT32 FirmwareRevision; + CHAR16 *FirmwareVendor; + UINT32 FirmwareRevision; - ACPI_EFI_HANDLE ConsoleInHandle; - ACPI_SIMPLE_INPUT_INTERFACE *ConIn; + EFI_HANDLE ConsoleInHandle; + SIMPLE_INPUT_INTERFACE *ConIn; - ACPI_EFI_HANDLE ConsoleOutHandle; - ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut; + EFI_HANDLE ConsoleOutHandle; + SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut; - ACPI_EFI_HANDLE StandardErrorHandle; - ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr; - - ACPI_EFI_RUNTIME_SERVICES *RuntimeServices; - ACPI_EFI_BOOT_SERVICES *BootServices; - - UINTN NumberOfTableEntries; - ACPI_EFI_CONFIGURATION_TABLE *ConfigurationTable; - -} ACPI_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; -/* FILE abstraction */ + UINTN NumberOfTableEntries; + EFI_CONFIGURATION_TABLE *ConfigurationTable; -union acpi_efi_file { - struct _ACPI_EFI_FILE_IO_INTERFACE File; - struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE ConOut; - struct _ACPI_SIMPLE_INPUT_INTERFACE ConIn; -}; +} EFI_SYSTEM_TABLE; /* GNU EFI definitions */ @@ -1023,10 +906,10 @@ DivU64x32 ( /* * EFI specific prototypes */ -ACPI_EFI_STATUS +EFI_STATUS efi_main ( - ACPI_EFI_HANDLE Image, - ACPI_EFI_SYSTEM_TABLE *SystemTab); + EFI_HANDLE Image, + EFI_SYSTEM_TABLE *SystemTab); int acpi_main ( @@ -1036,10 +919,9 @@ acpi_main ( #endif -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; +extern EFI_GUID AcpiGbl_LoadedImageProtocol; +extern EFI_GUID AcpiGbl_TextInProtocol; +extern EFI_GUID AcpiGbl_TextOutProtocol; +extern EFI_GUID AcpiGbl_FileSystemProtocol; #endif /* __ACEFIEX_H__ */ diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index b5268b4e6..7a7245624 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -151,7 +151,6 @@ (defined ACPI_EXAMPLE_APP) #define ACPI_APPLICATION #define ACPI_SINGLE_THREADED -#define USE_NATIVE_ALLOCATE_ZEROED #endif /* iASL configuration */ @@ -198,6 +197,7 @@ #ifdef ACPI_DUMP_APP #define ACPI_USE_NATIVE_MEMORY_MAPPING +#define USE_NATIVE_ALLOCATE_ZEROED #endif /* AcpiNames/Example configuration. Hardware disabled */ @@ -288,9 +288,6 @@ #elif defined(_GNU_EFI) #include "acefi.h" -#elif defined(_EDK2_EFI) -#include "acefi.h" - #elif defined(__HAIKU__) #include "achaiku.h" @@ -425,48 +422,12 @@ #include #include #include -#ifdef ACPI_APPLICATION -#include -#include -#include -#include -#include -#endif - -#else /* ACPI_USE_STANDARD_HEADERS */ - -#ifdef ACPI_USE_COMPILER_VA - -/* - * 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 /* ACPI_USE_STANDARD_HEADERS */ -#endif /* va_arg */ +/* We will be linking to the standard Clib functions */ -#endif /* ACPI_USE_COMPILER_VA */ +#else /****************************************************************************** * @@ -474,19 +435,6 @@ typedef char *va_list; * *****************************************************************************/ -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 @@ -518,16 +466,17 @@ 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 -#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 /* ACPI_FILE */ #endif /* __ACENV_H__ */ diff --git a/source/include/platform/acgcc.h b/source/include/platform/acgcc.h index 773bd8959..3d36a38a3 100644 --- a/source/include/platform/acgcc.h +++ b/source/include/platform/acgcc.h @@ -116,10 +116,6 @@ #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 c948f6900..912773593 100644 --- a/source/include/platform/aclinux.h +++ b/source/include/platform/aclinux.h @@ -245,9 +245,11 @@ #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 a154c6745..133f449ef 100644 --- a/source/include/platform/acmsvc.h +++ b/source/include/platform/acmsvc.h @@ -174,10 +174,6 @@ #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 @@ -212,7 +208,6 @@ n_lo >>= 1; \ } #endif -#endif /* warn C4100: unreferenced formal parameter */ #pragma warning(disable:4100) @@ -230,10 +225,6 @@ #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/oseficlib.c b/source/os_specific/service_layers/oseficlib.c deleted file mode 100644 index acc5f7b8d..000000000 --- a/source/os_specific/service_layers/oseficlib.c +++ /dev/null @@ -1,1268 +0,0 @@ -/****************************************************************************** - * - * 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 - -#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 */ - -static int -AcpiEfiArgify ( - char *String, - int *ArgcPtr, - char ***ArgvPtr); - -static int -AcpiEfiConvertArgcv ( - CHAR16 *LoadOpt, - UINT32 LoadOptSize, - int *ArgcPtr, - char ***ArgvPtr, - char **BufferPtr); - -static int -AcpiEfiGetFileInfo ( - FILE *File, - ACPI_EFI_FILE_INFO **InfoPtr); - -static CHAR16 * -AcpiEfiFlushFile ( - FILE *File, - CHAR16 *Begin, - CHAR16 *End, - CHAR16 *Pos, - BOOLEAN FlushAll); - - -/* Local variables */ - -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; - - -/******************************************************************************* - * - * 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) -{ - ACPI_EFI_STATUS EfiStatus = ACPI_EFI_SUCCESS; - UINT64 OpenModes; - ACPI_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 = ACPI_EFI_FILE_MODE_READ; - switch (*Modes++) - { - case 'r': - - break; - - case 'w': - - OpenModes |= (ACPI_EFI_FILE_MODE_WRITE | ACPI_EFI_FILE_MODE_CREATE); - break; - - case 'a': - - OpenModes |= (ACPI_EFI_FILE_MODE_WRITE | ACPI_EFI_FILE_MODE_CREATE); - IsAppend = TRUE; - break; - - default: - - errno = EINVAL; - return (NULL); - } - - for (; *Modes; Modes++) - { - switch (*Modes) - { - case '+': - - OpenModes |= (ACPI_EFI_FILE_MODE_WRITE | ACPI_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 = ACPI_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 (ACPI_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) -{ - ACPI_EFI_FILE_HANDLE EfiFile; - - - if (File == stdin || File == stdout || - File == stderr) - { - return; - } - EfiFile = (ACPI_EFI_FILE_HANDLE) File; - (void) uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Close, 1, EfiFile); - - return; -} - - -/******************************************************************************* - * - * 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: 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 - * - * 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 = -EINVAL; - ACPI_EFI_FILE_HANDLE EfiFile; - ACPI_SIMPLE_INPUT_INTERFACE *In; - UINTN ReadSize; - ACPI_EFI_STATUS EfiStatus; - ACPI_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 (ACPI_SIMPLE_INPUT_INTERFACE, File); - - while (Pos < ReadSize) - { -WaitKey: - EfiStatus = uefi_call_wrapper (In->ReadKeyStroke, 2, In, &Key); - if (ACPI_EFI_ERROR (EfiStatus)) - { - if (EfiStatus == ACPI_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 - { - EfiFile = (ACPI_EFI_FILE_HANDLE) File; - if (!EfiFile) - { - errno = EINVAL; - goto ErrorExit; - } - - EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Read, 3, - EfiFile, &ReadSize, Buffer); - if (ACPI_EFI_ERROR (EfiStatus)) - { - fprintf (stderr, "EFI_FILE_HANDLE->Read() failure.\n"); - errno = EIO; - Length = -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) -{ - ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *Out; - - - if (File == stdout || File == stderr) - { - Out = ACPI_CAST_PTR (ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE, File); - - if (FlushAll || Pos >= (End - 1)) - { - *Pos = 0; - uefi_call_wrapper (Out->OutputString, 2, Out, 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 = -EINVAL; - CHAR16 String[ACPI_EFI_PRINT_LENGTH]; - const char *Ascii; - CHAR16 *End; - CHAR16 *Pos; - int i, j; - ACPI_EFI_FILE_HANDLE EfiFile; - UINTN WriteSize; - ACPI_EFI_STATUS EfiStatus; - - - 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; - 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 = (ACPI_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 (ACPI_EFI_ERROR (EfiStatus)) - { - fprintf (stderr, "EFI_FILE_HANDLE->Write() failure.\n"); - errno = EIO; - goto ErrorExit; - } - Length = WriteSize; - } - -ErrorExit: - - return (Length); -} - - -/******************************************************************************* - * - * 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, - ACPI_EFI_FILE_INFO **InfoPtr) -{ - 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) - { - errno = EINVAL; - return (-EINVAL); - } - - while (EfiStatus == ACPI_EFI_BUFFER_TOO_SMALL) - { - EfiFile = ACPI_CAST_PTR (ACPI_EFI_FILE_STRUCT, File); - Buffer = AcpiOsAllocate (BufferSize); - if (!Buffer) - { - errno = ENOMEM; - return (-ENOMEM); - } - EfiStatus = uefi_call_wrapper (EfiFile->GetInfo, 4, EfiFile, - &AcpiGbl_GenericFileInfo, &BufferSize, Buffer); - if (ACPI_EFI_ERROR (EfiStatus)) - { - AcpiOsFree (Buffer); - if (EfiStatus != ACPI_EFI_BUFFER_TOO_SMALL) - { - errno = EIO; - return (-EIO); - } - } - } - - *InfoPtr = Buffer; - return (0); -} - - -/******************************************************************************* - * - * FUNCTION: ftell - * - * PARAMETERS: File - File descriptor - * - * RETURN: current position - * - * DESCRIPTION: Get current file offset. - * - ******************************************************************************/ - -long -ftell ( - FILE *File) -{ - long Offset = -1; - UINT64 Current; - ACPI_EFI_STATUS EfiStatus; - ACPI_EFI_FILE_HANDLE EfiFile; - - - if (File == stdin || File == stdout || File == stderr) - { - Offset = 0; - } - else - { - EfiFile = ACPI_CAST_PTR (ACPI_EFI_FILE_STRUCT, File); - - EfiStatus = uefi_call_wrapper (EfiFile->GetPosition, 2, - EfiFile, &Current); - if (ACPI_EFI_ERROR (EfiStatus)) - { - goto ErrorExit; - } - else - { - Offset = (long) Current; - } - } - -ErrorExit: - 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) -{ - ACPI_EFI_FILE_INFO *Info; - int Error; - ACPI_SIZE Size; - UINT64 Current; - ACPI_EFI_STATUS EfiStatus; - ACPI_EFI_FILE_HANDLE EfiFile; - - - if (File == stdin || File == stdout || File == stderr) - { - return (0); - } - else - { - EfiFile = ACPI_CAST_PTR (ACPI_EFI_FILE_STRUCT, File); - Error = AcpiEfiGetFileInfo (File, &Info); - if (Error) - { - return (Error); - } - Size = Info->FileSize; - AcpiOsFree (Info); - - if (From == SEEK_CUR) - { - EfiStatus = uefi_call_wrapper (EfiFile->GetPosition, 2, - EfiFile, &Current); - if (ACPI_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 (ACPI_EFI_ERROR (EfiStatus)) - { - errno = ERANGE; - return (-ERANGE); - } - } - - return (0); -} - - -/****************************************************************************** - * - * 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 - * - *****************************************************************************/ - -ACPI_EFI_STATUS -efi_main ( - ACPI_EFI_HANDLE Image, - ACPI_EFI_SYSTEM_TABLE *SystemTab) -{ - ACPI_EFI_LOADED_IMAGE *Info; - ACPI_EFI_STATUS EfiStatus = ACPI_EFI_SUCCESS; - int Error; - int argc; - char **argv = NULL; - char *OptBuffer = NULL; - ACPI_EFI_FILE_IO_INTERFACE *Volume = NULL; - - - /* Initialize global variables */ - - ST = SystemTab; - BS = SystemTab->BootServices; - RT = SystemTab->RuntimeServices; - - /* 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, - Image, &AcpiGbl_LoadedImageProtocol, ACPI_CAST_PTR (VOID, &Info)); - if (ACPI_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 (ACPI_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 (ACPI_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 = ACPI_EFI_DEVICE_ERROR; - goto ErrorAlloc; - } - - acpi_main (argc, argv); - -ErrorAlloc: - - if (argv) - { - ACPI_FREE (argv); - } - if (OptBuffer) - { - ACPI_FREE (OptBuffer); - } - - 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 diff --git a/source/os_specific/service_layers/osefitbl.c b/source/os_specific/service_layers/osefitbl.c index 81bbdc76b..ec2161915 100644 --- a/source/os_specific/service_layers/osefitbl.c +++ b/source/os_specific/service_layers/osefitbl.c @@ -305,7 +305,18 @@ AcpiOsGetTableByName ( /* Not a main ACPI table, attempt to extract it from the RSDT/XSDT */ - Status = OslGetTable (Signature, Instance, Table, Address); + 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; + } return (Status); } @@ -378,7 +389,7 @@ OslAddTableToList ( { if (Instance) { - fprintf (stderr, + AcpiLogError ( "%4.4s: Warning unmatched table instance %d, expected %d\n", Signature, Instance, NextInstance); } @@ -639,47 +650,56 @@ OslTableInitialize ( return (Status); } - /* Add mandatory tables to global table list first */ - - Status = OslAddTableToList (ACPI_RSDP_NAME, 0); - if (ACPI_FAILURE (Status)) + if (!Gbl_DumpCustomizedTables) { - return (Status); - } + /* Add mandatory tables to global table list first */ - Status = OslAddTableToList (ACPI_SIG_RSDT, 0); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + Status = OslAddTableToList (ACPI_RSDP_NAME, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - if (Gbl_Revision == 2) - { - Status = OslAddTableToList (ACPI_SIG_XSDT, 0); + Status = OslAddTableToList (ACPI_SIG_RSDT, 0); if (ACPI_FAILURE (Status)) { return (Status); } - } - Status = OslAddTableToList (ACPI_SIG_DSDT, 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_FACS, 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); + } - /* Add all tables found in the memory */ + /* Add all tables found in the memory */ - Status = OslListTables (); - if (ACPI_FAILURE (Status)) + Status = OslListTables (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + else { - return (Status); + /* Add all tables found in the static directory */ + + Status = AE_SUPPORT; } Gbl_TableListInitialized = TRUE; @@ -1014,7 +1034,7 @@ OslMapTable ( MappedTable = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); if (!MappedTable) { - fprintf (stderr, "Could not map table header at 0x%8.8X%8.8X\n", + AcpiLogError ("Could not map table header at 0x%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Address)); return (AE_BAD_ADDRESS); } @@ -1050,7 +1070,7 @@ OslMapTable ( MappedTable = AcpiOsMapMemory (Address, Length); if (!MappedTable) { - fprintf (stderr, "Could not map table at 0x%8.8X%8.8X length %8.8X\n", + AcpiLogError ("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 bc6c99f85..fa111b508 100644 --- a/source/os_specific/service_layers/osefixf.c +++ b/source/os_specific/service_layers/osefixf.c @@ -121,25 +121,52 @@ ACPI_MODULE_NAME ("osefixf") -/* Upcalls to AcpiExec */ +/* Local definitions */ + +#define ACPI_EFI_PRINT_LENGTH 256 -void -AeTableOverride ( - ACPI_TABLE_HEADER *ExistingTable, - ACPI_TABLE_HEADER **NewTable); /* Local prototypes */ -#ifndef ACPI_USE_NATIVE_RSDP_POINTER +static ACPI_STATUS +AcpiEfiArgify ( + char *String, + int *ArgcPtr, + char ***ArgvPtr); static BOOLEAN AcpiEfiCompareGuid ( - ACPI_EFI_GUID *Guid1, - ACPI_EFI_GUID *Guid2); + 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 ( - ACPI_EFI_GUID *Guid); + 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; /****************************************************************************** @@ -157,8 +184,8 @@ AcpiEfiGetRsdpViaGuid ( static BOOLEAN AcpiEfiCompareGuid ( - ACPI_EFI_GUID *Guid1, - ACPI_EFI_GUID *Guid2) + EFI_GUID *Guid1, + EFI_GUID *Guid2) { INT32 *g1; INT32 *g2; @@ -191,7 +218,7 @@ AcpiEfiCompareGuid ( static ACPI_PHYSICAL_ADDRESS AcpiEfiGetRsdpViaGuid ( - ACPI_EFI_GUID *Guid) + EFI_GUID *Guid) { ACPI_PHYSICAL_ADDRESS Address = 0; int i; @@ -228,8 +255,8 @@ AcpiOsGetRootPointer ( void) { ACPI_PHYSICAL_ADDRESS Address; - ACPI_EFI_GUID Guid10 = ACPI_TABLE_GUID; - ACPI_EFI_GUID Guid20 = ACPI_20_TABLE_GUID; + EFI_GUID Guid10 = ACPI_TABLE_GUID; + EFI_GUID Guid20 = ACPI_20_TABLE_GUID; Address = AcpiEfiGetRsdpViaGuid (&Guid20); @@ -241,104 +268,6 @@ 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); -} - - -/****************************************************************************** - * - * 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); -} - /****************************************************************************** * @@ -389,7 +318,7 @@ AcpiOsUnmapMemory ( /****************************************************************************** * - * FUNCTION: Single threaded stub interfaces + * FUNCTION: Spinlock interfaces * * DESCRIPTION: No-op on single threaded BIOS * @@ -422,493 +351,434 @@ 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; -} - /****************************************************************************** * - * FUNCTION: AcpiOsInstallInterruptHandler + * FUNCTION: AcpiOsAllocate * - * PARAMETERS: InterruptNumber - Level handler should respond to. - * ServiceRoutine - Address of the ACPI interrupt handler - * Context - Where status is returned + * PARAMETERS: Size - Amount to allocate, in bytes * - * RETURN: Handle to the newly installed handler. + * RETURN: Pointer to the new allocation. Null on error. * - * DESCRIPTION: Install an interrupt handler. Used to install the ACPI - * OS-independent handler. + * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. * *****************************************************************************/ -UINT32 -AcpiOsInstallInterruptHandler ( - UINT32 InterruptNumber, - ACPI_OSD_HANDLER ServiceRoutine, - void *Context) +void * +AcpiOsAllocate ( + ACPI_SIZE Size) { + EFI_STATUS EfiStatus; + void *Mem; - 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) -{ + EfiStatus = uefi_call_wrapper (BS->AllocatePool, 3, + EfiLoaderData, Size, &Mem); + if (EFI_ERROR (EfiStatus)) + { + AcpiLogError ("EFI_BOOT_SERVICES->AllocatePool(EfiLoaderData) failure.\n"); + return (NULL); + } - return (AE_OK); + return (Mem); } +#ifdef USE_NATIVE_ALLOCATE_ZEROED /****************************************************************************** * - * FUNCTION: AcpiOsReadPciConfiguration + * FUNCTION: AcpiOsAllocateZeroed * - * PARAMETERS: PciId - Seg/Bus/Dev - * PciRegister - Device Register - * Value - Buffer where value is placed - * Width - Number of bits + * PARAMETERS: Size - Amount to allocate, in bytes * - * RETURN: Status + * RETURN: Pointer to the new allocation. Null on error. * - * DESCRIPTION: Read data from PCI configuration space + * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS. * *****************************************************************************/ -ACPI_STATUS -AcpiOsReadPciConfiguration ( - ACPI_PCI_ID *PciId, - UINT32 PciRegister, - UINT64 *Value, - UINT32 Width) +void * +AcpiOsAllocateZeroed ( + ACPI_SIZE Size) { + void *Mem; - *Value = 0; - return (AE_OK); + + Mem = AcpiOsAllocate (Size); + if (Mem) + { + memset (Mem, 0, Size); + } + + return (Mem); } +#endif /****************************************************************************** * - * FUNCTION: AcpiOsWritePciConfiguration + * FUNCTION: AcpiOsFree * - * PARAMETERS: PciId - Seg/Bus/Dev - * PciRegister - Device Register - * Value - Value to be written - * Width - Number of bits + * PARAMETERS: Mem - Pointer to previously allocated memory * - * RETURN: Status. + * RETURN: None * - * DESCRIPTION: Write data to PCI configuration space + * DESCRIPTION: Free memory allocated via AcpiOsAllocate * *****************************************************************************/ -ACPI_STATUS -AcpiOsWritePciConfiguration ( - ACPI_PCI_ID *PciId, - UINT32 PciRegister, - UINT64 Value, - UINT32 Width) +void +AcpiOsFree ( + void *Mem) { - return (AE_OK); + uefi_call_wrapper (BS->FreePool, 1, Mem); } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiOsReadPort + * FUNCTION: AcpiOsOpenFile * - * PARAMETERS: Address - Address of I/O port/register to read - * Value - Where value is placed - * Width - Number of bits + * PARAMETERS: Path - File path + * Modes - File operation type * - * RETURN: Value read from port + * RETURN: File descriptor * - * DESCRIPTION: Read data from an I/O port or register + * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing + * (ACPI_FILE_WRITING). * - *****************************************************************************/ + ******************************************************************************/ -ACPI_STATUS -AcpiOsReadPort ( - ACPI_IO_ADDRESS Address, - UINT32 *Value, - UINT32 Width) +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; - switch (Width) + + if (!Path) { - case 8: + return (NULL); + } - *Value = 0xFF; - break; + /* Convert modes */ - case 16: + OpenModes = EFI_FILE_MODE_READ; + if (Modes & ACPI_FILE_WRITING) + { + OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); + } - *Value = 0xFFFF; - break; + /* Allocate path buffer */ - case 32: + 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'; - *Value = 0xFFFFFFFF; - break; + 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; + } - default: +ErrorExit: - return (AE_BAD_PARAMETER); + if (Path16) + { + ACPI_FREE (Path16); } - return (AE_OK); + return ((ACPI_FILE) EfiFile); } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiOsWritePort + * FUNCTION: AcpiOsCloseFile * - * PARAMETERS: Address - Address of I/O port/register to write - * Value - Value to write - * Width - Number of bits + * PARAMETERS: File - File descriptor * - * RETURN: None + * RETURN: None. * - * DESCRIPTION: Write data to an I/O port or register + * DESCRIPTION: Close a file. * - *****************************************************************************/ + ******************************************************************************/ -ACPI_STATUS -AcpiOsWritePort ( - ACPI_IO_ADDRESS Address, - UINT32 Value, - UINT32 Width) +void +AcpiOsCloseFile ( + ACPI_FILE File) { - - return (AE_OK); -} + EFI_FILE_HANDLE EfiFile; -/****************************************************************************** - * - * 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) + if (File == ACPI_FILE_OUT || + File == ACPI_FILE_ERR) { - case 8: - case 16: - case 32: - case 64: - - *Value = 0; - break; - - default: - - return (AE_BAD_PARAMETER); + return; } - 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) -{ + EfiFile = (EFI_FILE_HANDLE) File; + (void) uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Close, 1, EfiFile); - return (AE_OK); + return; } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiOsGetTimer + * FUNCTION: AcpiOsReadFile * - * PARAMETERS: None + * PARAMETERS: File - File descriptor + * Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks * - * RETURN: Current time in 100 nanosecond units + * RETURN: Size of successfully read buffer * - * DESCRIPTION: Get the current system time + * DESCRIPTION: Read from a file. * - *****************************************************************************/ + ******************************************************************************/ -UINT64 -AcpiOsGetTimer ( - void) +int +AcpiOsReadFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count) { - ACPI_EFI_STATUS EfiStatus; - ACPI_EFI_TIME EfiTime; - int Year, Month, Day; - int Hour, Minute, Second; - UINT64 Timer; + int Length = -1; + EFI_FILE_HANDLE EfiFile; + UINTN ReadSize; + EFI_STATUS EfiStatus; - EfiStatus = uefi_call_wrapper (RT->GetTime, 2, &EfiTime, NULL); - if (ACPI_EFI_ERROR (EfiStatus)) + if (File == ACPI_FILE_OUT || + File == ACPI_FILE_ERR) { - 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)) + else { - /* Feb has leap days */ + EfiFile = (EFI_FILE_HANDLE) File; + if (!EfiFile) + { + goto ErrorExit; + } + ReadSize = Size * Count; - Month += 12; - Year -= 1; + 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; } - /* Calculate days */ - - Timer = ((UINT64) (Year/4 - Year/100 + Year/400 + 367*Month/12 + Day) + - Year*365 - 719499); +ErrorExit: - /* Calculate seconds */ - - Timer = ((Timer*24 + Hour) * 60 + Minute) * 60 + Second; - - /* Calculate 100 nanoseconds */ - - return ((Timer * ACPI_100NSEC_PER_SEC) + (EfiTime.Nanosecond / 100)); + return (Length); } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiOsStall + * FUNCTION: AcpiEfiFlushFile * - * PARAMETERS: microseconds - Time to sleep + * PARAMETERS: File - File descriptor + * Begin - String with boundary + * End - Boundary of the string + * Pos - Current position + * FlushAll - Whether checking boundary before flushing * - * RETURN: Blocks until sleep is completed. + * RETURN: Updated position * - * DESCRIPTION: Sleep at microsecond granularity + * DESCRIPTION: Flush cached buffer to the file. * - *****************************************************************************/ + ******************************************************************************/ -void -AcpiOsStall ( - UINT32 microseconds) +static CHAR16 * +AcpiEfiFlushFile ( + ACPI_FILE File, + CHAR16 *Begin, + CHAR16 *End, + CHAR16 *Pos, + BOOLEAN FlushAll) { - if (microseconds) + if (FlushAll || Pos >= (End - 1)) { - uefi_call_wrapper (BS->Stall, 1, microseconds); + *Pos = 0; + uefi_call_wrapper (File->OutputString, 2, File, Begin); + Pos = Begin; } -} - - -/****************************************************************************** - * - * 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); + return (Pos); } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiOsAllocate + * FUNCTION: AcpiOsWriteFile * - * PARAMETERS: Size - Amount to allocate, in bytes + * PARAMETERS: File - File descriptor + * Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks * - * RETURN: Pointer to the new allocation. Null on error. + * RETURN: Size of successfully written buffer * - * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. + * DESCRIPTION: Write to a file. * - *****************************************************************************/ + ******************************************************************************/ -void * -AcpiOsAllocate ( - ACPI_SIZE Size) +int +AcpiOsWriteFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count) { - ACPI_EFI_STATUS EfiStatus; - void *Mem; - + 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; - EfiStatus = uefi_call_wrapper (BS->AllocatePool, 3, - AcpiEfiLoaderData, Size, &Mem); - if (ACPI_EFI_ERROR (EfiStatus)) + 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 { - fprintf (stderr, - "EFI_BOOT_SERVICES->AllocatePool(EfiLoaderData) failure.\n"); - return (NULL); + 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; } - return (Mem); +ErrorExit: + + return (Length); } -#ifdef USE_NATIVE_ALLOCATE_ZEROED -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiOsAllocateZeroed + * FUNCTION: AcpiOsGetFileOffset * - * PARAMETERS: Size - Amount to allocate, in bytes + * PARAMETERS: File - File descriptor * - * RETURN: Pointer to the new allocation. Null on error. + * RETURN: Size of current position * - * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS. + * DESCRIPTION: Get current file offset. * - *****************************************************************************/ + ******************************************************************************/ -void * -AcpiOsAllocateZeroed ( - ACPI_SIZE Size) +long +AcpiOsGetFileOffset ( + ACPI_FILE File) { - void *Mem; + long Offset = -1; - Mem = AcpiOsAllocate (Size); - if (Mem) - { - memset (Mem, 0, Size); - } - - return (Mem); + return (Offset); } -#endif -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiOsFree + * FUNCTION: AcpiOsSetFileOffset * - * PARAMETERS: Mem - Pointer to previously allocated memory + * PARAMETERS: File - File descriptor + * Offset - File offset + * From - From begin/end of file * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Free memory allocated via AcpiOsAllocate + * DESCRIPTION: Set current file offset. * - *****************************************************************************/ + ******************************************************************************/ -void -AcpiOsFree ( - void *Mem) +ACPI_STATUS +AcpiOsSetFileOffset ( + ACPI_FILE File, + long Offset, + UINT8 From) { - uefi_call_wrapper (BS->FreePool, 1, Mem); + return (AE_SUPPORT); } @@ -957,19 +827,19 @@ AcpiOsVprintf ( va_list Args) { - (void) vfprintf (ACPI_FILE_OUT, Format, Args); + (void) AcpiUtFileVprintf (ACPI_FILE_OUT, Format, Args); } /****************************************************************************** * - * FUNCTION: AcpiOsInitialize, AcpiOsTerminate + * FUNCTION: AcpiOsInitialize * * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Initialize/terminate this module. + * DESCRIPTION: Initialize this module. * *****************************************************************************/ @@ -981,94 +851,313 @@ AcpiOsInitialize ( return (AE_OK); } -ACPI_STATUS -AcpiOsTerminate ( - void) -{ - - return (AE_OK); -} - /****************************************************************************** * - * FUNCTION: AcpiOsSignal + * FUNCTION: AcpiEfiArgify * - * PARAMETERS: Function - ACPI A signal function code - * Info - Pointer to function-dependent structure + * 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: Miscellaneous functions. Example implementation only. + * DESCRIPTION: Convert EFI arguments into C arguments. * *****************************************************************************/ -ACPI_STATUS -AcpiOsSignal ( - UINT32 Function, - void *Info) +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; - switch (Function) - { - case ACPI_SIGNAL_FATAL: - - break; - - case ACPI_SIGNAL_BREAKPOINT: - break; + if (String == NULL) + { + return (AE_BAD_PARAMETER); + } - default: + CopyBuffer = String; - break; + 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; } - return (AE_OK); + *ArgcPtr = Argc; + *ArgvPtr = Argv; + + return ((MaxArgc < Argc) ? AE_NO_MEMORY : AE_OK); } /****************************************************************************** * - * FUNCTION: AcpiOsReadable + * FUNCTION: AcpiEfiConvertArgcv * - * PARAMETERS: Pointer - Area to be verified - * Length - Size of area + * 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: TRUE if readable for entire length + * RETURN: Status * - * DESCRIPTION: Verify that a pointer is valid for reading + * DESCRIPTION: Convert EFI arguments into C arguments. * *****************************************************************************/ -BOOLEAN -AcpiOsReadable ( - void *Pointer, - ACPI_SIZE Length) +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; + - return (TRUE); + /* 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: AcpiOsWritable + * FUNCTION: efi_main * - * PARAMETERS: Pointer - Area to be verified - * Length - Size of area + * PARAMETERS: Image - EFI image handle + * SystemTab - EFI system table * - * RETURN: TRUE if writable for entire length + * RETURN: EFI Status * - * DESCRIPTION: Verify that a pointer is valid for writing + * DESCRIPTION: Entry point of EFI executable * *****************************************************************************/ -BOOLEAN -AcpiOsWritable ( - void *Pointer, - ACPI_SIZE Length) +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 (TRUE); + return (EfiStatus); } diff --git a/source/os_specific/service_layers/oslibcfs.c b/source/os_specific/service_layers/oslibcfs.c new file mode 100644 index 000000000..26c1a8fed --- /dev/null +++ b/source/os_specific/service_layers/oslibcfs.c @@ -0,0 +1,330 @@ +/****************************************************************************** + * + * 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/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c index f04b59e65..c3a66d7b3 100644 --- a/source/os_specific/service_layers/osunixxf.c +++ b/source/os_specific/service_layers/osunixxf.c @@ -136,6 +136,9 @@ 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 07f284492..78a0526c4 100644 --- a/source/os_specific/service_layers/oswinxf.c +++ b/source/os_specific/service_layers/oswinxf.c @@ -172,6 +172,9 @@ 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/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h index 5d6ed795c..76843da28 100644 --- a/source/tools/acpidump/acpidump.h +++ b/source/tools/acpidump/acpidump.h @@ -128,6 +128,12 @@ #include "accommon.h" #include "actables.h" +#include +#include +#include +#include + + /* Globals */ EXTERN BOOLEAN INIT_GLOBAL (Gbl_SummaryMode, FALSE); @@ -139,6 +145,12 @@ 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/apdump.c b/source/tools/acpidump/apdump.c index 68065d733..783060080 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -148,7 +148,7 @@ ApIsValidHeader ( if (!AcpiUtValidNameseg (Table->Signature)) { - fprintf (stderr, "Table signature (0x%8.8X) is invalid\n", + AcpiLogError ("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)) { - fprintf (stderr, "Table length (0x%8.8X) is invalid\n", + AcpiLogError ("Table length (0x%8.8X) is invalid\n", Table->Length); return (FALSE); } @@ -203,7 +203,7 @@ ApIsValidChecksum ( if (ACPI_FAILURE (Status)) { - fprintf (stderr, "%4.4s: Warning: wrong checksum in table\n", + AcpiLogError ("%4.4s: Warning: wrong checksum in table\n", Table->Signature); } @@ -295,13 +295,13 @@ ApDumpTableBuffer ( * Note: simplest to just always emit a 64-bit address. AcpiXtract * utility can handle this. */ - fprintf (Gbl_OutputFile, "%4.4s @ 0x%8.8X%8.8X\n", + AcpiUtFilePrintf (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); - fprintf (Gbl_OutputFile, "\n"); + AcpiUtFilePrintf (Gbl_OutputFile, "\n"); return (0); } @@ -346,13 +346,13 @@ ApDumpAllTables ( } else if (i == 0) { - fprintf (stderr, "Could not get ACPI tables, %s\n", + AcpiLogError ("Could not get ACPI tables, %s\n", AcpiFormatException (Status)); return (-1); } else { - fprintf (stderr, "Could not get ACPI table at index %u, %s\n", + AcpiLogError ("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)) { - fprintf (stderr, "%s: Could not convert to a physical address\n", + AcpiLogError ("%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)) { - fprintf (stderr, "Could not get table at 0x%8.8X%8.8X, %s\n", + AcpiLogError ("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) { - fprintf (stderr, + AcpiLogError ( "Invalid table signature [%s]: must be exactly 4 characters\n", Signature); return (-1); @@ -487,7 +487,7 @@ ApDumpTableByName ( return (0); } - fprintf (stderr, + AcpiLogError ( "Could not get ACPI table with signature [%s], %s\n", LocalSignature, AcpiFormatException (Status)); return (-1); @@ -539,7 +539,7 @@ ApDumpTableFromFile ( if (!AcpiUtValidNameseg (Table->Signature)) { - fprintf (stderr, + AcpiLogError ( "No valid ACPI signature was found in input file %s\n", Pathname); } @@ -548,7 +548,7 @@ ApDumpTableFromFile ( if (Table->Length > FileSize) { - fprintf (stderr, + AcpiLogError ( "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) { - fprintf (stderr, + AcpiLogError ( "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 ad02f6d03..9394e98cf 100644 --- a/source/tools/acpidump/apfiles.c +++ b/source/tools/acpidump/apfiles.c @@ -146,7 +146,7 @@ ApIsExistingFile ( if (!stat (Pathname, &StatInfo)) { - fprintf (stderr, "Target path already exists, overwrite? [y|n] "); + AcpiLogError ("Target path already exists, overwrite? [y|n] "); if (getchar () != 'y') { @@ -188,10 +188,10 @@ ApOpenOutputFile ( /* Point stdout to the file */ - File = fopen (Pathname, "w"); + File = AcpiOsOpenFile (Pathname, ACPI_FILE_WRITING); if (!File) { - fprintf (stderr, "Could not open output file: %s\n", Pathname); + AcpiLogError ("Could not open output file: %s\n", Pathname); return (-1); } @@ -225,7 +225,7 @@ ApWriteToBinaryFile ( char Filename[ACPI_NAME_SIZE + 16]; char InstanceStr [16]; ACPI_FILE File; - ACPI_SIZE Actual; + size_t Actual; UINT32 TableLength; @@ -254,7 +254,7 @@ ApWriteToBinaryFile ( if (Instance > 0) { - snprintf (InstanceStr, sizeof (InstanceStr), "%u", Instance); + AcpiUtSnprintf (InstanceStr, sizeof (InstanceStr), "%u", Instance); strcat (Filename, InstanceStr); } @@ -262,29 +262,30 @@ ApWriteToBinaryFile ( if (Gbl_VerboseMode) { - fprintf (stderr, + AcpiLogError ( "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 = fopen (Filename, "wb"); + File = AcpiOsOpenFile (Filename, + ACPI_FILE_WRITING | ACPI_FILE_BINARY); if (!File) { - fprintf (stderr, "Could not open output file: %s\n", Filename); + AcpiLogError ("Could not open output file: %s\n", Filename); return (-1); } - Actual = fwrite (Table, 1, TableLength, File); + Actual = AcpiOsWriteFile (File, Table, 1, TableLength); if (Actual != TableLength) { - fprintf (stderr, "Error writing binary output file: %s\n", Filename); - fclose (File); + AcpiLogError ("Error writing binary output file: %s\n", Filename); + AcpiOsCloseFile (File); return (-1); } - fclose (File); + AcpiOsCloseFile (File); return (0); } @@ -310,15 +311,15 @@ ApGetTableFromFile ( ACPI_TABLE_HEADER *Buffer = NULL; ACPI_FILE File; UINT32 FileSize; - ACPI_SIZE Actual; + size_t Actual; /* Must use binary mode */ - File = fopen (Pathname, "rb"); + File = AcpiOsOpenFile (Pathname, ACPI_FILE_READING | ACPI_FILE_BINARY); if (!File) { - fprintf (stderr, "Could not open input file: %s\n", Pathname); + AcpiLogError ("Could not open input file: %s\n", Pathname); return (NULL); } @@ -327,7 +328,7 @@ ApGetTableFromFile ( FileSize = CmGetFileSize (File); if (FileSize == ACPI_UINT32_MAX) { - fprintf (stderr, + AcpiLogError ( "Could not get input file size: %s\n", Pathname); goto Cleanup; } @@ -337,17 +338,18 @@ ApGetTableFromFile ( Buffer = ACPI_ALLOCATE_ZEROED (FileSize); if (!Buffer) { - fprintf (stderr, + AcpiLogError ( "Could not allocate file buffer of size: %u\n", FileSize); goto Cleanup; } /* Read the entire file */ - Actual = fread (Buffer, 1, FileSize, File); + Actual = AcpiOsReadFile (File, Buffer, 1, FileSize); if (Actual != FileSize) { - fprintf (stderr, "Could not read input file: %s\n", Pathname); + AcpiLogError ( + "Could not read input file: %s\n", Pathname); ACPI_FREE (Buffer); Buffer = NULL; goto Cleanup; @@ -356,6 +358,6 @@ ApGetTableFromFile ( *OutFileSize = FileSize; Cleanup: - fclose (File); + AcpiOsCloseFile (File); return (Buffer); } diff --git a/source/tools/acpidump/apmain.c b/source/tools/acpidump/apmain.c index 0e0e5b218..cfe0c3261 100644 --- a/source/tools/acpidump/apmain.c +++ b/source/tools/acpidump/apmain.c @@ -233,7 +233,7 @@ ApInsertAction ( CurrentAction++; if (CurrentAction > AP_MAX_ACTIONS) { - fprintf (stderr, "Too many table options (max %u)\n", AP_MAX_ACTIONS); + AcpiLogError ("Too many table options (max %u)\n", AP_MAX_ACTIONS); return (-1); } @@ -287,7 +287,7 @@ ApDoOptions ( } else { - fprintf (stderr, "%s: Cannot handle this switch, please use on|off\n", + AcpiLogError ("%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)) { - fprintf (stderr, "%s: Could not convert to a physical address\n", + AcpiLogError ("%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; - fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); + AcpiLogError (ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); continue; /* @@ -427,7 +427,6 @@ acpi_main ( ACPI_DEBUG_INITIALIZE (); /* For debug version only */ AcpiOsInitialize (); Gbl_OutputFile = ACPI_FILE_OUT; - AcpiGbl_IntegerByteWidth = 8; /* Process command line options */ @@ -470,7 +469,7 @@ acpi_main ( default: - fprintf (stderr, "Internal error, invalid action: 0x%X\n", + AcpiLogError ("Internal error, invalid action: 0x%X\n", Action->ToBeDone); return (-1); } @@ -488,11 +487,11 @@ acpi_main ( /* Summary for the output file */ FileSize = CmGetFileSize (Gbl_OutputFile); - fprintf (stderr, "Output file %s contains 0x%X (%u) bytes\n\n", + AcpiLogError ("Output file %s contains 0x%X (%u) bytes\n\n", Gbl_OutputFilename, FileSize, FileSize); } - fclose (Gbl_OutputFile); + AcpiOsCloseFile (Gbl_OutputFile); } return (Status); diff --git a/source/tools/acpiexec/aecommon.h b/source/tools/acpiexec/aecommon.h index aaa7f9099..12199b04c 100644 --- a/source/tools/acpiexec/aecommon.h +++ b/source/tools/acpiexec/aecommon.h @@ -131,6 +131,11 @@ #include "amlresrc.h" #include "acapps.h" +#include +#include +#include +#include + /* * Debug Regions @@ -168,11 +173,9 @@ 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 c3d0a7db8..f08ffbe8e 100644 --- a/source/tools/acpiexec/aehandlers.c +++ b/source/tools/acpiexec/aehandlers.c @@ -192,12 +192,10 @@ 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 @@ -234,7 +232,6 @@ AeCtrlCHandler ( (void) AcpiOsTerminate (); exit (0); } -#endif /****************************************************************************** diff --git a/source/tools/acpiexec/aeinitfile.c b/source/tools/acpiexec/aeinitfile.c index 996cc8e9c..57c20dce0 100644 --- a/source/tools/acpiexec/aeinitfile.c +++ b/source/tools/acpiexec/aeinitfile.c @@ -122,8 +122,6 @@ /* Local prototypes */ -#ifndef ACPI_DISABLE_OBJECT_OVERRIDE - static void AeDoOneOverride ( char *Pathname, @@ -160,8 +158,7 @@ AeOpenInitializationFile ( InitFile = fopen (Filename, "r"); if (!InitFile) { - fprintf (stderr, - "Could not open initialization file: %s\n", Filename); + perror ("Could not open initialization file"); return (-1); } @@ -306,5 +303,3 @@ 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 b153121fe..a645ffa27 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -114,6 +114,7 @@ *****************************************************************************/ #include "aecommon.h" +#include "errno.h" #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("aemain") @@ -130,6 +131,7 @@ * Windows: The setargv.obj module must be linked in to automatically * expand wildcards. */ +extern BOOLEAN AcpiGbl_DebugTimeout; /* Local prototypes */ @@ -396,12 +398,10 @@ AeDoOptions ( return (-1); } -#ifndef ACPI_DISABLE_OBJECT_OVERRIDE if (AeOpenInitializationFile (AcpiGbl_Optarg)) { return (-1); } -#endif break; default: @@ -519,17 +519,10 @@ AeDoOptions ( * *****************************************************************************/ -#ifndef _GNU_EFI int ACPI_SYSTEM_XFACE main ( int argc, - char *argv[]) -#else -int ACPI_SYSTEM_XFACE -acpi_main ( - int argc, - char *argv[]) -#endif + char **argv) { ACPI_NEW_TABLE_DESC *ListHead = NULL; ACPI_STATUS Status; @@ -538,9 +531,7 @@ acpi_main ( ACPI_DEBUG_INITIALIZE (); /* For debug version only */ -#ifndef _GNU_EFI signal (SIGINT, AeCtrlCHandler); -#endif /* Init debug globals */ -- cgit v1.2.1