Commit 5847a636 authored by Daniel Schaefer's avatar Daniel Schaefer Committed by Barton Gao
Browse files

SctPkg: Add RISCV64 build support

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3042



Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>
Cc: Barton Gao <gaojie@byosoft.com.cn>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Cc: Eric Jin <eric.jin@intel.com>
Cc: Arvin Chen <arvinx.chen@intel.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Abner Chang <abner.chang@hpe.com>
Signed-off-by: default avatarDaniel Schaefer <daniel.schaefer@hpe.com>
Reviewed-by: default avatarAbner Chang <abner.chang@hpe.com>
Reviewed-by: Sunny Wang's avatarSunny Wang <sunny.wang@arm.com>
parent a635152c
......@@ -3,6 +3,7 @@
Copyright 2006 - 2017 Unified EFI, Inc.<BR>
Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2014, ARM Ltd. All rights reserved.<BR>
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
......@@ -32,6 +33,9 @@
#elif defined(EFIAARCH64)
#define INSTALL_SCT_PLATFORM_SHORT_NAME L"aarch64"
#define INSTALL_SCT_PLATFORM_NAME L"AARCH64"
#elif defined(EFIRISCV64)
#define INSTALL_SCT_PLATFORM_SHORT_NAME L"riscv64"
#define INSTALL_SCT_PLATFORM_NAME L"RISCV64"
#else
#error "Architecture not supported"
#endif
......
......@@ -3,6 +3,7 @@
# Copyright 2006 - 2016 Unified EFI, Inc.<BR>
# Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.<BR>
# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -62,6 +63,11 @@
Aarch64/initplat.c
Math.c
[sources.RISCV64]
Riscv64/SctLibPlat.h
Riscv64/initplat.c
Math.c
[sources.ia32]
ia32/SctLibPlat.h
ia32/initplat.c
......
......@@ -2,6 +2,7 @@
#
# Copyright 2006 - 2016 Unified EFI, Inc.<BR>
# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -39,6 +40,10 @@
Aarch64/GoVirtual.asm | RVCT
Aarch64/GoVirtual.S | GCC
[sources.RISCV64]
Riscv64/VirtualMemory.c
Riscv64/GoVirtual.S | GCC
[sources.ia32]
ia32/VirtualMemory.c
ia32/GoVirtual.asm | MSFT
......
......@@ -2,6 +2,7 @@
#
# Copyright 2006 - 2016 Unified EFI, Inc.<BR>
# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -69,6 +70,11 @@
Aarch64/Dump.c
Aarch64/Debug.c
[sources.RISCV64]
Riscv64/Io.c
Riscv64/Dump.c
Riscv64/Debug.c
[sources.common]
Guid.h
Guid.c
......
......@@ -3,6 +3,7 @@
# Copyright 2006 - 2012 Unified EFI, Inc.<BR>
# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2019, ARM Ltd. All rights reserved.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -67,6 +68,11 @@
Aarch64/DebugSupportBBTestExceptionCallbackFunction.c
Aarch64/DebugSupportBBTestCacheFunction.c
[sources.RISCV64]
Riscv64/PlatformIsa.c
Riscv64/DebugSupportBBTestExceptionCallbackFunction.c
Riscv64/DebugSupportBBTestCacheFunction.c
[Packages]
SctPkg/SctPkg.dec
SctPkg/UEFI/UEFI.dec
......
......@@ -2,6 +2,7 @@
#
# Copyright 2006 - 2016 Unified EFI, Inc.<BR>
# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -55,6 +56,9 @@
#[sources.Aarch64]
# IPF/TimerInterrupt.c
#[sources.Riscv64]
# IPF/TimerInterrupt.c
[Packages]
MdePkg/MdePkg.dec
SctPkg/SctPkg.dec
......
......@@ -2,6 +2,7 @@
#
# Copyright 2006 - 2012 Unified EFI, Inc.<BR>
# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -55,6 +56,9 @@
[sources.Aarch64]
Aarch64/TimerInterrupt.c
[sources.RISCV64]
Riscv64/TimerInterrupt.c
[Packages]
MdePkg/MdePkg.dec
SctPkg/SctPkg.dec
......
......@@ -3,6 +3,7 @@
# Copyright 2006 - 2012 Unified EFI, Inc.<BR>
# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2019, ARM Ltd. All rights reserved.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -66,6 +67,10 @@
Aarch64/EntsLibPlat.h
Aarch64/InitPlat.c
[sources.RISCV64]
Riscv64/EntsLibPlat.h
Riscv64/InitPlat.c
[Packages]
MdePkg/MdePkg.dec
SctPkg/SctPkg.dec
......
#
# Copyright 2006 - 2010 Unified EFI, Inc.<BR>
# Copyright (c) 2010 Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -31,6 +32,9 @@ ifndef ARCH
ifneq (,$(findstring arm,$(uname_m)))
ARCH=ARM
endif
ifneq (,$(findstring riscv64,$(uname_m)))
ARCH=RISCV64
endif
ifndef ARCH
$(info Could not detected ARCH from uname results)
$(error ARCH is not defined!)
......
......@@ -3,6 +3,7 @@
# Copyright 2006 - 2016 Unified EFI, Inc.<BR>
# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2019,Microchip Technology Inc.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -42,7 +43,7 @@
PLATFORM_VERSION = 0.1
DSC_SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/IhvSct
SUPPORTED_ARCHITECTURES = IA32|X64|ARM|AARCH64
SUPPORTED_ARCHITECTURES = IA32|X64|ARM|AARCH64|RISCV64
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
......@@ -109,6 +110,12 @@
*_*_AARCH64_PP_FLAGS = -D EFIAARCH64 $(GCC_VER_MACRO)
RVCT:*_*_AARCH64_DLINK_FLAGS = --muldefweak
*_*_RISCV64_CC_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO)
GCC:*_*_RISCV64_CC_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO) -ffreestanding -nostdinc -nostdlib -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error
*_*_RISCV64_VFRPP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO)
*_*_RISCV64_APP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO)
*_*_RISCV64_PP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO)
DEBUG_*_*_CC_FLAGS = -DEFI_DEBUG
RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
......@@ -124,6 +131,9 @@
[Libraries.AARCH64]
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
[Libraries.RISCV64]
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
[Libraries.IA32,Libraries.X64]
[LibraryClasses.common]
......@@ -146,6 +156,9 @@
[LibraryClasses.AARCH64]
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
[LibraryClasses.RISCV64]
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
[LibraryClasses.IA32]
###############################################################################
......@@ -228,4 +241,4 @@ SctPkg/TestInfrastructure/SCT/Framework/Sct.inf
[Components.IA32, Components.X64]
SctPkg/TestCase/UEFI/IHV/Protocol/PlatformDriverOverride/BlackBoxTest/IhvPlatformDriverOverrideBBTest.inf
SctPkg/TestCase/UEFI/IHV/Protocol/PlatformToDriverConfiguration/BlackBoxTest/IhvPlatformToDriverConfigurationBBTest.inf
\ No newline at end of file
SctPkg/TestCase/UEFI/IHV/Protocol/PlatformToDriverConfiguration/BlackBoxTest/IhvPlatformToDriverConfigurationBBTest.inf
......@@ -2,6 +2,7 @@
Copyright 2006 - 2016 Unified EFI, Inc.<BR>
Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
......@@ -607,6 +608,60 @@ typedef struct {
UINT64 FAR; // Fault Address Register
} EFI_SYSTEM_CONTEXT_AARCH64;
///
/// RISC-V processor exception types.
///
#define EXCEPT_RISCV_INST_MISALIGNED 0
#define EXCEPT_RISCV_INST_ACCESS_FAULT 1
#define EXCEPT_RISCV_ILLEGAL_INST 2
#define EXCEPT_RISCV_BREAKPOINT 3
#define EXCEPT_RISCV_LOAD_ADDRESS_MISALIGNED 4
#define EXCEPT_RISCV_LOAD_ACCESS_FAULT 5
#define EXCEPT_RISCV_STORE_AMO_ADDRESS_MISALIGNED 6
#define EXCEPT_RISCV_STORE_AMO_ACCESS_FAULT 7
#define EXCEPT_RISCV_ENV_CALL_FROM_UMODE 8
#define EXCEPT_RISCV_ENV_CALL_FROM_SMODE 9
#define EXCEPT_RISCV_ENV_CALL_FROM_HMODE 10
#define EXCEPT_RISCV_ENV_CALL_FROM_MMODE 11
#define EXCEPT_RISCV_SOFTWARE_INT 0x0
#define EXCEPT_RISCV_TIMER_INT 0x1
typedef struct {
UINT64 X0;
UINT64 X1;
UINT64 X2;
UINT64 X3;
UINT64 X4;
UINT64 X5;
UINT64 X6;
UINT64 X7;
UINT64 X8;
UINT64 X9;
UINT64 X10;
UINT64 X11;
UINT64 X12;
UINT64 X13;
UINT64 X14;
UINT64 X15;
UINT64 X16;
UINT64 X17;
UINT64 X18;
UINT64 X19;
UINT64 X20;
UINT64 X21;
UINT64 X22;
UINT64 X23;
UINT64 X24;
UINT64 X25;
UINT64 X26;
UINT64 X27;
UINT64 X28;
UINT64 X29;
UINT64 X30;
UINT64 X31;
} EFI_SYSTEM_CONTEXT_RISCV64;
//
// Universal EFI_SYSTEM_CONTEXT definition
//
......@@ -618,6 +673,7 @@ union {
EFI_SYSTEM_CONTEXT_IPF *SystemContextIpf;
EFI_SYSTEM_CONTEXT_ARM *SystemContextArm;
EFI_SYSTEM_CONTEXT_AARCH64 *SystemContextAArch64;
EFI_SYSTEM_CONTEXT_RISCV64 *SystemContextRiscV64;
} EFI_SYSTEM_CONTEXT;
//
......@@ -645,6 +701,8 @@ VOID
#define IMAGE_FILE_MACHINE_EBC 0x0EBC
#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED 0x01c2
#define IMAGE_FILE_MACHINE_ARM64 0xAA64
#define IMAGE_FILE_MACHINE_RISCV64 0x5064
typedef
enum {
......@@ -653,7 +711,8 @@ enum {
IsaIpf = IMAGE_FILE_MACHINE_IA64,
IsaEbc = IMAGE_FILE_MACHINE_EBC,
IsaArm = IMAGE_FILE_MACHINE_ARMTHUMB_MIXED, ///< 0x01c2
IsaAArch64 = IMAGE_FILE_MACHINE_ARM64 ///< 0xAA64
IsaAArch64 = IMAGE_FILE_MACHINE_ARM64, ///< 0xAA64
IsaRiscv64 = IMAGE_FILE_MACHINE_RISCV64 ///< 0x5064
} EFI_INSTRUCTION_SET_ARCHITECTURE;
typedef struct _EFI_DEBUG_SUPPORT_PROTOCOL EFI_DEBUG_SUPPORT_PROTOCOL;;
......
......@@ -2,7 +2,7 @@
#
# Copyright 2006 - 2017 Unified EFI, Inc.<BR>
# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>
# (C) Copyright 2017 - 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -42,7 +42,7 @@
PLATFORM_VERSION = 0.1
DSC_SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/UefiSct
SUPPORTED_ARCHITECTURES = IA32|X64|ARM|AARCH64
SUPPORTED_ARCHITECTURES = IA32|X64|ARM|AARCH64|RISCV64
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
......@@ -112,6 +112,12 @@
*_*_AARCH64_PP_FLAGS = -D EFIAARCH64 $(GCC_VER_MACRO)
RVCT:*_*_AARCH64_DLINK_FLAGS = --muldefweak
*_*_RISCV64_CC_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO)
GCC:*_*_RISCV64_CC_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO) -ffreestanding -nostdinc -nostdlib -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error
*_*_RISCV64_VFRPP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO)
*_*_RISCV64_APP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO)
*_*_RISCV64_PP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO)
DEBUG_*_*_CC_FLAGS = -DEFI_DEBUG
RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
......@@ -129,6 +135,9 @@
[Libraries.AARCH64]
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
[Libraries.RISCV64]
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
[LibraryClasses.common]
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
......@@ -157,6 +166,9 @@
[LibraryClasses.AARCH64]
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
[LibraryClasses.RISCV64]
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
###############################################################################
#
# These are the components that will be built by the master makefile
......@@ -483,4 +495,4 @@ SctPkg/TestCase/RIVL/Protocol/Http/Http/HttpENTSTest.inf
SctPkg/TestCase/RIVL/Protocol/Http/HttpServiceBinding/HttpServiceBindingENTSTest.inf
[Components.IA32, Components.X64]
SctPkg/TestCase/UEFI/EFI/Generic/ExeMode/BlackBoxTest/ExeModeBBTest.inf
\ No newline at end of file
SctPkg/TestCase/UEFI/EFI/Generic/ExeMode/BlackBoxTest/ExeModeBBTest.inf
......@@ -2,6 +2,7 @@
#
# Copyright 2006 - 2015 Unified EFI, Inc.<BR>
# Copyright (c) 2011 - 2020, ARM Ltd. All rights reserved.<BR>
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
......@@ -22,6 +23,8 @@ function get_build_arch
BUILD_ARCH=ARM;;
aarch64*)
BUILD_ARCH=AARCH64;;
riscv64*)
BUILD_ARCH=RISCV64;;
*)
BUILD_ARCH=other;;
esac
......@@ -47,6 +50,12 @@ function set_cross_compile
else
TEMP_CROSS_COMPILE=arm-linux-gnueabihf-
fi
elif [ "$SCT_TARGET_ARCH" == "RISCV64" ]; then
if [ X"$CROSS_COMPILE_64" != X"" ]; then
TEMP_CROSS_COMPILE="$CROSS_COMPILE_64"
else
TEMP_CROSS_COMPILE=riscv64-unknown-elf-
fi
else
echo "Unsupported target architecture '$SCT_TARGET_ARCH'!" >&2
fi
......@@ -110,7 +119,7 @@ PrintUsage() {
#Print Help
#
echo "Usage:"
echo " $0 <architecture (ARM, AARCH64, X64, etc)> \
echo " $0 <architecture (ARM, AARCH64, X64, RISCV64, etc)> \
<toolchain name (RVCT or ARMGCC or GCC*)> \
[build type (RELEASE OR DEBUG, DEFAULT: DEBUG)]"
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment