Andrew Fish
2015-07-16 05:02:44 UTC
Hi, I'm circling back.
I found some time to get the acpidump to compilr on edk2. Sorry I donât have time to debug it, or even run it, but maybe some one else could take it on (I can answer some questions on the mailing list to help out). I can also explain the changes I made to acpica if that is going to be required to push them upstream.Go to https://acpica.org/downloads <https://acpica.org/downloads> and download aspia-unix-20150619.tar
I copied to acpica/ in the root of the edk2 master as of today.
I had to mod the acpica code to add _EDK2_EFI #define to get the code to compile under the edk2. I also had to re-order a #if define() #elif tree as __APPLE__ is turned on by Xcode and this forced OS includes into the build. We need to check for the non OS targets 1st. I also had to port acpidump to use the acpica min-stdlib, and not system includes (there could be a better way to do this?).
~/work/src/edk2(acpica)>cat acpica.patch
diff --git a/acpica/source/common/cmfsize.c b/acpica/source/common/cmfsize.c
index 1e8de3c..d33fd43 100644
--- a/acpica/source/common/cmfsize.c
+++ b/acpica/source/common/cmfsize.c
@@ -116,7 +116,9 @@
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
+#if !defined(_EDK2_EFI)
#include <stdio.h>
+#endif
#define _COMPONENT ACPI_TOOLS
ACPI_MODULE_NAME ("cmfsize")
diff --git a/acpica/source/include/platform/acefi.h b/acpica/source/include/platform/acefi.h
index b7e8d6a..7c34bc8 100644
--- a/acpica/source/include/platform/acefi.h
+++ b/acpica/source/include/platform/acefi.h
@@ -116,6 +116,8 @@
#ifndef __ACEFI_H__
#define __ACEFI_H__
+#ifndef _EDK2_EFI
+
#include <stdarg.h>
#if defined(_GNU_EFI)
#include <stdint.h>
@@ -344,4 +346,63 @@ extern struct _EFI_BOOT_SERVICES *BS;
#define ACPI_FILE_OUT ST->ConOut
#define ACPI_FILE_ERR ST->ConOut
+#else
+
+#include <Library/UefiBootServicesTableLib.h>
+
+// Don't redefine all the stuff in acefiex.h
+#include <Protocol/SimpleFileSystem.h>
+#include <Protocol/SimpleTextIn.h>
+#include <Protocol/LoadedImage.h>
+
+#include <Guid/Acpi.h>
+
+#undef ACPI_USE_SYSTEM_CLIBRARY
+#undef ACPI_USE_STANDARD_HEADERS
+#undef ACPI_USE_NATIVE_DIVIDE
+
+#define ST gST
+#define BS gBS
+
+#define ACPI_FILE SIMPLE_TEXT_OUTPUT_INTERFACE *
+#define ACPI_FILE_OUT ST->ConOut
+#define ACPI_FILE_ERR ST->ConOut
+
+#if defined(MDE_CPU_ARM) || defined(MDE_CPU_IA32)
+#define ACPI_MACHINE_WIDTH 32
+#else
+#define ACPI_MACHINE_WIDTH 64
+#endif
+
+typedef UINTN size_t;
+
+#define ACPI_20_TABLE_GUID EFI_ACPI_20_TABLE_GUID
+#define SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID
+#define SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID
+#define SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
+#define LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE_PROTOCOL_GUID
+#define ST gST
+#define BS gBS
+
+#define ACPI_FILE SIMPLE_TEXT_OUTPUT_INTERFACE *
+#define ACPI_FILE_OUT ST->ConOut
+#define ACPI_FILE_ERR ST->ConOut
+
+#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__)
+
+/*
+ * EFI specific prototypes
+ */
+EFI_STATUS
+efi_main (
+ EFI_HANDLE Image,
+ EFI_SYSTEM_TABLE *SystemTab);
+
+int
+acpi_main (
+ int argc,
+ char *argv[]);
+
+#endif
+
#endif /* __ACEFI_H__ */
diff --git a/acpica/source/include/platform/acenv.h b/acpica/source/include/platform/acenv.h
index 4e5fc15..0187ce8 100644
--- a/acpica/source/include/platform/acenv.h
+++ b/acpica/source/include/platform/acenv.h
@@ -244,6 +244,16 @@
#if defined(_LINUX) || defined(__linux__)
#include "aclinux.h"
+// __APPL__ is turned on by clang, so we need to check user cross targets 1st.
+#elif defined(_AED_EFI)
+#include "acefi.h"
+
+#elif defined(_GNU_EFI)
+#include "acefi.h"
+
+#elif defined(_EDK2_EFI)
+#include "acefi.h"
+
#elif defined(_APPLE) || defined(__APPLE__)
#include "acmacosx.h"
@@ -280,12 +290,6 @@
#elif defined(__OS2__)
#include "acos2.h"
-#elif defined(_AED_EFI)
-#include "acefi.h"
-
-#elif defined(_GNU_EFI)
-#include "acefi.h"
-
#elif defined(__HAIKU__)
#include "achaiku.h"
diff --git a/acpica/source/tools/acpidump/acpidump.h b/acpica/source/tools/acpidump/acpidump.h
index 194bc4b..639fb78 100644
--- a/acpica/source/tools/acpidump/acpidump.h
+++ b/acpica/source/tools/acpidump/acpidump.h
@@ -128,11 +128,12 @@
#include "accommon.h"
#include "actables.h"
+#if !defined(_EDK2_EFI)
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
-
+#endif
/* Globals */
diff --git a/acpica/source/tools/acpidump/apfiles.c b/acpica/source/tools/acpidump/apfiles.c
index 39f80e0..08fcc1d 100644
--- a/acpica/source/tools/acpidump/apfiles.c
+++ b/acpica/source/tools/acpidump/apfiles.c
@@ -128,7 +128,7 @@ static int
ApIsExistingFile (
char *Pathname)
{
-#ifndef _GNU_EFI
+#if !defined(_GNU_EFI) && !defined(_EDK2_EFI)
struct stat StatInfo;
diff --git a/acpica/source/tools/acpidump/apmain.c b/acpica/source/tools/acpidump/apmain.c
index e4bcd34..1bb6c65 100644
--- a/acpica/source/tools/acpidump/apmain.c
+++ b/acpica/source/tools/acpidump/apmain.c
@@ -405,7 +405,7 @@ ApDoOptions (
*
******************************************************************************/
-#ifndef _GNU_EFI
+#if !defined(_GNU_EFI) && !defined(_EDK2_EFI)
int ACPI_SYSTEM_XFACE
main (
int argc,
Add the new files: acpica.dec, acpica.dsc, and acpidump.inf to the root of the new acpica/ directory:
~/work/src/edk2/acpica(acpica)>cat acpica.dec
## @file acpica.dec
# Package for ACPI CA.
#
# Mostly deals with include paths
#
# Copyright (c)2015, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License that 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]
DEC_SPECIFICATION = 0x00010005
PACKAGE_NAME = acpica
PACKAGE_GUID = 5FAA9961-2741-11E5-A457-C82A145113CC
PACKAGE_VERSION = 0.01
[Includes]
# acpica paths
source/include
source/include/platform
source/tools/acpidump
~/work/src/edk2/acpica(acpica)>cat acpica.dsc
## @file ~/work/src/edk2/acpica(acpica)>cat acpica.dec
## @file MdeModulePkg.dec
# Package for ACPI CA.
#
# Mostly deals with include paths
#
# Copyright (c)2015, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License that 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]
DEC_SPECIFICATION = 0x00010005
PACKAGE_NAME = acpica
PACKAGE_GUID = 5FAA9961-2741-11E5-A457-C82A145113CC
PACKAGE_VERSION = 0.01
[Includes]
# acpica paths
source/include
source/include/platform
source/tools/acpidump
~/work/src/edk2/acpica(acpica)>cat acpica.dsc
## @file MdeModulePkg.dsc
# DSC for ACPI CA.
#
# Map edk2 things needed by acpidump
#
# Copyright (c)2015, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License that 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]
PLATFORM_NAME = acpica
PLATFORM_GUID = 76248985-2742-11E5-B5DE-C82A145113CC
PLATFORM_VERSION = 0.01
DSC_SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/acpica
SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC|ARM|AARCH64
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
[LibraryClasses]
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
# Needed by UefiApplicationEntryPoint
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
[Components]
acpica/acpidump.inf
~/work/src/edk2/acpica(acpica)>cat acpidump.inf
## @file
# edk2 port of acpidump from
# https://acpica.org/sites/acpica/files/acpica-unix-20150619.tar.gz
#
# Copyright (c) 2015, Apple Inc. All rights reserved.<BR>
#
# 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 = 6987936E-ED34-44db-AE97-1FA5E4ED2116
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = efi_main
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
source/tools/acpidump/apdump.c
source/tools/acpidump/apfiles.c
source/tools/acpidump/apdump.c
source/tools/acpidump/apfiles.c
source/tools/acpidump/apmain.c
source/common/cmfsize.c
source/common/getopt.c
source/os_specific/service_layers/osefitbl.c
source/os_specific/service_layers/osefixf.c
source/components/tables/tbprint.c
source/components/tables/tbxfroot.c
source/components/utilities/utbuffer.c
source/components/utilities/utdebug.c
source/components/utilities/utclib.c
source/components/utilities/utexcep.c
source/components/utilities/utglobal.c
source/components/utilities/utmath.c
source/components/utilities/utprint.c
source/components/utilities/utstring.c
source/components/utilities/utxferror.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
acpica/acpica.dec
[LibraryClasses]
UefiApplicationEntryPoint
UefiBootServicesTableLib
[BuildOptions]
GCC: *_*_*_CC_FLAGS = -D_EDK2_EFI -DACPI_DUMP_APP -DACPI_USE_SYSTEM_INTTYPES -Wno-unused-function -Wno-unused-const-variable
~/work/src/edk2/acpica(acpica)>
# DSC for ACPI CA.
#
# Mostly deals with include paths
#
# Copyright (c)2015, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License that 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]
PLATFORM_NAME = acpica
PLATFORM_GUID = 76248985-2742-11E5-B5DE-C82A145113CC
PLATFORM_VERSION = 0.01
DSC_SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/acpica
SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC|ARM|AARCH64
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
[LibraryClasses]
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
# Needed by UefiApplicationEntryPoint
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
[Components]
acpica/acpidump.inf
~/work/src/edk2/acpica(acpica)>cat acpidump.inf
## @file
# edk2 port of acpidump from
# https://acpica.org/sites/acpica/files/acpica-unix-20150619.tar.gz
#
# Copyright (c) 2015, Apple Inc. All rights reserved.<BR>
#
# 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 = 6987936E-ED34-44db-AE97-1FA5E4ED2116
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = efi_main
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
source/tools/acpidump/apdump.c
source/tools/acpidump/apfiles.c
source/tools/acpidump/apdump.c
source/tools/acpidump/apfiles.c
source/tools/acpidump/apmain.c
source/common/cmfsize.c
source/common/getopt.c
source/os_specific/service_layers/osefitbl.c
source/os_specific/service_layers/osefixf.c
source/components/tables/tbprint.c
source/components/tables/tbxfroot.c
source/components/utilities/utbuffer.c
source/components/utilities/utdebug.c
source/components/utilities/utclib.c
source/components/utilities/utexcep.c
source/components/utilities/utglobal.c
source/components/utilities/utmath.c
source/components/utilities/utprint.c
source/components/utilities/utstring.c
source/components/utilities/utxferror.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
acpica/acpica.dec
[LibraryClasses]
UefiApplicationEntryPoint
UefiBootServicesTableLib
[BuildOptions]
GCC: *_*_*_CC_FLAGS = -D_EDK2_EFI -DACPI_DUMP_APP -DACPI_USE_SYSTEM_INTTYPES -Wno-unused-function -Wno-unused-const-variable
~/work/src/edk2(acpica)>. edksetup.sh BaseTools
~/work/src/edk2(acpica)>build -p acpica/acpica.dsc -a X64 -t XCODE5
This compiles for me with Xcode 6.4 on a Mac. Probably will just work for gcc, and likely to work for VC++ after the acpidump.inf [BuildOptions] section is updated to support VC++. You just need to change the -t, tools target in the build command to give it a try.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrew Fish <***@apple.com <mailto:***@apple.com>>
Thanks,
Andrew Fish
PS Tried to attach this stuff as files, but the mailing list kept rejecting meâŠ.