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