]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/RiscV64/ProcessorBind.h
2 Processor or Compiler specific defines and types for RISC-V
4 Copyright (c) 2016 - 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef PROCESSOR_BIND_H__
11 #define PROCESSOR_BIND_H__
14 /// Define the processor type so other code can make processor based choices
16 #define MDE_CPU_RISCV64
19 // Make sure we are using the correct packing rules per EFI specification
21 #if !defined (__GNUC__)
26 /// 8-byte unsigned value
28 typedef unsigned long long UINT64
__attribute__ ((aligned (8)));
30 /// 8-byte signed value
32 typedef long long INT64
__attribute__ ((aligned (8)));
34 /// 4-byte unsigned value
36 typedef unsigned int UINT32
__attribute__ ((aligned (4)));
38 /// 4-byte signed value
40 typedef int INT32
__attribute__ ((aligned (4)));
42 /// 2-byte unsigned value
44 typedef unsigned short UINT16
__attribute__ ((aligned (2)));
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.
49 typedef unsigned short CHAR16
__attribute__ ((aligned (2)));
51 /// 2-byte signed value
53 typedef short INT16
__attribute__ ((aligned (2)));
55 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
56 /// values are undefined.
58 typedef unsigned char BOOLEAN
;
60 /// 1-byte unsigned value
62 typedef unsigned char UINT8
;
68 /// 1-byte signed value
70 typedef signed char INT8
;
72 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
73 /// 8 bytes on supported 64-bit processor instructions)
75 typedef UINT64 UINTN
__attribute__ ((aligned (8)));
77 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
78 /// 8 bytes on supported 64-bit processor instructions)
80 typedef INT64 INTN
__attribute__ ((aligned (8)));
83 // Processor specific defines
87 /// A value of native width with the highest bit set.
89 #define MAX_BIT 0x8000000000000000ULL
91 /// A value of native width with the two highest bits set.
93 #define MAX_2_BITS 0xC000000000000000ULL
96 /// Maximum legal RV64 address
98 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
101 /// Maximum usable address at boot time (48 bits using 4 KB pages in Supervisor mode)
103 #define MAX_ALLOC_ADDRESS 0xFFFFFFFFFFFFULL
106 /// Maximum legal RISC-V INTN and UINTN values.
108 #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
109 #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
112 /// The stack alignment required for RISC-V
114 #define CPU_STACK_ALIGNMENT 16
117 /// Page allocation granularity for RISC-V
119 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
120 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)
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.
129 /// If EFIAPI is already defined, then we use that definition.
131 #elif defined (__GNUC__)
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.
143 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
149 #if defined (__GNUC__)
151 /// For GNU assembly code, .global or .globl can declare global symbols.
152 /// Define this macro to unify the usage.
154 #define ASM_GLOBAL .globl
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.
162 @param FunctionPointer A pointer to a function.
164 @return The pointer to the first instruction of a function given a function pointer.
167 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
169 #ifndef __USER_LABEL_PREFIX__
170 #define __USER_LABEL_PREFIX__