Skip to content

Commit

Permalink
EFI: Port acpidump to EDK2 environment
Browse files Browse the repository at this point in the history
This patch adds necessary build files for EDK2 environment to build ACPICA
tools.
The command steps of building edk2 binaries are (if you are using gcc4.7):
  # cd edk2
  # . ./edksetup.sh
  # ln -s <path to acpica> AcpiPkg
  # AcpiPkg/generate/efi/edksetup.sh
  # build -p AcpiPkg/AcpiPkg.dsc -t GCC47
Note the above build test was done in Linux, and the Windows hasn't been
tested when this patch is generated. For building edk2 binaries in the MSVC
environment, you need to modify acpidump.inf, adding necessary options when
they cannot pass the build in the following configure items:
MSFT:*_*_IA32_CC_FLAGS/MSFT:*_*_X64_CC_FLAGS. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Jul 22, 2016
1 parent a9dfb44 commit 790b8ba
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 2 deletions.
25 changes: 25 additions & 0 deletions generate/efi/AcpiPkg.dec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## @file
# Build description file to ACPICA applications.
#
# Copyright (c) 2009 - 2011, Intel Corporation. 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]
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 }}
46 changes: 46 additions & 0 deletions generate/efi/AcpiPkg.dsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#/** @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
59 changes: 59 additions & 0 deletions generate/efi/acpidump/acpidump.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## @file
# acpidump.inf
#
# Copyright (c) 2016, Intel Corporation. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = acpidump
FILE_GUID = bf942c9a-2942-11e6-9a64-0024e8c6d30e
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = UefiMain

[Sources]
tools/acpidump/apdump.c
tools/acpidump/apfiles.c
tools/acpidump/apmain.c
common/cmfsize.c
common/getopt.c
os_specific/service_layers/oseficlib.c
os_specific/service_layers/osefitbl.c
os_specific/service_layers/osefixf.c
components/tables/tbprint.c
components/tables/tbxfroot.c
components/utilities/utascii.c
components/utilities/utbuffer.c
components/utilities/utclib.c
components/utilities/utdebug.c
components/utilities/utexcep.c
components/utilities/utglobal.c
components/utilities/utmath.c
components/utilities/utnonansi.c
components/utilities/utprint.c
components/utilities/utstring.c
components/utilities/utxferror.c

[Packages]
AcpiPkg/AcpiPkg.dec
MdePkg/MdePkg.dec

[LibraryClasses]
UefiApplicationEntryPoint
BaseLib

[BuildOptions]
MSFT:*_*_IA32_CC_FLAGS = /Oi- /WX- /D_EDK2_EFI /DACPI_DUMP_APP
MSFT:*_*_X64_CC_FLAGS = /Oi- /WX- /D_EDK2_EFI /DACPI_DUMP_APP
GCC:*_*_IA32_CC_FLAGS = -U__linux__ -U_LINUX -D_EDK2_EFI -DACPI_DUMP_APP -fno-builtin -iwithprefix include
GCC:*_*_X64_CC_FLAGS = -U__linux__ -U_LINUX -D_EDK2_EFI -DACPI_DUMP_APP -fno-builtin -iwithprefix include
14 changes: 14 additions & 0 deletions generate/efi/edksetup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

EFIPROGS="acpidump"

EFIDIR=`(cd \`dirname $0\`; pwd)`
TOPDIR=`(cd ${EFIDIR}/../..; pwd)`

echo "Copying AcpiPkg package files..."
cp -f ${EFIDIR}/AcpiPkg.dec ${TOPDIR}/AcpiPkg.dec
cp -f ${EFIDIR}/AcpiPkg.dsc ${TOPDIR}/AcpiPkg.dsc
for p in ${EFIPROGS}; do
echo "Copying $p build files..."
cp -f ${EFIDIR}/$p/${p}.inf ${TOPDIR}/source/${p}.inf
done
8 changes: 8 additions & 0 deletions source/include/platform/acefi.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@
#ifndef __ACEFI_H__
#define __ACEFI_H__

/* EDK2 EFI environemnt */

#if defined(_EDK2_EFI)

#define _GNU_EFI

#endif

#ifdef __GNUC__
#include "acgcc.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion source/include/platform/acenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
* included after including all other host environmental definitions, in
* order to override the definitions.
*/
#elif defined(_AED_EFI) || defined(_GNU_EFI)
#elif defined(_AED_EFI) || defined(_GNU_EFI) || defined(_EDK2_EFI)
#include "acefi.h"

#else
Expand Down
2 changes: 1 addition & 1 deletion source/include/platform/acenvex.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
* included after including all other host environmental definitions, in
* order to override the definitions.
*/
#elif defined(_AED_EFI) || defined(_GNU_EFI)
#elif defined(_AED_EFI) || defined(_GNU_EFI) || defined(_EDK2_EFI)
#include "acefiex.h"

#endif
Expand Down
5 changes: 5 additions & 0 deletions source/include/platform/acmsvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@
#define ACPI_INTERNAL_XFACE
#define ACPI_INTERNAL_VAR_XFACE __cdecl


/* Do not maintain the architecture specific stuffs for the EFI ports */

#if !defined(_EDK2_EFI) && !defined(_GNU_EFI)
#ifndef _LINT
/*
* Math helper functions
Expand Down Expand Up @@ -212,6 +216,7 @@
n_lo >>= 1; \
}
#endif
#endif

/* warn C4100: unreferenced formal parameter */
#pragma warning(disable:4100)
Expand Down
20 changes: 20 additions & 0 deletions source/os_specific/service_layers/oseficlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,3 +878,23 @@ efi_main (

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

0 comments on commit 790b8ba

Please sign in to comment.