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