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