* [PATCH v4 0/6] Add ARM support for VS2017
@ 2018-01-10 16:26 Pete Batard
2018-01-10 16:26 ` [PATCH v4 1/6] MdePkg: Disable some Level 4 warnings for VS2017/ARM Pete Batard
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Pete Batard @ 2018-01-10 16:26 UTC (permalink / raw)
To: edk2-devel; +Cc: liming.gao, ard.biesheuvel
(This v4 is the same as v3 from 2017-12-08, except to take into account Ard's
remarks and reuse the existing RVCT assembly for the MSFT compiler intrinsics)
The following series adds ARM compilation support for the VS2017 toolchain.
* PATCH 1 targets the disabling of VS Level 4 warnings. The disabled warnings
for ARM are now aligned with IA32 and X64.
* PATCH 2 adds a NULL handler for the base stack check, since this is a GCC
functionality.
* PATCH 3 updates MdePkg/Library/BaseLib so that the RVCT assembly sources
are also used for MSFT.
* PATCH 4 adds the required compiler intrinsics replacements for division,
shift, by reusing the RVCT code, as well as memset/memcpy.
* PATCH 5 adds variable argument handlers for print output. Note that this
is done without relying on any external headers, with the VA_ARG macro
having been reverse engineered from MSFT ARM assembly output.
* PATCH 6 enables the selection of ARM in the conf templates.
With these patches, VS2017 toolchain users should be able to compile
regular UEFI ARM applications using EDK2. Note that, unlike ARM64 support,
ARM support does not require a specific update of Visual Studio 2017, as
the ARM toolchain has been available from the very first release.
Additional notes:
We tested compiling and running the full UEFI Shell with this series, as
well as a small set of applications and drivers, and found no issues.
With an additional patch [1], it is also possible to use this proposal to
compile a complete QEMU ARM firmware. As the patch shows, the changes that
need to be applied to the EDK2 sources to achieve this are actually very
minimal.
However, the generated firmware does not currently boot, possibly because
of the following warnings being generated by the MS compiler:
- ArmCpuDxe.dll : warning LNK4072: section count 118 exceeds max (96); image may not run
- UiApp.dll : warning LNK4072: section count 113 exceeds max (96); image may not run
As far as I could see, the section count max is hardcoded so a workaround
would be needed to address those.
Also, because the VS2017 ARM compiler forces a section alignment of 4096
bytes (which in turn forces use to use /FILEALIGN:4096 as a linker option
for the firmware generation), the generated firmware exceeds 2MB and we
had to double its size to 4MB.
At this stage, since the goal of this series is to allow users to compile
regular ARM UEFI applications using the VS2017 toolchain, I have no plans
to spend more time on the QEMU firmware issues, especially as I suspect
that reducing the firmware size back to 2 MB may not be achievable without
Microsoft altering their compiler. I am however hopeful that ARM
specialists can take this matter over eventually...
Regards,
/Pete
[1] https://github.com/pbatard/edk2/commit/c4ce41094a46f4f3dc7ccc64a90604813f037b13
Pete Batard (6):
MdePkg: Disable some Level 4 warnings for VS2017/ARM
MdePkg/Library/BaseStackCheckLib: Add Null handler for VS2017/ARM
MdePkg/Library/BaseLib: Enable VS2017/ARM builds
ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
MdePkg/Include: Add VA list support for VS2017/ARM
BaseTools/Conf: Add VS2017/ARM support
ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm | 43 +++++++--
ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm | 40 ++++++--
ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm | 22 +++--
ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 29 +++++-
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 16 +++-
ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c | 34 +++++++
ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c | 33 +++++++
BaseTools/Conf/build_rule.template | 31 ++++++-
BaseTools/Conf/tools_def.template | 31 +++++++
MdePkg/Include/Arm/ProcessorBind.h | 96 +++++++++++++++-----
MdePkg/Include/Base.h | 13 +++
MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm | 5 +-
MdePkg/Library/BaseLib/BaseLib.inf | 16 +++-
MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf | 5 +-
MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c | 18 ++++
15 files changed, 372 insertions(+), 60 deletions(-)
create mode 100644 ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
create mode 100644 ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
create mode 100644 MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c
--
2.9.3.windows.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 1/6] MdePkg: Disable some Level 4 warnings for VS2017/ARM
2018-01-10 16:26 [PATCH v4 0/6] Add ARM support for VS2017 Pete Batard
@ 2018-01-10 16:26 ` Pete Batard
2018-01-10 16:26 ` [PATCH v4 2/6] MdePkg/Library/BaseStackCheckLib: Add Null handler " Pete Batard
` (4 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Pete Batard @ 2018-01-10 16:26 UTC (permalink / raw)
To: edk2-devel; +Cc: liming.gao, ard.biesheuvel
We disable the exact same warnings as IA32 and X64.
Also create a dummy macro for PRESERVE8, as this is not supported by
the Microsoft ARM assembler.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
---
MdePkg/Include/Arm/ProcessorBind.h | 96 +++++++++++++++-----
1 file changed, 75 insertions(+), 21 deletions(-)
diff --git a/MdePkg/Include/Arm/ProcessorBind.h b/MdePkg/Include/Arm/ProcessorBind.h
index 42ea2f3055f3..afb2f05446f0 100644
--- a/MdePkg/Include/Arm/ProcessorBind.h
+++ b/MdePkg/Include/Arm/ProcessorBind.h
@@ -1,15 +1,15 @@
/** @file
Processor or Compiler specific defines and types for ARM.
- Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. 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
+ 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.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
@@ -28,14 +28,63 @@
#pragma pack()
#endif
+#if defined(_MSC_EXTENSIONS)
+
//
-// RVCT does not support the __builtin_unreachable() macro
+// Disable some level 4 compilation warnings (same as IA32 and X64)
//
-#ifdef __ARMCC_VERSION
+
+//
+// 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 )
+
+//
+// This warning is caused by functions defined but not used. For precompiled header only.
+//
+#pragma warning ( disable : 4505 )
+
+//
+// This warning is caused by empty (after preprocessing) source file. For precompiled header only.
+//
+#pragma warning ( disable : 4206 )
+
+//
+// Disable 'potentially uninitialized local variable X used' warnings
+//
+#pragma warning ( disable : 4701 )
+
+//
+// Disable 'potentially uninitialized local pointer variable X used' warnings
+//
+#pragma warning ( disable : 4703 )
+
+#endif
+
+//
+// RVCT and MSFT don't support the __builtin_unreachable() macro
+//
+#if defined(__ARMCC_VERSION) || defined(_MSC_EXTENSIONS)
#define UNREACHABLE()
#endif
-#if _MSC_EXTENSIONS
+#if defined(_MSC_EXTENSIONS)
//
// use Microsoft* C compiler dependent integer width types
//
@@ -52,7 +101,7 @@
typedef signed char INT8;
#else
//
- // Assume standard ARM alignment.
+ // Assume standard ARM alignment.
// Need to check portability of long long
//
typedef unsigned long long UINT64;
@@ -121,7 +170,7 @@ typedef INT32 INTN;
// use the correct C calling convention. All protocol member functions and
// EFI intrinsics are required to modify their member functions with EFIAPI.
//
-#define EFIAPI
+#define EFIAPI
// When compiling with Clang, we still use GNU as for the assembler, so we still
// need to define the GCC_ASM* macros.
@@ -142,34 +191,39 @@ typedef INT32 INTN;
#define GCC_ASM_EXPORT(func__) \
.global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\
- .type ASM_PFX(func__), %function
+ .type ASM_PFX(func__), %function
#define GCC_ASM_IMPORT(func__) \
.extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
-
+
#else
//
- // .type not supported by Apple Xcode tools
+ // .type not supported by Apple Xcode tools
//
- #define INTERWORK_FUNC(func__)
+ #define INTERWORK_FUNC(func__)
#define GCC_ASM_EXPORT(func__) \
.globl _CONCATENATE (__USER_LABEL_PREFIX__, func__) \
-
- #define GCC_ASM_IMPORT(name)
+
+ #define GCC_ASM_IMPORT(name)
#endif
+#elif defined(_MSC_EXTENSIONS)
+ //
+ // PRESERVE8 is not supported by the MSFT assembler.
+ //
+ #define PRESERVE8
#endif
/**
Return the pointer to the first instruction of a function given a function pointer.
- On ARM CPU architectures, these two pointer values are the same,
+ On ARM CPU architectures, these two pointer values are the same,
so the implementation of this macro is very simple.
-
+
@param FunctionPointer A pointer to a function.
@return The pointer to the first instruction of a function given a function pointer.
-
+
**/
#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 2/6] MdePkg/Library/BaseStackCheckLib: Add Null handler for VS2017/ARM
2018-01-10 16:26 [PATCH v4 0/6] Add ARM support for VS2017 Pete Batard
2018-01-10 16:26 ` [PATCH v4 1/6] MdePkg: Disable some Level 4 warnings for VS2017/ARM Pete Batard
@ 2018-01-10 16:26 ` Pete Batard
2018-01-10 16:26 ` [PATCH v4 3/6] MdePkg/Library/BaseLib: Enable VS2017/ARM builds Pete Batard
` (3 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Pete Batard @ 2018-01-10 16:26 UTC (permalink / raw)
To: edk2-devel; +Cc: liming.gao, ard.biesheuvel
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
---
MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf | 5 +++--
MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf b/MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
index d02d97107b08..e280651b1199 100644
--- a/MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
+++ b/MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
@@ -30,8 +30,9 @@ [Defines]
#
[Sources]
- BaseStackCheckGcc.c | GCC
- BaseStackCheckGcc.c | RVCT
+ BaseStackCheckGcc.c | GCC
+ BaseStackCheckGcc.c | RVCT
+ BaseStackCheckNull.c | MSFT
[Packages]
MdePkg/MdePkg.dec
diff --git a/MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c b/MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c
new file mode 100644
index 000000000000..ebb387fee5e1
--- /dev/null
+++ b/MdePkg/Library/BaseStackCheckLib/BaseStackCheckNull.c
@@ -0,0 +1,18 @@
+/*++
+
+ Copyright (c) 2018, 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.
+
+Abstract:
+
+ This file is purely empty as a work around for BaseStackCheck to pass MSVC build.
+
+**/
+
+extern int __BaseStackCheckNull;
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 3/6] MdePkg/Library/BaseLib: Enable VS2017/ARM builds
2018-01-10 16:26 [PATCH v4 0/6] Add ARM support for VS2017 Pete Batard
2018-01-10 16:26 ` [PATCH v4 1/6] MdePkg: Disable some Level 4 warnings for VS2017/ARM Pete Batard
2018-01-10 16:26 ` [PATCH v4 2/6] MdePkg/Library/BaseStackCheckLib: Add Null handler " Pete Batard
@ 2018-01-10 16:26 ` Pete Batard
2018-01-10 16:26 ` [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: " Pete Batard
` (2 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Pete Batard @ 2018-01-10 16:26 UTC (permalink / raw)
To: edk2-devel; +Cc: liming.gao, ard.biesheuvel
Most of the RVCT assembly can be reused as is for MSFT except
for CpuBreakpoint.asm, which we need to force to Arm mode.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
---
MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm | 5 ++++-
MdePkg/Library/BaseLib/BaseLib.inf | 16 +++++++++++++---
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm b/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm
index 8a8065159bf2..e7490b09d3dc 100644
--- a/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm
+++ b/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm
@@ -16,7 +16,10 @@
EXPORT CpuBreakpoint
- AREA Cpu_Breakpoint, CODE, READONLY
+; Force ARM mode for this section, as MSFT assembler defaults to THUMB
+ AREA Cpu_Breakpoint, CODE, READONLY, ARM
+
+ ARM
;/**
; Generates a breakpoint on the CPU.
diff --git a/MdePkg/Library/BaseLib/BaseLib.inf b/MdePkg/Library/BaseLib/BaseLib.inf
index fbfb0063b75f..3c07e6bad977 100644
--- a/MdePkg/Library/BaseLib/BaseLib.inf
+++ b/MdePkg/Library/BaseLib/BaseLib.inf
@@ -824,8 +824,9 @@ [Sources.EBC]
[Sources.ARM]
Arm/InternalSwitchStack.c
Arm/Unaligned.c
- Math64.c | RVCT
-
+ Math64.c | RVCT
+ Math64.c | MSFT
+
Arm/SwitchStack.asm | RVCT
Arm/SetJumpLongJump.asm | RVCT
Arm/DisableInterrupts.asm | RVCT
@@ -834,7 +835,16 @@ [Sources.ARM]
Arm/CpuPause.asm | RVCT
Arm/CpuBreakpoint.asm | RVCT
Arm/MemoryFence.asm | RVCT
-
+
+ Arm/SwitchStack.asm | MSFT
+ Arm/SetJumpLongJump.asm | MSFT
+ Arm/DisableInterrupts.asm | MSFT
+ Arm/EnableInterrupts.asm | MSFT
+ Arm/GetInterruptsState.asm | MSFT
+ Arm/CpuPause.asm | MSFT
+ Arm/CpuBreakpoint.asm | MSFT
+ Arm/MemoryFence.asm | MSFT
+
Arm/Math64.S | GCC
Arm/SwitchStack.S | GCC
Arm/EnableInterrupts.S | GCC
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
2018-01-10 16:26 [PATCH v4 0/6] Add ARM support for VS2017 Pete Batard
` (2 preceding siblings ...)
2018-01-10 16:26 ` [PATCH v4 3/6] MdePkg/Library/BaseLib: Enable VS2017/ARM builds Pete Batard
@ 2018-01-10 16:26 ` Pete Batard
2018-01-11 10:46 ` Ard Biesheuvel
2018-01-10 16:26 ` [PATCH v4 5/6] MdePkg/Include: Add VA list support for VS2017/ARM Pete Batard
2018-01-10 16:26 ` [PATCH v4 6/6] BaseTools/Conf: Add VS2017/ARM support Pete Batard
5 siblings, 1 reply; 14+ messages in thread
From: Pete Batard @ 2018-01-10 16:26 UTC (permalink / raw)
To: edk2-devel; +Cc: liming.gao, ard.biesheuvel
Introduce CRT assembly replacements for __rt_sdiv, __rt_udiv,
__rt_udiv64, __rt_sdiv64, __rt_srsh (by reusing the RVCT code)
as well as memcpy and memset.
For MSFT compatibility, some of the code needs to be explicitly
forced to ARM, and the /oldit assembly flag needs to be added.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
---
ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm | 43 +++++++++++++++++---
ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm | 40 +++++++++++++-----
ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm | 22 +++++-----
ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 29 +++++++++++--
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 16 +++++++-
ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c | 34 ++++++++++++++++
ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c | 33 +++++++++++++++
7 files changed, 185 insertions(+), 32 deletions(-)
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
index b539e516892d..f9e0107395f2 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
@@ -1,6 +1,7 @@
//------------------------------------------------------------------------------
//
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -17,18 +18,19 @@
EXPORT __aeabi_uidivmod
EXPORT __aeabi_idiv
EXPORT __aeabi_idivmod
+ EXPORT __rt_udiv
+ EXPORT __rt_sdiv
AREA Math, CODE, READONLY
;
;UINT32
;EFIAPI
-;__aeabi_uidivmode (
-; IN UINT32 Dividen
+;__aeabi_uidivmod (
+; IN UINT32 Dividend
; IN UINT32 Divisor
; );
;
-
__aeabi_uidiv
__aeabi_uidivmod
RSBS r12, r1, r0, LSR #4
@@ -40,10 +42,40 @@ __aeabi_uidivmod
B __arm_div_large
;
+;UINT64
+;EFIAPI
+;__rt_udiv (
+; IN UINT32 Divisor,
+; IN UINT32 Dividend
+; );
+;
+__rt_udiv
+ ; Swap R0 and R1
+ MOV r12, r0
+ MOV r0, r1
+ MOV r1, r12
+ B __aeabi_uidivmod
+
+;
+;UINT64
+;EFIAPI
+;__rt_sdiv (
+; IN INT32 Divisor,
+; IN INT32 Dividend
+; );
+;
+__rt_sdiv
+ ; Swap R0 and R1
+ MOV r12, r0
+ MOV r0, r1
+ MOV r1, r12
+ B __aeabi_idivmod
+
+;
;INT32
;EFIAPI
-;__aeabi_idivmode (
-; IN INT32 Dividen
+;__aeabi_idivmod (
+; IN INT32 Dividend
; IN INT32 Divisor
; );
;
@@ -152,4 +184,3 @@ __aeabi_idiv0
BX r14
END
-
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
index c71bd59e4520..3794cac35eed 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
@@ -1,6 +1,7 @@
//------------------------------------------------------------------------------
//
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -13,20 +14,41 @@
//------------------------------------------------------------------------------
- EXTERN __aeabi_uldivmod
+ IMPORT __aeabi_uldivmod
+ EXPORT __aeabi_ldivmod
+ EXPORT __rt_sdiv64
- INCLUDE AsmMacroExport.inc
+ AREA Math, CODE, READONLY, ARM
+
+ ARM
;
-;UINT32
+;INT64
;EFIAPI
-;__aeabi_uidivmode (
-; IN UINT32 Dividen
-; IN UINT32 Divisor
+;__rt_sdiv64 (
+; IN INT64 Divisor
+; IN INT64 Dividend
; );
;
+__rt_sdiv64
+ ; Swap r0-r1 and r2-r3
+ MOV r12, r0
+ MOV r0, r2
+ MOV r2, r12
+ MOV r12, r1
+ MOV r1, r3
+ MOV r3, r12
+ B __aeabi_ldivmod
- RVCT_ASM_EXPORT __aeabi_ldivmod
+;
+;INT64
+;EFIAPI
+;__aeabi_ldivmod (
+; IN INT64 Dividend
+; IN INT64 Divisor
+; );
+;
+__aeabi_ldivmod
PUSH {r4,lr}
ASRS r4,r1,#1
EOR r4,r4,r3,LSR #1
@@ -39,7 +61,7 @@ L_Test1
RSBS r2,r2,#0
RSC r3,r3,#0
L_Test2
- BL __aeabi_uldivmod ;
+ BL __aeabi_uldivmod
TST r4,#0x40000000
BEQ L_Test3
RSBS r0,r0,#0
@@ -53,5 +75,3 @@ L_Exit
POP {r4,pc}
END
-
-
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
index 881db106d9d7..db2fd5057832 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
@@ -1,6 +1,7 @@
//------------------------------------------------------------------------------
//
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -12,32 +13,33 @@
//
//------------------------------------------------------------------------------
+ EXPORT __aeabi_llsr
+ EXPORT __rt_srsh
+ AREA Math, CODE, READONLY, ARM
- INCLUDE AsmMacroExport.inc
+ ARM
;
;VOID
;EFIAPI
;__aeabi_llsr (
-; IN VOID *Destination,
-; IN VOID *Source,
-; IN UINT32 Size
-; );
+; IN UINT64 Value,
+; IN UINT32 Shift
+;)
;
- RVCT_ASM_EXPORT __aeabi_llsr
+__aeabi_llsr
+__rt_srsh
SUBS r3,r2,#0x20
- BPL {pc} + 0x18 ; 0x1c
+ BPL __aeabi_llsr_label1
RSB r3,r2,#0x20
LSR r0,r0,r2
ORR r0,r0,r1,LSL r3
LSR r1,r1,r2
BX lr
+__aeabi_llsr_label1
LSR r0,r1,r3
MOV r1,#0
BX lr
END
-
-
-
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
index 6b6184ebd3fc..c5632b4e95e7 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
@@ -1,6 +1,7 @@
//------------------------------------------------------------------------------
//
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -13,9 +14,30 @@
//------------------------------------------------------------------------------
+ EXPORT __aeabi_uldivmod
+ EXPORT __rt_udiv64
+ AREA Math, CODE, READONLY, ARM
- INCLUDE AsmMacroExport.inc
+ ARM
+
+;
+;UINT64
+;EFIAPI
+;__rt_udiv64 (
+; IN UINT64 Divisor
+; IN UINT64 Dividend
+; )
+;
+__rt_udiv64
+ ; Swap r0-r1 and r2-r3
+ mov r12, r0
+ mov r0, r2
+ mov r2, r12
+ mov r12, r1
+ mov r1, r3
+ mov r3, r12
+ b __aeabi_uldivmod
;
;UINT64
@@ -25,7 +47,7 @@
; IN UINT64 Divisor
; )
;
- RVCT_ASM_EXPORT __aeabi_uldivmod
+__aeabi_uldivmod
stmdb sp!, {r4, r5, r6, lr}
mov r4, r1
mov r5, r0
@@ -261,7 +283,6 @@ _ll_div0
b __aeabi_ldiv0
__aeabi_ldiv0
- BX r14
+ bx r14
END
-
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
index 44333141a70a..14e88da7ce06 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
@@ -23,8 +23,12 @@ [Defines]
LIBRARY_CLASS = CompilerIntrinsicsLib
[Sources]
- memcpy.c
- memset.c
+ memcpy.c | RVCT
+ memcpy.c | GCC
+ memcpy_ms.c | MSFT
+ memset.c | RVCT
+ memset.c | GCC
+ memset_ms.c | MSFT
[Sources.ARM]
Arm/mullu.asm | RVCT
@@ -94,6 +98,10 @@ [Sources.ARM]
Arm/llsr.S | GCC
Arm/llsl.S | GCC
+ Arm/div.asm | MSFT
+ Arm/uldiv.asm | MSFT
+ Arm/ldivmod.asm | MSFT
+ Arm/llsr.asm | MSFT
[Packages]
MdePkg/MdePkg.dec
@@ -101,3 +109,7 @@ [Packages]
[LibraryClasses]
+[BuildOptions]
+ MSFT:*_*_ARM_CC_FLAGS = /GL-
+ MSFT:*_*_ARM_ASM_FLAGS = /oldit
+ MSFT:*_*_AARCH64_CC_FLAGS = /GL-
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
new file mode 100644
index 000000000000..90bbbb930d31
--- /dev/null
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
@@ -0,0 +1,34 @@
+//------------------------------------------------------------------------------
+//
+// Copyright (c) 2017, Pete Batard. 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.
+//
+//------------------------------------------------------------------------------
+
+#if defined(_M_ARM64)
+typedef unsigned __int64 size_t;
+#else
+typedef unsigned __int32 size_t;
+#endif
+
+void* memcpy(void *, const void *, size_t);
+#pragma intrinsic(memcpy)
+#pragma function(memcpy)
+void* memcpy(void *dest, const void *src, size_t n)
+{
+ unsigned char *d = dest;
+ unsigned char const *s = src;
+
+ while (n--)
+ *d++ = *s++;
+
+ return dest;
+}
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
new file mode 100644
index 000000000000..64205e5d1012
--- /dev/null
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+//
+// Copyright (c) 2017, Pete Batard. 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.
+//
+//------------------------------------------------------------------------------
+
+#if defined(_M_ARM64)
+typedef unsigned __int64 size_t;
+#else
+typedef unsigned __int32 size_t;
+#endif
+
+void* memset(void *, int, size_t);
+#pragma intrinsic(memset)
+#pragma function(memset)
+void *memset(void *s, int c, size_t n)
+{
+ unsigned char *d = s;
+
+ while (n--)
+ *d++ = (unsigned char)c;
+
+ return s;
+}
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 5/6] MdePkg/Include: Add VA list support for VS2017/ARM
2018-01-10 16:26 [PATCH v4 0/6] Add ARM support for VS2017 Pete Batard
` (3 preceding siblings ...)
2018-01-10 16:26 ` [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: " Pete Batard
@ 2018-01-10 16:26 ` Pete Batard
2018-01-10 16:26 ` [PATCH v4 6/6] BaseTools/Conf: Add VS2017/ARM support Pete Batard
5 siblings, 0 replies; 14+ messages in thread
From: Pete Batard @ 2018-01-10 16:26 UTC (permalink / raw)
To: edk2-devel; +Cc: liming.gao, ard.biesheuvel
VA_START, VA_END and VA_COPY are the same as the generic macros.
VA_ARG was reverse engineered from MS ARM assembly output.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
---
MdePkg/Include/Base.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index 29db8a253e2f..7152ccda9764 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -660,6 +660,19 @@ struct _LIST_ENTRY {
#define VA_COPY(Dest, Start) __va_copy (Dest, Start)
+#elif defined(_M_ARM)
+//
+// MSFT ARM variable argument list support.
+// Same as the generic macros below, except for VA_ARG that needs extra adjustment.
+//
+
+typedef char* VA_LIST;
+
+#define VA_START(Marker, Parameter) (Marker = (VA_LIST) ((UINTN) & (Parameter) + _INT_SIZE_OF(Parameter)))
+#define VA_ARG(Marker, TYPE) (*(TYPE *) ((Marker += _INT_SIZE_OF(TYPE) + ((-(INTN)Marker) & (sizeof(TYPE) - 1))) - _INT_SIZE_OF (TYPE)))
+#define VA_END(Marker) (Marker = (VA_LIST) 0)
+#define VA_COPY(Dest, Start) ((void)((Dest) = (Start)))
+
#elif defined(__GNUC__)
#if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS)
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 6/6] BaseTools/Conf: Add VS2017/ARM support
2018-01-10 16:26 [PATCH v4 0/6] Add ARM support for VS2017 Pete Batard
` (4 preceding siblings ...)
2018-01-10 16:26 ` [PATCH v4 5/6] MdePkg/Include: Add VA list support for VS2017/ARM Pete Batard
@ 2018-01-10 16:26 ` Pete Batard
5 siblings, 0 replies; 14+ messages in thread
From: Pete Batard @ 2018-01-10 16:26 UTC (permalink / raw)
To: edk2-devel; +Cc: liming.gao, ard.biesheuvel
We duplicate the Assembly-Code-File section from build_rule.template
because --convert-hex cannot be used with the MSFT ARM assembler.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
---
BaseTools/Conf/build_rule.template | 31 +++++++++++++++++++-
BaseTools/Conf/tools_def.template | 31 ++++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template
index 3e6aa8ff0f34..6ea14fb7aa02 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -182,7 +182,6 @@
<Command>
-
[Assembly-Code-File.COMMON.COMMON]
<InputFile.MSFT, InputFile.INTEL, InputFile.RVCT>
?.asm, ?.Asm, ?.ASM
@@ -207,6 +206,36 @@
# For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
"$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
+[Assembly-Code-File.COMMON.ARM]
+ # Remove --convert-hex for ARM as it breaks MSFT assemblers
+ <InputFile.MSFT, InputFile.INTEL, InputFile.RVCT>
+ ?.asm, ?.Asm, ?.ASM
+
+ <InputFile.GCC, InputFile.GCCLD>
+ ?.S, ?.s
+
+ <ExtraDependency>
+ $(MAKE_FILE)
+
+ <OutputFile>
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+
+ <Command.INTEL>
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+ Trim --source-code --convert-hex --trim-long -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
+ "$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) ${d_path}(+)${s_base}.iii
+
+ <Command.MSFT>
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+ Trim --source-code --trim-long -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
+ "$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) ${d_path}(+)${s_base}.iii
+
+ <Command.GCC, Command.GCCLD, Command.RVCT>
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+ Trim --trim-long --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
+ # For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
+ "$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
+
[Nasm-Assembly-Code-File.COMMON.COMMON]
<InputFile>
?.nasm
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 98ab6dd45e81..f76c4da05938 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -79,6 +79,7 @@ DEFINE VS2017_HOST = x86
DEFINE VS2017_BIN_HOST = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\DEF(VS2017_HOST)
DEFINE VS2017_BIN_IA32 = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x86
DEFINE VS2017_BIN_X64 = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x64
+DEFINE VS2017_BIN_ARM = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\arm
DEFINE WINSDK_BIN = ENV(WINSDK_PREFIX)
DEFINE WINSDKx86_BIN = ENV(WINSDKx86_PREFIX)
@@ -335,6 +336,9 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
# Required to build platforms or ACPI tables:
# Intel(r) ACPI Compiler (iasl.exe) from
# https://acpica.org/downloads
+# Note:
+# Building of XIP firmware images for ARM is not currently supported (only applications).
+# /FILEALIGN:4096 and other changes are needed for ARM firmware builds.
# DDK3790 -win32- Requires:
# Microsoft Windows Server 2003 Driver Development Kit (Microsoft WINDDK) version 3790.1830
# Optional:
@@ -4169,6 +4173,33 @@ NOOPT_VS2017_X64_NASM_FLAGS = -O0 -f win64 -g
RELEASE_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
NOOPT_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+#################
+# ARM definitions
+#################
+*_VS2017_ARM_CC_PATH = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_VFRPP_PATH = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_SLINK_PATH = DEF(VS2017_BIN_ARM)\lib.exe
+*_VS2017_ARM_DLINK_PATH = DEF(VS2017_BIN_ARM)\link.exe
+*_VS2017_ARM_APP_PATH = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_PP_PATH = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_ASM_PATH = DEF(VS2017_BIN_ARM)\armasm.exe
+*_VS2017_ARM_ASLCC_PATH = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_ASLPP_PATH = DEF(VS2017_BIN_ARM)\cl.exe
+*_VS2017_ARM_ASLDLINK_PATH = DEF(VS2017_BIN_ARM)\link.exe
+
+ *_VS2017_ARM_MAKE_FLAGS = /nologo
+ DEBUG_VS2017_ARM_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm /Gw /Oi-
+RELEASE_VS2017_ARM_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gw /Oi-
+NOOPT_VS2017_ARM_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm /Od /Oi-
+
+ DEBUG_VS2017_ARM_ASM_FLAGS = /nologo /g
+RELEASE_VS2017_ARM_ASM_FLAGS = /nologo
+NOOPT_VS2017_ARM_ASM_FLAGS = /nologo
+
+ DEBUG_VS2017_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2017_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
+NOOPT_VS2017_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+
##################
# EBC definitions
##################
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
2018-01-10 16:26 ` [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: " Pete Batard
@ 2018-01-11 10:46 ` Ard Biesheuvel
2018-01-11 15:30 ` Cohen, Eugene
0 siblings, 1 reply; 14+ messages in thread
From: Ard Biesheuvel @ 2018-01-11 10:46 UTC (permalink / raw)
To: Pete Batard, Cohen, Eugene; +Cc: edk2-devel@lists.01.org, Gao, Liming
On 10 January 2018 at 16:26, Pete Batard <pete@akeo.ie> wrote:
> Introduce CRT assembly replacements for __rt_sdiv, __rt_udiv,
> __rt_udiv64, __rt_sdiv64, __rt_srsh (by reusing the RVCT code)
> as well as memcpy and memset.
> For MSFT compatibility, some of the code needs to be explicitly
> forced to ARM, and the /oldit assembly flag needs to be added.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Pete Batard <pete@akeo.ie>
This looks fine to me but I haven't been able to test it.
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Eugene: any comments regarding the changes to RVCT code?
> ---
> ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm | 43 +++++++++++++++++---
> ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm | 40 +++++++++++++-----
> ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm | 22 +++++-----
> ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 29 +++++++++++--
> ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 16 +++++++-
> ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c | 34 ++++++++++++++++
> ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c | 33 +++++++++++++++
> 7 files changed, 185 insertions(+), 32 deletions(-)
>
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> index b539e516892d..f9e0107395f2 100644
> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> @@ -1,6 +1,7 @@
> //------------------------------------------------------------------------------
> //
> // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
> //
> // This program and the accompanying materials
> // are licensed and made available under the terms and conditions of the BSD License
> @@ -17,18 +18,19 @@
> EXPORT __aeabi_uidivmod
> EXPORT __aeabi_idiv
> EXPORT __aeabi_idivmod
> + EXPORT __rt_udiv
> + EXPORT __rt_sdiv
>
> AREA Math, CODE, READONLY
>
> ;
> ;UINT32
> ;EFIAPI
> -;__aeabi_uidivmode (
> -; IN UINT32 Dividen
> +;__aeabi_uidivmod (
> +; IN UINT32 Dividend
> ; IN UINT32 Divisor
> ; );
> ;
> -
> __aeabi_uidiv
> __aeabi_uidivmod
> RSBS r12, r1, r0, LSR #4
> @@ -40,10 +42,40 @@ __aeabi_uidivmod
> B __arm_div_large
>
> ;
> +;UINT64
> +;EFIAPI
> +;__rt_udiv (
> +; IN UINT32 Divisor,
> +; IN UINT32 Dividend
> +; );
> +;
> +__rt_udiv
> + ; Swap R0 and R1
> + MOV r12, r0
> + MOV r0, r1
> + MOV r1, r12
> + B __aeabi_uidivmod
> +
> +;
> +;UINT64
> +;EFIAPI
> +;__rt_sdiv (
> +; IN INT32 Divisor,
> +; IN INT32 Dividend
> +; );
> +;
> +__rt_sdiv
> + ; Swap R0 and R1
> + MOV r12, r0
> + MOV r0, r1
> + MOV r1, r12
> + B __aeabi_idivmod
> +
> +;
> ;INT32
> ;EFIAPI
> -;__aeabi_idivmode (
> -; IN INT32 Dividen
> +;__aeabi_idivmod (
> +; IN INT32 Dividend
> ; IN INT32 Divisor
> ; );
> ;
> @@ -152,4 +184,3 @@ __aeabi_idiv0
> BX r14
>
> END
> -
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> index c71bd59e4520..3794cac35eed 100644
> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> @@ -1,6 +1,7 @@
> //------------------------------------------------------------------------------
> //
> // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
> //
> // This program and the accompanying materials
> // are licensed and made available under the terms and conditions of the BSD License
> @@ -13,20 +14,41 @@
> //------------------------------------------------------------------------------
>
>
> - EXTERN __aeabi_uldivmod
> + IMPORT __aeabi_uldivmod
> + EXPORT __aeabi_ldivmod
> + EXPORT __rt_sdiv64
>
> - INCLUDE AsmMacroExport.inc
> + AREA Math, CODE, READONLY, ARM
> +
> + ARM
>
> ;
> -;UINT32
> +;INT64
> ;EFIAPI
> -;__aeabi_uidivmode (
> -; IN UINT32 Dividen
> -; IN UINT32 Divisor
> +;__rt_sdiv64 (
> +; IN INT64 Divisor
> +; IN INT64 Dividend
> ; );
> ;
> +__rt_sdiv64
> + ; Swap r0-r1 and r2-r3
> + MOV r12, r0
> + MOV r0, r2
> + MOV r2, r12
> + MOV r12, r1
> + MOV r1, r3
> + MOV r3, r12
> + B __aeabi_ldivmod
>
> - RVCT_ASM_EXPORT __aeabi_ldivmod
> +;
> +;INT64
> +;EFIAPI
> +;__aeabi_ldivmod (
> +; IN INT64 Dividend
> +; IN INT64 Divisor
> +; );
> +;
> +__aeabi_ldivmod
> PUSH {r4,lr}
> ASRS r4,r1,#1
> EOR r4,r4,r3,LSR #1
> @@ -39,7 +61,7 @@ L_Test1
> RSBS r2,r2,#0
> RSC r3,r3,#0
> L_Test2
> - BL __aeabi_uldivmod ;
> + BL __aeabi_uldivmod
> TST r4,#0x40000000
> BEQ L_Test3
> RSBS r0,r0,#0
> @@ -53,5 +75,3 @@ L_Exit
> POP {r4,pc}
>
> END
> -
> -
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> index 881db106d9d7..db2fd5057832 100644
> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> @@ -1,6 +1,7 @@
> //------------------------------------------------------------------------------
> //
> // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
> //
> // This program and the accompanying materials
> // are licensed and made available under the terms and conditions of the BSD License
> @@ -12,32 +13,33 @@
> //
> //------------------------------------------------------------------------------
>
> + EXPORT __aeabi_llsr
> + EXPORT __rt_srsh
>
> + AREA Math, CODE, READONLY, ARM
>
> - INCLUDE AsmMacroExport.inc
> + ARM
>
> ;
> ;VOID
> ;EFIAPI
> ;__aeabi_llsr (
> -; IN VOID *Destination,
> -; IN VOID *Source,
> -; IN UINT32 Size
> -; );
> +; IN UINT64 Value,
> +; IN UINT32 Shift
> +;)
> ;
> - RVCT_ASM_EXPORT __aeabi_llsr
> +__aeabi_llsr
> +__rt_srsh
> SUBS r3,r2,#0x20
> - BPL {pc} + 0x18 ; 0x1c
> + BPL __aeabi_llsr_label1
> RSB r3,r2,#0x20
> LSR r0,r0,r2
> ORR r0,r0,r1,LSL r3
> LSR r1,r1,r2
> BX lr
> +__aeabi_llsr_label1
> LSR r0,r1,r3
> MOV r1,#0
> BX lr
>
> END
> -
> -
> -
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> index 6b6184ebd3fc..c5632b4e95e7 100644
> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> @@ -1,6 +1,7 @@
> //------------------------------------------------------------------------------
> //
> // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
> //
> // This program and the accompanying materials
> // are licensed and made available under the terms and conditions of the BSD License
> @@ -13,9 +14,30 @@
> //------------------------------------------------------------------------------
>
>
> + EXPORT __aeabi_uldivmod
> + EXPORT __rt_udiv64
>
> + AREA Math, CODE, READONLY, ARM
>
> - INCLUDE AsmMacroExport.inc
> + ARM
> +
> +;
> +;UINT64
> +;EFIAPI
> +;__rt_udiv64 (
> +; IN UINT64 Divisor
> +; IN UINT64 Dividend
> +; )
> +;
> +__rt_udiv64
> + ; Swap r0-r1 and r2-r3
> + mov r12, r0
> + mov r0, r2
> + mov r2, r12
> + mov r12, r1
> + mov r1, r3
> + mov r3, r12
> + b __aeabi_uldivmod
>
> ;
> ;UINT64
> @@ -25,7 +47,7 @@
> ; IN UINT64 Divisor
> ; )
> ;
> - RVCT_ASM_EXPORT __aeabi_uldivmod
> +__aeabi_uldivmod
> stmdb sp!, {r4, r5, r6, lr}
> mov r4, r1
> mov r5, r0
> @@ -261,7 +283,6 @@ _ll_div0
> b __aeabi_ldiv0
>
> __aeabi_ldiv0
> - BX r14
> + bx r14
>
> END
> -
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> index 44333141a70a..14e88da7ce06 100644
> --- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> @@ -23,8 +23,12 @@ [Defines]
> LIBRARY_CLASS = CompilerIntrinsicsLib
>
> [Sources]
> - memcpy.c
> - memset.c
> + memcpy.c | RVCT
> + memcpy.c | GCC
> + memcpy_ms.c | MSFT
> + memset.c | RVCT
> + memset.c | GCC
> + memset_ms.c | MSFT
>
> [Sources.ARM]
> Arm/mullu.asm | RVCT
> @@ -94,6 +98,10 @@ [Sources.ARM]
> Arm/llsr.S | GCC
> Arm/llsl.S | GCC
>
> + Arm/div.asm | MSFT
> + Arm/uldiv.asm | MSFT
> + Arm/ldivmod.asm | MSFT
> + Arm/llsr.asm | MSFT
>
> [Packages]
> MdePkg/MdePkg.dec
> @@ -101,3 +109,7 @@ [Packages]
>
> [LibraryClasses]
>
> +[BuildOptions]
> + MSFT:*_*_ARM_CC_FLAGS = /GL-
> + MSFT:*_*_ARM_ASM_FLAGS = /oldit
> + MSFT:*_*_AARCH64_CC_FLAGS = /GL-
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
> new file mode 100644
> index 000000000000..90bbbb930d31
> --- /dev/null
> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
> @@ -0,0 +1,34 @@
> +//------------------------------------------------------------------------------
> +//
> +// Copyright (c) 2017, Pete Batard. 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.
> +//
> +//------------------------------------------------------------------------------
> +
> +#if defined(_M_ARM64)
> +typedef unsigned __int64 size_t;
> +#else
> +typedef unsigned __int32 size_t;
> +#endif
> +
> +void* memcpy(void *, const void *, size_t);
> +#pragma intrinsic(memcpy)
> +#pragma function(memcpy)
> +void* memcpy(void *dest, const void *src, size_t n)
> +{
> + unsigned char *d = dest;
> + unsigned char const *s = src;
> +
> + while (n--)
> + *d++ = *s++;
> +
> + return dest;
> +}
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
> new file mode 100644
> index 000000000000..64205e5d1012
> --- /dev/null
> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
> @@ -0,0 +1,33 @@
> +//------------------------------------------------------------------------------
> +//
> +// Copyright (c) 2017, Pete Batard. 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.
> +//
> +//------------------------------------------------------------------------------
> +
> +#if defined(_M_ARM64)
> +typedef unsigned __int64 size_t;
> +#else
> +typedef unsigned __int32 size_t;
> +#endif
> +
> +void* memset(void *, int, size_t);
> +#pragma intrinsic(memset)
> +#pragma function(memset)
> +void *memset(void *s, int c, size_t n)
> +{
> + unsigned char *d = s;
> +
> + while (n--)
> + *d++ = (unsigned char)c;
> +
> + return s;
> +}
> --
> 2.9.3.windows.2
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
2018-01-11 10:46 ` Ard Biesheuvel
@ 2018-01-11 15:30 ` Cohen, Eugene
2018-01-11 16:31 ` Pete Batard
0 siblings, 1 reply; 14+ messages in thread
From: Cohen, Eugene @ 2018-01-11 15:30 UTC (permalink / raw)
To: Ard Biesheuvel, Pete Batard; +Cc: edk2-devel@lists.01.org, Gao, Liming
> > Introduce CRT assembly replacements for __rt_sdiv, __rt_udiv,
> > __rt_udiv64, __rt_sdiv64, __rt_srsh (by reusing the RVCT code) as well
> > as memcpy and memset.
> > For MSFT compatibility, some of the code needs to be explicitly forced
> > to ARM, and the /oldit assembly flag needs to be added.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Pete Batard <pete@akeo.ie>
>
> This looks fine to me but I haven't been able to test it.
>
> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> Eugene: any comments regarding the changes to RVCT code?
I've been away in Linux land for a while, it's nice that the day I catch up on my edk2-devel backlog I see my name! :)
One concern for RVCT is that every function is in its own section to enable proper dead code removal. This is addressed with this macro:
MACRO
RVCT_ASM_EXPORT $func
EXPORT $func
AREA s_$func, CODE, READONLY
$func
MEND
note the AREA directive - this makes a section per function.
Pete's patchset removes these macros which breaks dead code removal.
Please restore these macros for at least RVCT and please verify that the VS2017 path does appropriate dead code removal for these assembly functions.
Thanks!
Eugene
>
>
> > ---
> > ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm | 43
> +++++++++++++++++---
> > ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm | 40
> +++++++++++++-----
> > ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm | 22 +++++----
> -
> > ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 29
> +++++++++++--
> > ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 16
> +++++++-
> > ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c | 34
> ++++++++++++++++
> > ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c | 33
> +++++++++++++++
> > 7 files changed, 185 insertions(+), 32 deletions(-)
> >
> > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> > b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> > index b539e516892d..f9e0107395f2 100644
> > --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> > @@ -1,6 +1,7 @@
> >
> > //--------------------------------------------------------------------
> > ----------
> > //
> > // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> > +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
> > //
> > // This program and the accompanying materials // are licensed and
> > made available under the terms and conditions of the BSD License @@
> > -17,18 +18,19 @@
> > EXPORT __aeabi_uidivmod
> > EXPORT __aeabi_idiv
> > EXPORT __aeabi_idivmod
> > + EXPORT __rt_udiv
> > + EXPORT __rt_sdiv
> >
> > AREA Math, CODE, READONLY
> >
> > ;
> > ;UINT32
> > ;EFIAPI
> > -;__aeabi_uidivmode (
> > -; IN UINT32 Dividen
> > +;__aeabi_uidivmod (
> > +; IN UINT32 Dividend
> > ; IN UINT32 Divisor
> > ; );
> > ;
> > -
> > __aeabi_uidiv
> > __aeabi_uidivmod
> > RSBS r12, r1, r0, LSR #4
> > @@ -40,10 +42,40 @@ __aeabi_uidivmod
> > B __arm_div_large
> >
> > ;
> > +;UINT64
> > +;EFIAPI
> > +;__rt_udiv (
> > +; IN UINT32 Divisor,
> > +; IN UINT32 Dividend
> > +; );
> > +;
> > +__rt_udiv
> > + ; Swap R0 and R1
> > + MOV r12, r0
> > + MOV r0, r1
> > + MOV r1, r12
> > + B __aeabi_uidivmod
> > +
> > +;
> > +;UINT64
> > +;EFIAPI
> > +;__rt_sdiv (
> > +; IN INT32 Divisor,
> > +; IN INT32 Dividend
> > +; );
> > +;
> > +__rt_sdiv
> > + ; Swap R0 and R1
> > + MOV r12, r0
> > + MOV r0, r1
> > + MOV r1, r12
> > + B __aeabi_idivmod
> > +
> > +;
> > ;INT32
> > ;EFIAPI
> > -;__aeabi_idivmode (
> > -; IN INT32 Dividen
> > +;__aeabi_idivmod (
> > +; IN INT32 Dividend
> > ; IN INT32 Divisor
> > ; );
> > ;
> > @@ -152,4 +184,3 @@ __aeabi_idiv0
> > BX r14
> >
> > END
> > -
> > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> > b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> > index c71bd59e4520..3794cac35eed 100644
> > --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> > @@ -1,6 +1,7 @@
> >
> > //--------------------------------------------------------------------
> > ----------
> > //
> > // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> > +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
> > //
> > // This program and the accompanying materials // are licensed and
> > made available under the terms and conditions of the BSD License @@
> > -13,20 +14,41 @@
> >
> > //--------------------------------------------------------------------
> > ----------
> >
> >
> > - EXTERN __aeabi_uldivmod
> > + IMPORT __aeabi_uldivmod
> > + EXPORT __aeabi_ldivmod
> > + EXPORT __rt_sdiv64
> >
> > - INCLUDE AsmMacroExport.inc
> > + AREA Math, CODE, READONLY, ARM
> > +
> > + ARM
> >
> > ;
> > -;UINT32
> > +;INT64
> > ;EFIAPI
> > -;__aeabi_uidivmode (
> > -; IN UINT32 Dividen
> > -; IN UINT32 Divisor
> > +;__rt_sdiv64 (
> > +; IN INT64 Divisor
> > +; IN INT64 Dividend
> > ; );
> > ;
> > +__rt_sdiv64
> > + ; Swap r0-r1 and r2-r3
> > + MOV r12, r0
> > + MOV r0, r2
> > + MOV r2, r12
> > + MOV r12, r1
> > + MOV r1, r3
> > + MOV r3, r12
> > + B __aeabi_ldivmod
> >
> > - RVCT_ASM_EXPORT __aeabi_ldivmod
> > +;
> > +;INT64
> > +;EFIAPI
> > +;__aeabi_ldivmod (
> > +; IN INT64 Dividend
> > +; IN INT64 Divisor
> > +; );
> > +;
> > +__aeabi_ldivmod
> > PUSH {r4,lr}
> > ASRS r4,r1,#1
> > EOR r4,r4,r3,LSR #1
> > @@ -39,7 +61,7 @@ L_Test1
> > RSBS r2,r2,#0
> > RSC r3,r3,#0
> > L_Test2
> > - BL __aeabi_uldivmod ;
> > + BL __aeabi_uldivmod
> > TST r4,#0x40000000
> > BEQ L_Test3
> > RSBS r0,r0,#0
> > @@ -53,5 +75,3 @@ L_Exit
> > POP {r4,pc}
> >
> > END
> > -
> > -
> > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> > b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> > index 881db106d9d7..db2fd5057832 100644
> > --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> > @@ -1,6 +1,7 @@
> >
> > //--------------------------------------------------------------------
> > ----------
> > //
> > // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> > +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
> > //
> > // This program and the accompanying materials // are licensed and
> > made available under the terms and conditions of the BSD License @@
> > -12,32 +13,33 @@ //
> >
> > //--------------------------------------------------------------------
> > ----------
> >
> > + EXPORT __aeabi_llsr
> > + EXPORT __rt_srsh
> >
> > + AREA Math, CODE, READONLY, ARM
> >
> > - INCLUDE AsmMacroExport.inc
> > + ARM
> >
> > ;
> > ;VOID
> > ;EFIAPI
> > ;__aeabi_llsr (
> > -; IN VOID *Destination,
> > -; IN VOID *Source,
> > -; IN UINT32 Size
> > -; );
> > +; IN UINT64 Value,
> > +; IN UINT32 Shift
> > +;)
> > ;
> > - RVCT_ASM_EXPORT __aeabi_llsr
> > +__aeabi_llsr
> > +__rt_srsh
> > SUBS r3,r2,#0x20
> > - BPL {pc} + 0x18 ; 0x1c
> > + BPL __aeabi_llsr_label1
> > RSB r3,r2,#0x20
> > LSR r0,r0,r2
> > ORR r0,r0,r1,LSL r3
> > LSR r1,r1,r2
> > BX lr
> > +__aeabi_llsr_label1
> > LSR r0,r1,r3
> > MOV r1,#0
> > BX lr
> >
> > END
> > -
> > -
> > -
> > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> > b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> > index 6b6184ebd3fc..c5632b4e95e7 100644
> > --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> > @@ -1,6 +1,7 @@
> >
> > //--------------------------------------------------------------------
> > ----------
> > //
> > // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> > +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
> > //
> > // This program and the accompanying materials // are licensed and
> > made available under the terms and conditions of the BSD License @@
> > -13,9 +14,30 @@
> >
> > //--------------------------------------------------------------------
> > ----------
> >
> >
> > + EXPORT __aeabi_uldivmod
> > + EXPORT __rt_udiv64
> >
> > + AREA Math, CODE, READONLY, ARM
> >
> > - INCLUDE AsmMacroExport.inc
> > + ARM
> > +
> > +;
> > +;UINT64
> > +;EFIAPI
> > +;__rt_udiv64 (
> > +; IN UINT64 Divisor
> > +; IN UINT64 Dividend
> > +; )
> > +;
> > +__rt_udiv64
> > + ; Swap r0-r1 and r2-r3
> > + mov r12, r0
> > + mov r0, r2
> > + mov r2, r12
> > + mov r12, r1
> > + mov r1, r3
> > + mov r3, r12
> > + b __aeabi_uldivmod
> >
> > ;
> > ;UINT64
> > @@ -25,7 +47,7 @@
> > ; IN UINT64 Divisor
> > ; )
> > ;
> > - RVCT_ASM_EXPORT __aeabi_uldivmod
> > +__aeabi_uldivmod
> > stmdb sp!, {r4, r5, r6, lr}
> > mov r4, r1
> > mov r5, r0
> > @@ -261,7 +283,6 @@ _ll_div0
> > b __aeabi_ldiv0
> >
> > __aeabi_ldiv0
> > - BX r14
> > + bx r14
> >
> > END
> > -
> > diff --git
> > a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> > b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> > index 44333141a70a..14e88da7ce06 100644
> > --- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> > @@ -23,8 +23,12 @@ [Defines]
> > LIBRARY_CLASS = CompilerIntrinsicsLib
> >
> > [Sources]
> > - memcpy.c
> > - memset.c
> > + memcpy.c | RVCT
> > + memcpy.c | GCC
> > + memcpy_ms.c | MSFT
> > + memset.c | RVCT
> > + memset.c | GCC
> > + memset_ms.c | MSFT
> >
> > [Sources.ARM]
> > Arm/mullu.asm | RVCT
> > @@ -94,6 +98,10 @@ [Sources.ARM]
> > Arm/llsr.S | GCC
> > Arm/llsl.S | GCC
> >
> > + Arm/div.asm | MSFT
> > + Arm/uldiv.asm | MSFT
> > + Arm/ldivmod.asm | MSFT
> > + Arm/llsr.asm | MSFT
> >
> > [Packages]
> > MdePkg/MdePkg.dec
> > @@ -101,3 +109,7 @@ [Packages]
> >
> > [LibraryClasses]
> >
> > +[BuildOptions]
> > + MSFT:*_*_ARM_CC_FLAGS = /GL-
> > + MSFT:*_*_ARM_ASM_FLAGS = /oldit
> > + MSFT:*_*_AARCH64_CC_FLAGS = /GL-
> > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
> > b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
> > new file mode 100644
> > index 000000000000..90bbbb930d31
> > --- /dev/null
> > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
> > @@ -0,0 +1,34 @@
> > +//-------------------------------------------------------------------
> > +-----------
> > +//
> > +// Copyright (c) 2017, Pete Batard. 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.
> > +//
> > +//-------------------------------------------------------------------
> > +-----------
> > +
> > +#if defined(_M_ARM64)
> > +typedef unsigned __int64 size_t;
> > +#else
> > +typedef unsigned __int32 size_t;
> > +#endif
> > +
> > +void* memcpy(void *, const void *, size_t); #pragma intrinsic(memcpy)
> > +#pragma function(memcpy)
> > +void* memcpy(void *dest, const void *src, size_t n) {
> > + unsigned char *d = dest;
> > + unsigned char const *s = src;
> > +
> > + while (n--)
> > + *d++ = *s++;
> > +
> > + return dest;
> > +}
> > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
> > b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
> > new file mode 100644
> > index 000000000000..64205e5d1012
> > --- /dev/null
> > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
> > @@ -0,0 +1,33 @@
> > +//-------------------------------------------------------------------
> > +-----------
> > +//
> > +// Copyright (c) 2017, Pete Batard. 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.
> > +//
> > +//-------------------------------------------------------------------
> > +-----------
> > +
> > +#if defined(_M_ARM64)
> > +typedef unsigned __int64 size_t;
> > +#else
> > +typedef unsigned __int32 size_t;
> > +#endif
> > +
> > +void* memset(void *, int, size_t);
> > +#pragma intrinsic(memset)
> > +#pragma function(memset)
> > +void *memset(void *s, int c, size_t n) {
> > + unsigned char *d = s;
> > +
> > + while (n--)
> > + *d++ = (unsigned char)c;
> > +
> > + return s;
> > +}
> > --
> > 2.9.3.windows.2
> >
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
2018-01-11 15:30 ` Cohen, Eugene
@ 2018-01-11 16:31 ` Pete Batard
2018-01-11 16:56 ` Cohen, Eugene
0 siblings, 1 reply; 14+ messages in thread
From: Pete Batard @ 2018-01-11 16:31 UTC (permalink / raw)
To: Cohen, Eugene, Ard Biesheuvel; +Cc: edk2-devel@lists.01.org, Gao, Liming
Eugene,
How about I modify the patch to use "AREA s_<original_func_name>"
instead of "AREA Math" as per the current proposal?
I believe this should achieve the same result as the one you want,
without having to rely on introducing conditional differences between
MSFT and RVCT, which are going to make the code harder to maintain.
In the places we modified, there was exactly 1 use of the macro per
file, which means that, we should be able to "unroll" the macro and
preserve the existing behaviour, while keeping MSFT happy without having
to define separate macros and conditional stuff.
Also, you'll notice that the current div.asm [1], which is used by RVCT
does *not* rely on the macro, so, unless this is intentional, there
already seems to exist inconsistencies with regards to using the
RVCT_ASM_EXPORT macro to ensure the removal of dead code...
So, to summarise, I would much prefer if we could keep most of the
current patch, and simply use the following where needed:
AREA s___aeabi_ldivmod, CODE, READONLY, ARM
AREA s___aeabi_llsr, CODE, READONLY, ARM
AREA s___aeabi_uldivmod, CODE, READONLY, ARM
What do you think?
Regards,
/Pete
[1]
https://github.com/tianocore/edk2/blob/master/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
On 2018.01.11 15:30, Cohen, Eugene wrote:
>
>>> Introduce CRT assembly replacements for __rt_sdiv, __rt_udiv,
>>> __rt_udiv64, __rt_sdiv64, __rt_srsh (by reusing the RVCT code) as well
>>> as memcpy and memset.
>>> For MSFT compatibility, some of the code needs to be explicitly forced
>>> to ARM, and the /oldit assembly flag needs to be added.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Pete Batard <pete@akeo.ie>
>>
>> This looks fine to me but I haven't been able to test it.
>>
>> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>
>> Eugene: any comments regarding the changes to RVCT code?
>
> I've been away in Linux land for a while, it's nice that the day I catch up on my edk2-devel backlog I see my name! :)
>
> One concern for RVCT is that every function is in its own section to enable proper dead code removal. This is addressed with this macro:
>
> MACRO
> RVCT_ASM_EXPORT $func
> EXPORT $func
> AREA s_$func, CODE, READONLY
> $func
> MEND
>
> note the AREA directive - this makes a section per function.
>
> Pete's patchset removes these macros which breaks dead code removal.
>
> Please restore these macros for at least RVCT and please verify that the VS2017 path does appropriate dead code removal for these assembly functions.
>
> Thanks!
>
> Eugene
>
>>
>>
>>> ---
>>> ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm | 43
>> +++++++++++++++++---
>>> ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm | 40
>> +++++++++++++-----
>>> ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm | 22 +++++----
>> -
>>> ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 29
>> +++++++++++--
>>> ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 16
>> +++++++-
>>> ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c | 34
>> ++++++++++++++++
>>> ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c | 33
>> +++++++++++++++
>>> 7 files changed, 185 insertions(+), 32 deletions(-)
>>>
>>> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
>>> b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
>>> index b539e516892d..f9e0107395f2 100644
>>> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
>>> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
>>> @@ -1,6 +1,7 @@
>>>
>>> //--------------------------------------------------------------------
>>> ----------
>>> //
>>> // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
>>> +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
>>> //
>>> // This program and the accompanying materials // are licensed and
>>> made available under the terms and conditions of the BSD License @@
>>> -17,18 +18,19 @@
>>> EXPORT __aeabi_uidivmod
>>> EXPORT __aeabi_idiv
>>> EXPORT __aeabi_idivmod
>>> + EXPORT __rt_udiv
>>> + EXPORT __rt_sdiv
>>>
>>> AREA Math, CODE, READONLY
>>>
>>> ;
>>> ;UINT32
>>> ;EFIAPI
>>> -;__aeabi_uidivmode (
>>> -; IN UINT32 Dividen
>>> +;__aeabi_uidivmod (
>>> +; IN UINT32 Dividend
>>> ; IN UINT32 Divisor
>>> ; );
>>> ;
>>> -
>>> __aeabi_uidiv
>>> __aeabi_uidivmod
>>> RSBS r12, r1, r0, LSR #4
>>> @@ -40,10 +42,40 @@ __aeabi_uidivmod
>>> B __arm_div_large
>>>
>>> ;
>>> +;UINT64
>>> +;EFIAPI
>>> +;__rt_udiv (
>>> +; IN UINT32 Divisor,
>>> +; IN UINT32 Dividend
>>> +; );
>>> +;
>>> +__rt_udiv
>>> + ; Swap R0 and R1
>>> + MOV r12, r0
>>> + MOV r0, r1
>>> + MOV r1, r12
>>> + B __aeabi_uidivmod
>>> +
>>> +;
>>> +;UINT64
>>> +;EFIAPI
>>> +;__rt_sdiv (
>>> +; IN INT32 Divisor,
>>> +; IN INT32 Dividend
>>> +; );
>>> +;
>>> +__rt_sdiv
>>> + ; Swap R0 and R1
>>> + MOV r12, r0
>>> + MOV r0, r1
>>> + MOV r1, r12
>>> + B __aeabi_idivmod
>>> +
>>> +;
>>> ;INT32
>>> ;EFIAPI
>>> -;__aeabi_idivmode (
>>> -; IN INT32 Dividen
>>> +;__aeabi_idivmod (
>>> +; IN INT32 Dividend
>>> ; IN INT32 Divisor
>>> ; );
>>> ;
>>> @@ -152,4 +184,3 @@ __aeabi_idiv0
>>> BX r14
>>>
>>> END
>>> -
>>> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
>>> b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
>>> index c71bd59e4520..3794cac35eed 100644
>>> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
>>> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
>>> @@ -1,6 +1,7 @@
>>>
>>> //--------------------------------------------------------------------
>>> ----------
>>> //
>>> // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
>>> +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
>>> //
>>> // This program and the accompanying materials // are licensed and
>>> made available under the terms and conditions of the BSD License @@
>>> -13,20 +14,41 @@
>>>
>>> //--------------------------------------------------------------------
>>> ----------
>>>
>>>
>>> - EXTERN __aeabi_uldivmod
>>> + IMPORT __aeabi_uldivmod
>>> + EXPORT __aeabi_ldivmod
>>> + EXPORT __rt_sdiv64
>>>
>>> - INCLUDE AsmMacroExport.inc
>>> + AREA Math, CODE, READONLY, ARM
>>> +
>>> + ARM
>>>
>>> ;
>>> -;UINT32
>>> +;INT64
>>> ;EFIAPI
>>> -;__aeabi_uidivmode (
>>> -; IN UINT32 Dividen
>>> -; IN UINT32 Divisor
>>> +;__rt_sdiv64 (
>>> +; IN INT64 Divisor
>>> +; IN INT64 Dividend
>>> ; );
>>> ;
>>> +__rt_sdiv64
>>> + ; Swap r0-r1 and r2-r3
>>> + MOV r12, r0
>>> + MOV r0, r2
>>> + MOV r2, r12
>>> + MOV r12, r1
>>> + MOV r1, r3
>>> + MOV r3, r12
>>> + B __aeabi_ldivmod
>>>
>>> - RVCT_ASM_EXPORT __aeabi_ldivmod
>>> +;
>>> +;INT64
>>> +;EFIAPI
>>> +;__aeabi_ldivmod (
>>> +; IN INT64 Dividend
>>> +; IN INT64 Divisor
>>> +; );
>>> +;
>>> +__aeabi_ldivmod
>>> PUSH {r4,lr}
>>> ASRS r4,r1,#1
>>> EOR r4,r4,r3,LSR #1
>>> @@ -39,7 +61,7 @@ L_Test1
>>> RSBS r2,r2,#0
>>> RSC r3,r3,#0
>>> L_Test2
>>> - BL __aeabi_uldivmod ;
>>> + BL __aeabi_uldivmod
>>> TST r4,#0x40000000
>>> BEQ L_Test3
>>> RSBS r0,r0,#0
>>> @@ -53,5 +75,3 @@ L_Exit
>>> POP {r4,pc}
>>>
>>> END
>>> -
>>> -
>>> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
>>> b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
>>> index 881db106d9d7..db2fd5057832 100644
>>> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
>>> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
>>> @@ -1,6 +1,7 @@
>>>
>>> //--------------------------------------------------------------------
>>> ----------
>>> //
>>> // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
>>> +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
>>> //
>>> // This program and the accompanying materials // are licensed and
>>> made available under the terms and conditions of the BSD License @@
>>> -12,32 +13,33 @@ //
>>>
>>> //--------------------------------------------------------------------
>>> ----------
>>>
>>> + EXPORT __aeabi_llsr
>>> + EXPORT __rt_srsh
>>>
>>> + AREA Math, CODE, READONLY, ARM
>>>
>>> - INCLUDE AsmMacroExport.inc
>>> + ARM
>>>
>>> ;
>>> ;VOID
>>> ;EFIAPI
>>> ;__aeabi_llsr (
>>> -; IN VOID *Destination,
>>> -; IN VOID *Source,
>>> -; IN UINT32 Size
>>> -; );
>>> +; IN UINT64 Value,
>>> +; IN UINT32 Shift
>>> +;)
>>> ;
>>> - RVCT_ASM_EXPORT __aeabi_llsr
>>> +__aeabi_llsr
>>> +__rt_srsh
>>> SUBS r3,r2,#0x20
>>> - BPL {pc} + 0x18 ; 0x1c
>>> + BPL __aeabi_llsr_label1
>>> RSB r3,r2,#0x20
>>> LSR r0,r0,r2
>>> ORR r0,r0,r1,LSL r3
>>> LSR r1,r1,r2
>>> BX lr
>>> +__aeabi_llsr_label1
>>> LSR r0,r1,r3
>>> MOV r1,#0
>>> BX lr
>>>
>>> END
>>> -
>>> -
>>> -
>>> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
>>> b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
>>> index 6b6184ebd3fc..c5632b4e95e7 100644
>>> --- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
>>> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
>>> @@ -1,6 +1,7 @@
>>>
>>> //--------------------------------------------------------------------
>>> ----------
>>> //
>>> // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
>>> +// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
>>> //
>>> // This program and the accompanying materials // are licensed and
>>> made available under the terms and conditions of the BSD License @@
>>> -13,9 +14,30 @@
>>>
>>> //--------------------------------------------------------------------
>>> ----------
>>>
>>>
>>> + EXPORT __aeabi_uldivmod
>>> + EXPORT __rt_udiv64
>>>
>>> + AREA Math, CODE, READONLY, ARM
>>>
>>> - INCLUDE AsmMacroExport.inc
>>> + ARM
>>> +
>>> +;
>>> +;UINT64
>>> +;EFIAPI
>>> +;__rt_udiv64 (
>>> +; IN UINT64 Divisor
>>> +; IN UINT64 Dividend
>>> +; )
>>> +;
>>> +__rt_udiv64
>>> + ; Swap r0-r1 and r2-r3
>>> + mov r12, r0
>>> + mov r0, r2
>>> + mov r2, r12
>>> + mov r12, r1
>>> + mov r1, r3
>>> + mov r3, r12
>>> + b __aeabi_uldivmod
>>>
>>> ;
>>> ;UINT64
>>> @@ -25,7 +47,7 @@
>>> ; IN UINT64 Divisor
>>> ; )
>>> ;
>>> - RVCT_ASM_EXPORT __aeabi_uldivmod
>>> +__aeabi_uldivmod
>>> stmdb sp!, {r4, r5, r6, lr}
>>> mov r4, r1
>>> mov r5, r0
>>> @@ -261,7 +283,6 @@ _ll_div0
>>> b __aeabi_ldiv0
>>>
>>> __aeabi_ldiv0
>>> - BX r14
>>> + bx r14
>>>
>>> END
>>> -
>>> diff --git
>>> a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
>>> b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
>>> index 44333141a70a..14e88da7ce06 100644
>>> --- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
>>> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
>>> @@ -23,8 +23,12 @@ [Defines]
>>> LIBRARY_CLASS = CompilerIntrinsicsLib
>>>
>>> [Sources]
>>> - memcpy.c
>>> - memset.c
>>> + memcpy.c | RVCT
>>> + memcpy.c | GCC
>>> + memcpy_ms.c | MSFT
>>> + memset.c | RVCT
>>> + memset.c | GCC
>>> + memset_ms.c | MSFT
>>>
>>> [Sources.ARM]
>>> Arm/mullu.asm | RVCT
>>> @@ -94,6 +98,10 @@ [Sources.ARM]
>>> Arm/llsr.S | GCC
>>> Arm/llsl.S | GCC
>>>
>>> + Arm/div.asm | MSFT
>>> + Arm/uldiv.asm | MSFT
>>> + Arm/ldivmod.asm | MSFT
>>> + Arm/llsr.asm | MSFT
>>>
>>> [Packages]
>>> MdePkg/MdePkg.dec
>>> @@ -101,3 +109,7 @@ [Packages]
>>>
>>> [LibraryClasses]
>>>
>>> +[BuildOptions]
>>> + MSFT:*_*_ARM_CC_FLAGS = /GL-
>>> + MSFT:*_*_ARM_ASM_FLAGS = /oldit
>>> + MSFT:*_*_AARCH64_CC_FLAGS = /GL-
>>> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
>>> b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
>>> new file mode 100644
>>> index 000000000000..90bbbb930d31
>>> --- /dev/null
>>> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
>>> @@ -0,0 +1,34 @@
>>> +//-------------------------------------------------------------------
>>> +-----------
>>> +//
>>> +// Copyright (c) 2017, Pete Batard. 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.
>>> +//
>>> +//-------------------------------------------------------------------
>>> +-----------
>>> +
>>> +#if defined(_M_ARM64)
>>> +typedef unsigned __int64 size_t;
>>> +#else
>>> +typedef unsigned __int32 size_t;
>>> +#endif
>>> +
>>> +void* memcpy(void *, const void *, size_t); #pragma intrinsic(memcpy)
>>> +#pragma function(memcpy)
>>> +void* memcpy(void *dest, const void *src, size_t n) {
>>> + unsigned char *d = dest;
>>> + unsigned char const *s = src;
>>> +
>>> + while (n--)
>>> + *d++ = *s++;
>>> +
>>> + return dest;
>>> +}
>>> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
>>> b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
>>> new file mode 100644
>>> index 000000000000..64205e5d1012
>>> --- /dev/null
>>> +++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
>>> @@ -0,0 +1,33 @@
>>> +//-------------------------------------------------------------------
>>> +-----------
>>> +//
>>> +// Copyright (c) 2017, Pete Batard. 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.
>>> +//
>>> +//-------------------------------------------------------------------
>>> +-----------
>>> +
>>> +#if defined(_M_ARM64)
>>> +typedef unsigned __int64 size_t;
>>> +#else
>>> +typedef unsigned __int32 size_t;
>>> +#endif
>>> +
>>> +void* memset(void *, int, size_t);
>>> +#pragma intrinsic(memset)
>>> +#pragma function(memset)
>>> +void *memset(void *s, int c, size_t n) {
>>> + unsigned char *d = s;
>>> +
>>> + while (n--)
>>> + *d++ = (unsigned char)c;
>>> +
>>> + return s;
>>> +}
>>> --
>>> 2.9.3.windows.2
>>>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
2018-01-11 16:31 ` Pete Batard
@ 2018-01-11 16:56 ` Cohen, Eugene
2018-01-12 9:58 ` Ard Biesheuvel
0 siblings, 1 reply; 14+ messages in thread
From: Cohen, Eugene @ 2018-01-11 16:56 UTC (permalink / raw)
To: Pete Batard, Ard Biesheuvel; +Cc: edk2-devel@lists.01.org, Gao, Liming
Pete,
> How about I modify the patch to use "AREA s_<original_func_name>"
> instead of "AREA Math" as per the current proposal?
That's how it used to work before the macro was introduced, per commit dcb2e4bb61931e2dee1739bb76aba315002f0a82 two years ago.
I personally have no problem going back to the individual AREA s_<name> approach now that we have a good reason to do so.
> Also, you'll notice that the current div.asm [1], which is used by RVCT does
> *not* rely on the macro, so, unless this is intentional, there already seems
> to exist inconsistencies with regards to using the RVCT_ASM_EXPORT
> macro to ensure the removal of dead code...
I think this was likely an oversight.
> So, to summarise, I would much prefer if we could keep most of the
> current patch, and simply use the following where needed:
>
> AREA s___aeabi_ldivmod, CODE, READONLY, ARM AREA s___aeabi_llsr,
> CODE, READONLY, ARM AREA s___aeabi_uldivmod, CODE, READONLY,
> ARM
>
Agreed, this is fine so long as we agree on the definition of "where needed". In general I would expect each independent assembly function to have its own AREA directive (e.g. math functions). In some cases there will clearly be a collection of dependent functions that would be better served by a single area directive (e.g. MMU initialization functions).
Much Thanks!
Eugene
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
2018-01-11 16:56 ` Cohen, Eugene
@ 2018-01-12 9:58 ` Ard Biesheuvel
2018-01-12 11:10 ` Pete Batard
0 siblings, 1 reply; 14+ messages in thread
From: Ard Biesheuvel @ 2018-01-12 9:58 UTC (permalink / raw)
To: Cohen, Eugene; +Cc: Pete Batard, edk2-devel@lists.01.org, Gao, Liming
On 11 January 2018 at 16:56, Cohen, Eugene <eugene@hp.com> wrote:
> Pete,
>
>> How about I modify the patch to use "AREA s_<original_func_name>"
>> instead of "AREA Math" as per the current proposal?
>
> That's how it used to work before the macro was introduced, per commit dcb2e4bb61931e2dee1739bb76aba315002f0a82 two years ago.
>
> I personally have no problem going back to the individual AREA s_<name> approach now that we have a good reason to do so.
>
>> Also, you'll notice that the current div.asm [1], which is used by RVCT does
>> *not* rely on the macro, so, unless this is intentional, there already seems
>> to exist inconsistencies with regards to using the RVCT_ASM_EXPORT
>> macro to ensure the removal of dead code...
>
> I think this was likely an oversight.
>
>> So, to summarise, I would much prefer if we could keep most of the
>> current patch, and simply use the following where needed:
>>
>> AREA s___aeabi_ldivmod, CODE, READONLY, ARM AREA s___aeabi_llsr,
>> CODE, READONLY, ARM AREA s___aeabi_uldivmod, CODE, READONLY,
>> ARM
>>
>
> Agreed, this is fine so long as we agree on the definition of "where needed". In general I would expect each independent assembly function to have its own AREA directive (e.g. math functions). In some cases there will clearly be a collection of dependent functions that would be better served by a single area directive (e.g. MMU initialization functions).
>
> Much Thanks!
>
> Eugene
>
Agreed.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
2018-01-12 9:58 ` Ard Biesheuvel
@ 2018-01-12 11:10 ` Pete Batard
2018-01-12 13:25 ` Ard Biesheuvel
0 siblings, 1 reply; 14+ messages in thread
From: Pete Batard @ 2018-01-12 11:10 UTC (permalink / raw)
To: Ard Biesheuvel, Cohen, Eugene; +Cc: edk2-devel@lists.01.org, Gao, Liming
On 2018.01.12 09:58, Ard Biesheuvel wrote:
>>> So, to summarise, I would much prefer if we could keep most of the
>>> current patch, and simply use the following where needed:
>>>
>>> AREA s___aeabi_ldivmod, CODE, READONLY, ARM AREA s___aeabi_llsr,
>>> CODE, READONLY, ARM AREA s___aeabi_uldivmod, CODE, READONLY,
>>> ARM
>>>
>>
>> Agreed, this is fine so long as we agree on the definition of "where needed". In general I would expect each independent assembly function to have its own AREA directive (e.g. math functions). In some cases there will clearly be a collection of dependent functions that would be better served by a single area directive (e.g. MMU initialization functions).
>>
>> Much Thanks!
>>
>> Eugene
>>
>
> Agreed.
Okay.
Introducing/grouping/reviewing the code areas goes beyond the scope of
what I am planning to do for this proposal, especially as the current
goal is to leave RVCT with as little disturbance as possible, even if
some improvements might be applied...
So the only thing I am planning to do with the AREA's right now is have
them under the exact same name they would have used with the RVCT_...
macros.
I'll send a new patch to that effect in a couple hours.
Regards,
/Pete
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
2018-01-12 11:10 ` Pete Batard
@ 2018-01-12 13:25 ` Ard Biesheuvel
0 siblings, 0 replies; 14+ messages in thread
From: Ard Biesheuvel @ 2018-01-12 13:25 UTC (permalink / raw)
To: Pete Batard; +Cc: Cohen, Eugene, edk2-devel@lists.01.org, Gao, Liming
On 12 January 2018 at 11:10, Pete Batard <pete@akeo.ie> wrote:
> On 2018.01.12 09:58, Ard Biesheuvel wrote:
>>>>
>>>> So, to summarise, I would much prefer if we could keep most of the
>>>> current patch, and simply use the following where needed:
>>>>
>>>> AREA s___aeabi_ldivmod, CODE, READONLY, ARM AREA s___aeabi_llsr,
>>>> CODE, READONLY, ARM AREA s___aeabi_uldivmod, CODE, READONLY,
>>>> ARM
>>>>
>>>
>>> Agreed, this is fine so long as we agree on the definition of "where
>>> needed". In general I would expect each independent assembly function to
>>> have its own AREA directive (e.g. math functions). In some cases there will
>>> clearly be a collection of dependent functions that would be better served
>>> by a single area directive (e.g. MMU initialization functions).
>>>
>>> Much Thanks!
>>>
>>> Eugene
>>>
>>
>> Agreed.
>
>
> Okay.
>
> Introducing/grouping/reviewing the code areas goes beyond the scope of what
> I am planning to do for this proposal, especially as the current goal is to
> leave RVCT with as little disturbance as possible, even if some improvements
> might be applied...
>
> So the only thing I am planning to do with the AREA's right now is have them
> under the exact same name they would have used with the RVCT_... macros.
>
That's fine.
> I'll send a new patch to that effect in a couple hours.
>
> Regards,
>
> /Pete
Thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2018-01-12 13:20 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-10 16:26 [PATCH v4 0/6] Add ARM support for VS2017 Pete Batard
2018-01-10 16:26 ` [PATCH v4 1/6] MdePkg: Disable some Level 4 warnings for VS2017/ARM Pete Batard
2018-01-10 16:26 ` [PATCH v4 2/6] MdePkg/Library/BaseStackCheckLib: Add Null handler " Pete Batard
2018-01-10 16:26 ` [PATCH v4 3/6] MdePkg/Library/BaseLib: Enable VS2017/ARM builds Pete Batard
2018-01-10 16:26 ` [PATCH v4 4/6] ArmPkg/Library/CompilerIntrinsicsLib: " Pete Batard
2018-01-11 10:46 ` Ard Biesheuvel
2018-01-11 15:30 ` Cohen, Eugene
2018-01-11 16:31 ` Pete Batard
2018-01-11 16:56 ` Cohen, Eugene
2018-01-12 9:58 ` Ard Biesheuvel
2018-01-12 11:10 ` Pete Batard
2018-01-12 13:25 ` Ard Biesheuvel
2018-01-10 16:26 ` [PATCH v4 5/6] MdePkg/Include: Add VA list support for VS2017/ARM Pete Batard
2018-01-10 16:26 ` [PATCH v4 6/6] BaseTools/Conf: Add VS2017/ARM support Pete Batard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox