Skip to content

Commit

Permalink
Add Windows ARM 64-bit base tools (#376)
Browse files Browse the repository at this point in the history
# Preface

Please ensure you have read the [contribution
docs](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md) prior
to submitting the pull request. In particular,
[pull request
guidelines](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md#pull-request-best-practices).

## Description

This change is a part of
#305 feature work.

The change expanded the accepted target architecture for VS builds with
`AARCH64` option, which will output native Windows ARM64 binaries.

Note that the warnings due to integer conversions are suppressed for
this specific target to avoid too much local changes carried in MU. The
formal change should drop all these binaries and move to pythonic
scripts.

For each item, place an "x" in between `[` and `]` if true. Example:
`[x]`.
_(you can also check items in the GitHub UI)_

- [x] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

This was tested on Windows ARM64 hardware systems.

## Integration Instructions

N/A
  • Loading branch information
kuqin12 authored Apr 26, 2023
1 parent fef5df9 commit 4face87
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 18 deletions.
10 changes: 8 additions & 2 deletions .azurepipelines/BaseTools-Build-For-Publication.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ name: BaseTools_Bin_$(release_version)_$(Rev:r)
variables:
linux_build_output_path: '$(Build.Repository.LocalPath)/BaseTools/Source/C/bin'
linux_artifact_name: 'LinuxOutput'
windows_build_output_path: '$(Build.Repository.LocalPath)\BaseTools\Bin\Win32'
windows_build_output_path: '$(Build.Repository.LocalPath)\BaseTools\Bin'
windows_artifact_name: 'WindowsOutput'
temp_publication_directory: 'PackageStaging'
package_artifact_name: 'NugetReleasePackage'
Expand Down Expand Up @@ -86,8 +86,13 @@ jobs:
matrix:
TARGET_x86:
Build.Targets: 'IA32'
Build.TargetFolder: 'Win32'
TARGET_ARM:
Build.Targets: 'ARM'
Build.TargetFolder: 'Win32'
TARGET_AArch64:
Build.Targets: 'AARCH64'
Build.TargetFolder: 'Win64'

pool:
vmImage: windows-latest
Expand Down Expand Up @@ -126,7 +131,7 @@ jobs:
extra_parameters: '--skip_path_env -a $(Build.Targets)'
tool_chain_tag: 'VS2022'

- publish: $(windows_build_output_path)
- publish: '$(windows_build_output_path)\$(Build.TargetFolder)'
artifact: $(windows_artifact_name)_$(Build.Targets)
displayName: Publish To Pipeline
condition: SucceededOrFailed()
Expand Down Expand Up @@ -188,6 +193,7 @@ jobs:
mv $(Pipeline.Workspace)/$(linux_artifact_name)_AARCH64 $(Build.StagingDirectory)/$(temp_publication_directory)/Linux-ARM-64;
mv $(Pipeline.Workspace)/$(windows_artifact_name)_IA32 $(Build.StagingDirectory)/$(temp_publication_directory)/Windows-x86;
mv $(Pipeline.Workspace)/$(windows_artifact_name)_ARM $(Build.StagingDirectory)/$(temp_publication_directory)/Windows-ARM;
mv $(Pipeline.Workspace)/$(windows_artifact_name)_AARCH64 $(Build.StagingDirectory)/$(temp_publication_directory)/Windows-ARM-64;
displayName: Stage Package Files

- powershell:
Expand Down
3 changes: 2 additions & 1 deletion BaseTools/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ Source/C/VfrCompile/VfrTokens.h
Source/C/bin/
Source/C/libs/
Bin/Win32
Bin/Win64
Lib
BaseToolsBuild/
BaseToolsBuild/
12 changes: 11 additions & 1 deletion BaseTools/Edk2ToolsBuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,19 @@ def Go(self):
if self.target_arch == "IA32":
VcToolChainArch = "x86"
TargetInfoArch = "x86"
OutputDir = "Win32"
elif self.target_arch == "ARM":
VcToolChainArch = "x86_arm"
TargetInfoArch = "ARM"
OutputDir = "Win32"
elif self.target_arch == "X64":
VcToolChainArch = "amd64"
TargetInfoArch = "x86"
OutputDir = "Win64"
elif self.target_arch == "AARCH64":
VcToolChainArch = "amd64_arm64"
TargetInfoArch = "ARM"
OutputDir = "Win64"
else:
raise NotImplementedError()
# MU_CHANGE
Expand All @@ -166,7 +176,7 @@ def Go(self):
shell_env.set_shell_var('HOST_ARCH', self.target_arch)

self.OutputDir = os.path.join(
shell_env.get_shell_var("EDK_TOOLS_PATH"), "Bin", "Win32")
shell_env.get_shell_var("EDK_TOOLS_PATH"), "Bin", OutputDir)

# compiled tools need to be added to path because antlr is referenced
# MU_CHANGE: Added logic to support cross compilation scenarios
Expand Down
83 changes: 70 additions & 13 deletions BaseTools/Source/C/Include/AArch64/ProcessorBind.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,82 @@
#pragma pack()
#endif

// MU_CHANGE Starts: Fixing basic ARM definitions in Windows
#if _MSC_EXTENSIONS

//
// Disable warning that make it impossible to compile at /W4
// This only works for Microsoft* tools
//

//
// Disabling bitfield type checking warnings.
//
#pragma warning ( disable : 4214 )

//
// Disabling the unreferenced formal parameter warnings.
//
#pragma warning ( disable : 4100 )

//
// Disable slightly different base types warning as CHAR8 * can not be set
// to a constant string.
//
#pragma warning ( disable : 4057 )

//
// ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
//
#pragma warning ( disable : 4127 )


#endif

#if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)
//
// use Microsoft* C compiler dependent integer width types
// No ANSI C 2000 stdint.h integer width declarations, so define equivalents
//
typedef unsigned __int64 UINT64;
typedef __int64 INT64;
typedef unsigned __int32 UINT32;
typedef __int32 INT32;
typedef unsigned short UINT16;
typedef unsigned short CHAR16;
typedef short INT16;
typedef unsigned char BOOLEAN;
typedef unsigned char UINT8;
typedef char CHAR8;
typedef signed char INT8;

#if _MSC_EXTENSIONS
//
// use Microsoft* C compiler dependent integer width types
//
#include <stdint.h>
typedef unsigned __int64 UINT64;
typedef __int64 INT64;
typedef unsigned __int32 UINT32;
typedef __int32 INT32;
typedef unsigned short UINT16;
typedef unsigned short CHAR16;
typedef short INT16;
typedef unsigned char BOOLEAN;
typedef unsigned char UINT8;
typedef char CHAR8;
typedef signed char INT8;
#else
//
// Assume standard ARM alignment.
//
typedef unsigned long long UINT64;
typedef long long INT64;
typedef unsigned int UINT32;
typedef int INT32;
typedef unsigned short UINT16;
typedef unsigned short CHAR16;
typedef short INT16;
typedef unsigned char BOOLEAN;
typedef unsigned char UINT8;
typedef char CHAR8;
typedef signed char INT8;

#endif

#else
//
// Use ANSI C 2000 stdint.h integer width declarations
//
#include <stdint.h>
#include "stdint.h"
typedef uint8_t BOOLEAN;
typedef int8_t INT8;
typedef uint8_t UINT8;
Expand All @@ -57,6 +113,7 @@
typedef uint16_t CHAR16;

#endif
// MU_CHANGE Ends

///
/// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
Expand Down
12 changes: 11 additions & 1 deletion BaseTools/Source/C/Makefiles/ms.common
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,23 @@ LIB_PATH = $(BASE_TOOLS_PATH)\Lib\Win64
SYS_BIN_PATH = $(EDK_TOOLS_PATH)\Bin\Win64
SYS_LIB_PATH = $(EDK_TOOLS_PATH)\Lib\Win64

# MU_CHANGE Starts: Adding support to build base tools for ARM
# MU_CHANGE Starts: Adding support to build base tools for ARM and AARCH64
!ELSEIF "$(HOST_ARCH)"=="ARM"
ARCH_INCLUDE = $(SOURCE_PATH)\Include\Arm
BIN_PATH = $(BASE_TOOLS_PATH)\Bin\Win32
LIB_PATH = $(BASE_TOOLS_PATH)\Lib\Win32
SYS_BIN_PATH = $(EDK_TOOLS_PATH)\Bin\Win32
SYS_LIB_PATH = $(EDK_TOOLS_PATH)\Lib\Win32
!ELSEIF "$(HOST_ARCH)"=="AARCH64"
ARCH_INCLUDE = $(SOURCE_PATH)\Include\AArch64
BIN_PATH = $(BASE_TOOLS_PATH)\Bin\Win64
LIB_PATH = $(BASE_TOOLS_PATH)\Lib\Win64
SYS_BIN_PATH = $(EDK_TOOLS_PATH)\Bin\Win64
SYS_LIB_PATH = $(EDK_TOOLS_PATH)\Lib\Win64
# Note: These are bit-width conversion related warning suppressions we carry to avoid much more
# overrides in the C code. The future plan is to replace all of these binary based tools
# with python scripts, when it happens in tianocore..
CFLAGS = $(CFLAGS) /wd4267 /wd4244 /wd4334
# MU_CHANGE Ends

!ELSE
Expand Down

0 comments on commit 4face87

Please sign in to comment.