Skip to content

Commit

Permalink
Make AARCH64 FlatPageTableLib Compilable with MSVC (#476)
Browse files Browse the repository at this point in the history
## Description

MSVC does not allow inline Assembly, so some logic which reads an ARM
register needed to be moved to a separate nasm file:
https://learn.microsoft.com/en-us/cpp/assembler/inline/inline-assembler?view=msvc-170

- [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

Tested by building the module with MSVC

## Integration Instructions

N/A
  • Loading branch information
TaylorBeebe authored Apr 29, 2024
1 parent da051c7 commit f7075fc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ typedef union {

STATIC BOOLEAN mHierarchicalControlEnabled = FALSE;

#if !defined (__clang__) && !defined (__GNUC__)

/**
Reads the ID_AA64MMFR1_EL1 special register.
@retval The UINT64 value of the ID_AA64MMFR1_EL1 special register.
**/
UINT64
Asm_Read_ID_AA64MMFR1_EL1 (
VOID
);

#else

/**
Reads the ID_AA64MMFR1_EL1 special register.
Expand All @@ -90,6 +104,8 @@ Asm_Read_ID_AA64MMFR1_EL1 (
return value;
}

#endif

/**
Checks the ID_AA64MMFR1_EL1 and TCR special registers to see if hierarchical control is enabled.
Expand Down
23 changes: 23 additions & 0 deletions UefiTestingPkg/Library/FlatPageTableLib/AArch64/ReadIdMmfr1.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
;------------------------------------------------------------------------------
;
; Copyright (c) Microsoft Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent
;------------------------------------------------------------------------------

EXPORT Asm_Read_ID_AA64MMFR1_EL1
AREA |.text|, CODE, READONLY

;------------------------------------------------------------------------------
; Reads the ID_AA64MMFR1_EL1 special register.
;
; @retval The UINT64 value of the ID_AA64MMFR1_EL1 special register.
;
; UINT64
; Asm_Read_ID_AA64MMFR1_EL1 (
; VOID
; );
;------------------------------------------------------------------------------
Asm_Read_ID_AA64MMFR1_EL1
MRS X0, ID_AA64MMFR1_EL1
RET
END
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

[Sources.AARCH64]
AArch64/FlatPageTableAArch64.c
AArch64/ReadIdMmfr1.asm | MSFT

[Packages]
MdePkg/MdePkg.dec
Expand Down

0 comments on commit f7075fc

Please sign in to comment.