public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Akira Moroo" <retrage01@gmail.com>
To: devel@edk2.groups.io
Cc: afish@apple.com, ray.ni@intel.com, Akira Moroo <retrage01@gmail.com>
Subject: [RFC PATCH 4/4] EmulatorPkg: Add AArch64 Unix host build support
Date: Sun, 10 Oct 2021 00:49:18 +0900	[thread overview]
Message-ID: <7d717f2a0250a073f8738a200f1a95970e9ea1fd.1633789833.git.retrage01@gmail.com> (raw)
In-Reply-To: <cover.1633789833.git.retrage01@gmail.com>

This commit adds AArch64 Unix host build support for EmulatorPkg.

Signed-off-by: Akira Moroo <retrage01@gmail.com>
---
 EmulatorPkg/EmulatorPkg.dsc    | 15 ++++++++++++---
 EmulatorPkg/Readme.md          |  8 ++++++++
 EmulatorPkg/Unix/Host/Host.inf |  5 +++++
 EmulatorPkg/build.sh           |  8 ++++++++
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 554c13ddb5..91d0176fc7 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -19,7 +19,7 @@
   DSC_SPECIFICATION              = 0x00010005
   OUTPUT_DIRECTORY               = Build/Emulator$(ARCH)
 
-  SUPPORTED_ARCHITECTURES        = X64|IA32
+  SUPPORTED_ARCHITECTURES        = X64|IA32|AARCH64
   BUILD_TARGETS                  = DEBUG|RELEASE|NOOPT
   SKUID_IDENTIFIER               = DEFAULT
   FLASH_DEFINITION               = EmulatorPkg/EmulatorPkg.fdf
@@ -138,6 +138,13 @@
   AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
 
+[LibraryClasses.AARCH64]
+  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
+  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+  CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
+  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
+
 [LibraryClasses.common.SEC]
   PeiServicesLib|EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
@@ -209,8 +216,10 @@
   TimerLib|EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.inf
 
 [PcdsFeatureFlag]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst|FALSE
+
+[PcdsFeatureFlag.IA32,PcdsFeatureFlag.X64]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables|FALSE
 
 [PcdsFixedAtBuild]
@@ -288,7 +297,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|10
 
 [Components]
-!if "IA32" in $(ARCH) || "X64" in $(ARCH)
+!if "IA32" in $(ARCH) || "X64" in $(ARCH) || "AARCH64" in $(ARCH)
   !if "MSFT" in $(FAMILY) || $(WIN_HOST_BUILD) == TRUE
     ##
     #  Emulator, OS WIN application
diff --git a/EmulatorPkg/Readme.md b/EmulatorPkg/Readme.md
index 0c2eea6a9a..e3d0b58578 100644
--- a/EmulatorPkg/Readme.md
+++ b/EmulatorPkg/Readme.md
@@ -35,6 +35,10 @@ https://github.com/tianocore/tianocore.github.io/wiki/EmulatorPkg
 
     `build -p EmulatorPkg\EmulatorPkg.dsc -t GCC5 -a X64`
 
+  * AArch64 emulator in Linux:
+
+    `build -p EmulatorPkg\EmulatorPkg.dsc -t GCC5 -a AARCH64`
+
 **You can start/run the emulator using the following command:**
   * 32bit emulator in Windows:
 
@@ -52,6 +56,10 @@ https://github.com/tianocore/tianocore.github.io/wiki/EmulatorPkg
 
     `cd Build/EmulatorX64/DEBUG_GCC5/X64/ && ./Host`
 
+  * AArch64 emulator in Linux:
+
+    `cd Build/EmulatorAARCH64/DEBUG_GCC5/AARCH64/ && ./Host`
+
 **On posix-like environment with the bash shell you can use EmulatorPkg/build.sh to simplify building and running
 emulator.**
 
diff --git a/EmulatorPkg/Unix/Host/Host.inf b/EmulatorPkg/Unix/Host/Host.inf
index 43cb55aa21..fe4c6d511c 100644
--- a/EmulatorPkg/Unix/Host/Host.inf
+++ b/EmulatorPkg/Unix/Host/Host.inf
@@ -129,6 +129,11 @@
    GCC:*_*_X64_PP_FLAGS == -m64 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
    GCC:*_*_X64_ASM_FLAGS == -m64 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
 
+   GCC:*_*_AARCH64_DLINK_FLAGS == -fPIC -flto -o $(BIN_DIR)/Host -L/usr/X11R6/lib
+   GCC:*_*_AARCH64_ASM_FLAGS == -g -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
+   GCC:*_*_AARCH64_PP_FLAGS == -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+   GCC:*_*_AARCH64_CC_FLAGS == -c -O0 -g -fPIC -fshort-wchar -fno-strict-aliasing -idirafter/usr/include -include $(DEST_DIR_DEBUG)/AutoGen.h -DUSING_LTO -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
+
    GCC:*_*_*_DLINK2_FLAGS == -lpthread -ldl -lXext -lX11
 
 #
diff --git a/EmulatorPkg/build.sh b/EmulatorPkg/build.sh
index 76c22dfaf8..e2ce1b8e18 100755
--- a/EmulatorPkg/build.sh
+++ b/EmulatorPkg/build.sh
@@ -83,6 +83,9 @@ case `uname` in
       x86_64)
         HOST_PROCESSOR=X64
         ;;
+      aarch64)
+        HOST_PROCESSOR=AARCH64
+        ;;
     esac
 
     gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
@@ -174,6 +177,11 @@ case $PROCESSOR in
     LIB_NAMES="ld-linux-x86-64.so.2 libdl.so.2 crt1.o crti.o crtn.o"
     LIB_SEARCH_PATHS="/usr/lib/x86_64-linux-gnu /usr/lib64 /lib64 /usr/lib /lib"
     ;;
+  AARCH64)
+    ARCH_SIZE=64
+    LIB_NAMES="ld-linux-aarch64.so.1 libdl.so.2 crt1.o crti.o crtn.o"
+    LIB_SEARCH_PATHS="/usr/lib/aarch64-linux-gnu /usr/lib /lib"
+    ;;
 esac
 
 for libname in $LIB_NAMES
-- 
2.33.0


      parent reply	other threads:[~2021-10-09 15:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-09 15:49 [RFC PATCH 0/4] EmulatorPkg AArch64 Linux support retrage01
2021-10-09 15:49 ` [RFC PATCH 1/4] EmulatorPkg/Unix/Host: Fix typo Akira Moroo
2021-10-09 15:49 ` [RFC PATCH 2/4] EmulatorPkg/Sec: Add AArch64 support Akira Moroo
2021-10-09 15:49 ` [RFC PATCH 3/4] EmulatorPkg/Unix/Host: " Akira Moroo
2021-10-09 15:49 ` Akira Moroo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d717f2a0250a073f8738a200f1a95970e9ea1fd.1633789833.git.retrage01@gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox