iPXE
ProcessorBind.h
Go to the documentation of this file.
1/** @file
2 Processor or Compiler specific defines and types for LoongArch
3
4 Copyright (c) 2022, Loongson Technology Corporation Limited. 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_LOONGARCH64
20
21#define EFIAPI
22
23//
24// Make sure we are using the correct packing rules per EFI specification
25//
26#ifndef __GNUC__
27 #pragma pack()
28#endif
29
30//
31// Assume standard LoongArch 64-bit alignment.
32// Need to check portability of long long
33//
34typedef unsigned long long UINT64;
35typedef long long INT64;
36typedef unsigned int UINT32;
37typedef int INT32;
38typedef unsigned short UINT16;
39typedef unsigned short CHAR16;
40typedef short INT16;
41typedef unsigned char BOOLEAN;
42typedef unsigned char UINT8;
43typedef char CHAR8;
44typedef char INT8;
45
46//
47// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
48// 8 bytes on supported 64-bit processor instructions)
49//
50
51typedef UINT64 UINTN;
52
53//
54// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
55// 8 bytes on supported 64-bit processor instructions)
56//
57typedef INT64 INTN;
58
59//
60// Processor specific defines
61//
62
63//
64// A value of native width with the highest bit set.
65//
66#define MAX_BIT 0x8000000000000000ULL
67//
68// A value of native width with the two highest bits set.
69//
70#define MAX_2_BITS 0xC000000000000000ULL
71
72//
73// Maximum legal LoongArch 64-bit address
74//
75#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
76
77//
78// Maximum usable address at boot time (48 bits using 4KB pages)
79//
80#define MAX_ALLOC_ADDRESS 0xFFFFFFFFFFFFULL
81
82//
83// Maximum legal LoongArch 64-bit INTN and UINTN values.
84//
85#define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
86#define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
87
88//
89// Page allocation granularity for LoongArch
90//
91#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
92#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x10000)
93
94#if defined (__GNUC__)
95//
96// For GNU assembly code, .global or .globl can declare global symbols.
97// Define this macro to unify the usage.
98//
99#define ASM_GLOBAL .globl
100#endif
101
102//
103// The stack alignment required for LoongArch
104//
105#define CPU_STACK_ALIGNMENT 16
106
107/**
108 Return the pointer to the first instruction of a function given a function pointer.
109 On LOONGARCH CPU architectures, these two pointer values are the same,
110 so the implementation of this macro is very simple.
111
112 @param FunctionPointer A pointer to a function.
113
114 @return The pointer to the first instruction of a function given a function pointer.
115
116**/
117#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
118
119#ifndef __USER_LABEL_PREFIX__
120#define __USER_LABEL_PREFIX__
121#endif
122
123#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.
#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