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