]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Add RISC-V RISCV64 binding
authorAbner Chang <abner.chang@hpe.com>
Tue, 7 Apr 2020 07:45:31 +0000 (15:45 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 7 May 2020 03:17:15 +0000 (03:17 +0000)
Add RISCV64 sections in MdePkg.dec and RISCV64 ProcessorBind.h

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

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Co-authored-by: Gilbert Chen <gilbert.chen@hpe.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Gilbert Chen <gilbert.chen@hpe.com>
MdePkg/Include/RiscV64/ProcessorBind.h [new file with mode: 0644]
MdePkg/MdePkg.dec
MdePkg/MdePkg.dsc

diff --git a/MdePkg/Include/RiscV64/ProcessorBind.h b/MdePkg/Include/RiscV64/ProcessorBind.h
new file mode 100644 (file)
index 0000000..2b11f04
--- /dev/null
@@ -0,0 +1,173 @@
+/** @file\r
+  Processor or Compiler specific defines and types for RISC-V\r
+\r
+  Copyright (c) 2016 - 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef PROCESSOR_BIND_H__\r
+#define PROCESSOR_BIND_H__\r
+\r
+///\r
+/// Define the processor type so other code can make processor based choices\r
+///\r
+#define MDE_CPU_RISCV64\r
+\r
+//\r
+// Make sure we are using the correct packing rules per EFI specification\r
+//\r
+#if !defined(__GNUC__)\r
+#pragma pack()\r
+#endif\r
+\r
+///\r
+/// 8-byte unsigned value\r
+///\r
+typedef unsigned long long  UINT64  __attribute__ ((aligned (8)));\r
+///\r
+/// 8-byte signed value\r
+///\r
+typedef long long           INT64  __attribute__ ((aligned (8)));\r
+///\r
+/// 4-byte unsigned value\r
+///\r
+typedef unsigned int        UINT32 __attribute__ ((aligned (4)));\r
+///\r
+/// 4-byte signed value\r
+///\r
+typedef int                 INT32  __attribute__ ((aligned (4)));\r
+///\r
+/// 2-byte unsigned value\r
+///\r
+typedef unsigned short      UINT16  __attribute__ ((aligned (2)));\r
+///\r
+/// 2-byte Character.  Unless otherwise specified all strings are stored in the\r
+/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r
+///\r
+typedef unsigned short      CHAR16  __attribute__ ((aligned (2)));\r
+///\r
+/// 2-byte signed value\r
+///\r
+typedef short               INT16  __attribute__ ((aligned (2)));\r
+///\r
+/// Logical Boolean.  1-byte value containing 0 for FALSE or a 1 for TRUE.  Other\r
+/// values are undefined.\r
+///\r
+typedef unsigned char       BOOLEAN;\r
+///\r
+/// 1-byte unsigned value\r
+///\r
+typedef unsigned char       UINT8;\r
+///\r
+/// 1-byte Character\r
+///\r
+typedef char                CHAR8;\r
+///\r
+/// 1-byte signed value\r
+///\r
+typedef signed char         INT8;\r
+///\r
+/// Unsigned value of native width.  (4 bytes on supported 32-bit processor instructions,\r
+/// 8 bytes on supported 64-bit processor instructions)\r
+///\r
+typedef UINT64  UINTN __attribute__ ((aligned (8)));\r
+///\r
+/// Signed value of native width.  (4 bytes on supported 32-bit processor instructions,\r
+/// 8 bytes on supported 64-bit processor instructions)\r
+///\r
+typedef INT64   INTN __attribute__ ((aligned (8)));\r
+\r
+//\r
+// Processor specific defines\r
+//\r
+\r
+///\r
+/// A value of native width with the highest bit set.\r
+///\r
+#define MAX_BIT     0x8000000000000000ULL\r
+///\r
+/// A value of native width with the two highest bits set.\r
+///\r
+#define MAX_2_BITS  0xC000000000000000ULL\r
+\r
+///\r
+/// Maximum legal RV64 address\r
+///\r
+#define MAX_ADDRESS   0xFFFFFFFFFFFFFFFFULL\r
+\r
+///\r
+/// Maximum usable address at boot time (48 bits using 4 KB pages in Supervisor mode)\r
+///\r
+#define MAX_ALLOC_ADDRESS   0xFFFFFFFFFFFFULL\r
+\r
+///\r
+/// Maximum legal RISC-V INTN and UINTN values.\r
+///\r
+#define MAX_INTN   ((INTN)0x7FFFFFFFFFFFFFFFULL)\r
+#define MAX_UINTN  ((UINTN)0xFFFFFFFFFFFFFFFFULL)\r
+\r
+///\r
+/// The stack alignment required for RISC-V\r
+///\r
+#define CPU_STACK_ALIGNMENT   16\r
+\r
+///\r
+/// Page allocation granularity for RISC-V\r
+///\r
+#define DEFAULT_PAGE_ALLOCATION_GRANULARITY   (0x1000)\r
+#define RUNTIME_PAGE_ALLOCATION_GRANULARITY   (0x1000)\r
+\r
+//\r
+// Modifier to ensure that all protocol member functions and EFI intrinsics\r
+// use the correct C calling convention. All protocol member functions and\r
+// EFI intrinsics are required to modify their member functions with EFIAPI.\r
+//\r
+#ifdef EFIAPI\r
+  ///\r
+  /// If EFIAPI is already defined, then we use that definition.\r
+  ///\r
+#elif defined(__GNUC__)\r
+  ///\r
+  /// Define the standard calling convention regardless of optimization level\r
+  /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI\r
+  /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)\r
+  /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for\r
+  /// x64. Warning the assembly code in the MDE x64 does not follow the correct\r
+  /// ABI for the standard x64 (x86-64) GCC.\r
+  ///\r
+  #define EFIAPI\r
+#else\r
+  ///\r
+  /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI\r
+  /// is the standard.\r
+  ///\r
+  #define EFIAPI\r
+#endif\r
+\r
+#if defined(__GNUC__)\r
+  ///\r
+  /// For GNU assembly code, .global or .globl can declare global symbols.\r
+  /// Define this macro to unify the usage.\r
+  ///\r
+  #define ASM_GLOBAL .globl\r
+#endif\r
+\r
+/**\r
+  Return the pointer to the first instruction of a function given a function pointer.\r
+  On x64 CPU architectures, these two pointer values are the same,\r
+  so the implementation of this macro is very simple.\r
+\r
+  @param  FunctionPointer   A pointer to a function.\r
+\r
+  @return The pointer to the first instruction of a function given a function pointer.\r
+\r
+**/\r
+#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)\r
+\r
+#ifndef __USER_LABEL_PREFIX__\r
+#define __USER_LABEL_PREFIX__\r
+#endif\r
+\r
+#endif\r
index 6c37c2181c62fb7631710ffa16e7bf54ab5a3c81..0b9c4bc40aced659fb5c32452f3c399ed096aa12 100644 (file)
@@ -6,7 +6,7 @@
 #\r
 # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
+# (C) Copyright 2016 - 2020 Hewlett Packard Enterprise Development LP<BR>\r
 #\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -39,6 +39,9 @@
 [Includes.AARCH64]\r
   Include/AArch64\r
 \r
+[Includes.RISCV64]\r
+  Include/RiscV64\r
+\r
 [LibraryClasses]\r
   ##  @libraryclass  Provides most usb APIs to support the Hid requests defined in Usb Hid 1.1 spec\r
   #                  and the standard requests defined in Usb 1.1 spec.\r
index 2b2d5981e82bc8f47a4e62be010022451e859d96..6cd38e7ec3c9f7a856db70e7d908f18729801151 100644 (file)
@@ -3,6 +3,7 @@
 #\r
 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>\r
 #\r
 #    SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -14,7 +15,7 @@
   PLATFORM_VERSION               = 1.08\r
   DSC_SPECIFICATION              = 0x00010005\r
   OUTPUT_DIRECTORY               = Build/Mde\r
-  SUPPORTED_ARCHITECTURES        = IA32|X64|EBC|ARM|AARCH64\r
+  SUPPORTED_ARCHITECTURES        = IA32|X64|EBC|ARM|AARCH64|RISCV64\r
   BUILD_TARGETS                  = DEBUG|RELEASE|NOOPT\r
   SKUID_IDENTIFIER               = DEFAULT\r
 \r