MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance
[mirror_edk2.git] / MdePkg / Include / Ebc / ProcessorBind.h
1 /** @file
2 Processor or compiler specific defines and types for EBC.
3
4 We currently only have one EBC compiler so there may be some Intel compiler
5 specific functions in this file.
6
7 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials are licensed and made available under
9 the terms and conditions of the BSD License that accompanies this distribution.
10 The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php.
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __PROCESSOR_BIND_H__
19 #define __PROCESSOR_BIND_H__
20
21 ///
22 /// Define the processor type so other code can make processor based choices
23 ///
24 #define MDE_CPU_EBC
25
26 //
27 // Native integer types
28 //
29
30 ///
31 /// 1-byte signed value
32 ///
33 typedef signed char INT8;
34 ///
35 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
36 /// values are undefined.
37 ///
38 typedef unsigned char BOOLEAN;
39 ///
40 /// 1-byte unsigned value.
41 ///
42 typedef unsigned char UINT8;
43 ///
44 /// 1-byte Character.
45 ///
46 typedef char CHAR8;
47 ///
48 /// 2-byte signed value.
49 ///
50 typedef short INT16;
51 ///
52 /// 2-byte unsigned value.
53 ///
54 typedef unsigned short UINT16;
55 ///
56 /// 2-byte Character. Unless otherwise specified all strings are stored in the
57 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
58 ///
59 typedef unsigned short CHAR16;
60 ///
61 /// 4-byte signed value.
62 ///
63 typedef int INT32;
64 ///
65 /// 4-byte unsigned value.
66 ///
67 typedef unsigned int UINT32;
68 ///
69 /// 8-byte signed value.
70 ///
71 typedef __int64 INT64;
72 ///
73 /// 8-byte unsigned value.
74 ///
75 typedef unsigned __int64 UINT64;
76
77 ///
78 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
79 /// 8 bytes on supported 64-bit processor instructions)
80 /// "long" type scales to the processor native size with EBC compiler
81 ///
82 typedef long INTN;
83 ///
84 /// The unsigned value of native width. (4 bytes on supported 32-bit processor instructions;
85 /// 8 bytes on supported 64-bit processor instructions)
86 /// "long" type scales to the processor native size with the EBC compiler.
87 ///
88 typedef unsigned long UINTN;
89
90 ///
91 /// A value of native width with the highest bit set.
92 /// Scalable macro to set the most significant bit in a natural number.
93 ///
94 #define MAX_BIT ((UINTN)((1ULL << (sizeof (INTN) * 8 - 1))))
95 ///
96 /// A value of native width with the two highest bits set.
97 /// Scalable macro to set the most 2 significant bits in a natural number.
98 ///
99 #define MAX_2_BITS ((UINTN)(3ULL << (sizeof (INTN) * 8 - 2)))
100
101 ///
102 /// Maximum legal EBC address
103 ///
104 #define MAX_ADDRESS ((UINTN)(~0ULL >> (64 - sizeof (INTN) * 8)))
105
106 ///
107 /// Maximum legal EBC INTN and UINTN values.
108 ///
109 #define MAX_UINTN ((UINTN)(~0ULL >> (64 - sizeof (INTN) * 8)))
110 #define MAX_INTN ((INTN)(~0ULL >> (65 - sizeof (INTN) * 8)))
111
112 ///
113 /// Minimum legal EBC INTN value.
114 ///
115 #define MIN_INTN (((INTN)-MAX_INTN) - 1)
116
117 ///
118 /// The stack alignment required for EBC
119 ///
120 #define CPU_STACK_ALIGNMENT sizeof(UINTN)
121
122 ///
123 /// Page allocation granularity for EBC
124 ///
125 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
126 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)
127
128 ///
129 /// Modifier to ensure that all protocol member functions and EFI intrinsics
130 /// use the correct C calling convention. All protocol member functions and
131 /// EFI intrinsics are required to modify their member functions with EFIAPI.
132 ///
133 #ifdef EFIAPI
134 ///
135 /// If EFIAPI is already defined, then we use that definition.
136 ///
137 #else
138 #define EFIAPI
139 #endif
140
141 /**
142 Return the pointer to the first instruction of a function given a function pointer.
143 On EBC architectures, these two pointer values are the same,
144 so the implementation of this macro is very simple.
145
146 @param FunctionPointer A pointer to a function.
147
148 @return The pointer to the first instruction of a function given a function pointer.
149 **/
150 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
151
152 #ifndef __USER_LABEL_PREFIX__
153 #define __USER_LABEL_PREFIX__
154 #endif
155
156 #endif
157