Skip to content

Commit

Permalink
Adding support of building BaseTool for Windows ARM (#323)
Browse files Browse the repository at this point in the history
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).

This change focuses on the support of building basetool natively for
Windows ARM host system. The end goal is to publish the corresponding
external dependencies to nuget package.

This change should progress the issue here:
#305

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, ...

This change is manually tested on Surface Pro X system.

N/A
  • Loading branch information
kuqin12 authored and apop5 committed Feb 3, 2025
1 parent 7ca9c63 commit a1255d3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
10 changes: 6 additions & 4 deletions BaseTools/Source/C/GenFw/GenFw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ Routine Description:
UINT32 OutputFileLength;
UINT8 *InputFileBuffer;
UINT32 InputFileLength;
RUNTIME_FUNCTION *RuntimeFunction;
PD_RUNTIME_FUNCTION *RuntimeFunction; // MU_CHANGE: Resolve definition conflict for ARM
UNWIND_INFO *UnwindInfo;
STATUS Status;
BOOLEAN ReplaceFlag;
Expand Down Expand Up @@ -2553,8 +2553,10 @@ Routine Description:
//
memset (SectionHeader->Name, 0, sizeof (SectionHeader->Name));

RuntimeFunction = (RUNTIME_FUNCTION *)(FileBuffer + SectionHeader->PointerToRawData);
for (Index1 = 0; Index1 < Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size / sizeof (RUNTIME_FUNCTION); Index1++, RuntimeFunction++) {
// MU_CHANGE Starts: Resolve definition conflict for ARM
RuntimeFunction = (PD_RUNTIME_FUNCTION *)(FileBuffer + SectionHeader->PointerToRawData);
for (Index1 = 0; Index1 < Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size / sizeof (PD_RUNTIME_FUNCTION); Index1++, RuntimeFunction++) {
// MU_CHANGE Ends
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) &(PeHdr->Pe32.OptionalHeader) + PeHdr->Pe32.FileHeader.SizeOfOptionalHeader);
for (Index2 = 0; Index2 < PeHdr->Pe32.FileHeader.NumberOfSections; Index2++, SectionHeader++) {
if (RuntimeFunction->UnwindInfoAddress >= SectionHeader->VirtualAddress && RuntimeFunction->UnwindInfoAddress < (SectionHeader->VirtualAddress + SectionHeader->SizeOfRawData)) {
Expand All @@ -2566,7 +2568,7 @@ Routine Description:
break;
}
}
memset (RuntimeFunction, 0, sizeof (RUNTIME_FUNCTION));
memset (RuntimeFunction, 0, sizeof (PD_RUNTIME_FUNCTION)); // MU_CHANGE: Resolve definition conflict for ARM
}
//
// Zero Exception Table
Expand Down
3 changes: 3 additions & 0 deletions BaseTools/Source/C/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
# MU_CHANGE: Only override HOST_ARCH when it is not specified
!IFNDEF HOST_ARCH
HOST_ARCH = IA32
!ENDIF

!INCLUDE Makefiles\ms.common

Expand Down
9 changes: 9 additions & 0 deletions BaseTools/Source/C/Makefiles/ms.common
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ 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
!ELSEIF "$(HOST_ARCH)"=="ARM"
ARCH_INCLUDE = $(EDK2_PATH)\MdePkg\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
# MU_CHANGE Ends

!ELSE
!ERROR "Bad HOST_ARCH"
!ENDIF
Expand Down
2 changes: 1 addition & 1 deletion MdePkg/Include/IndustryStandard/PeImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ typedef struct {
UINT32 FunctionStartAddress;
UINT32 FunctionEndAddress;
UINT32 UnwindInfoAddress;
} RUNTIME_FUNCTION;
} PD_RUNTIME_FUNCTION; // MU_CHANGE: Resolve definition conflict in winnt.h for ARM target.

typedef struct {
UINT8 Version : 3;
Expand Down

0 comments on commit a1255d3

Please sign in to comment.