]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/RiscV64/ProcessorBind.h
MdePkg: Add RISC-V RISCV64 binding
[mirror_edk2.git] / MdePkg / Include / RiscV64 / ProcessorBind.h
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