]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/RiscV64/ProcessorBind.h
MdePkg: Add RISC-V RISCV64 binding
[mirror_edk2.git] / MdePkg / Include / RiscV64 / ProcessorBind.h
CommitLineData
1510d6a3
AC
1/** @file\r
2 Processor or Compiler specific defines and types for RISC-V\r
3\r
4 Copyright (c) 2016 - 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r
5\r
6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9\r
10#ifndef PROCESSOR_BIND_H__\r
11#define PROCESSOR_BIND_H__\r
12\r
13///\r
14/// Define the processor type so other code can make processor based choices\r
15///\r
16#define MDE_CPU_RISCV64\r
17\r
18//\r
19// Make sure we are using the correct packing rules per EFI specification\r
20//\r
21#if !defined(__GNUC__)\r
22#pragma pack()\r
23#endif\r
24\r
25///\r
26/// 8-byte unsigned value\r
27///\r
28typedef unsigned long long UINT64 __attribute__ ((aligned (8)));\r
29///\r
30/// 8-byte signed value\r
31///\r
32typedef long long INT64 __attribute__ ((aligned (8)));\r
33///\r
34/// 4-byte unsigned value\r
35///\r
36typedef unsigned int UINT32 __attribute__ ((aligned (4)));\r
37///\r
38/// 4-byte signed value\r
39///\r
40typedef int INT32 __attribute__ ((aligned (4)));\r
41///\r
42/// 2-byte unsigned value\r
43///\r
44typedef unsigned short UINT16 __attribute__ ((aligned (2)));\r
45///\r
46/// 2-byte Character. Unless otherwise specified all strings are stored in the\r
47/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r
48///\r
49typedef unsigned short CHAR16 __attribute__ ((aligned (2)));\r
50///\r
51/// 2-byte signed value\r
52///\r
53typedef short INT16 __attribute__ ((aligned (2)));\r
54///\r
55/// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r
56/// values are undefined.\r
57///\r
58typedef unsigned char BOOLEAN;\r
59///\r
60/// 1-byte unsigned value\r
61///\r
62typedef unsigned char UINT8;\r
63///\r
64/// 1-byte Character\r
65///\r
66typedef char CHAR8;\r
67///\r
68/// 1-byte signed value\r
69///\r
70typedef signed char INT8;\r
71///\r
72/// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,\r
73/// 8 bytes on supported 64-bit processor instructions)\r
74///\r
75typedef UINT64 UINTN __attribute__ ((aligned (8)));\r
76///\r
77/// Signed value of native width. (4 bytes on supported 32-bit processor instructions,\r
78/// 8 bytes on supported 64-bit processor instructions)\r
79///\r
80typedef INT64 INTN __attribute__ ((aligned (8)));\r
81\r
82//\r
83// Processor specific defines\r
84//\r
85\r
86///\r
87/// A value of native width with the highest bit set.\r
88///\r
89#define MAX_BIT 0x8000000000000000ULL\r
90///\r
91/// A value of native width with the two highest bits set.\r
92///\r
93#define MAX_2_BITS 0xC000000000000000ULL\r
94\r
95///\r
96/// Maximum legal RV64 address\r
97///\r
98#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL\r
99\r
100///\r
101/// Maximum usable address at boot time (48 bits using 4 KB pages in Supervisor mode)\r
102///\r
103#define MAX_ALLOC_ADDRESS 0xFFFFFFFFFFFFULL\r
104\r
105///\r
106/// Maximum legal RISC-V INTN and UINTN values.\r
107///\r
108#define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)\r
109#define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)\r
110\r
111///\r
112/// The stack alignment required for RISC-V\r
113///\r
114#define CPU_STACK_ALIGNMENT 16\r
115\r
116///\r
117/// Page allocation granularity for RISC-V\r
118///\r
119#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)\r
120#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)\r
121\r
122//\r
123// Modifier to ensure that all protocol member functions and EFI intrinsics\r
124// use the correct C calling convention. All protocol member functions and\r
125// EFI intrinsics are required to modify their member functions with EFIAPI.\r
126//\r
127#ifdef EFIAPI\r
128 ///\r
129 /// If EFIAPI is already defined, then we use that definition.\r
130 ///\r
131#elif defined(__GNUC__)\r
132 ///\r
133 /// Define the standard calling convention regardless of optimization level\r
134 /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI\r
135 /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)\r
136 /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for\r
137 /// x64. Warning the assembly code in the MDE x64 does not follow the correct\r
138 /// ABI for the standard x64 (x86-64) GCC.\r
139 ///\r
140 #define EFIAPI\r
141#else\r
142 ///\r
143 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI\r
144 /// is the standard.\r
145 ///\r
146 #define EFIAPI\r
147#endif\r
148\r
149#if defined(__GNUC__)\r
150 ///\r
151 /// For GNU assembly code, .global or .globl can declare global symbols.\r
152 /// Define this macro to unify the usage.\r
153 ///\r
154 #define ASM_GLOBAL .globl\r
155#endif\r
156\r
157/**\r
158 Return the pointer to the first instruction of a function given a function pointer.\r
159 On x64 CPU architectures, these two pointer values are the same,\r
160 so the implementation of this macro is very simple.\r
161\r
162 @param FunctionPointer A pointer to a function.\r
163\r
164 @return The pointer to the first instruction of a function given a function pointer.\r
165\r
166**/\r
167#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)\r
168\r
169#ifndef __USER_LABEL_PREFIX__\r
170#define __USER_LABEL_PREFIX__\r
171#endif\r
172\r
173#endif\r