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