]>
Commit | Line | Data |
---|---|---|
ac644614 | 1 | /** @file\r |
50a64e5b | 2 | Provides string functions, linked list functions, math functions, synchronization\r |
ae591c14 | 3 | functions, file path functions, and CPU architecture-specific functions.\r |
ac644614 | 4 | \r |
4ac02962 | 5 | Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r |
9df063a0 | 6 | Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r |
3b5a58c5 | 7 | Copyright (c) Microsoft Corporation.<BR>\r |
7601b251 AC |
8 | Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r |
9 | \r | |
9344f092 | 10 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
ac644614 | 11 | \r |
12 | **/\r | |
13 | \r | |
14 | #ifndef __BASE_LIB__\r | |
15 | #define __BASE_LIB__\r | |
16 | \r | |
1106ffe1 | 17 | //\r |
1a2f870c | 18 | // Definitions for architecture-specific types\r |
1106ffe1 | 19 | //\r |
ac644614 | 20 | #if defined (MDE_CPU_IA32)\r |
fc30687f | 21 | ///\r |
af2dc6a7 | 22 | /// The IA-32 architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 23 | ///\r |
ac644614 | 24 | typedef struct {\r |
2f88bd3a MK |
25 | UINT32 Ebx;\r |
26 | UINT32 Esi;\r | |
27 | UINT32 Edi;\r | |
28 | UINT32 Ebp;\r | |
29 | UINT32 Esp;\r | |
30 | UINT32 Eip;\r | |
31 | UINT32 Ssp;\r | |
ac644614 | 32 | } BASE_LIBRARY_JUMP_BUFFER;\r |
33 | \r | |
2f88bd3a | 34 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r |
ac644614 | 35 | \r |
aa4df547 | 36 | #endif // defined (MDE_CPU_IA32)\r |
37 | \r | |
aa4df547 | 38 | #if defined (MDE_CPU_X64)\r |
fc30687f | 39 | ///\r |
af2dc6a7 | 40 | /// The x64 architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 41 | ///\r |
ac644614 | 42 | typedef struct {\r |
2f88bd3a MK |
43 | UINT64 Rbx;\r |
44 | UINT64 Rsp;\r | |
45 | UINT64 Rbp;\r | |
46 | UINT64 Rdi;\r | |
47 | UINT64 Rsi;\r | |
48 | UINT64 R12;\r | |
49 | UINT64 R13;\r | |
50 | UINT64 R14;\r | |
51 | UINT64 R15;\r | |
52 | UINT64 Rip;\r | |
53 | UINT64 MxCsr;\r | |
54 | UINT8 XmmBuffer[160]; ///< XMM6-XMM15.\r | |
55 | UINT64 Ssp;\r | |
ac644614 | 56 | } BASE_LIBRARY_JUMP_BUFFER;\r |
57 | \r | |
2f88bd3a | 58 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r |
ac644614 | 59 | \r |
aa4df547 | 60 | #endif // defined (MDE_CPU_X64)\r |
61 | \r | |
62 | #if defined (MDE_CPU_EBC)\r | |
fc30687f | 63 | ///\r |
af2dc6a7 | 64 | /// The EBC context buffer used by SetJump() and LongJump().\r |
fc30687f | 65 | ///\r |
ac644614 | 66 | typedef struct {\r |
2f88bd3a MK |
67 | UINT64 R0;\r |
68 | UINT64 R1;\r | |
69 | UINT64 R2;\r | |
70 | UINT64 R3;\r | |
71 | UINT64 IP;\r | |
ac644614 | 72 | } BASE_LIBRARY_JUMP_BUFFER;\r |
73 | \r | |
2f88bd3a | 74 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r |
ac644614 | 75 | \r |
aa4df547 | 76 | #endif // defined (MDE_CPU_EBC)\r |
ac644614 | 77 | \r |
ebd04fc2 | 78 | #if defined (MDE_CPU_ARM)\r |
79 | \r | |
80 | typedef struct {\r | |
af2dc6a7 | 81 | UINT32 R3; ///< A copy of R13.\r |
01a54966 | 82 | UINT32 R4;\r |
83 | UINT32 R5;\r | |
84 | UINT32 R6;\r | |
85 | UINT32 R7;\r | |
86 | UINT32 R8;\r | |
87 | UINT32 R9;\r | |
88 | UINT32 R10;\r | |
89 | UINT32 R11;\r | |
90 | UINT32 R12;\r | |
91 | UINT32 R14;\r | |
ebd04fc2 | 92 | } BASE_LIBRARY_JUMP_BUFFER;\r |
93 | \r | |
2f88bd3a | 94 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r |
ebd04fc2 | 95 | \r |
2f88bd3a | 96 | #endif // defined (MDE_CPU_ARM)\r |
ebd04fc2 | 97 | \r |
807e2604 HL |
98 | #if defined (MDE_CPU_AARCH64)\r |
99 | typedef struct {\r | |
100 | // GP regs\r | |
101 | UINT64 X19;\r | |
102 | UINT64 X20;\r | |
103 | UINT64 X21;\r | |
104 | UINT64 X22;\r | |
105 | UINT64 X23;\r | |
106 | UINT64 X24;\r | |
107 | UINT64 X25;\r | |
108 | UINT64 X26;\r | |
109 | UINT64 X27;\r | |
110 | UINT64 X28;\r | |
111 | UINT64 FP;\r | |
112 | UINT64 LR;\r | |
113 | UINT64 IP0;\r | |
114 | \r | |
115 | // FP regs\r | |
116 | UINT64 D8;\r | |
117 | UINT64 D9;\r | |
118 | UINT64 D10;\r | |
119 | UINT64 D11;\r | |
120 | UINT64 D12;\r | |
121 | UINT64 D13;\r | |
122 | UINT64 D14;\r | |
123 | UINT64 D15;\r | |
124 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
125 | \r | |
2f88bd3a | 126 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r |
807e2604 | 127 | \r |
2f88bd3a | 128 | #endif // defined (MDE_CPU_AARCH64)\r |
807e2604 | 129 | \r |
7601b251 AC |
130 | #if defined (MDE_CPU_RISCV64)\r |
131 | ///\r | |
132 | /// The RISC-V architecture context buffer used by SetJump() and LongJump().\r | |
133 | ///\r | |
134 | typedef struct {\r | |
2f88bd3a MK |
135 | UINT64 RA;\r |
136 | UINT64 S0;\r | |
137 | UINT64 S1;\r | |
138 | UINT64 S2;\r | |
139 | UINT64 S3;\r | |
140 | UINT64 S4;\r | |
141 | UINT64 S5;\r | |
142 | UINT64 S6;\r | |
143 | UINT64 S7;\r | |
144 | UINT64 S8;\r | |
145 | UINT64 S9;\r | |
146 | UINT64 S10;\r | |
147 | UINT64 S11;\r | |
148 | UINT64 SP;\r | |
7601b251 AC |
149 | } BASE_LIBRARY_JUMP_BUFFER;\r |
150 | \r | |
2f88bd3a | 151 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r |
7601b251 AC |
152 | \r |
153 | #endif // defined (MDE_CPU_RISCV64)\r | |
807e2604 | 154 | \r |
ac644614 | 155 | //\r |
156 | // String Services\r | |
157 | //\r | |
158 | \r | |
c058d59f JY |
159 | /**\r |
160 | Returns the length of a Null-terminated Unicode string.\r | |
161 | \r | |
328f84b1 JY |
162 | This function is similar as strlen_s defined in C11.\r |
163 | \r | |
c058d59f JY |
164 | If String is not aligned on a 16-bit boundary, then ASSERT().\r |
165 | \r | |
166 | @param String A pointer to a Null-terminated Unicode string.\r | |
167 | @param MaxSize The maximum number of Destination Unicode\r | |
168 | char, including terminating null char.\r | |
169 | \r | |
170 | @retval 0 If String is NULL.\r | |
171 | @retval MaxSize If there is no null character in the first MaxSize characters of String.\r | |
172 | @return The number of characters that percede the terminating null character.\r | |
173 | \r | |
174 | **/\r | |
175 | UINTN\r | |
176 | EFIAPI\r | |
177 | StrnLenS (\r | |
2f88bd3a MK |
178 | IN CONST CHAR16 *String,\r |
179 | IN UINTN MaxSize\r | |
c058d59f JY |
180 | );\r |
181 | \r | |
b590e43a HW |
182 | /**\r |
183 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
184 | Null terminator.\r | |
185 | \r | |
186 | This function returns the size of the Null-terminated Unicode string\r | |
187 | specified by String in bytes, including the Null terminator.\r | |
188 | \r | |
189 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
190 | \r | |
191 | @param String A pointer to a Null-terminated Unicode string.\r | |
192 | @param MaxSize The maximum number of Destination Unicode\r | |
193 | char, including the Null terminator.\r | |
194 | \r | |
195 | @retval 0 If String is NULL.\r | |
196 | @retval (sizeof (CHAR16) * (MaxSize + 1))\r | |
197 | If there is no Null terminator in the first MaxSize characters of\r | |
198 | String.\r | |
199 | @return The size of the Null-terminated Unicode string in bytes, including\r | |
200 | the Null terminator.\r | |
201 | \r | |
202 | **/\r | |
203 | UINTN\r | |
204 | EFIAPI\r | |
205 | StrnSizeS (\r | |
2f88bd3a MK |
206 | IN CONST CHAR16 *String,\r |
207 | IN UINTN MaxSize\r | |
b590e43a HW |
208 | );\r |
209 | \r | |
c058d59f JY |
210 | /**\r |
211 | Copies the string pointed to by Source (including the terminating null char)\r | |
212 | to the array pointed to by Destination.\r | |
213 | \r | |
328f84b1 JY |
214 | This function is similar as strcpy_s defined in C11.\r |
215 | \r | |
c058d59f JY |
216 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
217 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
218 | \r | |
328f84b1 JY |
219 | If an error is returned, then the Destination is unmodified.\r |
220 | \r | |
c058d59f JY |
221 | @param Destination A pointer to a Null-terminated Unicode string.\r |
222 | @param DestMax The maximum number of Destination Unicode\r | |
223 | char, including terminating null char.\r | |
224 | @param Source A pointer to a Null-terminated Unicode string.\r | |
225 | \r | |
226 | @retval RETURN_SUCCESS String is copied.\r | |
227 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
228 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
229 | If Source is NULL.\r | |
230 | If PcdMaximumUnicodeStringLength is not zero,\r | |
9095d37b | 231 | and DestMax is greater than\r |
c058d59f JY |
232 | PcdMaximumUnicodeStringLength.\r |
233 | If DestMax is 0.\r | |
234 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
235 | **/\r | |
236 | RETURN_STATUS\r | |
237 | EFIAPI\r | |
238 | StrCpyS (\r | |
2f88bd3a MK |
239 | OUT CHAR16 *Destination,\r |
240 | IN UINTN DestMax,\r | |
241 | IN CONST CHAR16 *Source\r | |
c058d59f JY |
242 | );\r |
243 | \r | |
244 | /**\r | |
245 | Copies not more than Length successive char from the string pointed to by\r | |
246 | Source to the array pointed to by Destination. If no null char is copied from\r | |
247 | Source, then Destination[Length] is always set to null.\r | |
248 | \r | |
328f84b1 JY |
249 | This function is similar as strncpy_s defined in C11.\r |
250 | \r | |
c058d59f JY |
251 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
252 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
253 | \r | |
328f84b1 JY |
254 | If an error is returned, then the Destination is unmodified.\r |
255 | \r | |
c058d59f JY |
256 | @param Destination A pointer to a Null-terminated Unicode string.\r |
257 | @param DestMax The maximum number of Destination Unicode\r | |
258 | char, including terminating null char.\r | |
259 | @param Source A pointer to a Null-terminated Unicode string.\r | |
260 | @param Length The maximum number of Unicode characters to copy.\r | |
261 | \r | |
262 | @retval RETURN_SUCCESS String is copied.\r | |
9095d37b | 263 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r |
c058d59f JY |
264 | MIN(StrLen(Source), Length).\r |
265 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
266 | If Source is NULL.\r | |
267 | If PcdMaximumUnicodeStringLength is not zero,\r | |
9095d37b | 268 | and DestMax is greater than\r |
c058d59f JY |
269 | PcdMaximumUnicodeStringLength.\r |
270 | If DestMax is 0.\r | |
271 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
272 | **/\r | |
273 | RETURN_STATUS\r | |
274 | EFIAPI\r | |
275 | StrnCpyS (\r | |
2f88bd3a MK |
276 | OUT CHAR16 *Destination,\r |
277 | IN UINTN DestMax,\r | |
278 | IN CONST CHAR16 *Source,\r | |
279 | IN UINTN Length\r | |
c058d59f JY |
280 | );\r |
281 | \r | |
282 | /**\r | |
283 | Appends a copy of the string pointed to by Source (including the terminating\r | |
284 | null char) to the end of the string pointed to by Destination.\r | |
285 | \r | |
328f84b1 JY |
286 | This function is similar as strcat_s defined in C11.\r |
287 | \r | |
c058d59f JY |
288 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
289 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
290 | \r | |
328f84b1 JY |
291 | If an error is returned, then the Destination is unmodified.\r |
292 | \r | |
c058d59f JY |
293 | @param Destination A pointer to a Null-terminated Unicode string.\r |
294 | @param DestMax The maximum number of Destination Unicode\r | |
295 | char, including terminating null char.\r | |
296 | @param Source A pointer to a Null-terminated Unicode string.\r | |
297 | \r | |
298 | @retval RETURN_SUCCESS String is appended.\r | |
9095d37b | 299 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r |
c058d59f JY |
300 | StrLen(Destination).\r |
301 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
302 | greater than StrLen(Source).\r | |
303 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
304 | If Source is NULL.\r | |
305 | If PcdMaximumUnicodeStringLength is not zero,\r | |
9095d37b | 306 | and DestMax is greater than\r |
c058d59f JY |
307 | PcdMaximumUnicodeStringLength.\r |
308 | If DestMax is 0.\r | |
309 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
310 | **/\r | |
311 | RETURN_STATUS\r | |
312 | EFIAPI\r | |
313 | StrCatS (\r | |
2f88bd3a MK |
314 | IN OUT CHAR16 *Destination,\r |
315 | IN UINTN DestMax,\r | |
316 | IN CONST CHAR16 *Source\r | |
c058d59f JY |
317 | );\r |
318 | \r | |
319 | /**\r | |
320 | Appends not more than Length successive char from the string pointed to by\r | |
321 | Source to the end of the string pointed to by Destination. If no null char is\r | |
322 | copied from Source, then Destination[StrLen(Destination) + Length] is always\r | |
323 | set to null.\r | |
324 | \r | |
328f84b1 JY |
325 | This function is similar as strncat_s defined in C11.\r |
326 | \r | |
c058d59f | 327 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
0e93edbb | 328 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r |
c058d59f | 329 | \r |
328f84b1 JY |
330 | If an error is returned, then the Destination is unmodified.\r |
331 | \r | |
c058d59f JY |
332 | @param Destination A pointer to a Null-terminated Unicode string.\r |
333 | @param DestMax The maximum number of Destination Unicode\r | |
334 | char, including terminating null char.\r | |
335 | @param Source A pointer to a Null-terminated Unicode string.\r | |
336 | @param Length The maximum number of Unicode characters to copy.\r | |
337 | \r | |
338 | @retval RETURN_SUCCESS String is appended.\r | |
339 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r | |
340 | StrLen(Destination).\r | |
341 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
342 | greater than MIN(StrLen(Source), Length).\r | |
343 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
344 | If Source is NULL.\r | |
345 | If PcdMaximumUnicodeStringLength is not zero,\r | |
9095d37b | 346 | and DestMax is greater than\r |
c058d59f JY |
347 | PcdMaximumUnicodeStringLength.\r |
348 | If DestMax is 0.\r | |
349 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
350 | **/\r | |
351 | RETURN_STATUS\r | |
352 | EFIAPI\r | |
353 | StrnCatS (\r | |
2f88bd3a MK |
354 | IN OUT CHAR16 *Destination,\r |
355 | IN UINTN DestMax,\r | |
356 | IN CONST CHAR16 *Source,\r | |
357 | IN UINTN Length\r | |
c058d59f JY |
358 | );\r |
359 | \r | |
d8af3301 HW |
360 | /**\r |
361 | Convert a Null-terminated Unicode decimal string to a value of type UINTN.\r | |
362 | \r | |
363 | This function outputs a value of type UINTN by interpreting the contents of\r | |
364 | the Unicode string specified by String as a decimal number. The format of the\r | |
365 | input Unicode string String is:\r | |
366 | \r | |
367 | [spaces] [decimal digits].\r | |
368 | \r | |
369 | The valid decimal digit character is in the range [0-9]. The function will\r | |
370 | ignore the pad space, which includes spaces or tab characters, before\r | |
371 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
372 | be ignored. Then, the function stops at the first character that is a not a\r | |
373 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
374 | \r | |
d8af3301 | 375 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
d8af3301 HW |
376 | \r |
377 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
378 | at the location pointed to by Data.\r | |
379 | If the number represented by String exceeds the range defined by UINTN, then\r | |
380 | MAX_UINTN is stored at the location pointed to by Data.\r | |
381 | \r | |
382 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
383 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
384 | decimal digits right after the optional pad spaces, the value of String is\r | |
385 | stored at the location pointed to by EndPointer.\r | |
386 | \r | |
387 | @param String Pointer to a Null-terminated Unicode string.\r | |
388 | @param EndPointer Pointer to character that stops scan.\r | |
389 | @param Data Pointer to the converted value.\r | |
390 | \r | |
391 | @retval RETURN_SUCCESS Value is translated from String.\r | |
392 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
393 | If Data is NULL.\r | |
394 | If PcdMaximumUnicodeStringLength is not\r | |
395 | zero, and String contains more than\r | |
396 | PcdMaximumUnicodeStringLength Unicode\r | |
397 | characters, not including the\r | |
398 | Null-terminator.\r | |
399 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
400 | the range defined by UINTN.\r | |
401 | \r | |
402 | **/\r | |
403 | RETURN_STATUS\r | |
404 | EFIAPI\r | |
405 | StrDecimalToUintnS (\r | |
2f88bd3a MK |
406 | IN CONST CHAR16 *String,\r |
407 | OUT CHAR16 **EndPointer OPTIONAL,\r | |
408 | OUT UINTN *Data\r | |
d8af3301 HW |
409 | );\r |
410 | \r | |
411 | /**\r | |
412 | Convert a Null-terminated Unicode decimal string to a value of type UINT64.\r | |
413 | \r | |
414 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
415 | the Unicode string specified by String as a decimal number. The format of the\r | |
416 | input Unicode string String is:\r | |
417 | \r | |
418 | [spaces] [decimal digits].\r | |
419 | \r | |
420 | The valid decimal digit character is in the range [0-9]. The function will\r | |
421 | ignore the pad space, which includes spaces or tab characters, before\r | |
422 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
423 | be ignored. Then, the function stops at the first character that is a not a\r | |
424 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
425 | \r | |
d8af3301 | 426 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
d8af3301 HW |
427 | \r |
428 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
429 | at the location pointed to by Data.\r | |
430 | If the number represented by String exceeds the range defined by UINT64, then\r | |
431 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
432 | \r | |
433 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
434 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
435 | decimal digits right after the optional pad spaces, the value of String is\r | |
436 | stored at the location pointed to by EndPointer.\r | |
437 | \r | |
438 | @param String Pointer to a Null-terminated Unicode string.\r | |
439 | @param EndPointer Pointer to character that stops scan.\r | |
440 | @param Data Pointer to the converted value.\r | |
441 | \r | |
442 | @retval RETURN_SUCCESS Value is translated from String.\r | |
443 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
444 | If Data is NULL.\r | |
445 | If PcdMaximumUnicodeStringLength is not\r | |
446 | zero, and String contains more than\r | |
447 | PcdMaximumUnicodeStringLength Unicode\r | |
448 | characters, not including the\r | |
449 | Null-terminator.\r | |
450 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
451 | the range defined by UINT64.\r | |
452 | \r | |
453 | **/\r | |
454 | RETURN_STATUS\r | |
455 | EFIAPI\r | |
456 | StrDecimalToUint64S (\r | |
2f88bd3a MK |
457 | IN CONST CHAR16 *String,\r |
458 | OUT CHAR16 **EndPointer OPTIONAL,\r | |
459 | OUT UINT64 *Data\r | |
d8af3301 HW |
460 | );\r |
461 | \r | |
462 | /**\r | |
463 | Convert a Null-terminated Unicode hexadecimal string to a value of type\r | |
464 | UINTN.\r | |
465 | \r | |
466 | This function outputs a value of type UINTN by interpreting the contents of\r | |
467 | the Unicode string specified by String as a hexadecimal number. The format of\r | |
468 | the input Unicode string String is:\r | |
469 | \r | |
470 | [spaces][zeros][x][hexadecimal digits].\r | |
471 | \r | |
472 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
473 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
474 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
475 | The function will ignore the pad space, which includes spaces or tab\r | |
476 | characters, before [zeros], [x] or [hexadecimal digit]. The running zero\r | |
477 | before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts\r | |
478 | after [x] or the first valid hexadecimal digit. Then, the function stops at\r | |
479 | the first character that is a not a valid hexadecimal character or NULL,\r | |
480 | whichever one comes first.\r | |
481 | \r | |
d8af3301 | 482 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
d8af3301 HW |
483 | \r |
484 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
485 | stored at the location pointed to by Data.\r | |
486 | If the number represented by String exceeds the range defined by UINTN, then\r | |
487 | MAX_UINTN is stored at the location pointed to by Data.\r | |
488 | \r | |
489 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
490 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
491 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
492 | is stored at the location pointed to by EndPointer.\r | |
493 | \r | |
494 | @param String Pointer to a Null-terminated Unicode string.\r | |
495 | @param EndPointer Pointer to character that stops scan.\r | |
496 | @param Data Pointer to the converted value.\r | |
497 | \r | |
498 | @retval RETURN_SUCCESS Value is translated from String.\r | |
499 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
500 | If Data is NULL.\r | |
501 | If PcdMaximumUnicodeStringLength is not\r | |
502 | zero, and String contains more than\r | |
503 | PcdMaximumUnicodeStringLength Unicode\r | |
504 | characters, not including the\r | |
505 | Null-terminator.\r | |
506 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
507 | the range defined by UINTN.\r | |
508 | \r | |
509 | **/\r | |
510 | RETURN_STATUS\r | |
511 | EFIAPI\r | |
512 | StrHexToUintnS (\r | |
2f88bd3a MK |
513 | IN CONST CHAR16 *String,\r |
514 | OUT CHAR16 **EndPointer OPTIONAL,\r | |
515 | OUT UINTN *Data\r | |
d8af3301 HW |
516 | );\r |
517 | \r | |
518 | /**\r | |
519 | Convert a Null-terminated Unicode hexadecimal string to a value of type\r | |
520 | UINT64.\r | |
521 | \r | |
522 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
523 | the Unicode string specified by String as a hexadecimal number. The format of\r | |
524 | the input Unicode string String is:\r | |
525 | \r | |
526 | [spaces][zeros][x][hexadecimal digits].\r | |
527 | \r | |
528 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
529 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
530 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
531 | The function will ignore the pad space, which includes spaces or tab\r | |
532 | characters, before [zeros], [x] or [hexadecimal digit]. The running zero\r | |
533 | before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts\r | |
534 | after [x] or the first valid hexadecimal digit. Then, the function stops at\r | |
535 | the first character that is a not a valid hexadecimal character or NULL,\r | |
536 | whichever one comes first.\r | |
537 | \r | |
d8af3301 | 538 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
d8af3301 HW |
539 | \r |
540 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
541 | stored at the location pointed to by Data.\r | |
542 | If the number represented by String exceeds the range defined by UINT64, then\r | |
543 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
544 | \r | |
545 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
546 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
547 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
548 | is stored at the location pointed to by EndPointer.\r | |
549 | \r | |
550 | @param String Pointer to a Null-terminated Unicode string.\r | |
551 | @param EndPointer Pointer to character that stops scan.\r | |
552 | @param Data Pointer to the converted value.\r | |
553 | \r | |
554 | @retval RETURN_SUCCESS Value is translated from String.\r | |
555 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
556 | If Data is NULL.\r | |
557 | If PcdMaximumUnicodeStringLength is not\r | |
558 | zero, and String contains more than\r | |
559 | PcdMaximumUnicodeStringLength Unicode\r | |
560 | characters, not including the\r | |
561 | Null-terminator.\r | |
562 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
563 | the range defined by UINT64.\r | |
564 | \r | |
565 | **/\r | |
566 | RETURN_STATUS\r | |
567 | EFIAPI\r | |
568 | StrHexToUint64S (\r | |
2f88bd3a MK |
569 | IN CONST CHAR16 *String,\r |
570 | OUT CHAR16 **EndPointer OPTIONAL,\r | |
571 | OUT UINT64 *Data\r | |
d8af3301 HW |
572 | );\r |
573 | \r | |
c058d59f JY |
574 | /**\r |
575 | Returns the length of a Null-terminated Ascii string.\r | |
576 | \r | |
328f84b1 JY |
577 | This function is similar as strlen_s defined in C11.\r |
578 | \r | |
c058d59f JY |
579 | @param String A pointer to a Null-terminated Ascii string.\r |
580 | @param MaxSize The maximum number of Destination Ascii\r | |
581 | char, including terminating null char.\r | |
582 | \r | |
583 | @retval 0 If String is NULL.\r | |
584 | @retval MaxSize If there is no null character in the first MaxSize characters of String.\r | |
585 | @return The number of characters that percede the terminating null character.\r | |
586 | \r | |
587 | **/\r | |
588 | UINTN\r | |
589 | EFIAPI\r | |
590 | AsciiStrnLenS (\r | |
2f88bd3a MK |
591 | IN CONST CHAR8 *String,\r |
592 | IN UINTN MaxSize\r | |
c058d59f JY |
593 | );\r |
594 | \r | |
b590e43a HW |
595 | /**\r |
596 | Returns the size of a Null-terminated Ascii string in bytes, including the\r | |
597 | Null terminator.\r | |
598 | \r | |
599 | This function returns the size of the Null-terminated Ascii string specified\r | |
600 | by String in bytes, including the Null terminator.\r | |
601 | \r | |
602 | @param String A pointer to a Null-terminated Ascii string.\r | |
603 | @param MaxSize The maximum number of Destination Ascii\r | |
604 | char, including the Null terminator.\r | |
605 | \r | |
606 | @retval 0 If String is NULL.\r | |
607 | @retval (sizeof (CHAR8) * (MaxSize + 1))\r | |
608 | If there is no Null terminator in the first MaxSize characters of\r | |
609 | String.\r | |
610 | @return The size of the Null-terminated Ascii string in bytes, including the\r | |
611 | Null terminator.\r | |
612 | \r | |
613 | **/\r | |
614 | UINTN\r | |
615 | EFIAPI\r | |
616 | AsciiStrnSizeS (\r | |
2f88bd3a MK |
617 | IN CONST CHAR8 *String,\r |
618 | IN UINTN MaxSize\r | |
b590e43a HW |
619 | );\r |
620 | \r | |
c058d59f JY |
621 | /**\r |
622 | Copies the string pointed to by Source (including the terminating null char)\r | |
623 | to the array pointed to by Destination.\r | |
624 | \r | |
328f84b1 JY |
625 | This function is similar as strcpy_s defined in C11.\r |
626 | \r | |
328f84b1 JY |
627 | If an error is returned, then the Destination is unmodified.\r |
628 | \r | |
c058d59f JY |
629 | @param Destination A pointer to a Null-terminated Ascii string.\r |
630 | @param DestMax The maximum number of Destination Ascii\r | |
631 | char, including terminating null char.\r | |
632 | @param Source A pointer to a Null-terminated Ascii string.\r | |
633 | \r | |
634 | @retval RETURN_SUCCESS String is copied.\r | |
635 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
636 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
637 | If Source is NULL.\r | |
638 | If PcdMaximumAsciiStringLength is not zero,\r | |
9095d37b | 639 | and DestMax is greater than\r |
c058d59f JY |
640 | PcdMaximumAsciiStringLength.\r |
641 | If DestMax is 0.\r | |
642 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
643 | **/\r | |
644 | RETURN_STATUS\r | |
645 | EFIAPI\r | |
646 | AsciiStrCpyS (\r | |
647 | OUT CHAR8 *Destination,\r | |
648 | IN UINTN DestMax,\r | |
649 | IN CONST CHAR8 *Source\r | |
650 | );\r | |
651 | \r | |
652 | /**\r | |
653 | Copies not more than Length successive char from the string pointed to by\r | |
654 | Source to the array pointed to by Destination. If no null char is copied from\r | |
655 | Source, then Destination[Length] is always set to null.\r | |
656 | \r | |
328f84b1 JY |
657 | This function is similar as strncpy_s defined in C11.\r |
658 | \r | |
328f84b1 JY |
659 | If an error is returned, then the Destination is unmodified.\r |
660 | \r | |
c058d59f JY |
661 | @param Destination A pointer to a Null-terminated Ascii string.\r |
662 | @param DestMax The maximum number of Destination Ascii\r | |
663 | char, including terminating null char.\r | |
664 | @param Source A pointer to a Null-terminated Ascii string.\r | |
665 | @param Length The maximum number of Ascii characters to copy.\r | |
666 | \r | |
667 | @retval RETURN_SUCCESS String is copied.\r | |
9095d37b | 668 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r |
c058d59f JY |
669 | MIN(StrLen(Source), Length).\r |
670 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
671 | If Source is NULL.\r | |
672 | If PcdMaximumAsciiStringLength is not zero,\r | |
9095d37b | 673 | and DestMax is greater than\r |
c058d59f JY |
674 | PcdMaximumAsciiStringLength.\r |
675 | If DestMax is 0.\r | |
676 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
677 | **/\r | |
678 | RETURN_STATUS\r | |
679 | EFIAPI\r | |
680 | AsciiStrnCpyS (\r | |
681 | OUT CHAR8 *Destination,\r | |
682 | IN UINTN DestMax,\r | |
683 | IN CONST CHAR8 *Source,\r | |
684 | IN UINTN Length\r | |
685 | );\r | |
686 | \r | |
687 | /**\r | |
688 | Appends a copy of the string pointed to by Source (including the terminating\r | |
689 | null char) to the end of the string pointed to by Destination.\r | |
690 | \r | |
328f84b1 JY |
691 | This function is similar as strcat_s defined in C11.\r |
692 | \r | |
328f84b1 JY |
693 | If an error is returned, then the Destination is unmodified.\r |
694 | \r | |
c058d59f JY |
695 | @param Destination A pointer to a Null-terminated Ascii string.\r |
696 | @param DestMax The maximum number of Destination Ascii\r | |
697 | char, including terminating null char.\r | |
698 | @param Source A pointer to a Null-terminated Ascii string.\r | |
699 | \r | |
700 | @retval RETURN_SUCCESS String is appended.\r | |
9095d37b | 701 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r |
c058d59f JY |
702 | StrLen(Destination).\r |
703 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
704 | greater than StrLen(Source).\r | |
705 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
706 | If Source is NULL.\r | |
707 | If PcdMaximumAsciiStringLength is not zero,\r | |
9095d37b | 708 | and DestMax is greater than\r |
c058d59f JY |
709 | PcdMaximumAsciiStringLength.\r |
710 | If DestMax is 0.\r | |
711 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
712 | **/\r | |
713 | RETURN_STATUS\r | |
714 | EFIAPI\r | |
715 | AsciiStrCatS (\r | |
716 | IN OUT CHAR8 *Destination,\r | |
717 | IN UINTN DestMax,\r | |
718 | IN CONST CHAR8 *Source\r | |
719 | );\r | |
720 | \r | |
721 | /**\r | |
722 | Appends not more than Length successive char from the string pointed to by\r | |
723 | Source to the end of the string pointed to by Destination. If no null char is\r | |
724 | copied from Source, then Destination[StrLen(Destination) + Length] is always\r | |
725 | set to null.\r | |
726 | \r | |
328f84b1 JY |
727 | This function is similar as strncat_s defined in C11.\r |
728 | \r | |
328f84b1 JY |
729 | If an error is returned, then the Destination is unmodified.\r |
730 | \r | |
c058d59f JY |
731 | @param Destination A pointer to a Null-terminated Ascii string.\r |
732 | @param DestMax The maximum number of Destination Ascii\r | |
733 | char, including terminating null char.\r | |
734 | @param Source A pointer to a Null-terminated Ascii string.\r | |
735 | @param Length The maximum number of Ascii characters to copy.\r | |
736 | \r | |
737 | @retval RETURN_SUCCESS String is appended.\r | |
738 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r | |
739 | StrLen(Destination).\r | |
740 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
741 | greater than MIN(StrLen(Source), Length).\r | |
742 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
743 | If Source is NULL.\r | |
744 | If PcdMaximumAsciiStringLength is not zero,\r | |
9095d37b | 745 | and DestMax is greater than\r |
c058d59f JY |
746 | PcdMaximumAsciiStringLength.\r |
747 | If DestMax is 0.\r | |
748 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
749 | **/\r | |
750 | RETURN_STATUS\r | |
751 | EFIAPI\r | |
752 | AsciiStrnCatS (\r | |
753 | IN OUT CHAR8 *Destination,\r | |
754 | IN UINTN DestMax,\r | |
755 | IN CONST CHAR8 *Source,\r | |
756 | IN UINTN Length\r | |
757 | );\r | |
758 | \r | |
d8af3301 HW |
759 | /**\r |
760 | Convert a Null-terminated Ascii decimal string to a value of type UINTN.\r | |
761 | \r | |
762 | This function outputs a value of type UINTN by interpreting the contents of\r | |
763 | the Ascii string specified by String as a decimal number. The format of the\r | |
764 | input Ascii string String is:\r | |
765 | \r | |
766 | [spaces] [decimal digits].\r | |
767 | \r | |
768 | The valid decimal digit character is in the range [0-9]. The function will\r | |
769 | ignore the pad space, which includes spaces or tab characters, before\r | |
770 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
771 | be ignored. Then, the function stops at the first character that is a not a\r | |
772 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
773 | \r | |
d8af3301 HW |
774 | If String has no valid decimal digits in the above format, then 0 is stored\r |
775 | at the location pointed to by Data.\r | |
776 | If the number represented by String exceeds the range defined by UINTN, then\r | |
777 | MAX_UINTN is stored at the location pointed to by Data.\r | |
778 | \r | |
779 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
780 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
781 | decimal digits right after the optional pad spaces, the value of String is\r | |
782 | stored at the location pointed to by EndPointer.\r | |
783 | \r | |
784 | @param String Pointer to a Null-terminated Ascii string.\r | |
785 | @param EndPointer Pointer to character that stops scan.\r | |
786 | @param Data Pointer to the converted value.\r | |
787 | \r | |
788 | @retval RETURN_SUCCESS Value is translated from String.\r | |
789 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
790 | If Data is NULL.\r | |
791 | If PcdMaximumAsciiStringLength is not zero,\r | |
792 | and String contains more than\r | |
793 | PcdMaximumAsciiStringLength Ascii\r | |
794 | characters, not including the\r | |
795 | Null-terminator.\r | |
796 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
797 | the range defined by UINTN.\r | |
798 | \r | |
799 | **/\r | |
800 | RETURN_STATUS\r | |
801 | EFIAPI\r | |
802 | AsciiStrDecimalToUintnS (\r | |
2f88bd3a MK |
803 | IN CONST CHAR8 *String,\r |
804 | OUT CHAR8 **EndPointer OPTIONAL,\r | |
805 | OUT UINTN *Data\r | |
d8af3301 HW |
806 | );\r |
807 | \r | |
808 | /**\r | |
809 | Convert a Null-terminated Ascii decimal string to a value of type UINT64.\r | |
810 | \r | |
811 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
812 | the Ascii string specified by String as a decimal number. The format of the\r | |
813 | input Ascii string String is:\r | |
814 | \r | |
815 | [spaces] [decimal digits].\r | |
816 | \r | |
817 | The valid decimal digit character is in the range [0-9]. The function will\r | |
818 | ignore the pad space, which includes spaces or tab characters, before\r | |
819 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
820 | be ignored. Then, the function stops at the first character that is a not a\r | |
821 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
822 | \r | |
d8af3301 HW |
823 | If String has no valid decimal digits in the above format, then 0 is stored\r |
824 | at the location pointed to by Data.\r | |
825 | If the number represented by String exceeds the range defined by UINT64, then\r | |
826 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
827 | \r | |
828 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
829 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
830 | decimal digits right after the optional pad spaces, the value of String is\r | |
831 | stored at the location pointed to by EndPointer.\r | |
832 | \r | |
833 | @param String Pointer to a Null-terminated Ascii string.\r | |
834 | @param EndPointer Pointer to character that stops scan.\r | |
835 | @param Data Pointer to the converted value.\r | |
836 | \r | |
837 | @retval RETURN_SUCCESS Value is translated from String.\r | |
838 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
839 | If Data is NULL.\r | |
840 | If PcdMaximumAsciiStringLength is not zero,\r | |
841 | and String contains more than\r | |
842 | PcdMaximumAsciiStringLength Ascii\r | |
843 | characters, not including the\r | |
844 | Null-terminator.\r | |
845 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
846 | the range defined by UINT64.\r | |
847 | \r | |
848 | **/\r | |
849 | RETURN_STATUS\r | |
850 | EFIAPI\r | |
851 | AsciiStrDecimalToUint64S (\r | |
2f88bd3a MK |
852 | IN CONST CHAR8 *String,\r |
853 | OUT CHAR8 **EndPointer OPTIONAL,\r | |
854 | OUT UINT64 *Data\r | |
d8af3301 HW |
855 | );\r |
856 | \r | |
857 | /**\r | |
858 | Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN.\r | |
859 | \r | |
860 | This function outputs a value of type UINTN by interpreting the contents of\r | |
861 | the Ascii string specified by String as a hexadecimal number. The format of\r | |
862 | the input Ascii string String is:\r | |
863 | \r | |
864 | [spaces][zeros][x][hexadecimal digits].\r | |
865 | \r | |
866 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
867 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If\r | |
868 | "x" appears in the input string, it must be prefixed with at least one 0. The\r | |
869 | function will ignore the pad space, which includes spaces or tab characters,\r | |
870 | before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or\r | |
871 | [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or\r | |
872 | the first valid hexadecimal digit. Then, the function stops at the first\r | |
873 | character that is a not a valid hexadecimal character or Null-terminator,\r | |
874 | whichever on comes first.\r | |
875 | \r | |
d8af3301 HW |
876 | If String has no valid hexadecimal digits in the above format, then 0 is\r |
877 | stored at the location pointed to by Data.\r | |
878 | If the number represented by String exceeds the range defined by UINTN, then\r | |
879 | MAX_UINTN is stored at the location pointed to by Data.\r | |
880 | \r | |
881 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
882 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
883 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
884 | is stored at the location pointed to by EndPointer.\r | |
885 | \r | |
886 | @param String Pointer to a Null-terminated Ascii string.\r | |
887 | @param EndPointer Pointer to character that stops scan.\r | |
888 | @param Data Pointer to the converted value.\r | |
889 | \r | |
890 | @retval RETURN_SUCCESS Value is translated from String.\r | |
891 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
892 | If Data is NULL.\r | |
893 | If PcdMaximumAsciiStringLength is not zero,\r | |
894 | and String contains more than\r | |
895 | PcdMaximumAsciiStringLength Ascii\r | |
896 | characters, not including the\r | |
897 | Null-terminator.\r | |
898 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
899 | the range defined by UINTN.\r | |
900 | \r | |
901 | **/\r | |
902 | RETURN_STATUS\r | |
903 | EFIAPI\r | |
904 | AsciiStrHexToUintnS (\r | |
2f88bd3a MK |
905 | IN CONST CHAR8 *String,\r |
906 | OUT CHAR8 **EndPointer OPTIONAL,\r | |
907 | OUT UINTN *Data\r | |
d8af3301 HW |
908 | );\r |
909 | \r | |
910 | /**\r | |
911 | Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64.\r | |
912 | \r | |
913 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
914 | the Ascii string specified by String as a hexadecimal number. The format of\r | |
915 | the input Ascii string String is:\r | |
916 | \r | |
917 | [spaces][zeros][x][hexadecimal digits].\r | |
918 | \r | |
919 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
920 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If\r | |
921 | "x" appears in the input string, it must be prefixed with at least one 0. The\r | |
922 | function will ignore the pad space, which includes spaces or tab characters,\r | |
923 | before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or\r | |
924 | [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or\r | |
925 | the first valid hexadecimal digit. Then, the function stops at the first\r | |
926 | character that is a not a valid hexadecimal character or Null-terminator,\r | |
927 | whichever on comes first.\r | |
928 | \r | |
d8af3301 HW |
929 | If String has no valid hexadecimal digits in the above format, then 0 is\r |
930 | stored at the location pointed to by Data.\r | |
931 | If the number represented by String exceeds the range defined by UINT64, then\r | |
932 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
933 | \r | |
934 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
935 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
936 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
937 | is stored at the location pointed to by EndPointer.\r | |
938 | \r | |
939 | @param String Pointer to a Null-terminated Ascii string.\r | |
940 | @param EndPointer Pointer to character that stops scan.\r | |
941 | @param Data Pointer to the converted value.\r | |
942 | \r | |
943 | @retval RETURN_SUCCESS Value is translated from String.\r | |
944 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
945 | If Data is NULL.\r | |
946 | If PcdMaximumAsciiStringLength is not zero,\r | |
947 | and String contains more than\r | |
948 | PcdMaximumAsciiStringLength Ascii\r | |
949 | characters, not including the\r | |
950 | Null-terminator.\r | |
951 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
952 | the range defined by UINT64.\r | |
953 | \r | |
954 | **/\r | |
955 | RETURN_STATUS\r | |
956 | EFIAPI\r | |
957 | AsciiStrHexToUint64S (\r | |
2f88bd3a MK |
958 | IN CONST CHAR8 *String,\r |
959 | OUT CHAR8 **EndPointer OPTIONAL,\r | |
960 | OUT UINT64 *Data\r | |
d8af3301 HW |
961 | );\r |
962 | \r | |
ac644614 | 963 | /**\r |
964 | Returns the length of a Null-terminated Unicode string.\r | |
965 | \r | |
966 | This function returns the number of Unicode characters in the Null-terminated\r | |
967 | Unicode string specified by String.\r | |
968 | \r | |
969 | If String is NULL, then ASSERT().\r | |
970 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
971 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
972 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
973 | Null-terminator, then ASSERT().\r | |
974 | \r | |
975 | @param String Pointer to a Null-terminated Unicode string.\r | |
976 | \r | |
977 | @return The length of String.\r | |
978 | \r | |
979 | **/\r | |
980 | UINTN\r | |
981 | EFIAPI\r | |
982 | StrLen (\r | |
2f88bd3a | 983 | IN CONST CHAR16 *String\r |
ac644614 | 984 | );\r |
985 | \r | |
ac644614 | 986 | /**\r |
987 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
988 | Null terminator.\r | |
989 | \r | |
9095d37b | 990 | This function returns the size, in bytes, of the Null-terminated Unicode string\r |
17f695ed | 991 | specified by String.\r |
ac644614 | 992 | \r |
993 | If String is NULL, then ASSERT().\r | |
994 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
995 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
996 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
997 | Null-terminator, then ASSERT().\r | |
998 | \r | |
af2dc6a7 | 999 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1000 | \r |
1001 | @return The size of String.\r | |
1002 | \r | |
1003 | **/\r | |
1004 | UINTN\r | |
1005 | EFIAPI\r | |
1006 | StrSize (\r | |
2f88bd3a | 1007 | IN CONST CHAR16 *String\r |
ac644614 | 1008 | );\r |
1009 | \r | |
ac644614 | 1010 | /**\r |
1011 | Compares two Null-terminated Unicode strings, and returns the difference\r | |
1012 | between the first mismatched Unicode characters.\r | |
1013 | \r | |
1014 | This function compares the Null-terminated Unicode string FirstString to the\r | |
1015 | Null-terminated Unicode string SecondString. If FirstString is identical to\r | |
1016 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
1017 | mismatched Unicode character in SecondString subtracted from the first\r | |
1018 | mismatched Unicode character in FirstString.\r | |
1019 | \r | |
1020 | If FirstString is NULL, then ASSERT().\r | |
1021 | If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r | |
1022 | If SecondString is NULL, then ASSERT().\r | |
1023 | If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r | |
1024 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r | |
1025 | than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
1026 | Null-terminator, then ASSERT().\r | |
1027 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r | |
af2dc6a7 | 1028 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1029 | Null-terminator, then ASSERT().\r |
1030 | \r | |
af2dc6a7 | 1031 | @param FirstString The pointer to a Null-terminated Unicode string.\r |
1032 | @param SecondString The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 1033 | \r |
1106ffe1 | 1034 | @retval 0 FirstString is identical to SecondString.\r |
1035 | @return others FirstString is not identical to SecondString.\r | |
ac644614 | 1036 | \r |
1037 | **/\r | |
1038 | INTN\r | |
1039 | EFIAPI\r | |
1040 | StrCmp (\r | |
2f88bd3a MK |
1041 | IN CONST CHAR16 *FirstString,\r |
1042 | IN CONST CHAR16 *SecondString\r | |
ac644614 | 1043 | );\r |
1044 | \r | |
ac644614 | 1045 | /**\r |
17f695ed | 1046 | Compares up to a specified length the contents of two Null-terminated Unicode strings,\r |
1047 | and returns the difference between the first mismatched Unicode characters.\r | |
9095d37b | 1048 | \r |
ac644614 | 1049 | This function compares the Null-terminated Unicode string FirstString to the\r |
1050 | Null-terminated Unicode string SecondString. At most, Length Unicode\r | |
1051 | characters will be compared. If Length is 0, then 0 is returned. If\r | |
1052 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
1053 | value returned is the first mismatched Unicode character in SecondString\r | |
1054 | subtracted from the first mismatched Unicode character in FirstString.\r | |
1055 | \r | |
1056 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
77f863ee | 1057 | If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 1058 | If Length > 0 and SecondString is NULL, then ASSERT().\r |
77f863ee | 1059 | If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().\r |
50c247fd | 1060 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than\r |
1061 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
1062 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than\r | |
1063 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
1064 | then ASSERT().\r | |
1065 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than\r | |
1066 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
1067 | then ASSERT().\r | |
ac644614 | 1068 | \r |
af2dc6a7 | 1069 | @param FirstString The pointer to a Null-terminated Unicode string.\r |
1070 | @param SecondString The pointer to a Null-terminated Unicode string.\r | |
1071 | @param Length The maximum number of Unicode characters to compare.\r | |
ac644614 | 1072 | \r |
1106ffe1 | 1073 | @retval 0 FirstString is identical to SecondString.\r |
1074 | @return others FirstString is not identical to SecondString.\r | |
ac644614 | 1075 | \r |
1076 | **/\r | |
1077 | INTN\r | |
1078 | EFIAPI\r | |
1079 | StrnCmp (\r | |
2f88bd3a MK |
1080 | IN CONST CHAR16 *FirstString,\r |
1081 | IN CONST CHAR16 *SecondString,\r | |
1082 | IN UINTN Length\r | |
ac644614 | 1083 | );\r |
1084 | \r | |
ac644614 | 1085 | /**\r |
9aa049d9 | 1086 | Returns the first occurrence of a Null-terminated Unicode sub-string\r |
ac644614 | 1087 | in a Null-terminated Unicode string.\r |
1088 | \r | |
1089 | This function scans the contents of the Null-terminated Unicode string\r | |
1090 | specified by String and returns the first occurrence of SearchString.\r | |
1091 | If SearchString is not found in String, then NULL is returned. If\r | |
af2dc6a7 | 1092 | the length of SearchString is zero, then String is returned.\r |
ac644614 | 1093 | \r |
1094 | If String is NULL, then ASSERT().\r | |
1095 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
1096 | If SearchString is NULL, then ASSERT().\r | |
1097 | If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r | |
1098 | \r | |
1099 | If PcdMaximumUnicodeStringLength is not zero, and SearchString\r | |
1100 | or String contains more than PcdMaximumUnicodeStringLength Unicode\r | |
af2dc6a7 | 1101 | characters, not including the Null-terminator, then ASSERT().\r |
ac644614 | 1102 | \r |
af2dc6a7 | 1103 | @param String The pointer to a Null-terminated Unicode string.\r |
1104 | @param SearchString The pointer to a Null-terminated Unicode string to search for.\r | |
ac644614 | 1105 | \r |
1106 | @retval NULL If the SearchString does not appear in String.\r | |
1106ffe1 | 1107 | @return others If there is a match.\r |
ac644614 | 1108 | \r |
1109 | **/\r | |
1110 | CHAR16 *\r | |
1111 | EFIAPI\r | |
1112 | StrStr (\r | |
2f88bd3a MK |
1113 | IN CONST CHAR16 *String,\r |
1114 | IN CONST CHAR16 *SearchString\r | |
ac644614 | 1115 | );\r |
1116 | \r | |
1117 | /**\r | |
1118 | Convert a Null-terminated Unicode decimal string to a value of\r | |
1119 | type UINTN.\r | |
1120 | \r | |
1121 | This function returns a value of type UINTN by interpreting the contents\r | |
1122 | of the Unicode string specified by String as a decimal number. The format\r | |
1123 | of the input Unicode string String is:\r | |
1124 | \r | |
1125 | [spaces] [decimal digits].\r | |
1126 | \r | |
1127 | The valid decimal digit character is in the range [0-9]. The\r | |
1128 | function will ignore the pad space, which includes spaces or\r | |
1129 | tab characters, before [decimal digits]. The running zero in the\r | |
1130 | beginning of [decimal digits] will be ignored. Then, the function\r | |
1131 | stops at the first character that is a not a valid decimal character\r | |
1132 | or a Null-terminator, whichever one comes first.\r | |
1133 | \r | |
1134 | If String is NULL, then ASSERT().\r | |
1135 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1136 | If String has only pad spaces, then 0 is returned.\r | |
1137 | If String has no pad spaces or valid decimal digits,\r | |
1138 | then 0 is returned.\r | |
1139 | If the number represented by String overflows according\r | |
ea2e0921 | 1140 | to the range defined by UINTN, then MAX_UINTN is returned.\r |
ac644614 | 1141 | \r |
1142 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
1143 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
1144 | the Null-terminator, then ASSERT().\r | |
1145 | \r | |
af2dc6a7 | 1146 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1147 | \r |
38bbd3d9 | 1148 | @retval Value translated from String.\r |
ac644614 | 1149 | \r |
1150 | **/\r | |
1151 | UINTN\r | |
1152 | EFIAPI\r | |
1153 | StrDecimalToUintn (\r | |
2f88bd3a | 1154 | IN CONST CHAR16 *String\r |
ac644614 | 1155 | );\r |
1156 | \r | |
1157 | /**\r | |
1158 | Convert a Null-terminated Unicode decimal string to a value of\r | |
1159 | type UINT64.\r | |
1160 | \r | |
1161 | This function returns a value of type UINT64 by interpreting the contents\r | |
1162 | of the Unicode string specified by String as a decimal number. The format\r | |
1163 | of the input Unicode string String is:\r | |
1164 | \r | |
1165 | [spaces] [decimal digits].\r | |
1166 | \r | |
1167 | The valid decimal digit character is in the range [0-9]. The\r | |
1168 | function will ignore the pad space, which includes spaces or\r | |
1169 | tab characters, before [decimal digits]. The running zero in the\r | |
1170 | beginning of [decimal digits] will be ignored. Then, the function\r | |
1171 | stops at the first character that is a not a valid decimal character\r | |
1172 | or a Null-terminator, whichever one comes first.\r | |
1173 | \r | |
1174 | If String is NULL, then ASSERT().\r | |
1175 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1176 | If String has only pad spaces, then 0 is returned.\r | |
1177 | If String has no pad spaces or valid decimal digits,\r | |
1178 | then 0 is returned.\r | |
1179 | If the number represented by String overflows according\r | |
ea2e0921 | 1180 | to the range defined by UINT64, then MAX_UINT64 is returned.\r |
ac644614 | 1181 | \r |
1182 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
1183 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
1184 | the Null-terminator, then ASSERT().\r | |
1185 | \r | |
af2dc6a7 | 1186 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1187 | \r |
38bbd3d9 | 1188 | @retval Value translated from String.\r |
ac644614 | 1189 | \r |
1190 | **/\r | |
1191 | UINT64\r | |
1192 | EFIAPI\r | |
1193 | StrDecimalToUint64 (\r | |
2f88bd3a | 1194 | IN CONST CHAR16 *String\r |
ac644614 | 1195 | );\r |
9095d37b | 1196 | \r |
ac644614 | 1197 | /**\r |
1198 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r | |
1199 | \r | |
1200 | This function returns a value of type UINTN by interpreting the contents\r | |
1201 | of the Unicode string specified by String as a hexadecimal number.\r | |
1202 | The format of the input Unicode string String is:\r | |
1203 | \r | |
1204 | [spaces][zeros][x][hexadecimal digits].\r | |
1205 | \r | |
1206 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1207 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
1208 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
1209 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
1210 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
1211 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
9095d37b | 1212 | first valid hexadecimal digit. Then, the function stops at the first character\r |
af2dc6a7 | 1213 | that is a not a valid hexadecimal character or NULL, whichever one comes first.\r |
ac644614 | 1214 | \r |
1215 | If String is NULL, then ASSERT().\r | |
1216 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1217 | If String has only pad spaces, then zero is returned.\r | |
1218 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r | |
1219 | then zero is returned.\r | |
1220 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 1221 | UINTN, then MAX_UINTN is returned.\r |
ac644614 | 1222 | \r |
1223 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1224 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
1225 | then ASSERT().\r | |
1226 | \r | |
af2dc6a7 | 1227 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1228 | \r |
38bbd3d9 | 1229 | @retval Value translated from String.\r |
ac644614 | 1230 | \r |
1231 | **/\r | |
1232 | UINTN\r | |
1233 | EFIAPI\r | |
1234 | StrHexToUintn (\r | |
2f88bd3a | 1235 | IN CONST CHAR16 *String\r |
ac644614 | 1236 | );\r |
1237 | \r | |
ac644614 | 1238 | /**\r |
1239 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r | |
1240 | \r | |
1241 | This function returns a value of type UINT64 by interpreting the contents\r | |
1242 | of the Unicode string specified by String as a hexadecimal number.\r | |
1243 | The format of the input Unicode string String is\r | |
1244 | \r | |
1245 | [spaces][zeros][x][hexadecimal digits].\r | |
1246 | \r | |
1247 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1248 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
1249 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
1250 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
1251 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
1252 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
1253 | first valid hexadecimal digit. Then, the function stops at the first character that is\r | |
1254 | a not a valid hexadecimal character or NULL, whichever one comes first.\r | |
1255 | \r | |
1256 | If String is NULL, then ASSERT().\r | |
1257 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1258 | If String has only pad spaces, then zero is returned.\r | |
1259 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r | |
1260 | then zero is returned.\r | |
1261 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 1262 | UINT64, then MAX_UINT64 is returned.\r |
ac644614 | 1263 | \r |
1264 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1265 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
1266 | then ASSERT().\r | |
1267 | \r | |
af2dc6a7 | 1268 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1269 | \r |
38bbd3d9 | 1270 | @retval Value translated from String.\r |
ac644614 | 1271 | \r |
1272 | **/\r | |
1273 | UINT64\r | |
1274 | EFIAPI\r | |
1275 | StrHexToUint64 (\r | |
2f88bd3a | 1276 | IN CONST CHAR16 *String\r |
ac644614 | 1277 | );\r |
1278 | \r | |
36396ea2 RN |
1279 | /**\r |
1280 | Convert a Null-terminated Unicode string to IPv6 address and prefix length.\r | |
1281 | \r | |
1282 | This function outputs a value of type IPv6_ADDRESS and may output a value\r | |
1283 | of type UINT8 by interpreting the contents of the Unicode string specified\r | |
1284 | by String. The format of the input Unicode string String is as follows:\r | |
1285 | \r | |
1286 | X:X:X:X:X:X:X:X[/P]\r | |
1287 | \r | |
1288 | X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and\r | |
1289 | [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low\r | |
1290 | memory address and high byte is stored in high memory address. P contains decimal\r | |
1291 | digit characters in the range [0-9]. The running zero in the beginning of P will\r | |
1292 | be ignored. /P is optional.\r | |
1293 | \r | |
1294 | When /P is not in the String, the function stops at the first character that is\r | |
1295 | not a valid hexadecimal digit character after eight X's are converted.\r | |
1296 | \r | |
1297 | When /P is in the String, the function stops at the first character that is not\r | |
1298 | a valid decimal digit character after P is converted.\r | |
1299 | \r | |
1300 | "::" can be used to compress one or more groups of X when X contains only 0.\r | |
1301 | The "::" can only appear once in the String.\r | |
1302 | \r | |
36396ea2 RN |
1303 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
1304 | \r | |
36396ea2 RN |
1305 | If EndPointer is not NULL and Address is translated from String, a pointer\r |
1306 | to the character that stopped the scan is stored at the location pointed to\r | |
1307 | by EndPointer.\r | |
1308 | \r | |
1309 | @param String Pointer to a Null-terminated Unicode string.\r | |
1310 | @param EndPointer Pointer to character that stops scan.\r | |
1311 | @param Address Pointer to the converted IPv6 address.\r | |
1312 | @param PrefixLength Pointer to the converted IPv6 address prefix\r | |
1313 | length. MAX_UINT8 is returned when /P is\r | |
1314 | not in the String.\r | |
1315 | \r | |
1316 | @retval RETURN_SUCCESS Address is translated from String.\r | |
1317 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1318 | If Data is NULL.\r | |
1319 | @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal\r | |
1320 | digit characters.\r | |
1321 | If String contains "::" and number of X\r | |
1322 | is not less than 8.\r | |
1323 | If P starts with character that is not a\r | |
1324 | valid decimal digit character.\r | |
1325 | If the decimal number converted from P\r | |
1326 | exceeds 128.\r | |
1327 | \r | |
1328 | **/\r | |
1329 | RETURN_STATUS\r | |
1330 | EFIAPI\r | |
1331 | StrToIpv6Address (\r | |
2f88bd3a MK |
1332 | IN CONST CHAR16 *String,\r |
1333 | OUT CHAR16 **EndPointer OPTIONAL,\r | |
1334 | OUT IPv6_ADDRESS *Address,\r | |
1335 | OUT UINT8 *PrefixLength OPTIONAL\r | |
36396ea2 RN |
1336 | );\r |
1337 | \r | |
1338 | /**\r | |
1339 | Convert a Null-terminated Unicode string to IPv4 address and prefix length.\r | |
1340 | \r | |
1341 | This function outputs a value of type IPv4_ADDRESS and may output a value\r | |
1342 | of type UINT8 by interpreting the contents of the Unicode string specified\r | |
1343 | by String. The format of the input Unicode string String is as follows:\r | |
1344 | \r | |
1345 | D.D.D.D[/P]\r | |
1346 | \r | |
1347 | D and P are decimal digit characters in the range [0-9]. The running zero in\r | |
1348 | the beginning of D and P will be ignored. /P is optional.\r | |
1349 | \r | |
1350 | When /P is not in the String, the function stops at the first character that is\r | |
1351 | not a valid decimal digit character after four D's are converted.\r | |
1352 | \r | |
1353 | When /P is in the String, the function stops at the first character that is not\r | |
1354 | a valid decimal digit character after P is converted.\r | |
1355 | \r | |
36396ea2 RN |
1356 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
1357 | \r | |
36396ea2 RN |
1358 | If EndPointer is not NULL and Address is translated from String, a pointer\r |
1359 | to the character that stopped the scan is stored at the location pointed to\r | |
1360 | by EndPointer.\r | |
1361 | \r | |
1362 | @param String Pointer to a Null-terminated Unicode string.\r | |
1363 | @param EndPointer Pointer to character that stops scan.\r | |
1364 | @param Address Pointer to the converted IPv4 address.\r | |
1365 | @param PrefixLength Pointer to the converted IPv4 address prefix\r | |
1366 | length. MAX_UINT8 is returned when /P is\r | |
1367 | not in the String.\r | |
1368 | \r | |
1369 | @retval RETURN_SUCCESS Address is translated from String.\r | |
1370 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1371 | If Data is NULL.\r | |
1372 | @retval RETURN_UNSUPPORTED If String is not in the correct format.\r | |
1373 | If any decimal number converted from D\r | |
1374 | exceeds 255.\r | |
1375 | If the decimal number converted from P\r | |
1376 | exceeds 32.\r | |
1377 | \r | |
1378 | **/\r | |
1379 | RETURN_STATUS\r | |
1380 | EFIAPI\r | |
1381 | StrToIpv4Address (\r | |
2f88bd3a MK |
1382 | IN CONST CHAR16 *String,\r |
1383 | OUT CHAR16 **EndPointer OPTIONAL,\r | |
1384 | OUT IPv4_ADDRESS *Address,\r | |
1385 | OUT UINT8 *PrefixLength OPTIONAL\r | |
36396ea2 RN |
1386 | );\r |
1387 | \r | |
1388 | #define GUID_STRING_LENGTH 36\r | |
1389 | \r | |
1390 | /**\r | |
1391 | Convert a Null-terminated Unicode GUID string to a value of type\r | |
1392 | EFI_GUID.\r | |
1393 | \r | |
1394 | This function outputs a GUID value by interpreting the contents of\r | |
1395 | the Unicode string specified by String. The format of the input\r | |
1396 | Unicode string String consists of 36 characters, as follows:\r | |
1397 | \r | |
1398 | aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\r | |
1399 | \r | |
1400 | The pairs aa - pp are two characters in the range [0-9], [a-f] and\r | |
1401 | [A-F], with each pair representing a single byte hexadecimal value.\r | |
1402 | \r | |
1403 | The mapping between String and the EFI_GUID structure is as follows:\r | |
1404 | aa Data1[24:31]\r | |
1405 | bb Data1[16:23]\r | |
1406 | cc Data1[8:15]\r | |
1407 | dd Data1[0:7]\r | |
1408 | ee Data2[8:15]\r | |
1409 | ff Data2[0:7]\r | |
1410 | gg Data3[8:15]\r | |
1411 | hh Data3[0:7]\r | |
1412 | ii Data4[0:7]\r | |
1413 | jj Data4[8:15]\r | |
1414 | kk Data4[16:23]\r | |
1415 | ll Data4[24:31]\r | |
1416 | mm Data4[32:39]\r | |
1417 | nn Data4[40:47]\r | |
1418 | oo Data4[48:55]\r | |
1419 | pp Data4[56:63]\r | |
1420 | \r | |
36396ea2 RN |
1421 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
1422 | \r | |
1423 | @param String Pointer to a Null-terminated Unicode string.\r | |
1424 | @param Guid Pointer to the converted GUID.\r | |
1425 | \r | |
1426 | @retval RETURN_SUCCESS Guid is translated from String.\r | |
1427 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1428 | If Data is NULL.\r | |
1429 | @retval RETURN_UNSUPPORTED If String is not as the above format.\r | |
1430 | \r | |
1431 | **/\r | |
1432 | RETURN_STATUS\r | |
1433 | EFIAPI\r | |
1434 | StrToGuid (\r | |
2f88bd3a MK |
1435 | IN CONST CHAR16 *String,\r |
1436 | OUT GUID *Guid\r | |
36396ea2 RN |
1437 | );\r |
1438 | \r | |
1439 | /**\r | |
1440 | Convert a Null-terminated Unicode hexadecimal string to a byte array.\r | |
1441 | \r | |
1442 | This function outputs a byte array by interpreting the contents of\r | |
1443 | the Unicode string specified by String in hexadecimal format. The format of\r | |
1444 | the input Unicode string String is:\r | |
1445 | \r | |
1446 | [XX]*\r | |
1447 | \r | |
1448 | X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].\r | |
1449 | The function decodes every two hexadecimal digit characters as one byte. The\r | |
1450 | decoding stops after Length of characters and outputs Buffer containing\r | |
1451 | (Length / 2) bytes.\r | |
1452 | \r | |
1453 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1454 | \r | |
36396ea2 RN |
1455 | @param String Pointer to a Null-terminated Unicode string.\r |
1456 | @param Length The number of Unicode characters to decode.\r | |
1457 | @param Buffer Pointer to the converted bytes array.\r | |
1458 | @param MaxBufferSize The maximum size of Buffer.\r | |
1459 | \r | |
1460 | @retval RETURN_SUCCESS Buffer is translated from String.\r | |
1461 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1462 | If Data is NULL.\r | |
1463 | If Length is not multiple of 2.\r | |
1464 | If PcdMaximumUnicodeStringLength is not zero,\r | |
1465 | and Length is greater than\r | |
1466 | PcdMaximumUnicodeStringLength.\r | |
1467 | @retval RETURN_UNSUPPORTED If Length of characters from String contain\r | |
1468 | a character that is not valid hexadecimal\r | |
1469 | digit characters, or a Null-terminator.\r | |
1470 | @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).\r | |
1471 | **/\r | |
1472 | RETURN_STATUS\r | |
1473 | EFIAPI\r | |
1474 | StrHexToBytes (\r | |
2f88bd3a MK |
1475 | IN CONST CHAR16 *String,\r |
1476 | IN UINTN Length,\r | |
1477 | OUT UINT8 *Buffer,\r | |
1478 | IN UINTN MaxBufferSize\r | |
36396ea2 RN |
1479 | );\r |
1480 | \r | |
3ab41b7a JY |
1481 | /**\r |
1482 | Convert a Null-terminated Unicode string to a Null-terminated\r | |
1483 | ASCII string.\r | |
1484 | \r | |
1485 | This function is similar to AsciiStrCpyS.\r | |
1486 | \r | |
1487 | This function converts the content of the Unicode string Source\r | |
1488 | to the ASCII string Destination by copying the lower 8 bits of\r | |
1489 | each Unicode character. The function terminates the ASCII string\r | |
1490 | Destination by appending a Null-terminator character at the end.\r | |
1491 | \r | |
1492 | The caller is responsible to make sure Destination points to a buffer with size\r | |
1493 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
1494 | \r | |
1495 | If any Unicode characters in Source contain non-zero value in\r | |
1496 | the upper 8 bits, then ASSERT().\r | |
1497 | \r | |
1498 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
3ab41b7a JY |
1499 | \r |
1500 | If an error is returned, then the Destination is unmodified.\r | |
1501 | \r | |
1502 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1503 | @param Destination The pointer to a Null-terminated ASCII string.\r | |
1504 | @param DestMax The maximum number of Destination Ascii\r | |
1505 | char, including terminating null char.\r | |
1506 | \r | |
1507 | @retval RETURN_SUCCESS String is converted.\r | |
1508 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
1509 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
1510 | If Source is NULL.\r | |
1511 | If PcdMaximumAsciiStringLength is not zero,\r | |
1512 | and DestMax is greater than\r | |
1513 | PcdMaximumAsciiStringLength.\r | |
1514 | If PcdMaximumUnicodeStringLength is not zero,\r | |
1515 | and DestMax is greater than\r | |
1516 | PcdMaximumUnicodeStringLength.\r | |
1517 | If DestMax is 0.\r | |
1518 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
1519 | \r | |
1520 | **/\r | |
1521 | RETURN_STATUS\r | |
1522 | EFIAPI\r | |
1523 | UnicodeStrToAsciiStrS (\r | |
2f88bd3a MK |
1524 | IN CONST CHAR16 *Source,\r |
1525 | OUT CHAR8 *Destination,\r | |
1526 | IN UINTN DestMax\r | |
3ab41b7a | 1527 | );\r |
ac644614 | 1528 | \r |
02263214 HW |
1529 | /**\r |
1530 | Convert not more than Length successive characters from a Null-terminated\r | |
1531 | Unicode string to a Null-terminated Ascii string. If no null char is copied\r | |
1532 | from Source, then Destination[Length] is always set to null.\r | |
1533 | \r | |
1534 | This function converts not more than Length successive characters from the\r | |
1535 | Unicode string Source to the Ascii string Destination by copying the lower 8\r | |
1536 | bits of each Unicode character. The function terminates the Ascii string\r | |
1537 | Destination by appending a Null-terminator character at the end.\r | |
1538 | \r | |
1539 | The caller is responsible to make sure Destination points to a buffer with size\r | |
1540 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
1541 | \r | |
1542 | If any Unicode characters in Source contain non-zero value in the upper 8\r | |
1543 | bits, then ASSERT().\r | |
1544 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
02263214 HW |
1545 | \r |
1546 | If an error is returned, then the Destination is unmodified.\r | |
1547 | \r | |
1548 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1549 | @param Length The maximum number of Unicode characters to\r | |
1550 | convert.\r | |
1551 | @param Destination The pointer to a Null-terminated Ascii string.\r | |
1552 | @param DestMax The maximum number of Destination Ascii\r | |
1553 | char, including terminating null char.\r | |
1554 | @param DestinationLength The number of Unicode characters converted.\r | |
1555 | \r | |
1556 | @retval RETURN_SUCCESS String is converted.\r | |
1557 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
1558 | If Source is NULL.\r | |
1559 | If DestinationLength is NULL.\r | |
1560 | If PcdMaximumAsciiStringLength is not zero,\r | |
1561 | and Length or DestMax is greater than\r | |
1562 | PcdMaximumAsciiStringLength.\r | |
1563 | If PcdMaximumUnicodeStringLength is not\r | |
1564 | zero, and Length or DestMax is greater than\r | |
1565 | PcdMaximumUnicodeStringLength.\r | |
1566 | If DestMax is 0.\r | |
1567 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r | |
1568 | MIN(StrLen(Source), Length).\r | |
1569 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
1570 | \r | |
1571 | **/\r | |
1572 | RETURN_STATUS\r | |
1573 | EFIAPI\r | |
1574 | UnicodeStrnToAsciiStrS (\r | |
2f88bd3a MK |
1575 | IN CONST CHAR16 *Source,\r |
1576 | IN UINTN Length,\r | |
1577 | OUT CHAR8 *Destination,\r | |
1578 | IN UINTN DestMax,\r | |
1579 | OUT UINTN *DestinationLength\r | |
02263214 HW |
1580 | );\r |
1581 | \r | |
ac644614 | 1582 | /**\r |
1583 | Returns the length of a Null-terminated ASCII string.\r | |
1584 | \r | |
1585 | This function returns the number of ASCII characters in the Null-terminated\r | |
1586 | ASCII string specified by String.\r | |
1587 | \r | |
1588 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
1589 | If Length > 0 and Source is NULL, then ASSERT().\r | |
1590 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
1591 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1592 | then ASSERT().\r | |
1593 | \r | |
af2dc6a7 | 1594 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1595 | \r |
1596 | @return The length of String.\r | |
1597 | \r | |
1598 | **/\r | |
1599 | UINTN\r | |
1600 | EFIAPI\r | |
1601 | AsciiStrLen (\r | |
2f88bd3a | 1602 | IN CONST CHAR8 *String\r |
ac644614 | 1603 | );\r |
1604 | \r | |
ac644614 | 1605 | /**\r |
1606 | Returns the size of a Null-terminated ASCII string in bytes, including the\r | |
1607 | Null terminator.\r | |
1608 | \r | |
1609 | This function returns the size, in bytes, of the Null-terminated ASCII string\r | |
1610 | specified by String.\r | |
1611 | \r | |
1612 | If String is NULL, then ASSERT().\r | |
1613 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
1614 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1615 | then ASSERT().\r | |
1616 | \r | |
af2dc6a7 | 1617 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1618 | \r |
1619 | @return The size of String.\r | |
1620 | \r | |
1621 | **/\r | |
1622 | UINTN\r | |
1623 | EFIAPI\r | |
1624 | AsciiStrSize (\r | |
2f88bd3a | 1625 | IN CONST CHAR8 *String\r |
ac644614 | 1626 | );\r |
1627 | \r | |
ac644614 | 1628 | /**\r |
1629 | Compares two Null-terminated ASCII strings, and returns the difference\r | |
1630 | between the first mismatched ASCII characters.\r | |
1631 | \r | |
1632 | This function compares the Null-terminated ASCII string FirstString to the\r | |
1633 | Null-terminated ASCII string SecondString. If FirstString is identical to\r | |
1634 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
1635 | mismatched ASCII character in SecondString subtracted from the first\r | |
1636 | mismatched ASCII character in FirstString.\r | |
1637 | \r | |
1638 | If FirstString is NULL, then ASSERT().\r | |
1639 | If SecondString is NULL, then ASSERT().\r | |
1640 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
1641 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1642 | then ASSERT().\r | |
1643 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
1644 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
1645 | Null-terminator, then ASSERT().\r | |
1646 | \r | |
af2dc6a7 | 1647 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
1648 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1649 | \r |
17f695ed | 1650 | @retval ==0 FirstString is identical to SecondString.\r |
1651 | @retval !=0 FirstString is not identical to SecondString.\r | |
ac644614 | 1652 | \r |
1653 | **/\r | |
1654 | INTN\r | |
1655 | EFIAPI\r | |
1656 | AsciiStrCmp (\r | |
2f88bd3a MK |
1657 | IN CONST CHAR8 *FirstString,\r |
1658 | IN CONST CHAR8 *SecondString\r | |
ac644614 | 1659 | );\r |
1660 | \r | |
ac644614 | 1661 | /**\r |
1662 | Performs a case insensitive comparison of two Null-terminated ASCII strings,\r | |
1663 | and returns the difference between the first mismatched ASCII characters.\r | |
1664 | \r | |
1665 | This function performs a case insensitive comparison of the Null-terminated\r | |
1666 | ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r | |
1667 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
1668 | value returned is the first mismatched lower case ASCII character in\r | |
1669 | SecondString subtracted from the first mismatched lower case ASCII character\r | |
1670 | in FirstString.\r | |
1671 | \r | |
1672 | If FirstString is NULL, then ASSERT().\r | |
1673 | If SecondString is NULL, then ASSERT().\r | |
1674 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
1675 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1676 | then ASSERT().\r | |
1677 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
1678 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
1679 | Null-terminator, then ASSERT().\r | |
1680 | \r | |
af2dc6a7 | 1681 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
1682 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1683 | \r |
17f695ed | 1684 | @retval ==0 FirstString is identical to SecondString using case insensitive\r |
1106ffe1 | 1685 | comparisons.\r |
17f695ed | 1686 | @retval !=0 FirstString is not identical to SecondString using case\r |
1106ffe1 | 1687 | insensitive comparisons.\r |
ac644614 | 1688 | \r |
1689 | **/\r | |
1690 | INTN\r | |
1691 | EFIAPI\r | |
1692 | AsciiStriCmp (\r | |
2f88bd3a MK |
1693 | IN CONST CHAR8 *FirstString,\r |
1694 | IN CONST CHAR8 *SecondString\r | |
ac644614 | 1695 | );\r |
1696 | \r | |
ac644614 | 1697 | /**\r |
1698 | Compares two Null-terminated ASCII strings with maximum lengths, and returns\r | |
1699 | the difference between the first mismatched ASCII characters.\r | |
1700 | \r | |
1701 | This function compares the Null-terminated ASCII string FirstString to the\r | |
1702 | Null-terminated ASCII string SecondString. At most, Length ASCII characters\r | |
1703 | will be compared. If Length is 0, then 0 is returned. If FirstString is\r | |
1704 | identical to SecondString, then 0 is returned. Otherwise, the value returned\r | |
1705 | is the first mismatched ASCII character in SecondString subtracted from the\r | |
1706 | first mismatched ASCII character in FirstString.\r | |
1707 | \r | |
1708 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
1709 | If Length > 0 and SecondString is NULL, then ASSERT().\r | |
9095d37b | 1710 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than\r |
50c247fd | 1711 | PcdMaximumAsciiStringLength, then ASSERT().\r |
1712 | If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than\r | |
1713 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
ac644614 | 1714 | then ASSERT().\r |
50c247fd | 1715 | If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than\r |
1716 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
ac644614 | 1717 | then ASSERT().\r |
1718 | \r | |
af2dc6a7 | 1719 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
1720 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
1721 | @param Length The maximum number of ASCII characters for compare.\r | |
9095d37b | 1722 | \r |
17f695ed | 1723 | @retval ==0 FirstString is identical to SecondString.\r |
1724 | @retval !=0 FirstString is not identical to SecondString.\r | |
ac644614 | 1725 | \r |
1726 | **/\r | |
1727 | INTN\r | |
1728 | EFIAPI\r | |
1729 | AsciiStrnCmp (\r | |
2f88bd3a MK |
1730 | IN CONST CHAR8 *FirstString,\r |
1731 | IN CONST CHAR8 *SecondString,\r | |
1732 | IN UINTN Length\r | |
ac644614 | 1733 | );\r |
1734 | \r | |
ac644614 | 1735 | /**\r |
9aa049d9 | 1736 | Returns the first occurrence of a Null-terminated ASCII sub-string\r |
ac644614 | 1737 | in a Null-terminated ASCII string.\r |
1738 | \r | |
1739 | This function scans the contents of the ASCII string specified by String\r | |
1740 | and returns the first occurrence of SearchString. If SearchString is not\r | |
1741 | found in String, then NULL is returned. If the length of SearchString is zero,\r | |
1742 | then String is returned.\r | |
1743 | \r | |
1744 | If String is NULL, then ASSERT().\r | |
1745 | If SearchString is NULL, then ASSERT().\r | |
1746 | \r | |
1747 | If PcdMaximumAsciiStringLength is not zero, and SearchString or\r | |
1748 | String contains more than PcdMaximumAsciiStringLength Unicode characters\r | |
1749 | not including the Null-terminator, then ASSERT().\r | |
1750 | \r | |
af2dc6a7 | 1751 | @param String The pointer to a Null-terminated ASCII string.\r |
1752 | @param SearchString The pointer to a Null-terminated ASCII string to search for.\r | |
ac644614 | 1753 | \r |
1754 | @retval NULL If the SearchString does not appear in String.\r | |
17f695ed | 1755 | @retval others If there is a match return the first occurrence of SearchingString.\r |
9aa049d9 | 1756 | If the length of SearchString is zero,return String.\r |
ac644614 | 1757 | \r |
1758 | **/\r | |
1759 | CHAR8 *\r | |
1760 | EFIAPI\r | |
1761 | AsciiStrStr (\r | |
2f88bd3a MK |
1762 | IN CONST CHAR8 *String,\r |
1763 | IN CONST CHAR8 *SearchString\r | |
ac644614 | 1764 | );\r |
1765 | \r | |
ac644614 | 1766 | /**\r |
1767 | Convert a Null-terminated ASCII decimal string to a value of type\r | |
1768 | UINTN.\r | |
1769 | \r | |
1770 | This function returns a value of type UINTN by interpreting the contents\r | |
1771 | of the ASCII string String as a decimal number. The format of the input\r | |
1772 | ASCII string String is:\r | |
1773 | \r | |
1774 | [spaces] [decimal digits].\r | |
1775 | \r | |
1776 | The valid decimal digit character is in the range [0-9]. The function will\r | |
1777 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
1778 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
1779 | function stops at the first character that is a not a valid decimal character or\r | |
1780 | Null-terminator, whichever on comes first.\r | |
1781 | \r | |
1782 | If String has only pad spaces, then 0 is returned.\r | |
1783 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
1784 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 1785 | UINTN, then MAX_UINTN is returned.\r |
ac644614 | 1786 | If String is NULL, then ASSERT().\r |
1787 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
1788 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1789 | then ASSERT().\r | |
1790 | \r | |
af2dc6a7 | 1791 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1792 | \r |
af2dc6a7 | 1793 | @retval The value translated from String.\r |
ac644614 | 1794 | \r |
1795 | **/\r | |
1796 | UINTN\r | |
1797 | EFIAPI\r | |
1798 | AsciiStrDecimalToUintn (\r | |
2f88bd3a | 1799 | IN CONST CHAR8 *String\r |
ac644614 | 1800 | );\r |
1801 | \r | |
ac644614 | 1802 | /**\r |
1803 | Convert a Null-terminated ASCII decimal string to a value of type\r | |
1804 | UINT64.\r | |
1805 | \r | |
1806 | This function returns a value of type UINT64 by interpreting the contents\r | |
1807 | of the ASCII string String as a decimal number. The format of the input\r | |
1808 | ASCII string String is:\r | |
1809 | \r | |
1810 | [spaces] [decimal digits].\r | |
1811 | \r | |
1812 | The valid decimal digit character is in the range [0-9]. The function will\r | |
1813 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
1814 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
1815 | function stops at the first character that is a not a valid decimal character or\r | |
1816 | Null-terminator, whichever on comes first.\r | |
1817 | \r | |
1818 | If String has only pad spaces, then 0 is returned.\r | |
1819 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
1820 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 1821 | UINT64, then MAX_UINT64 is returned.\r |
ac644614 | 1822 | If String is NULL, then ASSERT().\r |
1823 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
1824 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1825 | then ASSERT().\r | |
1826 | \r | |
af2dc6a7 | 1827 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1828 | \r |
38bbd3d9 | 1829 | @retval Value translated from String.\r |
ac644614 | 1830 | \r |
1831 | **/\r | |
1832 | UINT64\r | |
1833 | EFIAPI\r | |
1834 | AsciiStrDecimalToUint64 (\r | |
2f88bd3a | 1835 | IN CONST CHAR8 *String\r |
ac644614 | 1836 | );\r |
1837 | \r | |
ac644614 | 1838 | /**\r |
1839 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r | |
1840 | \r | |
1841 | This function returns a value of type UINTN by interpreting the contents of\r | |
1842 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
1843 | string String is:\r | |
1844 | \r | |
1845 | [spaces][zeros][x][hexadecimal digits].\r | |
1846 | \r | |
1847 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1848 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
1849 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
1850 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
1851 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
1852 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
1853 | digit. Then, the function stops at the first character that is a not a valid\r | |
1854 | hexadecimal character or Null-terminator, whichever on comes first.\r | |
1855 | \r | |
1856 | If String has only pad spaces, then 0 is returned.\r | |
1857 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
1858 | 0 is returned.\r | |
1859 | \r | |
1860 | If the number represented by String overflows according to the range defined by UINTN,\r | |
ea2e0921 | 1861 | then MAX_UINTN is returned.\r |
ac644614 | 1862 | If String is NULL, then ASSERT().\r |
1863 | If PcdMaximumAsciiStringLength is not zero,\r | |
1864 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
1865 | the Null-terminator, then ASSERT().\r | |
1866 | \r | |
af2dc6a7 | 1867 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1868 | \r |
38bbd3d9 | 1869 | @retval Value translated from String.\r |
ac644614 | 1870 | \r |
1871 | **/\r | |
1872 | UINTN\r | |
1873 | EFIAPI\r | |
1874 | AsciiStrHexToUintn (\r | |
2f88bd3a | 1875 | IN CONST CHAR8 *String\r |
ac644614 | 1876 | );\r |
1877 | \r | |
ac644614 | 1878 | /**\r |
1879 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r | |
1880 | \r | |
1881 | This function returns a value of type UINT64 by interpreting the contents of\r | |
1882 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
1883 | string String is:\r | |
1884 | \r | |
1885 | [spaces][zeros][x][hexadecimal digits].\r | |
1886 | \r | |
1887 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1888 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
1889 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
1890 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
1891 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
1892 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
1893 | digit. Then, the function stops at the first character that is a not a valid\r | |
1894 | hexadecimal character or Null-terminator, whichever on comes first.\r | |
1895 | \r | |
1896 | If String has only pad spaces, then 0 is returned.\r | |
1897 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
1898 | 0 is returned.\r | |
1899 | \r | |
1900 | If the number represented by String overflows according to the range defined by UINT64,\r | |
ea2e0921 | 1901 | then MAX_UINT64 is returned.\r |
ac644614 | 1902 | If String is NULL, then ASSERT().\r |
1903 | If PcdMaximumAsciiStringLength is not zero,\r | |
1904 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
1905 | the Null-terminator, then ASSERT().\r | |
1906 | \r | |
af2dc6a7 | 1907 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1908 | \r |
38bbd3d9 | 1909 | @retval Value translated from String.\r |
ac644614 | 1910 | \r |
1911 | **/\r | |
1912 | UINT64\r | |
1913 | EFIAPI\r | |
1914 | AsciiStrHexToUint64 (\r | |
2f88bd3a | 1915 | IN CONST CHAR8 *String\r |
ac644614 | 1916 | );\r |
1917 | \r | |
fb4dd857 RN |
1918 | /**\r |
1919 | Convert a Null-terminated ASCII string to IPv6 address and prefix length.\r | |
1920 | \r | |
1921 | This function outputs a value of type IPv6_ADDRESS and may output a value\r | |
1922 | of type UINT8 by interpreting the contents of the ASCII string specified\r | |
1923 | by String. The format of the input ASCII string String is as follows:\r | |
1924 | \r | |
1925 | X:X:X:X:X:X:X:X[/P]\r | |
1926 | \r | |
1927 | X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and\r | |
1928 | [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low\r | |
1929 | memory address and high byte is stored in high memory address. P contains decimal\r | |
1930 | digit characters in the range [0-9]. The running zero in the beginning of P will\r | |
1931 | be ignored. /P is optional.\r | |
1932 | \r | |
1933 | When /P is not in the String, the function stops at the first character that is\r | |
1934 | not a valid hexadecimal digit character after eight X's are converted.\r | |
1935 | \r | |
1936 | When /P is in the String, the function stops at the first character that is not\r | |
1937 | a valid decimal digit character after P is converted.\r | |
1938 | \r | |
1939 | "::" can be used to compress one or more groups of X when X contains only 0.\r | |
1940 | The "::" can only appear once in the String.\r | |
1941 | \r | |
fb4dd857 RN |
1942 | If EndPointer is not NULL and Address is translated from String, a pointer\r |
1943 | to the character that stopped the scan is stored at the location pointed to\r | |
1944 | by EndPointer.\r | |
1945 | \r | |
1946 | @param String Pointer to a Null-terminated ASCII string.\r | |
1947 | @param EndPointer Pointer to character that stops scan.\r | |
1948 | @param Address Pointer to the converted IPv6 address.\r | |
1949 | @param PrefixLength Pointer to the converted IPv6 address prefix\r | |
1950 | length. MAX_UINT8 is returned when /P is\r | |
1951 | not in the String.\r | |
1952 | \r | |
1953 | @retval RETURN_SUCCESS Address is translated from String.\r | |
1954 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1955 | If Data is NULL.\r | |
1956 | @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal\r | |
1957 | digit characters.\r | |
1958 | If String contains "::" and number of X\r | |
1959 | is not less than 8.\r | |
1960 | If P starts with character that is not a\r | |
1961 | valid decimal digit character.\r | |
1962 | If the decimal number converted from P\r | |
1963 | exceeds 128.\r | |
1964 | \r | |
1965 | **/\r | |
1966 | RETURN_STATUS\r | |
1967 | EFIAPI\r | |
1968 | AsciiStrToIpv6Address (\r | |
2f88bd3a MK |
1969 | IN CONST CHAR8 *String,\r |
1970 | OUT CHAR8 **EndPointer OPTIONAL,\r | |
1971 | OUT IPv6_ADDRESS *Address,\r | |
1972 | OUT UINT8 *PrefixLength OPTIONAL\r | |
fb4dd857 RN |
1973 | );\r |
1974 | \r | |
1975 | /**\r | |
1976 | Convert a Null-terminated ASCII string to IPv4 address and prefix length.\r | |
1977 | \r | |
1978 | This function outputs a value of type IPv4_ADDRESS and may output a value\r | |
1979 | of type UINT8 by interpreting the contents of the ASCII string specified\r | |
1980 | by String. The format of the input ASCII string String is as follows:\r | |
1981 | \r | |
1982 | D.D.D.D[/P]\r | |
1983 | \r | |
1984 | D and P are decimal digit characters in the range [0-9]. The running zero in\r | |
1985 | the beginning of D and P will be ignored. /P is optional.\r | |
1986 | \r | |
1987 | When /P is not in the String, the function stops at the first character that is\r | |
1988 | not a valid decimal digit character after four D's are converted.\r | |
1989 | \r | |
1990 | When /P is in the String, the function stops at the first character that is not\r | |
1991 | a valid decimal digit character after P is converted.\r | |
1992 | \r | |
fb4dd857 RN |
1993 | If EndPointer is not NULL and Address is translated from String, a pointer\r |
1994 | to the character that stopped the scan is stored at the location pointed to\r | |
1995 | by EndPointer.\r | |
1996 | \r | |
1997 | @param String Pointer to a Null-terminated ASCII string.\r | |
1998 | @param EndPointer Pointer to character that stops scan.\r | |
1999 | @param Address Pointer to the converted IPv4 address.\r | |
2000 | @param PrefixLength Pointer to the converted IPv4 address prefix\r | |
2001 | length. MAX_UINT8 is returned when /P is\r | |
2002 | not in the String.\r | |
2003 | \r | |
2004 | @retval RETURN_SUCCESS Address is translated from String.\r | |
2005 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
2006 | If Data is NULL.\r | |
2007 | @retval RETURN_UNSUPPORTED If String is not in the correct format.\r | |
2008 | If any decimal number converted from D\r | |
2009 | exceeds 255.\r | |
2010 | If the decimal number converted from P\r | |
2011 | exceeds 32.\r | |
2012 | \r | |
2013 | **/\r | |
2014 | RETURN_STATUS\r | |
2015 | EFIAPI\r | |
2016 | AsciiStrToIpv4Address (\r | |
2f88bd3a MK |
2017 | IN CONST CHAR8 *String,\r |
2018 | OUT CHAR8 **EndPointer OPTIONAL,\r | |
2019 | OUT IPv4_ADDRESS *Address,\r | |
2020 | OUT UINT8 *PrefixLength OPTIONAL\r | |
fb4dd857 RN |
2021 | );\r |
2022 | \r | |
2023 | /**\r | |
2024 | Convert a Null-terminated ASCII GUID string to a value of type\r | |
2025 | EFI_GUID.\r | |
2026 | \r | |
2027 | This function outputs a GUID value by interpreting the contents of\r | |
2028 | the ASCII string specified by String. The format of the input\r | |
2029 | ASCII string String consists of 36 characters, as follows:\r | |
2030 | \r | |
2031 | aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\r | |
2032 | \r | |
2033 | The pairs aa - pp are two characters in the range [0-9], [a-f] and\r | |
2034 | [A-F], with each pair representing a single byte hexadecimal value.\r | |
2035 | \r | |
2036 | The mapping between String and the EFI_GUID structure is as follows:\r | |
2037 | aa Data1[24:31]\r | |
2038 | bb Data1[16:23]\r | |
2039 | cc Data1[8:15]\r | |
2040 | dd Data1[0:7]\r | |
2041 | ee Data2[8:15]\r | |
2042 | ff Data2[0:7]\r | |
2043 | gg Data3[8:15]\r | |
2044 | hh Data3[0:7]\r | |
2045 | ii Data4[0:7]\r | |
2046 | jj Data4[8:15]\r | |
2047 | kk Data4[16:23]\r | |
2048 | ll Data4[24:31]\r | |
2049 | mm Data4[32:39]\r | |
2050 | nn Data4[40:47]\r | |
2051 | oo Data4[48:55]\r | |
2052 | pp Data4[56:63]\r | |
2053 | \r | |
fb4dd857 RN |
2054 | @param String Pointer to a Null-terminated ASCII string.\r |
2055 | @param Guid Pointer to the converted GUID.\r | |
2056 | \r | |
2057 | @retval RETURN_SUCCESS Guid is translated from String.\r | |
2058 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
2059 | If Data is NULL.\r | |
2060 | @retval RETURN_UNSUPPORTED If String is not as the above format.\r | |
2061 | \r | |
2062 | **/\r | |
2063 | RETURN_STATUS\r | |
2064 | EFIAPI\r | |
2065 | AsciiStrToGuid (\r | |
2f88bd3a MK |
2066 | IN CONST CHAR8 *String,\r |
2067 | OUT GUID *Guid\r | |
fb4dd857 RN |
2068 | );\r |
2069 | \r | |
2070 | /**\r | |
2071 | Convert a Null-terminated ASCII hexadecimal string to a byte array.\r | |
2072 | \r | |
2073 | This function outputs a byte array by interpreting the contents of\r | |
2074 | the ASCII string specified by String in hexadecimal format. The format of\r | |
2075 | the input ASCII string String is:\r | |
2076 | \r | |
2077 | [XX]*\r | |
2078 | \r | |
2079 | X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].\r | |
2080 | The function decodes every two hexadecimal digit characters as one byte. The\r | |
2081 | decoding stops after Length of characters and outputs Buffer containing\r | |
2082 | (Length / 2) bytes.\r | |
2083 | \r | |
fb4dd857 RN |
2084 | @param String Pointer to a Null-terminated ASCII string.\r |
2085 | @param Length The number of ASCII characters to decode.\r | |
2086 | @param Buffer Pointer to the converted bytes array.\r | |
2087 | @param MaxBufferSize The maximum size of Buffer.\r | |
2088 | \r | |
2089 | @retval RETURN_SUCCESS Buffer is translated from String.\r | |
2090 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
2091 | If Data is NULL.\r | |
2092 | If Length is not multiple of 2.\r | |
2093 | If PcdMaximumAsciiStringLength is not zero,\r | |
2094 | and Length is greater than\r | |
2095 | PcdMaximumAsciiStringLength.\r | |
2096 | @retval RETURN_UNSUPPORTED If Length of characters from String contain\r | |
2097 | a character that is not valid hexadecimal\r | |
2098 | digit characters, or a Null-terminator.\r | |
2099 | @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).\r | |
2100 | **/\r | |
2101 | RETURN_STATUS\r | |
2102 | EFIAPI\r | |
2103 | AsciiStrHexToBytes (\r | |
2f88bd3a MK |
2104 | IN CONST CHAR8 *String,\r |
2105 | IN UINTN Length,\r | |
2106 | OUT UINT8 *Buffer,\r | |
2107 | IN UINTN MaxBufferSize\r | |
fb4dd857 RN |
2108 | );\r |
2109 | \r | |
3ab41b7a JY |
2110 | /**\r |
2111 | Convert one Null-terminated ASCII string to a Null-terminated\r | |
2112 | Unicode string.\r | |
2113 | \r | |
2114 | This function is similar to StrCpyS.\r | |
2115 | \r | |
2116 | This function converts the contents of the ASCII string Source to the Unicode\r | |
2117 | string Destination. The function terminates the Unicode string Destination by\r | |
2118 | appending a Null-terminator character at the end.\r | |
2119 | \r | |
2120 | The caller is responsible to make sure Destination points to a buffer with size\r | |
2121 | equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r | |
2122 | \r | |
2123 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
3ab41b7a JY |
2124 | \r |
2125 | If an error is returned, then the Destination is unmodified.\r | |
2126 | \r | |
2127 | @param Source The pointer to a Null-terminated ASCII string.\r | |
2128 | @param Destination The pointer to a Null-terminated Unicode string.\r | |
2129 | @param DestMax The maximum number of Destination Unicode\r | |
2130 | char, including terminating null char.\r | |
2131 | \r | |
2132 | @retval RETURN_SUCCESS String is converted.\r | |
2133 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
2134 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
2135 | If Source is NULL.\r | |
2136 | If PcdMaximumUnicodeStringLength is not zero,\r | |
2137 | and DestMax is greater than\r | |
2138 | PcdMaximumUnicodeStringLength.\r | |
2139 | If PcdMaximumAsciiStringLength is not zero,\r | |
2140 | and DestMax is greater than\r | |
2141 | PcdMaximumAsciiStringLength.\r | |
2142 | If DestMax is 0.\r | |
2143 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
2144 | \r | |
2145 | **/\r | |
2146 | RETURN_STATUS\r | |
2147 | EFIAPI\r | |
2148 | AsciiStrToUnicodeStrS (\r | |
2f88bd3a MK |
2149 | IN CONST CHAR8 *Source,\r |
2150 | OUT CHAR16 *Destination,\r | |
2151 | IN UINTN DestMax\r | |
3ab41b7a | 2152 | );\r |
ac644614 | 2153 | \r |
02263214 HW |
2154 | /**\r |
2155 | Convert not more than Length successive characters from a Null-terminated\r | |
2156 | Ascii string to a Null-terminated Unicode string. If no null char is copied\r | |
2157 | from Source, then Destination[Length] is always set to null.\r | |
2158 | \r | |
2159 | This function converts not more than Length successive characters from the\r | |
2160 | Ascii string Source to the Unicode string Destination. The function\r | |
2161 | terminates the Unicode string Destination by appending a Null-terminator\r | |
2162 | character at the end.\r | |
2163 | \r | |
2164 | The caller is responsible to make sure Destination points to a buffer with\r | |
2165 | size not smaller than\r | |
2166 | ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.\r | |
2167 | \r | |
2168 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
02263214 HW |
2169 | \r |
2170 | If an error is returned, then Destination and DestinationLength are\r | |
2171 | unmodified.\r | |
2172 | \r | |
2173 | @param Source The pointer to a Null-terminated Ascii string.\r | |
2174 | @param Length The maximum number of Ascii characters to convert.\r | |
2175 | @param Destination The pointer to a Null-terminated Unicode string.\r | |
2176 | @param DestMax The maximum number of Destination Unicode char,\r | |
2177 | including terminating null char.\r | |
2178 | @param DestinationLength The number of Ascii characters converted.\r | |
2179 | \r | |
2180 | @retval RETURN_SUCCESS String is converted.\r | |
2181 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
2182 | If Source is NULL.\r | |
2183 | If DestinationLength is NULL.\r | |
2184 | If PcdMaximumUnicodeStringLength is not\r | |
2185 | zero, and Length or DestMax is greater than\r | |
2186 | PcdMaximumUnicodeStringLength.\r | |
2187 | If PcdMaximumAsciiStringLength is not zero,\r | |
2188 | and Length or DestMax is greater than\r | |
2189 | PcdMaximumAsciiStringLength.\r | |
2190 | If DestMax is 0.\r | |
2191 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r | |
2192 | MIN(AsciiStrLen(Source), Length).\r | |
2193 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
2194 | \r | |
2195 | **/\r | |
2196 | RETURN_STATUS\r | |
2197 | EFIAPI\r | |
2198 | AsciiStrnToUnicodeStrS (\r | |
2f88bd3a MK |
2199 | IN CONST CHAR8 *Source,\r |
2200 | IN UINTN Length,\r | |
2201 | OUT CHAR16 *Destination,\r | |
2202 | IN UINTN DestMax,\r | |
2203 | OUT UINTN *DestinationLength\r | |
02263214 HW |
2204 | );\r |
2205 | \r | |
5dbfa01e MT |
2206 | /**\r |
2207 | Convert a Unicode character to upper case only if\r | |
2208 | it maps to a valid small-case ASCII character.\r | |
2209 | \r | |
2210 | This internal function only deal with Unicode character\r | |
2211 | which maps to a valid small-case ASCII character, i.e.\r | |
2212 | L'a' to L'z'. For other Unicode character, the input character\r | |
2213 | is returned directly.\r | |
2214 | \r | |
2215 | @param Char The character to convert.\r | |
2216 | \r | |
2217 | @retval LowerCharacter If the Char is with range L'a' to L'z'.\r | |
2218 | @retval Unchanged Otherwise.\r | |
2219 | \r | |
2220 | **/\r | |
2221 | CHAR16\r | |
2222 | EFIAPI\r | |
2223 | CharToUpper (\r | |
2f88bd3a | 2224 | IN CHAR16 Char\r |
5dbfa01e MT |
2225 | );\r |
2226 | \r | |
2227 | /**\r | |
2228 | Converts a lowercase Ascii character to upper one.\r | |
2229 | \r | |
2230 | If Chr is lowercase Ascii character, then converts it to upper one.\r | |
2231 | \r | |
2232 | If Value >= 0xA0, then ASSERT().\r | |
2233 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
2234 | \r | |
2235 | @param Chr one Ascii character\r | |
2236 | \r | |
2237 | @return The uppercase value of Ascii character\r | |
2238 | \r | |
2239 | **/\r | |
2240 | CHAR8\r | |
2241 | EFIAPI\r | |
2242 | AsciiCharToUpper (\r | |
2f88bd3a | 2243 | IN CHAR8 Chr\r |
5dbfa01e MT |
2244 | );\r |
2245 | \r | |
1f7af69d MT |
2246 | /**\r |
2247 | Convert binary data to a Base64 encoded ascii string based on RFC4648.\r | |
2248 | \r | |
2249 | Produce a Null-terminated Ascii string in the output buffer specified by Destination and DestinationSize.\r | |
2250 | The Ascii string is produced by converting the data string specified by Source and SourceLength.\r | |
2251 | \r | |
2252 | @param Source Input UINT8 data\r | |
2253 | @param SourceLength Number of UINT8 bytes of data\r | |
2254 | @param Destination Pointer to output string buffer\r | |
2255 | @param DestinationSize Size of ascii buffer. Set to 0 to get the size needed.\r | |
2256 | Caller is responsible for passing in buffer of DestinationSize\r | |
2257 | \r | |
2258 | @retval RETURN_SUCCESS When ascii buffer is filled in.\r | |
2259 | @retval RETURN_INVALID_PARAMETER If Source is NULL or DestinationSize is NULL.\r | |
2260 | @retval RETURN_INVALID_PARAMETER If SourceLength or DestinationSize is bigger than (MAX_ADDRESS - (UINTN)Destination).\r | |
2261 | @retval RETURN_BUFFER_TOO_SMALL If SourceLength is 0 and DestinationSize is <1.\r | |
2262 | @retval RETURN_BUFFER_TOO_SMALL If Destination is NULL or DestinationSize is smaller than required buffersize.\r | |
2263 | \r | |
2264 | **/\r | |
2265 | RETURN_STATUS\r | |
2266 | EFIAPI\r | |
2267 | Base64Encode (\r | |
2268 | IN CONST UINT8 *Source,\r | |
2f88bd3a | 2269 | IN UINTN SourceLength,\r |
1f7af69d MT |
2270 | OUT CHAR8 *Destination OPTIONAL,\r |
2271 | IN OUT UINTN *DestinationSize\r | |
2272 | );\r | |
2273 | \r | |
2274 | /**\r | |
5d68fc67 LE |
2275 | Decode Base64 ASCII encoded data to 8-bit binary representation, based on\r |
2276 | RFC4648.\r | |
2277 | \r | |
2278 | Decoding occurs according to "Table 1: The Base 64 Alphabet" in RFC4648.\r | |
2279 | \r | |
2280 | Whitespace is ignored at all positions:\r | |
2281 | - 0x09 ('\t') horizontal tab\r | |
2282 | - 0x0A ('\n') new line\r | |
2283 | - 0x0B ('\v') vertical tab\r | |
2284 | - 0x0C ('\f') form feed\r | |
2285 | - 0x0D ('\r') carriage return\r | |
2286 | - 0x20 (' ') space\r | |
2287 | \r | |
2288 | The minimum amount of required padding (with ASCII 0x3D, '=') is tolerated\r | |
2289 | and enforced at the end of the Base64 ASCII encoded data, and only there.\r | |
2290 | \r | |
2291 | Other characters outside of the encoding alphabet cause the function to\r | |
2292 | reject the Base64 ASCII encoded data.\r | |
2293 | \r | |
2294 | @param[in] Source Array of CHAR8 elements containing the Base64\r | |
2295 | ASCII encoding. May be NULL if SourceSize is\r | |
2296 | zero.\r | |
2297 | \r | |
2298 | @param[in] SourceSize Number of CHAR8 elements in Source.\r | |
2299 | \r | |
2300 | @param[out] Destination Array of UINT8 elements receiving the decoded\r | |
2301 | 8-bit binary representation. Allocated by the\r | |
2302 | caller. May be NULL if DestinationSize is\r | |
2303 | zero on input. If NULL, decoding is\r | |
2304 | performed, but the 8-bit binary\r | |
2305 | representation is not stored. If non-NULL and\r | |
2306 | the function returns an error, the contents\r | |
2307 | of Destination are indeterminate.\r | |
2308 | \r | |
2309 | @param[in,out] DestinationSize On input, the number of UINT8 elements that\r | |
2310 | the caller allocated for Destination. On\r | |
2311 | output, if the function returns\r | |
2312 | RETURN_SUCCESS or RETURN_BUFFER_TOO_SMALL,\r | |
2313 | the number of UINT8 elements that are\r | |
2314 | required for decoding the Base64 ASCII\r | |
2315 | representation. If the function returns a\r | |
2316 | value different from both RETURN_SUCCESS and\r | |
2317 | RETURN_BUFFER_TOO_SMALL, then DestinationSize\r | |
2318 | is indeterminate on output.\r | |
2319 | \r | |
2320 | @retval RETURN_SUCCESS SourceSize CHAR8 elements at Source have\r | |
2321 | been decoded to on-output DestinationSize\r | |
2322 | UINT8 elements at Destination. Note that\r | |
2323 | RETURN_SUCCESS covers the case when\r | |
2324 | DestinationSize is zero on input, and\r | |
2325 | Source decodes to zero bytes (due to\r | |
2326 | containing at most ignored whitespace).\r | |
2327 | \r | |
2328 | @retval RETURN_BUFFER_TOO_SMALL The input value of DestinationSize is not\r | |
2329 | large enough for decoding SourceSize CHAR8\r | |
2330 | elements at Source. The required number of\r | |
2331 | UINT8 elements has been stored to\r | |
2332 | DestinationSize.\r | |
2333 | \r | |
2334 | @retval RETURN_INVALID_PARAMETER DestinationSize is NULL.\r | |
2335 | \r | |
2336 | @retval RETURN_INVALID_PARAMETER Source is NULL, but SourceSize is not zero.\r | |
2337 | \r | |
2338 | @retval RETURN_INVALID_PARAMETER Destination is NULL, but DestinationSize is\r | |
2339 | not zero on input.\r | |
2340 | \r | |
2341 | @retval RETURN_INVALID_PARAMETER Source is non-NULL, and (Source +\r | |
2342 | SourceSize) would wrap around MAX_ADDRESS.\r | |
2343 | \r | |
2344 | @retval RETURN_INVALID_PARAMETER Destination is non-NULL, and (Destination +\r | |
2345 | DestinationSize) would wrap around\r | |
2346 | MAX_ADDRESS, as specified on input.\r | |
2347 | \r | |
2348 | @retval RETURN_INVALID_PARAMETER None of Source and Destination are NULL,\r | |
2349 | and CHAR8[SourceSize] at Source overlaps\r | |
2350 | UINT8[DestinationSize] at Destination, as\r | |
2351 | specified on input.\r | |
2352 | \r | |
2353 | @retval RETURN_INVALID_PARAMETER Invalid CHAR8 element encountered in\r | |
2354 | Source.\r | |
2355 | **/\r | |
1f7af69d MT |
2356 | RETURN_STATUS\r |
2357 | EFIAPI\r | |
2358 | Base64Decode (\r | |
2f88bd3a MK |
2359 | IN CONST CHAR8 *Source OPTIONAL,\r |
2360 | IN UINTN SourceSize,\r | |
2361 | OUT UINT8 *Destination OPTIONAL,\r | |
2362 | IN OUT UINTN *DestinationSize\r | |
1f7af69d MT |
2363 | );\r |
2364 | \r | |
ac644614 | 2365 | /**\r |
2366 | Converts an 8-bit value to an 8-bit BCD value.\r | |
2367 | \r | |
2368 | Converts the 8-bit value specified by Value to BCD. The BCD value is\r | |
2369 | returned.\r | |
2370 | \r | |
2371 | If Value >= 100, then ASSERT().\r | |
2372 | \r | |
2373 | @param Value The 8-bit value to convert to BCD. Range 0..99.\r | |
2374 | \r | |
9aa049d9 | 2375 | @return The BCD value.\r |
ac644614 | 2376 | \r |
2377 | **/\r | |
2378 | UINT8\r | |
2379 | EFIAPI\r | |
2380 | DecimalToBcd8 (\r | |
2f88bd3a | 2381 | IN UINT8 Value\r |
ac644614 | 2382 | );\r |
2383 | \r | |
ac644614 | 2384 | /**\r |
2385 | Converts an 8-bit BCD value to an 8-bit value.\r | |
2386 | \r | |
2387 | Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r | |
2388 | value is returned.\r | |
2389 | \r | |
2390 | If Value >= 0xA0, then ASSERT().\r | |
2391 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
2392 | \r | |
2393 | @param Value The 8-bit BCD value to convert to an 8-bit value.\r | |
2394 | \r | |
2395 | @return The 8-bit value is returned.\r | |
2396 | \r | |
2397 | **/\r | |
2398 | UINT8\r | |
2399 | EFIAPI\r | |
2400 | BcdToDecimal8 (\r | |
2f88bd3a | 2401 | IN UINT8 Value\r |
ac644614 | 2402 | );\r |
2403 | \r | |
ae591c14 DM |
2404 | //\r |
2405 | // File Path Manipulation Functions\r | |
2406 | //\r | |
2407 | \r | |
2408 | /**\r | |
6a623094 | 2409 | Removes the last directory or file entry in a path.\r |
ae591c14 DM |
2410 | \r |
2411 | @param[in, out] Path The pointer to the path to modify.\r | |
2412 | \r | |
2413 | @retval FALSE Nothing was found to remove.\r | |
2414 | @retval TRUE A directory or file was removed.\r | |
2415 | **/\r | |
2416 | BOOLEAN\r | |
2417 | EFIAPI\r | |
2f88bd3a MK |
2418 | PathRemoveLastItem (\r |
2419 | IN OUT CHAR16 *Path\r | |
ae591c14 DM |
2420 | );\r |
2421 | \r | |
2422 | /**\r | |
2423 | Function to clean up paths.\r | |
2424 | - Single periods in the path are removed.\r | |
2425 | - Double periods in the path are removed along with a single parent directory.\r | |
2426 | - Forward slashes L'/' are converted to backward slashes L'\'.\r | |
2427 | \r | |
2428 | This will be done inline and the existing buffer may be larger than required\r | |
2429 | upon completion.\r | |
2430 | \r | |
2431 | @param[in] Path The pointer to the string containing the path.\r | |
2432 | \r | |
00b7cc0f | 2433 | @return Returns Path, otherwise returns NULL to indicate that an error has occurred.\r |
ae591c14 | 2434 | **/\r |
2f88bd3a | 2435 | CHAR16 *\r |
ae591c14 | 2436 | EFIAPI\r |
2f88bd3a MK |
2437 | PathCleanUpDirectories (\r |
2438 | IN CHAR16 *Path\r | |
909ac47b | 2439 | );\r |
ac644614 | 2440 | \r |
2441 | //\r | |
2442 | // Linked List Functions and Macros\r | |
2443 | //\r | |
2444 | \r | |
2445 | /**\r | |
2446 | Initializes the head node of a doubly linked list that is declared as a\r | |
2447 | global variable in a module.\r | |
2448 | \r | |
2449 | Initializes the forward and backward links of a new linked list. After\r | |
2450 | initializing a linked list with this macro, the other linked list functions\r | |
2451 | may be used to add and remove nodes from the linked list. This macro results\r | |
2452 | in smaller executables by initializing the linked list in the data section,\r | |
2453 | instead if calling the InitializeListHead() function to perform the\r | |
2454 | equivalent operation.\r | |
2455 | \r | |
77f863ee | 2456 | @param ListHead The head note of a list to initialize.\r |
ac644614 | 2457 | \r |
2458 | **/\r | |
17f695ed | 2459 | #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}\r |
ac644614 | 2460 | \r |
3b5a58c5 MK |
2461 | /**\r |
2462 | Iterates over each node in a doubly linked list using each node's forward link.\r | |
2463 | \r | |
2464 | @param Entry A pointer to a list node used as a loop cursor during iteration\r | |
2465 | @param ListHead The head node of the doubly linked list\r | |
2466 | \r | |
2467 | **/\r | |
2468 | #define BASE_LIST_FOR_EACH(Entry, ListHead) \\r | |
2469 | for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)\r | |
2470 | \r | |
2471 | /**\r | |
2472 | Iterates over each node in a doubly linked list using each node's forward link\r | |
2473 | with safety against node removal.\r | |
2474 | \r | |
2475 | This macro uses NextEntry to temporarily store the next list node so the node\r | |
2476 | pointed to by Entry may be deleted in the current loop iteration step and\r | |
2477 | iteration can continue from the node pointed to by NextEntry.\r | |
2478 | \r | |
2479 | @param Entry A pointer to a list node used as a loop cursor during iteration\r | |
2480 | @param NextEntry A pointer to a list node used to temporarily store the next node\r | |
2481 | @param ListHead The head node of the doubly linked list\r | |
2482 | \r | |
2483 | **/\r | |
2484 | #define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \\r | |
2485 | for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\\r | |
2486 | Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)\r | |
ac644614 | 2487 | \r |
d0aef615 MH |
2488 | /**\r |
2489 | Checks whether FirstEntry and SecondEntry are part of the same doubly-linked\r | |
2490 | list.\r | |
2491 | \r | |
2492 | If FirstEntry is NULL, then ASSERT().\r | |
2493 | If FirstEntry->ForwardLink is NULL, then ASSERT().\r | |
2494 | If FirstEntry->BackLink is NULL, then ASSERT().\r | |
2495 | If SecondEntry is NULL, then ASSERT();\r | |
2496 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r | |
2497 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
2498 | \r | |
2499 | @param FirstEntry A pointer to a node in a linked list.\r | |
2500 | @param SecondEntry A pointer to the node to locate.\r | |
2501 | \r | |
2502 | @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.\r | |
2503 | @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,\r | |
2504 | or FirstEntry is invalid.\r | |
2505 | \r | |
2506 | **/\r | |
2507 | BOOLEAN\r | |
2508 | EFIAPI\r | |
2509 | IsNodeInList (\r | |
2f88bd3a MK |
2510 | IN CONST LIST_ENTRY *FirstEntry,\r |
2511 | IN CONST LIST_ENTRY *SecondEntry\r | |
d0aef615 MH |
2512 | );\r |
2513 | \r | |
ac644614 | 2514 | /**\r |
2515 | Initializes the head node of a doubly linked list, and returns the pointer to\r | |
2516 | the head node of the doubly linked list.\r | |
2517 | \r | |
2518 | Initializes the forward and backward links of a new linked list. After\r | |
2519 | initializing a linked list with this function, the other linked list\r | |
2520 | functions may be used to add and remove nodes from the linked list. It is up\r | |
2521 | to the caller of this function to allocate the memory for ListHead.\r | |
2522 | \r | |
2523 | If ListHead is NULL, then ASSERT().\r | |
2524 | \r | |
2525 | @param ListHead A pointer to the head node of a new doubly linked list.\r | |
2526 | \r | |
2527 | @return ListHead\r | |
2528 | \r | |
2529 | **/\r | |
2530 | LIST_ENTRY *\r | |
2531 | EFIAPI\r | |
2532 | InitializeListHead (\r | |
2f88bd3a | 2533 | IN OUT LIST_ENTRY *ListHead\r |
ac644614 | 2534 | );\r |
2535 | \r | |
ac644614 | 2536 | /**\r |
2537 | Adds a node to the beginning of a doubly linked list, and returns the pointer\r | |
2538 | to the head node of the doubly linked list.\r | |
2539 | \r | |
2540 | Adds the node Entry at the beginning of the doubly linked list denoted by\r | |
2541 | ListHead, and returns ListHead.\r | |
2542 | \r | |
2543 | If ListHead is NULL, then ASSERT().\r | |
2544 | If Entry is NULL, then ASSERT().\r | |
17f695ed | 2545 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
2546 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 2547 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 2548 | of nodes in ListHead, including the ListHead node, is greater than or\r |
2549 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
2550 | \r | |
2551 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
2552 | @param Entry A pointer to a node that is to be inserted at the beginning\r | |
2553 | of a doubly linked list.\r | |
2554 | \r | |
2555 | @return ListHead\r | |
2556 | \r | |
2557 | **/\r | |
2558 | LIST_ENTRY *\r | |
2559 | EFIAPI\r | |
2560 | InsertHeadList (\r | |
2f88bd3a MK |
2561 | IN OUT LIST_ENTRY *ListHead,\r |
2562 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 2563 | );\r |
2564 | \r | |
ac644614 | 2565 | /**\r |
2566 | Adds a node to the end of a doubly linked list, and returns the pointer to\r | |
2567 | the head node of the doubly linked list.\r | |
2568 | \r | |
2569 | Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r | |
2570 | and returns ListHead.\r | |
2571 | \r | |
2572 | If ListHead is NULL, then ASSERT().\r | |
2573 | If Entry is NULL, then ASSERT().\r | |
9095d37b | 2574 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 2575 | InitializeListHead(), then ASSERT().\r |
a71865b1 | 2576 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 2577 | of nodes in ListHead, including the ListHead node, is greater than or\r |
2578 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
2579 | \r | |
2580 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
2581 | @param Entry A pointer to a node that is to be added at the end of the\r | |
2582 | doubly linked list.\r | |
2583 | \r | |
2584 | @return ListHead\r | |
2585 | \r | |
2586 | **/\r | |
2587 | LIST_ENTRY *\r | |
2588 | EFIAPI\r | |
2589 | InsertTailList (\r | |
2f88bd3a MK |
2590 | IN OUT LIST_ENTRY *ListHead,\r |
2591 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 2592 | );\r |
2593 | \r | |
ac644614 | 2594 | /**\r |
2595 | Retrieves the first node of a doubly linked list.\r | |
2596 | \r | |
9095d37b | 2597 | Returns the first node of a doubly linked list. List must have been\r |
17f695ed | 2598 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
2599 | If List is empty, then List is returned.\r | |
ac644614 | 2600 | \r |
2601 | If List is NULL, then ASSERT().\r | |
9095d37b | 2602 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 2603 | InitializeListHead(), then ASSERT().\r |
a71865b1 | 2604 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 2605 | in List, including the List node, is greater than or equal to\r |
2606 | PcdMaximumLinkedListLength, then ASSERT().\r | |
2607 | \r | |
2608 | @param List A pointer to the head node of a doubly linked list.\r | |
2609 | \r | |
2610 | @return The first node of a doubly linked list.\r | |
e01a125f | 2611 | @retval List The list is empty.\r |
ac644614 | 2612 | \r |
2613 | **/\r | |
2614 | LIST_ENTRY *\r | |
2615 | EFIAPI\r | |
2616 | GetFirstNode (\r | |
2f88bd3a | 2617 | IN CONST LIST_ENTRY *List\r |
ac644614 | 2618 | );\r |
2619 | \r | |
ac644614 | 2620 | /**\r |
2621 | Retrieves the next node of a doubly linked list.\r | |
2622 | \r | |
9095d37b | 2623 | Returns the node of a doubly linked list that follows Node.\r |
17f695ed | 2624 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r |
2625 | or InitializeListHead(). If List is empty, then List is returned.\r | |
ac644614 | 2626 | \r |
2627 | If List is NULL, then ASSERT().\r | |
2628 | If Node is NULL, then ASSERT().\r | |
9095d37b | 2629 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 2630 | InitializeListHead(), then ASSERT().\r |
a71865b1 LG |
2631 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
2632 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
1081f624 | 2633 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 2634 | \r |
2635 | @param List A pointer to the head node of a doubly linked list.\r | |
2636 | @param Node A pointer to a node in the doubly linked list.\r | |
2637 | \r | |
af2dc6a7 | 2638 | @return The pointer to the next node if one exists. Otherwise List is returned.\r |
ac644614 | 2639 | \r |
2640 | **/\r | |
2641 | LIST_ENTRY *\r | |
2642 | EFIAPI\r | |
2643 | GetNextNode (\r | |
2f88bd3a MK |
2644 | IN CONST LIST_ENTRY *List,\r |
2645 | IN CONST LIST_ENTRY *Node\r | |
ac644614 | 2646 | );\r |
2647 | \r | |
cbca8de5 | 2648 | /**\r |
2649 | Retrieves the previous node of a doubly linked list.\r | |
9095d37b LG |
2650 | \r |
2651 | Returns the node of a doubly linked list that precedes Node.\r | |
cbca8de5 | 2652 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r |
2653 | or InitializeListHead(). If List is empty, then List is returned.\r | |
9095d37b | 2654 | \r |
cbca8de5 | 2655 | If List is NULL, then ASSERT().\r |
2656 | If Node is NULL, then ASSERT().\r | |
9095d37b | 2657 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
cbca8de5 | 2658 | InitializeListHead(), then ASSERT().\r |
a71865b1 LG |
2659 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
2660 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
cbca8de5 | 2661 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
9095d37b | 2662 | \r |
cbca8de5 | 2663 | @param List A pointer to the head node of a doubly linked list.\r |
2664 | @param Node A pointer to a node in the doubly linked list.\r | |
9095d37b | 2665 | \r |
af2dc6a7 | 2666 | @return The pointer to the previous node if one exists. Otherwise List is returned.\r |
9095d37b | 2667 | \r |
cbca8de5 | 2668 | **/\r |
2669 | LIST_ENTRY *\r | |
2670 | EFIAPI\r | |
2671 | GetPreviousNode (\r | |
2f88bd3a MK |
2672 | IN CONST LIST_ENTRY *List,\r |
2673 | IN CONST LIST_ENTRY *Node\r | |
cbca8de5 | 2674 | );\r |
ac644614 | 2675 | \r |
2676 | /**\r | |
2677 | Checks to see if a doubly linked list is empty or not.\r | |
2678 | \r | |
2679 | Checks to see if the doubly linked list is empty. If the linked list contains\r | |
2680 | zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r | |
2681 | \r | |
2682 | If ListHead is NULL, then ASSERT().\r | |
9095d37b | 2683 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 2684 | InitializeListHead(), then ASSERT().\r |
a71865b1 | 2685 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 2686 | in List, including the List node, is greater than or equal to\r |
2687 | PcdMaximumLinkedListLength, then ASSERT().\r | |
2688 | \r | |
2689 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
2690 | \r | |
2691 | @retval TRUE The linked list is empty.\r | |
2692 | @retval FALSE The linked list is not empty.\r | |
2693 | \r | |
2694 | **/\r | |
2695 | BOOLEAN\r | |
2696 | EFIAPI\r | |
2697 | IsListEmpty (\r | |
2f88bd3a | 2698 | IN CONST LIST_ENTRY *ListHead\r |
ac644614 | 2699 | );\r |
2700 | \r | |
ac644614 | 2701 | /**\r |
aa0583c7 | 2702 | Determines if a node in a doubly linked list is the head node of a the same\r |
2703 | doubly linked list. This function is typically used to terminate a loop that\r | |
2704 | traverses all the nodes in a doubly linked list starting with the head node.\r | |
ac644614 | 2705 | \r |
aa0583c7 | 2706 | Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the\r |
2707 | nodes in the doubly linked list specified by List. List must have been\r | |
17f695ed | 2708 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 2709 | \r |
2710 | If List is NULL, then ASSERT().\r | |
2711 | If Node is NULL, then ASSERT().\r | |
9095d37b | 2712 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),\r |
17f695ed | 2713 | then ASSERT().\r |
a71865b1 | 2714 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 2715 | in List, including the List node, is greater than or equal to\r |
2716 | PcdMaximumLinkedListLength, then ASSERT().\r | |
9095d37b | 2717 | If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal\r |
1081f624 | 2718 | to List, then ASSERT().\r |
ac644614 | 2719 | \r |
2720 | @param List A pointer to the head node of a doubly linked list.\r | |
2721 | @param Node A pointer to a node in the doubly linked list.\r | |
2722 | \r | |
1955808d LG |
2723 | @retval TRUE Node is the head of the doubly-linked list pointed by List.\r |
2724 | @retval FALSE Node is not the head of the doubly-linked list pointed by List.\r | |
ac644614 | 2725 | \r |
2726 | **/\r | |
2727 | BOOLEAN\r | |
2728 | EFIAPI\r | |
2729 | IsNull (\r | |
2f88bd3a MK |
2730 | IN CONST LIST_ENTRY *List,\r |
2731 | IN CONST LIST_ENTRY *Node\r | |
ac644614 | 2732 | );\r |
2733 | \r | |
ac644614 | 2734 | /**\r |
2735 | Determines if a node the last node in a doubly linked list.\r | |
2736 | \r | |
2737 | Returns TRUE if Node is the last node in the doubly linked list specified by\r | |
2738 | List. Otherwise, FALSE is returned. List must have been initialized with\r | |
17f695ed | 2739 | INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 2740 | \r |
2741 | If List is NULL, then ASSERT().\r | |
2742 | If Node is NULL, then ASSERT().\r | |
17f695ed | 2743 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
2744 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 2745 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 2746 | in List, including the List node, is greater than or equal to\r |
2747 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1081f624 | 2748 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 2749 | \r |
2750 | @param List A pointer to the head node of a doubly linked list.\r | |
2751 | @param Node A pointer to a node in the doubly linked list.\r | |
2752 | \r | |
2753 | @retval TRUE Node is the last node in the linked list.\r | |
2754 | @retval FALSE Node is not the last node in the linked list.\r | |
2755 | \r | |
2756 | **/\r | |
2757 | BOOLEAN\r | |
2758 | EFIAPI\r | |
2759 | IsNodeAtEnd (\r | |
2f88bd3a MK |
2760 | IN CONST LIST_ENTRY *List,\r |
2761 | IN CONST LIST_ENTRY *Node\r | |
ac644614 | 2762 | );\r |
2763 | \r | |
ac644614 | 2764 | /**\r |
2765 | Swaps the location of two nodes in a doubly linked list, and returns the\r | |
2766 | first node after the swap.\r | |
2767 | \r | |
2768 | If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r | |
2769 | Otherwise, the location of the FirstEntry node is swapped with the location\r | |
2770 | of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r | |
2771 | same double linked list as FirstEntry and that double linked list must have\r | |
9095d37b | 2772 | been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
17f695ed | 2773 | SecondEntry is returned after the nodes are swapped.\r |
ac644614 | 2774 | \r |
2775 | If FirstEntry is NULL, then ASSERT().\r | |
2776 | If SecondEntry is NULL, then ASSERT().\r | |
9095d37b | 2777 | If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the\r |
1081f624 | 2778 | same linked list, then ASSERT().\r |
ac644614 | 2779 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r |
2780 | linked list containing the FirstEntry and SecondEntry nodes, including\r | |
2781 | the FirstEntry and SecondEntry nodes, is greater than or equal to\r | |
2782 | PcdMaximumLinkedListLength, then ASSERT().\r | |
2783 | \r | |
2784 | @param FirstEntry A pointer to a node in a linked list.\r | |
2785 | @param SecondEntry A pointer to another node in the same linked list.\r | |
9095d37b | 2786 | \r |
9aa049d9 | 2787 | @return SecondEntry.\r |
ac644614 | 2788 | \r |
2789 | **/\r | |
2790 | LIST_ENTRY *\r | |
2791 | EFIAPI\r | |
2792 | SwapListEntries (\r | |
2f88bd3a MK |
2793 | IN OUT LIST_ENTRY *FirstEntry,\r |
2794 | IN OUT LIST_ENTRY *SecondEntry\r | |
ac644614 | 2795 | );\r |
2796 | \r | |
ac644614 | 2797 | /**\r |
2798 | Removes a node from a doubly linked list, and returns the node that follows\r | |
2799 | the removed node.\r | |
2800 | \r | |
2801 | Removes the node Entry from a doubly linked list. It is up to the caller of\r | |
2802 | this function to release the memory used by this node if that is required. On\r | |
2803 | exit, the node following Entry in the doubly linked list is returned. If\r | |
2804 | Entry is the only node in the linked list, then the head node of the linked\r | |
2805 | list is returned.\r | |
2806 | \r | |
2807 | If Entry is NULL, then ASSERT().\r | |
2808 | If Entry is the head node of an empty list, then ASSERT().\r | |
2809 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r | |
2810 | linked list containing Entry, including the Entry node, is greater than\r | |
2811 | or equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
2812 | \r | |
9aa049d9 | 2813 | @param Entry A pointer to a node in a linked list.\r |
ac644614 | 2814 | \r |
9aa049d9 | 2815 | @return Entry.\r |
ac644614 | 2816 | \r |
2817 | **/\r | |
2818 | LIST_ENTRY *\r | |
2819 | EFIAPI\r | |
2820 | RemoveEntryList (\r | |
2f88bd3a | 2821 | IN CONST LIST_ENTRY *Entry\r |
ac644614 | 2822 | );\r |
2823 | \r | |
2824 | //\r | |
2825 | // Math Services\r | |
2826 | //\r | |
2f88bd3a | 2827 | \r |
4225a464 IK |
2828 | /**\r |
2829 | Prototype for comparison function for any two element types.\r | |
2830 | \r | |
2831 | @param[in] Buffer1 The pointer to first buffer.\r | |
2832 | @param[in] Buffer2 The pointer to second buffer.\r | |
2833 | \r | |
2834 | @retval 0 Buffer1 equal to Buffer2.\r | |
2835 | @return <0 Buffer1 is less than Buffer2.\r | |
2836 | @return >0 Buffer1 is greater than Buffer2.\r | |
2837 | **/\r | |
2838 | typedef\r | |
2839 | INTN\r | |
2840 | (EFIAPI *BASE_SORT_COMPARE)(\r | |
2841 | IN CONST VOID *Buffer1,\r | |
2842 | IN CONST VOID *Buffer2\r | |
2843 | );\r | |
2844 | \r | |
2845 | /**\r | |
2846 | This function is identical to perform QuickSort,\r | |
2847 | except that is uses the pre-allocated buffer so the in place sorting does not need to\r | |
2848 | allocate and free buffers constantly.\r | |
2849 | \r | |
2850 | Each element must be equal sized.\r | |
2851 | \r | |
2852 | if BufferToSort is NULL, then ASSERT.\r | |
2853 | if CompareFunction is NULL, then ASSERT.\r | |
2854 | if BufferOneElement is NULL, then ASSERT.\r | |
2855 | if ElementSize is < 1, then ASSERT.\r | |
2856 | \r | |
2857 | if Count is < 2 then perform no action.\r | |
2858 | \r | |
2859 | @param[in, out] BufferToSort on call a Buffer of (possibly sorted) elements\r | |
2860 | on return a buffer of sorted elements\r | |
2861 | @param[in] Count the number of elements in the buffer to sort\r | |
2862 | @param[in] ElementSize Size of an element in bytes\r | |
2863 | @param[in] CompareFunction The function to call to perform the comparison\r | |
2864 | of any 2 elements\r | |
2865 | @param[out] BufferOneElement Caller provided buffer whose size equals to ElementSize.\r | |
2866 | It's used by QuickSort() for swapping in sorting.\r | |
2867 | **/\r | |
2868 | VOID\r | |
2869 | EFIAPI\r | |
2870 | QuickSort (\r | |
2f88bd3a MK |
2871 | IN OUT VOID *BufferToSort,\r |
2872 | IN CONST UINTN Count,\r | |
2873 | IN CONST UINTN ElementSize,\r | |
2874 | IN BASE_SORT_COMPARE CompareFunction,\r | |
2875 | OUT VOID *BufferOneElement\r | |
4225a464 | 2876 | );\r |
ac644614 | 2877 | \r |
2878 | /**\r | |
2879 | Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r | |
2880 | with zeros. The shifted value is returned.\r | |
2881 | \r | |
2882 | This function shifts the 64-bit value Operand to the left by Count bits. The\r | |
2883 | low Count bits are set to zero. The shifted value is returned.\r | |
2884 | \r | |
2885 | If Count is greater than 63, then ASSERT().\r | |
2886 | \r | |
2887 | @param Operand The 64-bit operand to shift left.\r | |
2888 | @param Count The number of bits to shift left.\r | |
2889 | \r | |
9aa049d9 | 2890 | @return Operand << Count.\r |
ac644614 | 2891 | \r |
2892 | **/\r | |
2893 | UINT64\r | |
2894 | EFIAPI\r | |
2895 | LShiftU64 (\r | |
2f88bd3a MK |
2896 | IN UINT64 Operand,\r |
2897 | IN UINTN Count\r | |
ac644614 | 2898 | );\r |
2899 | \r | |
ac644614 | 2900 | /**\r |
2901 | Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r | |
2902 | filled with zeros. The shifted value is returned.\r | |
2903 | \r | |
2904 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
2905 | high Count bits are set to zero. The shifted value is returned.\r | |
2906 | \r | |
2907 | If Count is greater than 63, then ASSERT().\r | |
2908 | \r | |
2909 | @param Operand The 64-bit operand to shift right.\r | |
2910 | @param Count The number of bits to shift right.\r | |
2911 | \r | |
2912 | @return Operand >> Count\r | |
2913 | \r | |
2914 | **/\r | |
2915 | UINT64\r | |
2916 | EFIAPI\r | |
2917 | RShiftU64 (\r | |
2f88bd3a MK |
2918 | IN UINT64 Operand,\r |
2919 | IN UINTN Count\r | |
ac644614 | 2920 | );\r |
2921 | \r | |
ac644614 | 2922 | /**\r |
2923 | Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r | |
2924 | with original integer's bit 63. The shifted value is returned.\r | |
2925 | \r | |
2926 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
2927 | high Count bits are set to bit 63 of Operand. The shifted value is returned.\r | |
2928 | \r | |
2929 | If Count is greater than 63, then ASSERT().\r | |
2930 | \r | |
2931 | @param Operand The 64-bit operand to shift right.\r | |
2932 | @param Count The number of bits to shift right.\r | |
2933 | \r | |
2934 | @return Operand >> Count\r | |
2935 | \r | |
2936 | **/\r | |
2937 | UINT64\r | |
2938 | EFIAPI\r | |
2939 | ARShiftU64 (\r | |
2f88bd3a MK |
2940 | IN UINT64 Operand,\r |
2941 | IN UINTN Count\r | |
ac644614 | 2942 | );\r |
2943 | \r | |
ac644614 | 2944 | /**\r |
2945 | Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r | |
2946 | with the high bits that were rotated.\r | |
2947 | \r | |
2948 | This function rotates the 32-bit value Operand to the left by Count bits. The\r | |
2949 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
2950 | value is returned.\r | |
2951 | \r | |
2952 | If Count is greater than 31, then ASSERT().\r | |
2953 | \r | |
2954 | @param Operand The 32-bit operand to rotate left.\r | |
2955 | @param Count The number of bits to rotate left.\r | |
2956 | \r | |
17f695ed | 2957 | @return Operand << Count\r |
ac644614 | 2958 | \r |
2959 | **/\r | |
2960 | UINT32\r | |
2961 | EFIAPI\r | |
2962 | LRotU32 (\r | |
2f88bd3a MK |
2963 | IN UINT32 Operand,\r |
2964 | IN UINTN Count\r | |
ac644614 | 2965 | );\r |
2966 | \r | |
ac644614 | 2967 | /**\r |
2968 | Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r | |
2969 | with the low bits that were rotated.\r | |
2970 | \r | |
2971 | This function rotates the 32-bit value Operand to the right by Count bits.\r | |
2972 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
2973 | value is returned.\r | |
2974 | \r | |
2975 | If Count is greater than 31, then ASSERT().\r | |
2976 | \r | |
2977 | @param Operand The 32-bit operand to rotate right.\r | |
2978 | @param Count The number of bits to rotate right.\r | |
2979 | \r | |
2fe241a2 | 2980 | @return Operand >> Count\r |
ac644614 | 2981 | \r |
2982 | **/\r | |
2983 | UINT32\r | |
2984 | EFIAPI\r | |
2985 | RRotU32 (\r | |
2f88bd3a MK |
2986 | IN UINT32 Operand,\r |
2987 | IN UINTN Count\r | |
ac644614 | 2988 | );\r |
2989 | \r | |
ac644614 | 2990 | /**\r |
2991 | Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r | |
2992 | with the high bits that were rotated.\r | |
2993 | \r | |
2994 | This function rotates the 64-bit value Operand to the left by Count bits. The\r | |
2995 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
2996 | value is returned.\r | |
2997 | \r | |
2998 | If Count is greater than 63, then ASSERT().\r | |
2999 | \r | |
3000 | @param Operand The 64-bit operand to rotate left.\r | |
3001 | @param Count The number of bits to rotate left.\r | |
3002 | \r | |
17f695ed | 3003 | @return Operand << Count\r |
ac644614 | 3004 | \r |
3005 | **/\r | |
3006 | UINT64\r | |
3007 | EFIAPI\r | |
3008 | LRotU64 (\r | |
2f88bd3a MK |
3009 | IN UINT64 Operand,\r |
3010 | IN UINTN Count\r | |
ac644614 | 3011 | );\r |
3012 | \r | |
ac644614 | 3013 | /**\r |
3014 | Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r | |
3015 | with the high low bits that were rotated.\r | |
3016 | \r | |
3017 | This function rotates the 64-bit value Operand to the right by Count bits.\r | |
3018 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
3019 | value is returned.\r | |
3020 | \r | |
3021 | If Count is greater than 63, then ASSERT().\r | |
3022 | \r | |
3023 | @param Operand The 64-bit operand to rotate right.\r | |
3024 | @param Count The number of bits to rotate right.\r | |
3025 | \r | |
17f695ed | 3026 | @return Operand >> Count\r |
ac644614 | 3027 | \r |
3028 | **/\r | |
3029 | UINT64\r | |
3030 | EFIAPI\r | |
3031 | RRotU64 (\r | |
2f88bd3a MK |
3032 | IN UINT64 Operand,\r |
3033 | IN UINTN Count\r | |
ac644614 | 3034 | );\r |
3035 | \r | |
ac644614 | 3036 | /**\r |
3037 | Returns the bit position of the lowest bit set in a 32-bit value.\r | |
3038 | \r | |
3039 | This function computes the bit position of the lowest bit set in the 32-bit\r | |
3040 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3041 | Otherwise, a value between 0 and 31 is returned.\r | |
3042 | \r | |
3043 | @param Operand The 32-bit operand to evaluate.\r | |
3044 | \r | |
9aa049d9 | 3045 | @retval 0..31 The lowest bit set in Operand was found.\r |
17f695ed | 3046 | @retval -1 Operand is zero.\r |
ac644614 | 3047 | \r |
3048 | **/\r | |
3049 | INTN\r | |
3050 | EFIAPI\r | |
3051 | LowBitSet32 (\r | |
2f88bd3a | 3052 | IN UINT32 Operand\r |
ac644614 | 3053 | );\r |
3054 | \r | |
ac644614 | 3055 | /**\r |
3056 | Returns the bit position of the lowest bit set in a 64-bit value.\r | |
3057 | \r | |
3058 | This function computes the bit position of the lowest bit set in the 64-bit\r | |
3059 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3060 | Otherwise, a value between 0 and 63 is returned.\r | |
3061 | \r | |
3062 | @param Operand The 64-bit operand to evaluate.\r | |
3063 | \r | |
9aa049d9 | 3064 | @retval 0..63 The lowest bit set in Operand was found.\r |
17f695ed | 3065 | @retval -1 Operand is zero.\r |
3066 | \r | |
ac644614 | 3067 | \r |
3068 | **/\r | |
3069 | INTN\r | |
3070 | EFIAPI\r | |
3071 | LowBitSet64 (\r | |
2f88bd3a | 3072 | IN UINT64 Operand\r |
ac644614 | 3073 | );\r |
3074 | \r | |
ac644614 | 3075 | /**\r |
3076 | Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r | |
3077 | to log2(x).\r | |
3078 | \r | |
3079 | This function computes the bit position of the highest bit set in the 32-bit\r | |
3080 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3081 | Otherwise, a value between 0 and 31 is returned.\r | |
3082 | \r | |
3083 | @param Operand The 32-bit operand to evaluate.\r | |
3084 | \r | |
9aa049d9 | 3085 | @retval 0..31 Position of the highest bit set in Operand if found.\r |
17f695ed | 3086 | @retval -1 Operand is zero.\r |
ac644614 | 3087 | \r |
3088 | **/\r | |
3089 | INTN\r | |
3090 | EFIAPI\r | |
3091 | HighBitSet32 (\r | |
2f88bd3a | 3092 | IN UINT32 Operand\r |
ac644614 | 3093 | );\r |
3094 | \r | |
ac644614 | 3095 | /**\r |
3096 | Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r | |
3097 | to log2(x).\r | |
3098 | \r | |
3099 | This function computes the bit position of the highest bit set in the 64-bit\r | |
3100 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3101 | Otherwise, a value between 0 and 63 is returned.\r | |
3102 | \r | |
3103 | @param Operand The 64-bit operand to evaluate.\r | |
3104 | \r | |
9aa049d9 | 3105 | @retval 0..63 Position of the highest bit set in Operand if found.\r |
17f695ed | 3106 | @retval -1 Operand is zero.\r |
ac644614 | 3107 | \r |
3108 | **/\r | |
3109 | INTN\r | |
3110 | EFIAPI\r | |
3111 | HighBitSet64 (\r | |
2f88bd3a | 3112 | IN UINT64 Operand\r |
ac644614 | 3113 | );\r |
3114 | \r | |
ac644614 | 3115 | /**\r |
3116 | Returns the value of the highest bit set in a 32-bit value. Equivalent to\r | |
17f695ed | 3117 | 1 << log2(x).\r |
ac644614 | 3118 | \r |
3119 | This function computes the value of the highest bit set in the 32-bit value\r | |
3120 | specified by Operand. If Operand is zero, then zero is returned.\r | |
3121 | \r | |
3122 | @param Operand The 32-bit operand to evaluate.\r | |
3123 | \r | |
3124 | @return 1 << HighBitSet32(Operand)\r | |
3125 | @retval 0 Operand is zero.\r | |
3126 | \r | |
3127 | **/\r | |
3128 | UINT32\r | |
3129 | EFIAPI\r | |
3130 | GetPowerOfTwo32 (\r | |
2f88bd3a | 3131 | IN UINT32 Operand\r |
ac644614 | 3132 | );\r |
3133 | \r | |
ac644614 | 3134 | /**\r |
3135 | Returns the value of the highest bit set in a 64-bit value. Equivalent to\r | |
17f695ed | 3136 | 1 << log2(x).\r |
ac644614 | 3137 | \r |
3138 | This function computes the value of the highest bit set in the 64-bit value\r | |
3139 | specified by Operand. If Operand is zero, then zero is returned.\r | |
3140 | \r | |
3141 | @param Operand The 64-bit operand to evaluate.\r | |
3142 | \r | |
3143 | @return 1 << HighBitSet64(Operand)\r | |
3144 | @retval 0 Operand is zero.\r | |
3145 | \r | |
3146 | **/\r | |
3147 | UINT64\r | |
3148 | EFIAPI\r | |
3149 | GetPowerOfTwo64 (\r | |
2f88bd3a | 3150 | IN UINT64 Operand\r |
ac644614 | 3151 | );\r |
3152 | \r | |
ac644614 | 3153 | /**\r |
af2dc6a7 | 3154 | Switches the endianness of a 16-bit integer.\r |
ac644614 | 3155 | \r |
3156 | This function swaps the bytes in a 16-bit unsigned value to switch the value\r | |
3157 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3158 | returned.\r | |
3159 | \r | |
2a53dabf | 3160 | @param Value A 16-bit unsigned value.\r |
ac644614 | 3161 | \r |
efb23117 | 3162 | @return The byte swapped Value.\r |
ac644614 | 3163 | \r |
3164 | **/\r | |
3165 | UINT16\r | |
3166 | EFIAPI\r | |
3167 | SwapBytes16 (\r | |
2f88bd3a | 3168 | IN UINT16 Value\r |
ac644614 | 3169 | );\r |
3170 | \r | |
ac644614 | 3171 | /**\r |
af2dc6a7 | 3172 | Switches the endianness of a 32-bit integer.\r |
ac644614 | 3173 | \r |
3174 | This function swaps the bytes in a 32-bit unsigned value to switch the value\r | |
3175 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3176 | returned.\r | |
3177 | \r | |
2a53dabf | 3178 | @param Value A 32-bit unsigned value.\r |
ac644614 | 3179 | \r |
efb23117 | 3180 | @return The byte swapped Value.\r |
ac644614 | 3181 | \r |
3182 | **/\r | |
3183 | UINT32\r | |
3184 | EFIAPI\r | |
3185 | SwapBytes32 (\r | |
2f88bd3a | 3186 | IN UINT32 Value\r |
ac644614 | 3187 | );\r |
3188 | \r | |
ac644614 | 3189 | /**\r |
af2dc6a7 | 3190 | Switches the endianness of a 64-bit integer.\r |
ac644614 | 3191 | \r |
3192 | This function swaps the bytes in a 64-bit unsigned value to switch the value\r | |
3193 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3194 | returned.\r | |
3195 | \r | |
2a53dabf | 3196 | @param Value A 64-bit unsigned value.\r |
ac644614 | 3197 | \r |
efb23117 | 3198 | @return The byte swapped Value.\r |
ac644614 | 3199 | \r |
3200 | **/\r | |
3201 | UINT64\r | |
3202 | EFIAPI\r | |
3203 | SwapBytes64 (\r | |
2f88bd3a | 3204 | IN UINT64 Value\r |
ac644614 | 3205 | );\r |
3206 | \r | |
ac644614 | 3207 | /**\r |
3208 | Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r | |
3209 | generates a 64-bit unsigned result.\r | |
3210 | \r | |
3211 | This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r | |
3212 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
3213 | bit unsigned result is returned.\r | |
3214 | \r | |
ac644614 | 3215 | @param Multiplicand A 64-bit unsigned value.\r |
3216 | @param Multiplier A 32-bit unsigned value.\r | |
3217 | \r | |
3218 | @return Multiplicand * Multiplier\r | |
3219 | \r | |
3220 | **/\r | |
3221 | UINT64\r | |
3222 | EFIAPI\r | |
3223 | MultU64x32 (\r | |
2f88bd3a MK |
3224 | IN UINT64 Multiplicand,\r |
3225 | IN UINT32 Multiplier\r | |
ac644614 | 3226 | );\r |
3227 | \r | |
ac644614 | 3228 | /**\r |
3229 | Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r | |
3230 | generates a 64-bit unsigned result.\r | |
3231 | \r | |
3232 | This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r | |
3233 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
3234 | bit unsigned result is returned.\r | |
3235 | \r | |
ac644614 | 3236 | @param Multiplicand A 64-bit unsigned value.\r |
3237 | @param Multiplier A 64-bit unsigned value.\r | |
3238 | \r | |
af2dc6a7 | 3239 | @return Multiplicand * Multiplier.\r |
ac644614 | 3240 | \r |
3241 | **/\r | |
3242 | UINT64\r | |
3243 | EFIAPI\r | |
3244 | MultU64x64 (\r | |
2f88bd3a MK |
3245 | IN UINT64 Multiplicand,\r |
3246 | IN UINT64 Multiplier\r | |
ac644614 | 3247 | );\r |
3248 | \r | |
ac644614 | 3249 | /**\r |
3250 | Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
3251 | 64-bit signed result.\r | |
3252 | \r | |
3253 | This function multiples the 64-bit signed value Multiplicand by the 64-bit\r | |
3254 | signed value Multiplier and generates a 64-bit signed result. This 64-bit\r | |
3255 | signed result is returned.\r | |
3256 | \r | |
ac644614 | 3257 | @param Multiplicand A 64-bit signed value.\r |
3258 | @param Multiplier A 64-bit signed value.\r | |
3259 | \r | |
3260 | @return Multiplicand * Multiplier\r | |
3261 | \r | |
3262 | **/\r | |
3263 | INT64\r | |
3264 | EFIAPI\r | |
3265 | MultS64x64 (\r | |
2f88bd3a MK |
3266 | IN INT64 Multiplicand,\r |
3267 | IN INT64 Multiplier\r | |
ac644614 | 3268 | );\r |
3269 | \r | |
ac644614 | 3270 | /**\r |
3271 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3272 | a 64-bit unsigned result.\r | |
3273 | \r | |
3274 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3275 | unsigned value Divisor and generates a 64-bit unsigned quotient. This\r | |
3276 | function returns the 64-bit unsigned quotient.\r | |
3277 | \r | |
3278 | If Divisor is 0, then ASSERT().\r | |
3279 | \r | |
3280 | @param Dividend A 64-bit unsigned value.\r | |
3281 | @param Divisor A 32-bit unsigned value.\r | |
3282 | \r | |
af2dc6a7 | 3283 | @return Dividend / Divisor.\r |
ac644614 | 3284 | \r |
3285 | **/\r | |
3286 | UINT64\r | |
3287 | EFIAPI\r | |
3288 | DivU64x32 (\r | |
2f88bd3a MK |
3289 | IN UINT64 Dividend,\r |
3290 | IN UINT32 Divisor\r | |
ac644614 | 3291 | );\r |
3292 | \r | |
ac644614 | 3293 | /**\r |
3294 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3295 | a 32-bit unsigned remainder.\r | |
3296 | \r | |
3297 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3298 | unsigned value Divisor and generates a 32-bit remainder. This function\r | |
3299 | returns the 32-bit unsigned remainder.\r | |
3300 | \r | |
3301 | If Divisor is 0, then ASSERT().\r | |
3302 | \r | |
3303 | @param Dividend A 64-bit unsigned value.\r | |
3304 | @param Divisor A 32-bit unsigned value.\r | |
3305 | \r | |
af2dc6a7 | 3306 | @return Dividend % Divisor.\r |
ac644614 | 3307 | \r |
3308 | **/\r | |
3309 | UINT32\r | |
3310 | EFIAPI\r | |
3311 | ModU64x32 (\r | |
2f88bd3a MK |
3312 | IN UINT64 Dividend,\r |
3313 | IN UINT32 Divisor\r | |
ac644614 | 3314 | );\r |
3315 | \r | |
ac644614 | 3316 | /**\r |
3317 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3318 | a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r | |
3319 | \r | |
3320 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3321 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
3322 | is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r | |
3323 | This function returns the 64-bit unsigned quotient.\r | |
3324 | \r | |
3325 | If Divisor is 0, then ASSERT().\r | |
3326 | \r | |
3327 | @param Dividend A 64-bit unsigned value.\r | |
3328 | @param Divisor A 32-bit unsigned value.\r | |
3329 | @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r | |
3330 | optional and may be NULL.\r | |
3331 | \r | |
af2dc6a7 | 3332 | @return Dividend / Divisor.\r |
ac644614 | 3333 | \r |
3334 | **/\r | |
3335 | UINT64\r | |
3336 | EFIAPI\r | |
3337 | DivU64x32Remainder (\r | |
2f88bd3a MK |
3338 | IN UINT64 Dividend,\r |
3339 | IN UINT32 Divisor,\r | |
3340 | OUT UINT32 *Remainder OPTIONAL\r | |
ac644614 | 3341 | );\r |
3342 | \r | |
ac644614 | 3343 | /**\r |
3344 | Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r | |
3345 | a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r | |
3346 | \r | |
3347 | This function divides the 64-bit unsigned value Dividend by the 64-bit\r | |
3348 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
3349 | is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r | |
3350 | This function returns the 64-bit unsigned quotient.\r | |
3351 | \r | |
3352 | If Divisor is 0, then ASSERT().\r | |
3353 | \r | |
3354 | @param Dividend A 64-bit unsigned value.\r | |
3355 | @param Divisor A 64-bit unsigned value.\r | |
3356 | @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r | |
3357 | optional and may be NULL.\r | |
3358 | \r | |
af2dc6a7 | 3359 | @return Dividend / Divisor.\r |
ac644614 | 3360 | \r |
3361 | **/\r | |
3362 | UINT64\r | |
3363 | EFIAPI\r | |
3364 | DivU64x64Remainder (\r | |
2f88bd3a MK |
3365 | IN UINT64 Dividend,\r |
3366 | IN UINT64 Divisor,\r | |
3367 | OUT UINT64 *Remainder OPTIONAL\r | |
ac644614 | 3368 | );\r |
3369 | \r | |
ac644614 | 3370 | /**\r |
3371 | Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
3372 | 64-bit signed result and a optional 64-bit signed remainder.\r | |
3373 | \r | |
3374 | This function divides the 64-bit signed value Dividend by the 64-bit signed\r | |
3375 | value Divisor and generates a 64-bit signed quotient. If Remainder is not\r | |
3376 | NULL, then the 64-bit signed remainder is returned in Remainder. This\r | |
3377 | function returns the 64-bit signed quotient.\r | |
3378 | \r | |
9aa049d9 | 3379 | It is the caller's responsibility to not call this function with a Divisor of 0.\r |
9095d37b | 3380 | If Divisor is 0, then the quotient and remainder should be assumed to be\r |
17f695ed | 3381 | the largest negative integer.\r |
3382 | \r | |
ac644614 | 3383 | If Divisor is 0, then ASSERT().\r |
3384 | \r | |
3385 | @param Dividend A 64-bit signed value.\r | |
3386 | @param Divisor A 64-bit signed value.\r | |
3387 | @param Remainder A pointer to a 64-bit signed value. This parameter is\r | |
3388 | optional and may be NULL.\r | |
3389 | \r | |
af2dc6a7 | 3390 | @return Dividend / Divisor.\r |
ac644614 | 3391 | \r |
3392 | **/\r | |
3393 | INT64\r | |
3394 | EFIAPI\r | |
3395 | DivS64x64Remainder (\r | |
2f88bd3a MK |
3396 | IN INT64 Dividend,\r |
3397 | IN INT64 Divisor,\r | |
3398 | OUT INT64 *Remainder OPTIONAL\r | |
ac644614 | 3399 | );\r |
3400 | \r | |
ac644614 | 3401 | /**\r |
3402 | Reads a 16-bit value from memory that may be unaligned.\r | |
3403 | \r | |
3404 | This function returns the 16-bit value pointed to by Buffer. The function\r | |
3405 | guarantees that the read operation does not produce an alignment fault.\r | |
3406 | \r | |
3407 | If the Buffer is NULL, then ASSERT().\r | |
3408 | \r | |
af2dc6a7 | 3409 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 3410 | \r |
5385a579 | 3411 | @return The 16-bit value read from Buffer.\r |
ac644614 | 3412 | \r |
3413 | **/\r | |
3414 | UINT16\r | |
3415 | EFIAPI\r | |
3416 | ReadUnaligned16 (\r | |
2f88bd3a | 3417 | IN CONST UINT16 *Buffer\r |
ac644614 | 3418 | );\r |
3419 | \r | |
ac644614 | 3420 | /**\r |
3421 | Writes a 16-bit value to memory that may be unaligned.\r | |
3422 | \r | |
3423 | This function writes the 16-bit value specified by Value to Buffer. Value is\r | |
3424 | returned. The function guarantees that the write operation does not produce\r | |
3425 | an alignment fault.\r | |
3426 | \r | |
3427 | If the Buffer is NULL, then ASSERT().\r | |
3428 | \r | |
af2dc6a7 | 3429 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 3430 | @param Value 16-bit value to write to Buffer.\r |
3431 | \r | |
5385a579 | 3432 | @return The 16-bit value to write to Buffer.\r |
ac644614 | 3433 | \r |
3434 | **/\r | |
3435 | UINT16\r | |
3436 | EFIAPI\r | |
3437 | WriteUnaligned16 (\r | |
2f88bd3a MK |
3438 | OUT UINT16 *Buffer,\r |
3439 | IN UINT16 Value\r | |
ac644614 | 3440 | );\r |
3441 | \r | |
ac644614 | 3442 | /**\r |
3443 | Reads a 24-bit value from memory that may be unaligned.\r | |
3444 | \r | |
3445 | This function returns the 24-bit value pointed to by Buffer. The function\r | |
3446 | guarantees that the read operation does not produce an alignment fault.\r | |
3447 | \r | |
3448 | If the Buffer is NULL, then ASSERT().\r | |
3449 | \r | |
af2dc6a7 | 3450 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 3451 | \r |
5385a579 | 3452 | @return The 24-bit value read from Buffer.\r |
ac644614 | 3453 | \r |
3454 | **/\r | |
3455 | UINT32\r | |
3456 | EFIAPI\r | |
3457 | ReadUnaligned24 (\r | |
2f88bd3a | 3458 | IN CONST UINT32 *Buffer\r |
ac644614 | 3459 | );\r |
3460 | \r | |
ac644614 | 3461 | /**\r |
3462 | Writes a 24-bit value to memory that may be unaligned.\r | |
3463 | \r | |
3464 | This function writes the 24-bit value specified by Value to Buffer. Value is\r | |
3465 | returned. The function guarantees that the write operation does not produce\r | |
3466 | an alignment fault.\r | |
3467 | \r | |
3468 | If the Buffer is NULL, then ASSERT().\r | |
3469 | \r | |
af2dc6a7 | 3470 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 3471 | @param Value 24-bit value to write to Buffer.\r |
3472 | \r | |
5385a579 | 3473 | @return The 24-bit value to write to Buffer.\r |
ac644614 | 3474 | \r |
3475 | **/\r | |
3476 | UINT32\r | |
3477 | EFIAPI\r | |
3478 | WriteUnaligned24 (\r | |
2f88bd3a MK |
3479 | OUT UINT32 *Buffer,\r |
3480 | IN UINT32 Value\r | |
ac644614 | 3481 | );\r |
3482 | \r | |
ac644614 | 3483 | /**\r |
3484 | Reads a 32-bit value from memory that may be unaligned.\r | |
3485 | \r | |
3486 | This function returns the 32-bit value pointed to by Buffer. The function\r | |
3487 | guarantees that the read operation does not produce an alignment fault.\r | |
3488 | \r | |
3489 | If the Buffer is NULL, then ASSERT().\r | |
3490 | \r | |
af2dc6a7 | 3491 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 3492 | \r |
5385a579 | 3493 | @return The 32-bit value read from Buffer.\r |
ac644614 | 3494 | \r |
3495 | **/\r | |
3496 | UINT32\r | |
3497 | EFIAPI\r | |
3498 | ReadUnaligned32 (\r | |
2f88bd3a | 3499 | IN CONST UINT32 *Buffer\r |
ac644614 | 3500 | );\r |
3501 | \r | |
ac644614 | 3502 | /**\r |
3503 | Writes a 32-bit value to memory that may be unaligned.\r | |
3504 | \r | |
3505 | This function writes the 32-bit value specified by Value to Buffer. Value is\r | |
3506 | returned. The function guarantees that the write operation does not produce\r | |
3507 | an alignment fault.\r | |
3508 | \r | |
3509 | If the Buffer is NULL, then ASSERT().\r | |
3510 | \r | |
af2dc6a7 | 3511 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 3512 | @param Value 32-bit value to write to Buffer.\r |
3513 | \r | |
5385a579 | 3514 | @return The 32-bit value to write to Buffer.\r |
ac644614 | 3515 | \r |
3516 | **/\r | |
3517 | UINT32\r | |
3518 | EFIAPI\r | |
3519 | WriteUnaligned32 (\r | |
2f88bd3a MK |
3520 | OUT UINT32 *Buffer,\r |
3521 | IN UINT32 Value\r | |
ac644614 | 3522 | );\r |
3523 | \r | |
ac644614 | 3524 | /**\r |
3525 | Reads a 64-bit value from memory that may be unaligned.\r | |
3526 | \r | |
3527 | This function returns the 64-bit value pointed to by Buffer. The function\r | |
3528 | guarantees that the read operation does not produce an alignment fault.\r | |
3529 | \r | |
3530 | If the Buffer is NULL, then ASSERT().\r | |
3531 | \r | |
af2dc6a7 | 3532 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 3533 | \r |
5385a579 | 3534 | @return The 64-bit value read from Buffer.\r |
ac644614 | 3535 | \r |
3536 | **/\r | |
3537 | UINT64\r | |
3538 | EFIAPI\r | |
3539 | ReadUnaligned64 (\r | |
2f88bd3a | 3540 | IN CONST UINT64 *Buffer\r |
ac644614 | 3541 | );\r |
3542 | \r | |
ac644614 | 3543 | /**\r |
3544 | Writes a 64-bit value to memory that may be unaligned.\r | |
3545 | \r | |
3546 | This function writes the 64-bit value specified by Value to Buffer. Value is\r | |
3547 | returned. The function guarantees that the write operation does not produce\r | |
3548 | an alignment fault.\r | |
3549 | \r | |
3550 | If the Buffer is NULL, then ASSERT().\r | |
3551 | \r | |
af2dc6a7 | 3552 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 3553 | @param Value 64-bit value to write to Buffer.\r |
3554 | \r | |
5385a579 | 3555 | @return The 64-bit value to write to Buffer.\r |
ac644614 | 3556 | \r |
3557 | **/\r | |
3558 | UINT64\r | |
3559 | EFIAPI\r | |
3560 | WriteUnaligned64 (\r | |
2f88bd3a MK |
3561 | OUT UINT64 *Buffer,\r |
3562 | IN UINT64 Value\r | |
ac644614 | 3563 | );\r |
3564 | \r | |
ac644614 | 3565 | //\r |
3566 | // Bit Field Functions\r | |
3567 | //\r | |
3568 | \r | |
3569 | /**\r | |
3570 | Returns a bit field from an 8-bit value.\r | |
3571 | \r | |
3572 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
3573 | \r | |
3574 | If 8-bit operations are not supported, then ASSERT().\r | |
3575 | If StartBit is greater than 7, then ASSERT().\r | |
3576 | If EndBit is greater than 7, then ASSERT().\r | |
3577 | If EndBit is less than StartBit, then ASSERT().\r | |
3578 | \r | |
3579 | @param Operand Operand on which to perform the bitfield operation.\r | |
3580 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3581 | Range 0..7.\r | |
3582 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3583 | Range 0..7.\r | |
3584 | \r | |
3585 | @return The bit field read.\r | |
3586 | \r | |
3587 | **/\r | |
3588 | UINT8\r | |
3589 | EFIAPI\r | |
3590 | BitFieldRead8 (\r | |
2f88bd3a MK |
3591 | IN UINT8 Operand,\r |
3592 | IN UINTN StartBit,\r | |
3593 | IN UINTN EndBit\r | |
ac644614 | 3594 | );\r |
3595 | \r | |
ac644614 | 3596 | /**\r |
3597 | Writes a bit field to an 8-bit value, and returns the result.\r | |
3598 | \r | |
3599 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
3600 | Operand. All other bits in Operand are preserved. The new 8-bit value is\r | |
3601 | returned.\r | |
3602 | \r | |
3603 | If 8-bit operations are not supported, then ASSERT().\r | |
3604 | If StartBit is greater than 7, then ASSERT().\r | |
3605 | If EndBit is greater than 7, then ASSERT().\r | |
3606 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3607 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3608 | \r |
3609 | @param Operand Operand on which to perform the bitfield operation.\r | |
3610 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3611 | Range 0..7.\r | |
3612 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3613 | Range 0..7.\r | |
3614 | @param Value New value of the bit field.\r | |
3615 | \r | |
3616 | @return The new 8-bit value.\r | |
3617 | \r | |
3618 | **/\r | |
3619 | UINT8\r | |
3620 | EFIAPI\r | |
3621 | BitFieldWrite8 (\r | |
2f88bd3a MK |
3622 | IN UINT8 Operand,\r |
3623 | IN UINTN StartBit,\r | |
3624 | IN UINTN EndBit,\r | |
3625 | IN UINT8 Value\r | |
ac644614 | 3626 | );\r |
3627 | \r | |
ac644614 | 3628 | /**\r |
3629 | Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r | |
3630 | result.\r | |
3631 | \r | |
62991af2 | 3632 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 3633 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
3634 | Operand are preserved. The new 8-bit value is returned.\r | |
3635 | \r | |
3636 | If 8-bit operations are not supported, then ASSERT().\r | |
3637 | If StartBit is greater than 7, then ASSERT().\r | |
3638 | If EndBit is greater than 7, then ASSERT().\r | |
3639 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3640 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3641 | \r |
3642 | @param Operand Operand on which to perform the bitfield operation.\r | |
3643 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3644 | Range 0..7.\r | |
3645 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3646 | Range 0..7.\r | |
3647 | @param OrData The value to OR with the read value from the value\r | |
3648 | \r | |
3649 | @return The new 8-bit value.\r | |
3650 | \r | |
3651 | **/\r | |
3652 | UINT8\r | |
3653 | EFIAPI\r | |
3654 | BitFieldOr8 (\r | |
2f88bd3a MK |
3655 | IN UINT8 Operand,\r |
3656 | IN UINTN StartBit,\r | |
3657 | IN UINTN EndBit,\r | |
3658 | IN UINT8 OrData\r | |
ac644614 | 3659 | );\r |
3660 | \r | |
ac644614 | 3661 | /**\r |
3662 | Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r | |
3663 | the result.\r | |
3664 | \r | |
3665 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
3666 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
3667 | preserved. The new 8-bit value is returned.\r | |
3668 | \r | |
3669 | If 8-bit operations are not supported, then ASSERT().\r | |
3670 | If StartBit is greater than 7, then ASSERT().\r | |
3671 | If EndBit is greater than 7, then ASSERT().\r | |
3672 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3673 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3674 | \r |
3675 | @param Operand Operand on which to perform the bitfield operation.\r | |
3676 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3677 | Range 0..7.\r | |
3678 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3679 | Range 0..7.\r | |
3680 | @param AndData The value to AND with the read value from the value.\r | |
3681 | \r | |
3682 | @return The new 8-bit value.\r | |
3683 | \r | |
3684 | **/\r | |
3685 | UINT8\r | |
3686 | EFIAPI\r | |
3687 | BitFieldAnd8 (\r | |
2f88bd3a MK |
3688 | IN UINT8 Operand,\r |
3689 | IN UINTN StartBit,\r | |
3690 | IN UINTN EndBit,\r | |
3691 | IN UINT8 AndData\r | |
ac644614 | 3692 | );\r |
3693 | \r | |
ac644614 | 3694 | /**\r |
3695 | Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r | |
3696 | bitwise OR, and returns the result.\r | |
3697 | \r | |
3698 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 3699 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 3700 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 3701 | preserved. The new 8-bit value is returned.\r |
3702 | \r | |
3703 | If 8-bit operations are not supported, then ASSERT().\r | |
3704 | If StartBit is greater than 7, then ASSERT().\r | |
3705 | If EndBit is greater than 7, then ASSERT().\r | |
3706 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
3707 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
3708 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 3709 | \r |
3710 | @param Operand Operand on which to perform the bitfield operation.\r | |
3711 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3712 | Range 0..7.\r | |
3713 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3714 | Range 0..7.\r | |
3715 | @param AndData The value to AND with the read value from the value.\r | |
3716 | @param OrData The value to OR with the result of the AND operation.\r | |
3717 | \r | |
3718 | @return The new 8-bit value.\r | |
3719 | \r | |
3720 | **/\r | |
3721 | UINT8\r | |
3722 | EFIAPI\r | |
3723 | BitFieldAndThenOr8 (\r | |
2f88bd3a MK |
3724 | IN UINT8 Operand,\r |
3725 | IN UINTN StartBit,\r | |
3726 | IN UINTN EndBit,\r | |
3727 | IN UINT8 AndData,\r | |
3728 | IN UINT8 OrData\r | |
ac644614 | 3729 | );\r |
3730 | \r | |
ac644614 | 3731 | /**\r |
3732 | Returns a bit field from a 16-bit value.\r | |
3733 | \r | |
3734 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
3735 | \r | |
3736 | If 16-bit operations are not supported, then ASSERT().\r | |
3737 | If StartBit is greater than 15, then ASSERT().\r | |
3738 | If EndBit is greater than 15, then ASSERT().\r | |
3739 | If EndBit is less than StartBit, then ASSERT().\r | |
3740 | \r | |
3741 | @param Operand Operand on which to perform the bitfield operation.\r | |
3742 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3743 | Range 0..15.\r | |
3744 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3745 | Range 0..15.\r | |
3746 | \r | |
3747 | @return The bit field read.\r | |
3748 | \r | |
3749 | **/\r | |
3750 | UINT16\r | |
3751 | EFIAPI\r | |
3752 | BitFieldRead16 (\r | |
2f88bd3a MK |
3753 | IN UINT16 Operand,\r |
3754 | IN UINTN StartBit,\r | |
3755 | IN UINTN EndBit\r | |
ac644614 | 3756 | );\r |
3757 | \r | |
ac644614 | 3758 | /**\r |
3759 | Writes a bit field to a 16-bit value, and returns the result.\r | |
3760 | \r | |
3761 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
3762 | Operand. All other bits in Operand are preserved. The new 16-bit value is\r | |
3763 | returned.\r | |
3764 | \r | |
3765 | If 16-bit operations are not supported, then ASSERT().\r | |
3766 | If StartBit is greater than 15, then ASSERT().\r | |
3767 | If EndBit is greater than 15, then ASSERT().\r | |
3768 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3769 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3770 | \r |
3771 | @param Operand Operand on which to perform the bitfield operation.\r | |
3772 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3773 | Range 0..15.\r | |
3774 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3775 | Range 0..15.\r | |
3776 | @param Value New value of the bit field.\r | |
3777 | \r | |
3778 | @return The new 16-bit value.\r | |
3779 | \r | |
3780 | **/\r | |
3781 | UINT16\r | |
3782 | EFIAPI\r | |
3783 | BitFieldWrite16 (\r | |
2f88bd3a MK |
3784 | IN UINT16 Operand,\r |
3785 | IN UINTN StartBit,\r | |
3786 | IN UINTN EndBit,\r | |
3787 | IN UINT16 Value\r | |
ac644614 | 3788 | );\r |
3789 | \r | |
ac644614 | 3790 | /**\r |
3791 | Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r | |
3792 | result.\r | |
3793 | \r | |
62991af2 | 3794 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 3795 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
3796 | Operand are preserved. The new 16-bit value is returned.\r | |
3797 | \r | |
3798 | If 16-bit operations are not supported, then ASSERT().\r | |
3799 | If StartBit is greater than 15, then ASSERT().\r | |
3800 | If EndBit is greater than 15, then ASSERT().\r | |
3801 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3802 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3803 | \r |
3804 | @param Operand Operand on which to perform the bitfield operation.\r | |
3805 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3806 | Range 0..15.\r | |
3807 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3808 | Range 0..15.\r | |
3809 | @param OrData The value to OR with the read value from the value\r | |
3810 | \r | |
3811 | @return The new 16-bit value.\r | |
3812 | \r | |
3813 | **/\r | |
3814 | UINT16\r | |
3815 | EFIAPI\r | |
3816 | BitFieldOr16 (\r | |
2f88bd3a MK |
3817 | IN UINT16 Operand,\r |
3818 | IN UINTN StartBit,\r | |
3819 | IN UINTN EndBit,\r | |
3820 | IN UINT16 OrData\r | |
ac644614 | 3821 | );\r |
3822 | \r | |
ac644614 | 3823 | /**\r |
3824 | Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r | |
3825 | the result.\r | |
3826 | \r | |
3827 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
3828 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
3829 | preserved. The new 16-bit value is returned.\r | |
3830 | \r | |
3831 | If 16-bit operations are not supported, then ASSERT().\r | |
3832 | If StartBit is greater than 15, then ASSERT().\r | |
3833 | If EndBit is greater than 15, then ASSERT().\r | |
3834 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3835 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3836 | \r |
3837 | @param Operand Operand on which to perform the bitfield operation.\r | |
3838 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3839 | Range 0..15.\r | |
3840 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3841 | Range 0..15.\r | |
3842 | @param AndData The value to AND with the read value from the value\r | |
3843 | \r | |
3844 | @return The new 16-bit value.\r | |
3845 | \r | |
3846 | **/\r | |
3847 | UINT16\r | |
3848 | EFIAPI\r | |
3849 | BitFieldAnd16 (\r | |
2f88bd3a MK |
3850 | IN UINT16 Operand,\r |
3851 | IN UINTN StartBit,\r | |
3852 | IN UINTN EndBit,\r | |
3853 | IN UINT16 AndData\r | |
ac644614 | 3854 | );\r |
3855 | \r | |
ac644614 | 3856 | /**\r |
3857 | Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r | |
3858 | bitwise OR, and returns the result.\r | |
3859 | \r | |
3860 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 3861 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 3862 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 3863 | preserved. The new 16-bit value is returned.\r |
3864 | \r | |
3865 | If 16-bit operations are not supported, then ASSERT().\r | |
3866 | If StartBit is greater than 15, then ASSERT().\r | |
3867 | If EndBit is greater than 15, then ASSERT().\r | |
3868 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
3869 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
3870 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 3871 | \r |
3872 | @param Operand Operand on which to perform the bitfield operation.\r | |
3873 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3874 | Range 0..15.\r | |
3875 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3876 | Range 0..15.\r | |
3877 | @param AndData The value to AND with the read value from the value.\r | |
3878 | @param OrData The value to OR with the result of the AND operation.\r | |
3879 | \r | |
3880 | @return The new 16-bit value.\r | |
3881 | \r | |
3882 | **/\r | |
3883 | UINT16\r | |
3884 | EFIAPI\r | |
3885 | BitFieldAndThenOr16 (\r | |
2f88bd3a MK |
3886 | IN UINT16 Operand,\r |
3887 | IN UINTN StartBit,\r | |
3888 | IN UINTN EndBit,\r | |
3889 | IN UINT16 AndData,\r | |
3890 | IN UINT16 OrData\r | |
ac644614 | 3891 | );\r |
3892 | \r | |
ac644614 | 3893 | /**\r |
3894 | Returns a bit field from a 32-bit value.\r | |
3895 | \r | |
3896 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
3897 | \r | |
3898 | If 32-bit operations are not supported, then ASSERT().\r | |
3899 | If StartBit is greater than 31, then ASSERT().\r | |
3900 | If EndBit is greater than 31, then ASSERT().\r | |
3901 | If EndBit is less than StartBit, then ASSERT().\r | |
3902 | \r | |
3903 | @param Operand Operand on which to perform the bitfield operation.\r | |
3904 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3905 | Range 0..31.\r | |
3906 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3907 | Range 0..31.\r | |
3908 | \r | |
3909 | @return The bit field read.\r | |
3910 | \r | |
3911 | **/\r | |
3912 | UINT32\r | |
3913 | EFIAPI\r | |
3914 | BitFieldRead32 (\r | |
2f88bd3a MK |
3915 | IN UINT32 Operand,\r |
3916 | IN UINTN StartBit,\r | |
3917 | IN UINTN EndBit\r | |
ac644614 | 3918 | );\r |
3919 | \r | |
ac644614 | 3920 | /**\r |
3921 | Writes a bit field to a 32-bit value, and returns the result.\r | |
3922 | \r | |
3923 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
3924 | Operand. All other bits in Operand are preserved. The new 32-bit value is\r | |
3925 | returned.\r | |
3926 | \r | |
3927 | If 32-bit operations are not supported, then ASSERT().\r | |
3928 | If StartBit is greater than 31, then ASSERT().\r | |
3929 | If EndBit is greater than 31, then ASSERT().\r | |
3930 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3931 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3932 | \r |
3933 | @param Operand Operand on which to perform the bitfield operation.\r | |
3934 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3935 | Range 0..31.\r | |
3936 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3937 | Range 0..31.\r | |
3938 | @param Value New value of the bit field.\r | |
3939 | \r | |
3940 | @return The new 32-bit value.\r | |
3941 | \r | |
3942 | **/\r | |
3943 | UINT32\r | |
3944 | EFIAPI\r | |
3945 | BitFieldWrite32 (\r | |
2f88bd3a MK |
3946 | IN UINT32 Operand,\r |
3947 | IN UINTN StartBit,\r | |
3948 | IN UINTN EndBit,\r | |
3949 | IN UINT32 Value\r | |
ac644614 | 3950 | );\r |
3951 | \r | |
ac644614 | 3952 | /**\r |
3953 | Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r | |
3954 | result.\r | |
3955 | \r | |
62991af2 | 3956 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 3957 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
3958 | Operand are preserved. The new 32-bit value is returned.\r | |
3959 | \r | |
3960 | If 32-bit operations are not supported, then ASSERT().\r | |
3961 | If StartBit is greater than 31, then ASSERT().\r | |
3962 | If EndBit is greater than 31, then ASSERT().\r | |
3963 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3964 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3965 | \r |
3966 | @param Operand Operand on which to perform the bitfield operation.\r | |
3967 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3968 | Range 0..31.\r | |
3969 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3970 | Range 0..31.\r | |
af2dc6a7 | 3971 | @param OrData The value to OR with the read value from the value.\r |
ac644614 | 3972 | \r |
3973 | @return The new 32-bit value.\r | |
3974 | \r | |
3975 | **/\r | |
3976 | UINT32\r | |
3977 | EFIAPI\r | |
3978 | BitFieldOr32 (\r | |
2f88bd3a MK |
3979 | IN UINT32 Operand,\r |
3980 | IN UINTN StartBit,\r | |
3981 | IN UINTN EndBit,\r | |
3982 | IN UINT32 OrData\r | |
ac644614 | 3983 | );\r |
3984 | \r | |
ac644614 | 3985 | /**\r |
3986 | Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r | |
3987 | the result.\r | |
3988 | \r | |
3989 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
3990 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
3991 | preserved. The new 32-bit value is returned.\r | |
3992 | \r | |
3993 | If 32-bit operations are not supported, then ASSERT().\r | |
3994 | If StartBit is greater than 31, then ASSERT().\r | |
3995 | If EndBit is greater than 31, then ASSERT().\r | |
3996 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3997 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3998 | \r |
3999 | @param Operand Operand on which to perform the bitfield operation.\r | |
4000 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4001 | Range 0..31.\r | |
4002 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4003 | Range 0..31.\r | |
4004 | @param AndData The value to AND with the read value from the value\r | |
4005 | \r | |
4006 | @return The new 32-bit value.\r | |
4007 | \r | |
4008 | **/\r | |
4009 | UINT32\r | |
4010 | EFIAPI\r | |
4011 | BitFieldAnd32 (\r | |
2f88bd3a MK |
4012 | IN UINT32 Operand,\r |
4013 | IN UINTN StartBit,\r | |
4014 | IN UINTN EndBit,\r | |
4015 | IN UINT32 AndData\r | |
ac644614 | 4016 | );\r |
4017 | \r | |
ac644614 | 4018 | /**\r |
4019 | Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r | |
4020 | bitwise OR, and returns the result.\r | |
4021 | \r | |
4022 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4023 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4024 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4025 | preserved. The new 32-bit value is returned.\r |
4026 | \r | |
4027 | If 32-bit operations are not supported, then ASSERT().\r | |
4028 | If StartBit is greater than 31, then ASSERT().\r | |
4029 | If EndBit is greater than 31, then ASSERT().\r | |
4030 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4031 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4032 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4033 | \r |
4034 | @param Operand Operand on which to perform the bitfield operation.\r | |
4035 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4036 | Range 0..31.\r | |
4037 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4038 | Range 0..31.\r | |
4039 | @param AndData The value to AND with the read value from the value.\r | |
4040 | @param OrData The value to OR with the result of the AND operation.\r | |
4041 | \r | |
4042 | @return The new 32-bit value.\r | |
4043 | \r | |
4044 | **/\r | |
4045 | UINT32\r | |
4046 | EFIAPI\r | |
4047 | BitFieldAndThenOr32 (\r | |
2f88bd3a MK |
4048 | IN UINT32 Operand,\r |
4049 | IN UINTN StartBit,\r | |
4050 | IN UINTN EndBit,\r | |
4051 | IN UINT32 AndData,\r | |
4052 | IN UINT32 OrData\r | |
ac644614 | 4053 | );\r |
4054 | \r | |
ac644614 | 4055 | /**\r |
4056 | Returns a bit field from a 64-bit value.\r | |
4057 | \r | |
4058 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4059 | \r | |
4060 | If 64-bit operations are not supported, then ASSERT().\r | |
4061 | If StartBit is greater than 63, then ASSERT().\r | |
4062 | If EndBit is greater than 63, then ASSERT().\r | |
4063 | If EndBit is less than StartBit, then ASSERT().\r | |
4064 | \r | |
4065 | @param Operand Operand on which to perform the bitfield operation.\r | |
4066 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4067 | Range 0..63.\r | |
4068 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4069 | Range 0..63.\r | |
4070 | \r | |
4071 | @return The bit field read.\r | |
4072 | \r | |
4073 | **/\r | |
4074 | UINT64\r | |
4075 | EFIAPI\r | |
4076 | BitFieldRead64 (\r | |
2f88bd3a MK |
4077 | IN UINT64 Operand,\r |
4078 | IN UINTN StartBit,\r | |
4079 | IN UINTN EndBit\r | |
ac644614 | 4080 | );\r |
4081 | \r | |
ac644614 | 4082 | /**\r |
4083 | Writes a bit field to a 64-bit value, and returns the result.\r | |
4084 | \r | |
4085 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4086 | Operand. All other bits in Operand are preserved. The new 64-bit value is\r | |
4087 | returned.\r | |
4088 | \r | |
4089 | If 64-bit operations are not supported, then ASSERT().\r | |
4090 | If StartBit is greater than 63, then ASSERT().\r | |
4091 | If EndBit is greater than 63, then ASSERT().\r | |
4092 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4093 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4094 | \r |
4095 | @param Operand Operand on which to perform the bitfield operation.\r | |
4096 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4097 | Range 0..63.\r | |
4098 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4099 | Range 0..63.\r | |
4100 | @param Value New value of the bit field.\r | |
4101 | \r | |
4102 | @return The new 64-bit value.\r | |
4103 | \r | |
4104 | **/\r | |
4105 | UINT64\r | |
4106 | EFIAPI\r | |
4107 | BitFieldWrite64 (\r | |
2f88bd3a MK |
4108 | IN UINT64 Operand,\r |
4109 | IN UINTN StartBit,\r | |
4110 | IN UINTN EndBit,\r | |
4111 | IN UINT64 Value\r | |
ac644614 | 4112 | );\r |
4113 | \r | |
ac644614 | 4114 | /**\r |
4115 | Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r | |
4116 | result.\r | |
4117 | \r | |
62991af2 | 4118 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4119 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4120 | Operand are preserved. The new 64-bit value is returned.\r | |
4121 | \r | |
4122 | If 64-bit operations are not supported, then ASSERT().\r | |
4123 | If StartBit is greater than 63, then ASSERT().\r | |
4124 | If EndBit is greater than 63, then ASSERT().\r | |
4125 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4126 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4127 | \r |
4128 | @param Operand Operand on which to perform the bitfield operation.\r | |
4129 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4130 | Range 0..63.\r | |
4131 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4132 | Range 0..63.\r | |
4133 | @param OrData The value to OR with the read value from the value\r | |
4134 | \r | |
4135 | @return The new 64-bit value.\r | |
4136 | \r | |
4137 | **/\r | |
4138 | UINT64\r | |
4139 | EFIAPI\r | |
4140 | BitFieldOr64 (\r | |
2f88bd3a MK |
4141 | IN UINT64 Operand,\r |
4142 | IN UINTN StartBit,\r | |
4143 | IN UINTN EndBit,\r | |
4144 | IN UINT64 OrData\r | |
ac644614 | 4145 | );\r |
4146 | \r | |
ac644614 | 4147 | /**\r |
4148 | Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r | |
4149 | the result.\r | |
4150 | \r | |
4151 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4152 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4153 | preserved. The new 64-bit value is returned.\r | |
4154 | \r | |
4155 | If 64-bit operations are not supported, then ASSERT().\r | |
4156 | If StartBit is greater than 63, then ASSERT().\r | |
4157 | If EndBit is greater than 63, then ASSERT().\r | |
4158 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4159 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4160 | \r |
4161 | @param Operand Operand on which to perform the bitfield operation.\r | |
4162 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4163 | Range 0..63.\r | |
4164 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4165 | Range 0..63.\r | |
4166 | @param AndData The value to AND with the read value from the value\r | |
4167 | \r | |
4168 | @return The new 64-bit value.\r | |
4169 | \r | |
4170 | **/\r | |
4171 | UINT64\r | |
4172 | EFIAPI\r | |
4173 | BitFieldAnd64 (\r | |
2f88bd3a MK |
4174 | IN UINT64 Operand,\r |
4175 | IN UINTN StartBit,\r | |
4176 | IN UINTN EndBit,\r | |
4177 | IN UINT64 AndData\r | |
ac644614 | 4178 | );\r |
4179 | \r | |
ac644614 | 4180 | /**\r |
4181 | Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r | |
4182 | bitwise OR, and returns the result.\r | |
4183 | \r | |
4184 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4185 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4186 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4187 | preserved. The new 64-bit value is returned.\r |
4188 | \r | |
4189 | If 64-bit operations are not supported, then ASSERT().\r | |
4190 | If StartBit is greater than 63, then ASSERT().\r | |
4191 | If EndBit is greater than 63, then ASSERT().\r | |
4192 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4193 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4194 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4195 | \r |
4196 | @param Operand Operand on which to perform the bitfield operation.\r | |
4197 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4198 | Range 0..63.\r | |
4199 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4200 | Range 0..63.\r | |
4201 | @param AndData The value to AND with the read value from the value.\r | |
4202 | @param OrData The value to OR with the result of the AND operation.\r | |
4203 | \r | |
4204 | @return The new 64-bit value.\r | |
4205 | \r | |
4206 | **/\r | |
4207 | UINT64\r | |
4208 | EFIAPI\r | |
4209 | BitFieldAndThenOr64 (\r | |
2f88bd3a MK |
4210 | IN UINT64 Operand,\r |
4211 | IN UINTN StartBit,\r | |
4212 | IN UINTN EndBit,\r | |
4213 | IN UINT64 AndData,\r | |
4214 | IN UINT64 OrData\r | |
ac644614 | 4215 | );\r |
4216 | \r | |
d7634dc0 TP |
4217 | /**\r |
4218 | Reads a bit field from a 32-bit value, counts and returns\r | |
4219 | the number of set bits.\r | |
4220 | \r | |
4221 | Counts the number of set bits in the bit field specified by\r | |
4222 | StartBit and EndBit in Operand. The count is returned.\r | |
4223 | \r | |
4224 | If StartBit is greater than 31, then ASSERT().\r | |
4225 | If EndBit is greater than 31, then ASSERT().\r | |
4226 | If EndBit is less than StartBit, then ASSERT().\r | |
4227 | \r | |
4228 | @param Operand Operand on which to perform the bitfield operation.\r | |
4229 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4230 | Range 0..31.\r | |
4231 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4232 | Range 0..31.\r | |
4233 | \r | |
4234 | @return The number of bits set between StartBit and EndBit.\r | |
4235 | \r | |
4236 | **/\r | |
4237 | UINT8\r | |
4238 | EFIAPI\r | |
4239 | BitFieldCountOnes32 (\r | |
2f88bd3a MK |
4240 | IN UINT32 Operand,\r |
4241 | IN UINTN StartBit,\r | |
4242 | IN UINTN EndBit\r | |
d7634dc0 TP |
4243 | );\r |
4244 | \r | |
4245 | /**\r | |
4246 | Reads a bit field from a 64-bit value, counts and returns\r | |
4247 | the number of set bits.\r | |
4248 | \r | |
4249 | Counts the number of set bits in the bit field specified by\r | |
4250 | StartBit and EndBit in Operand. The count is returned.\r | |
4251 | \r | |
4252 | If StartBit is greater than 63, then ASSERT().\r | |
4253 | If EndBit is greater than 63, then ASSERT().\r | |
4254 | If EndBit is less than StartBit, then ASSERT().\r | |
4255 | \r | |
4256 | @param Operand Operand on which to perform the bitfield operation.\r | |
4257 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4258 | Range 0..63.\r | |
4259 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4260 | Range 0..63.\r | |
4261 | \r | |
4262 | @return The number of bits set between StartBit and EndBit.\r | |
4263 | \r | |
4264 | **/\r | |
4265 | UINT8\r | |
4266 | EFIAPI\r | |
4267 | BitFieldCountOnes64 (\r | |
2f88bd3a MK |
4268 | IN UINT64 Operand,\r |
4269 | IN UINTN StartBit,\r | |
4270 | IN UINTN EndBit\r | |
d7634dc0 TP |
4271 | );\r |
4272 | \r | |
ac644614 | 4273 | //\r |
4274 | // Base Library Checksum Functions\r | |
4275 | //\r | |
4276 | \r | |
4277 | /**\r | |
17f695ed | 4278 | Returns the sum of all elements in a buffer in unit of UINT8.\r |
ac644614 | 4279 | During calculation, the carry bits are dropped.\r |
4280 | \r | |
4281 | This function calculates the sum of all elements in a buffer\r | |
4282 | in unit of UINT8. The carry bits in result of addition are dropped.\r | |
4283 | The result is returned as UINT8. If Length is Zero, then Zero is\r | |
4284 | returned.\r | |
4285 | \r | |
4286 | If Buffer is NULL, then ASSERT().\r | |
4287 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4288 | \r | |
af2dc6a7 | 4289 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
17f695ed | 4290 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4291 | \r |
4292 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4293 | \r | |
4294 | **/\r | |
4295 | UINT8\r | |
4296 | EFIAPI\r | |
4297 | CalculateSum8 (\r | |
2f88bd3a MK |
4298 | IN CONST UINT8 *Buffer,\r |
4299 | IN UINTN Length\r | |
ac644614 | 4300 | );\r |
4301 | \r | |
ac644614 | 4302 | /**\r |
4303 | Returns the two's complement checksum of all elements in a buffer\r | |
4304 | of 8-bit values.\r | |
4305 | \r | |
4306 | This function first calculates the sum of the 8-bit values in the\r | |
4307 | buffer specified by Buffer and Length. The carry bits in the result\r | |
4308 | of addition are dropped. Then, the two's complement of the sum is\r | |
4309 | returned. If Length is 0, then 0 is returned.\r | |
4310 | \r | |
4311 | If Buffer is NULL, then ASSERT().\r | |
4312 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4313 | \r | |
af2dc6a7 | 4314 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4315 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4316 | \r |
af2dc6a7 | 4317 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4318 | \r |
4319 | **/\r | |
4320 | UINT8\r | |
4321 | EFIAPI\r | |
4322 | CalculateCheckSum8 (\r | |
2f88bd3a MK |
4323 | IN CONST UINT8 *Buffer,\r |
4324 | IN UINTN Length\r | |
ac644614 | 4325 | );\r |
4326 | \r | |
ac644614 | 4327 | /**\r |
4328 | Returns the sum of all elements in a buffer of 16-bit values. During\r | |
4329 | calculation, the carry bits are dropped.\r | |
4330 | \r | |
4331 | This function calculates the sum of the 16-bit values in the buffer\r | |
4332 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
4333 | The 16-bit result is returned. If Length is 0, then 0 is returned.\r | |
4334 | \r | |
4335 | If Buffer is NULL, then ASSERT().\r | |
4336 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
4337 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
4338 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4339 | \r | |
af2dc6a7 | 4340 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4341 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4342 | \r |
4343 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4344 | \r | |
4345 | **/\r | |
4346 | UINT16\r | |
4347 | EFIAPI\r | |
4348 | CalculateSum16 (\r | |
2f88bd3a MK |
4349 | IN CONST UINT16 *Buffer,\r |
4350 | IN UINTN Length\r | |
ac644614 | 4351 | );\r |
4352 | \r | |
ac644614 | 4353 | /**\r |
4354 | Returns the two's complement checksum of all elements in a buffer of\r | |
4355 | 16-bit values.\r | |
4356 | \r | |
4357 | This function first calculates the sum of the 16-bit values in the buffer\r | |
4358 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4359 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4360 | is 0, then 0 is returned.\r | |
4361 | \r | |
4362 | If Buffer is NULL, then ASSERT().\r | |
4363 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
4364 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
4365 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4366 | \r | |
af2dc6a7 | 4367 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4368 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4369 | \r |
af2dc6a7 | 4370 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4371 | \r |
4372 | **/\r | |
4373 | UINT16\r | |
4374 | EFIAPI\r | |
4375 | CalculateCheckSum16 (\r | |
2f88bd3a MK |
4376 | IN CONST UINT16 *Buffer,\r |
4377 | IN UINTN Length\r | |
ac644614 | 4378 | );\r |
4379 | \r | |
ac644614 | 4380 | /**\r |
17f695ed | 4381 | Returns the sum of all elements in a buffer of 32-bit values. During\r |
ac644614 | 4382 | calculation, the carry bits are dropped.\r |
4383 | \r | |
4384 | This function calculates the sum of the 32-bit values in the buffer\r | |
4385 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
17f695ed | 4386 | The 32-bit result is returned. If Length is 0, then 0 is returned.\r |
ac644614 | 4387 | \r |
4388 | If Buffer is NULL, then ASSERT().\r | |
4389 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
4390 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
4391 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4392 | \r | |
af2dc6a7 | 4393 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4394 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4395 | \r |
4396 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4397 | \r | |
4398 | **/\r | |
4399 | UINT32\r | |
4400 | EFIAPI\r | |
4401 | CalculateSum32 (\r | |
2f88bd3a MK |
4402 | IN CONST UINT32 *Buffer,\r |
4403 | IN UINTN Length\r | |
ac644614 | 4404 | );\r |
4405 | \r | |
ac644614 | 4406 | /**\r |
4407 | Returns the two's complement checksum of all elements in a buffer of\r | |
4408 | 32-bit values.\r | |
4409 | \r | |
4410 | This function first calculates the sum of the 32-bit values in the buffer\r | |
4411 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4412 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4413 | is 0, then 0 is returned.\r | |
4414 | \r | |
4415 | If Buffer is NULL, then ASSERT().\r | |
4416 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
4417 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
4418 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4419 | \r | |
af2dc6a7 | 4420 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4421 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4422 | \r |
af2dc6a7 | 4423 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4424 | \r |
4425 | **/\r | |
4426 | UINT32\r | |
4427 | EFIAPI\r | |
4428 | CalculateCheckSum32 (\r | |
2f88bd3a MK |
4429 | IN CONST UINT32 *Buffer,\r |
4430 | IN UINTN Length\r | |
ac644614 | 4431 | );\r |
4432 | \r | |
ac644614 | 4433 | /**\r |
4434 | Returns the sum of all elements in a buffer of 64-bit values. During\r | |
4435 | calculation, the carry bits are dropped.\r | |
4436 | \r | |
4437 | This function calculates the sum of the 64-bit values in the buffer\r | |
4438 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
4439 | The 64-bit result is returned. If Length is 0, then 0 is returned.\r | |
4440 | \r | |
4441 | If Buffer is NULL, then ASSERT().\r | |
4442 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
4443 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
4444 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4445 | \r | |
af2dc6a7 | 4446 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4447 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4448 | \r |
4449 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4450 | \r | |
4451 | **/\r | |
4452 | UINT64\r | |
4453 | EFIAPI\r | |
4454 | CalculateSum64 (\r | |
2f88bd3a MK |
4455 | IN CONST UINT64 *Buffer,\r |
4456 | IN UINTN Length\r | |
ac644614 | 4457 | );\r |
4458 | \r | |
ac644614 | 4459 | /**\r |
4460 | Returns the two's complement checksum of all elements in a buffer of\r | |
4461 | 64-bit values.\r | |
4462 | \r | |
4463 | This function first calculates the sum of the 64-bit values in the buffer\r | |
4464 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4465 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4466 | is 0, then 0 is returned.\r | |
4467 | \r | |
4468 | If Buffer is NULL, then ASSERT().\r | |
4469 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
4470 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
4471 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4472 | \r | |
af2dc6a7 | 4473 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4474 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4475 | \r |
af2dc6a7 | 4476 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4477 | \r |
4478 | **/\r | |
4479 | UINT64\r | |
4480 | EFIAPI\r | |
4481 | CalculateCheckSum64 (\r | |
2f88bd3a MK |
4482 | IN CONST UINT64 *Buffer,\r |
4483 | IN UINTN Length\r | |
ac644614 | 4484 | );\r |
4485 | \r | |
0a8e6f79 LG |
4486 | /**\r |
4487 | Computes and returns a 32-bit CRC for a data buffer.\r | |
4488 | CRC32 value bases on ITU-T V.42.\r | |
4489 | \r | |
4490 | If Buffer is NULL, then ASSERT().\r | |
4491 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4492 | \r | |
4493 | @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed.\r | |
4494 | @param[in] Length The number of bytes in the buffer Data.\r | |
4495 | \r | |
4496 | @retval Crc32 The 32-bit CRC was computed for the data buffer.\r | |
4497 | \r | |
4498 | **/\r | |
4499 | UINT32\r | |
4500 | EFIAPI\r | |
2f88bd3a MK |
4501 | CalculateCrc32 (\r |
4502 | IN VOID *Buffer,\r | |
4503 | IN UINTN Length\r | |
0a8e6f79 | 4504 | );\r |
ac644614 | 4505 | \r |
d75f9fc2 | 4506 | //\r |
4507 | // Base Library CPU Functions\r | |
4508 | //\r | |
4509 | \r | |
4510 | /**\r | |
4511 | Function entry point used when a stack switch is requested with SwitchStack()\r | |
4512 | \r | |
4513 | @param Context1 Context1 parameter passed into SwitchStack().\r | |
4514 | @param Context2 Context2 parameter passed into SwitchStack().\r | |
4515 | \r | |
4516 | **/\r | |
ac644614 | 4517 | typedef\r |
4518 | VOID\r | |
9810cdd8 | 4519 | (EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r |
d0e2f823 | 4520 | IN VOID *Context1 OPTIONAL,\r |
ac644614 | 4521 | IN VOID *Context2 OPTIONAL\r |
4522 | );\r | |
4523 | \r | |
ac644614 | 4524 | /**\r |
4525 | Used to serialize load and store operations.\r | |
4526 | \r | |
4527 | All loads and stores that proceed calls to this function are guaranteed to be\r | |
4528 | globally visible when this function returns.\r | |
4529 | \r | |
4530 | **/\r | |
4531 | VOID\r | |
4532 | EFIAPI\r | |
4533 | MemoryFence (\r | |
4534 | VOID\r | |
4535 | );\r | |
4536 | \r | |
ac644614 | 4537 | /**\r |
4538 | Saves the current CPU context that can be restored with a call to LongJump()\r | |
4539 | and returns 0.\r | |
4540 | \r | |
4541 | Saves the current CPU context in the buffer specified by JumpBuffer and\r | |
4542 | returns 0. The initial call to SetJump() must always return 0. Subsequent\r | |
4543 | calls to LongJump() cause a non-zero value to be returned by SetJump().\r | |
4544 | \r | |
4545 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 4546 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
9095d37b | 4547 | \r |
17f695ed | 4548 | NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.\r |
4549 | The same structure must never be used for more than one CPU architecture context.\r | |
9095d37b LG |
4550 | For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.\r |
4551 | SetJump()/LongJump() is not currently supported for the EBC processor type.\r | |
ac644614 | 4552 | \r |
4553 | @param JumpBuffer A pointer to CPU context buffer.\r | |
4554 | \r | |
4555 | @retval 0 Indicates a return from SetJump().\r | |
4556 | \r | |
4557 | **/\r | |
2117989c | 4558 | RETURNS_TWICE\r |
ac644614 | 4559 | UINTN\r |
4560 | EFIAPI\r | |
4561 | SetJump (\r | |
4562 | OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r | |
4563 | );\r | |
4564 | \r | |
ac644614 | 4565 | /**\r |
4566 | Restores the CPU context that was saved with SetJump().\r | |
4567 | \r | |
4568 | Restores the CPU context from the buffer specified by JumpBuffer. This\r | |
4569 | function never returns to the caller. Instead is resumes execution based on\r | |
4570 | the state of JumpBuffer.\r | |
4571 | \r | |
4572 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 4573 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
ac644614 | 4574 | If Value is 0, then ASSERT().\r |
4575 | \r | |
4576 | @param JumpBuffer A pointer to CPU context buffer.\r | |
4577 | @param Value The value to return when the SetJump() context is\r | |
4578 | restored and must be non-zero.\r | |
4579 | \r | |
4580 | **/\r | |
4581 | VOID\r | |
4582 | EFIAPI\r | |
4583 | LongJump (\r | |
4584 | IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r | |
4585 | IN UINTN Value\r | |
4586 | );\r | |
4587 | \r | |
ac644614 | 4588 | /**\r |
4589 | Enables CPU interrupts.\r | |
4590 | \r | |
ac644614 | 4591 | **/\r |
4592 | VOID\r | |
4593 | EFIAPI\r | |
4594 | EnableInterrupts (\r | |
4595 | VOID\r | |
4596 | );\r | |
4597 | \r | |
ac644614 | 4598 | /**\r |
4599 | Disables CPU interrupts.\r | |
4600 | \r | |
ac644614 | 4601 | **/\r |
4602 | VOID\r | |
4603 | EFIAPI\r | |
4604 | DisableInterrupts (\r | |
4605 | VOID\r | |
4606 | );\r | |
4607 | \r | |
ac644614 | 4608 | /**\r |
4609 | Disables CPU interrupts and returns the interrupt state prior to the disable\r | |
4610 | operation.\r | |
4611 | \r | |
ac644614 | 4612 | @retval TRUE CPU interrupts were enabled on entry to this call.\r |
4613 | @retval FALSE CPU interrupts were disabled on entry to this call.\r | |
4614 | \r | |
4615 | **/\r | |
4616 | BOOLEAN\r | |
4617 | EFIAPI\r | |
4618 | SaveAndDisableInterrupts (\r | |
4619 | VOID\r | |
4620 | );\r | |
4621 | \r | |
ac644614 | 4622 | /**\r |
4623 | Enables CPU interrupts for the smallest window required to capture any\r | |
4624 | pending interrupts.\r | |
4625 | \r | |
ac644614 | 4626 | **/\r |
4627 | VOID\r | |
4628 | EFIAPI\r | |
4629 | EnableDisableInterrupts (\r | |
4630 | VOID\r | |
4631 | );\r | |
4632 | \r | |
ac644614 | 4633 | /**\r |
4634 | Retrieves the current CPU interrupt state.\r | |
4635 | \r | |
af2dc6a7 | 4636 | Returns TRUE if interrupts are currently enabled. Otherwise\r |
38bbd3d9 | 4637 | returns FALSE.\r |
ac644614 | 4638 | \r |
4639 | @retval TRUE CPU interrupts are enabled.\r | |
4640 | @retval FALSE CPU interrupts are disabled.\r | |
4641 | \r | |
4642 | **/\r | |
4643 | BOOLEAN\r | |
4644 | EFIAPI\r | |
4645 | GetInterruptState (\r | |
4646 | VOID\r | |
4647 | );\r | |
4648 | \r | |
ac644614 | 4649 | /**\r |
4650 | Set the current CPU interrupt state.\r | |
4651 | \r | |
4652 | Sets the current CPU interrupt state to the state specified by\r | |
4653 | InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r | |
4654 | InterruptState is FALSE, then interrupts are disabled. InterruptState is\r | |
4655 | returned.\r | |
4656 | \r | |
4657 | @param InterruptState TRUE if interrupts should enabled. FALSE if\r | |
4658 | interrupts should be disabled.\r | |
4659 | \r | |
4660 | @return InterruptState\r | |
4661 | \r | |
4662 | **/\r | |
4663 | BOOLEAN\r | |
4664 | EFIAPI\r | |
4665 | SetInterruptState (\r | |
2f88bd3a | 4666 | IN BOOLEAN InterruptState\r |
ac644614 | 4667 | );\r |
4668 | \r | |
ac644614 | 4669 | /**\r |
4670 | Requests CPU to pause for a short period of time.\r | |
4671 | \r | |
4672 | Requests CPU to pause for a short period of time. Typically used in MP\r | |
4673 | systems to prevent memory starvation while waiting for a spin lock.\r | |
4674 | \r | |
4675 | **/\r | |
4676 | VOID\r | |
4677 | EFIAPI\r | |
4678 | CpuPause (\r | |
4679 | VOID\r | |
4680 | );\r | |
4681 | \r | |
ac644614 | 4682 | /**\r |
4683 | Transfers control to a function starting with a new stack.\r | |
4684 | \r | |
4685 | Transfers control to the function specified by EntryPoint using the\r | |
4686 | new stack specified by NewStack and passing in the parameters specified\r | |
4687 | by Context1 and Context2. Context1 and Context2 are optional and may\r | |
4688 | be NULL. The function EntryPoint must never return. This function\r | |
4689 | supports a variable number of arguments following the NewStack parameter.\r | |
1a2f870c | 4690 | These additional arguments are ignored on IA-32, x64, and EBC architectures.\r |
4691 | Itanium processors expect one additional parameter of type VOID * that specifies\r | |
ac644614 | 4692 | the new backing store pointer.\r |
4693 | \r | |
4694 | If EntryPoint is NULL, then ASSERT().\r | |
4695 | If NewStack is NULL, then ASSERT().\r | |
4696 | \r | |
4697 | @param EntryPoint A pointer to function to call with the new stack.\r | |
4698 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
4699 | function.\r | |
4700 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
4701 | function.\r | |
4702 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
4703 | function.\r | |
9095d37b LG |
4704 | @param ... This variable argument list is ignored for IA-32, x64, and\r |
4705 | EBC architectures. For Itanium processors, this variable\r | |
4706 | argument list is expected to contain a single parameter of\r | |
af2dc6a7 | 4707 | type VOID * that specifies the new backing store pointer.\r |
42eedea9 | 4708 | \r |
ac644614 | 4709 | \r |
4710 | **/\r | |
4711 | VOID\r | |
4712 | EFIAPI\r | |
4713 | SwitchStack (\r | |
4714 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
d0e2f823 MK |
4715 | IN VOID *Context1 OPTIONAL,\r |
4716 | IN VOID *Context2 OPTIONAL,\r | |
ac644614 | 4717 | IN VOID *NewStack,\r |
4718 | ...\r | |
4719 | );\r | |
4720 | \r | |
ac644614 | 4721 | /**\r |
4722 | Generates a breakpoint on the CPU.\r | |
4723 | \r | |
4724 | Generates a breakpoint on the CPU. The breakpoint must be implemented such\r | |
4725 | that code can resume normal execution after the breakpoint.\r | |
4726 | \r | |
4727 | **/\r | |
4728 | VOID\r | |
4729 | EFIAPI\r | |
4730 | CpuBreakpoint (\r | |
4731 | VOID\r | |
4732 | );\r | |
4733 | \r | |
ac644614 | 4734 | /**\r |
4735 | Executes an infinite loop.\r | |
4736 | \r | |
4737 | Forces the CPU to execute an infinite loop. A debugger may be used to skip\r | |
4738 | past the loop and the code that follows the loop must execute properly. This\r | |
4739 | implies that the infinite loop must not cause the code that follow it to be\r | |
4740 | optimized away.\r | |
4741 | \r | |
4742 | **/\r | |
4743 | VOID\r | |
4744 | EFIAPI\r | |
4745 | CpuDeadLoop (\r | |
4746 | VOID\r | |
4747 | );\r | |
9095d37b | 4748 | \r |
d9f1cac5 HW |
4749 | /**\r |
4750 | Uses as a barrier to stop speculative execution.\r | |
4751 | \r | |
4752 | Ensures that no later instruction will execute speculatively, until all prior\r | |
4753 | instructions have completed.\r | |
4754 | \r | |
4755 | **/\r | |
4756 | VOID\r | |
4757 | EFIAPI\r | |
4758 | SpeculationBarrier (\r | |
4759 | VOID\r | |
4760 | );\r | |
4761 | \r | |
5a7cbd54 BS |
4762 | #if defined (MDE_CPU_X64)\r |
4763 | //\r | |
4764 | // The page size for the PVALIDATE instruction\r | |
4765 | //\r | |
4766 | typedef enum {\r | |
4767 | PvalidatePageSize4K = 0,\r | |
4768 | PvalidatePageSize2MB,\r | |
4769 | } PVALIDATE_PAGE_SIZE;\r | |
4770 | \r | |
4771 | //\r | |
4772 | // PVALIDATE Return Code.\r | |
4773 | //\r | |
2f88bd3a MK |
4774 | #define PVALIDATE_RET_SUCCESS 0\r |
4775 | #define PVALIDATE_RET_FAIL_INPUT 1\r | |
4776 | #define PVALIDATE_RET_SIZE_MISMATCH 6\r | |
5a7cbd54 BS |
4777 | \r |
4778 | //\r | |
4779 | // The PVALIDATE instruction did not make any changes to the RMP entry.\r | |
4780 | //\r | |
2f88bd3a | 4781 | #define PVALIDATE_RET_NO_RMPUPDATE 255\r |
5a7cbd54 BS |
4782 | \r |
4783 | /**\r | |
4784 | Execute a PVALIDATE instruction to validate or to rescinds validation of a guest\r | |
4785 | page's RMP entry.\r | |
4786 | \r | |
4787 | The instruction is available only when CPUID Fn8000_001F_EAX[SNP]=1.\r | |
4788 | \r | |
4789 | The function is available on X64.\r | |
4790 | \r | |
4791 | @param[in] PageSize The page size to use.\r | |
4792 | @param[in] Validate If TRUE, validate the guest virtual address\r | |
4793 | otherwise invalidate the guest virtual address.\r | |
4794 | @param[in] Address The guest virtual address.\r | |
4795 | \r | |
4796 | @retval PVALIDATE_RET_SUCCESS The PVALIDATE instruction succeeded, and\r | |
4797 | updated the RMP entry.\r | |
4798 | @retval PVALIDATE_RET_NO_RMPUPDATE The PVALIDATE instruction succeeded, but\r | |
4799 | did not update the RMP entry.\r | |
4800 | @return Failure code from the PVALIDATE\r | |
4801 | instruction.\r | |
4802 | **/\r | |
4803 | UINT32\r | |
4804 | EFIAPI\r | |
4805 | AsmPvalidate (\r | |
2f88bd3a MK |
4806 | IN PVALIDATE_PAGE_SIZE PageSize,\r |
4807 | IN BOOLEAN Validate,\r | |
4808 | IN PHYSICAL_ADDRESS Address\r | |
5a7cbd54 | 4809 | );\r |
2b5b2ff0 TL |
4810 | \r |
4811 | //\r | |
4812 | // RDX settings for RMPADJUST\r | |
4813 | //\r | |
4814 | #define RMPADJUST_VMPL_MAX 3\r | |
4815 | #define RMPADJUST_VMPL_MASK 0xFF\r | |
4816 | #define RMPADJUST_VMPL_SHIFT 0\r | |
4817 | #define RMPADJUST_PERMISSION_MASK_MASK 0xFF\r | |
4818 | #define RMPADJUST_PERMISSION_MASK_SHIFT 8\r | |
4819 | #define RMPADJUST_VMSA_PAGE_BIT BIT16\r | |
4820 | \r | |
4821 | /**\r | |
4822 | Adjusts the permissions of an SEV-SNP guest page.\r | |
4823 | \r | |
4824 | Executes a RMPADJUST instruction with the register state specified by Rax,\r | |
4825 | Rcx, and Rdx. Returns Eax. This function is only available on X64.\r | |
4826 | \r | |
4827 | The instruction is available only when CPUID Fn8000_001F_EAX[SNP]=1.\r | |
4828 | \r | |
4829 | @param[in] Rax The value to load into RAX before executing the RMPADJUST\r | |
4830 | instruction.\r | |
4831 | @param[in] Rcx The value to load into RCX before executing the RMPADJUST\r | |
4832 | instruction.\r | |
4833 | @param[in] Rdx The value to load into RDX before executing the RMPADJUST\r | |
4834 | instruction.\r | |
4835 | \r | |
4836 | @return Eax\r | |
4837 | **/\r | |
4838 | UINT32\r | |
4839 | EFIAPI\r | |
4840 | AsmRmpAdjust (\r | |
2f88bd3a MK |
4841 | IN UINT64 Rax,\r |
4842 | IN UINT64 Rcx,\r | |
4843 | IN UINT64 Rdx\r | |
2b5b2ff0 | 4844 | );\r |
5a7cbd54 | 4845 | \r |
2f88bd3a | 4846 | #endif\r |
d9f1cac5 | 4847 | \r |
fd163050 | 4848 | #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
1106ffe1 | 4849 | ///\r |
af2dc6a7 | 4850 | /// IA32 and x64 Specific Functions.\r |
4851 | /// Byte packed structure for 16-bit Real Mode EFLAGS.\r | |
1106ffe1 | 4852 | ///\r |
ac644614 | 4853 | typedef union {\r |
4854 | struct {\r | |
2f88bd3a MK |
4855 | UINT32 CF : 1; ///< Carry Flag.\r |
4856 | UINT32 Reserved_0 : 1; ///< Reserved.\r | |
4857 | UINT32 PF : 1; ///< Parity Flag.\r | |
4858 | UINT32 Reserved_1 : 1; ///< Reserved.\r | |
4859 | UINT32 AF : 1; ///< Auxiliary Carry Flag.\r | |
4860 | UINT32 Reserved_2 : 1; ///< Reserved.\r | |
4861 | UINT32 ZF : 1; ///< Zero Flag.\r | |
4862 | UINT32 SF : 1; ///< Sign Flag.\r | |
4863 | UINT32 TF : 1; ///< Trap Flag.\r | |
4864 | UINT32 IF : 1; ///< Interrupt Enable Flag.\r | |
4865 | UINT32 DF : 1; ///< Direction Flag.\r | |
4866 | UINT32 OF : 1; ///< Overflow Flag.\r | |
4867 | UINT32 IOPL : 2; ///< I/O Privilege Level.\r | |
4868 | UINT32 NT : 1; ///< Nested Task.\r | |
4869 | UINT32 Reserved_3 : 1; ///< Reserved.\r | |
ac644614 | 4870 | } Bits;\r |
4871 | UINT16 Uint16;\r | |
4872 | } IA32_FLAGS16;\r | |
4873 | \r | |
1106ffe1 | 4874 | ///\r |
af2dc6a7 | 4875 | /// Byte packed structure for EFLAGS/RFLAGS.\r |
4876 | /// 32-bits on IA-32.\r | |
4877 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 4878 | ///\r |
ac644614 | 4879 | typedef union {\r |
4880 | struct {\r | |
2f88bd3a MK |
4881 | UINT32 CF : 1; ///< Carry Flag.\r |
4882 | UINT32 Reserved_0 : 1; ///< Reserved.\r | |
4883 | UINT32 PF : 1; ///< Parity Flag.\r | |
4884 | UINT32 Reserved_1 : 1; ///< Reserved.\r | |
4885 | UINT32 AF : 1; ///< Auxiliary Carry Flag.\r | |
4886 | UINT32 Reserved_2 : 1; ///< Reserved.\r | |
4887 | UINT32 ZF : 1; ///< Zero Flag.\r | |
4888 | UINT32 SF : 1; ///< Sign Flag.\r | |
4889 | UINT32 TF : 1; ///< Trap Flag.\r | |
4890 | UINT32 IF : 1; ///< Interrupt Enable Flag.\r | |
4891 | UINT32 DF : 1; ///< Direction Flag.\r | |
4892 | UINT32 OF : 1; ///< Overflow Flag.\r | |
4893 | UINT32 IOPL : 2; ///< I/O Privilege Level.\r | |
4894 | UINT32 NT : 1; ///< Nested Task.\r | |
4895 | UINT32 Reserved_3 : 1; ///< Reserved.\r | |
4896 | UINT32 RF : 1; ///< Resume Flag.\r | |
4897 | UINT32 VM : 1; ///< Virtual 8086 Mode.\r | |
4898 | UINT32 AC : 1; ///< Alignment Check.\r | |
4899 | UINT32 VIF : 1; ///< Virtual Interrupt Flag.\r | |
4900 | UINT32 VIP : 1; ///< Virtual Interrupt Pending.\r | |
4901 | UINT32 ID : 1; ///< ID Flag.\r | |
4902 | UINT32 Reserved_4 : 10; ///< Reserved.\r | |
ac644614 | 4903 | } Bits;\r |
2f88bd3a | 4904 | UINTN UintN;\r |
ac644614 | 4905 | } IA32_EFLAGS32;\r |
4906 | \r | |
1106ffe1 | 4907 | ///\r |
af2dc6a7 | 4908 | /// Byte packed structure for Control Register 0 (CR0).\r |
4909 | /// 32-bits on IA-32.\r | |
4910 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 4911 | ///\r |
ac644614 | 4912 | typedef union {\r |
4913 | struct {\r | |
2f88bd3a MK |
4914 | UINT32 PE : 1; ///< Protection Enable.\r |
4915 | UINT32 MP : 1; ///< Monitor Coprocessor.\r | |
4916 | UINT32 EM : 1; ///< Emulation.\r | |
4917 | UINT32 TS : 1; ///< Task Switched.\r | |
4918 | UINT32 ET : 1; ///< Extension Type.\r | |
4919 | UINT32 NE : 1; ///< Numeric Error.\r | |
4920 | UINT32 Reserved_0 : 10; ///< Reserved.\r | |
4921 | UINT32 WP : 1; ///< Write Protect.\r | |
4922 | UINT32 Reserved_1 : 1; ///< Reserved.\r | |
4923 | UINT32 AM : 1; ///< Alignment Mask.\r | |
4924 | UINT32 Reserved_2 : 10; ///< Reserved.\r | |
4925 | UINT32 NW : 1; ///< Mot Write-through.\r | |
4926 | UINT32 CD : 1; ///< Cache Disable.\r | |
4927 | UINT32 PG : 1; ///< Paging.\r | |
ac644614 | 4928 | } Bits;\r |
2f88bd3a | 4929 | UINTN UintN;\r |
ac644614 | 4930 | } IA32_CR0;\r |
4931 | \r | |
1106ffe1 | 4932 | ///\r |
af2dc6a7 | 4933 | /// Byte packed structure for Control Register 4 (CR4).\r |
4934 | /// 32-bits on IA-32.\r | |
4935 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 4936 | ///\r |
ac644614 | 4937 | typedef union {\r |
4938 | struct {\r | |
2f88bd3a MK |
4939 | UINT32 VME : 1; ///< Virtual-8086 Mode Extensions.\r |
4940 | UINT32 PVI : 1; ///< Protected-Mode Virtual Interrupts.\r | |
4941 | UINT32 TSD : 1; ///< Time Stamp Disable.\r | |
4942 | UINT32 DE : 1; ///< Debugging Extensions.\r | |
4943 | UINT32 PSE : 1; ///< Page Size Extensions.\r | |
4944 | UINT32 PAE : 1; ///< Physical Address Extension.\r | |
4945 | UINT32 MCE : 1; ///< Machine Check Enable.\r | |
4946 | UINT32 PGE : 1; ///< Page Global Enable.\r | |
4947 | UINT32 PCE : 1; ///< Performance Monitoring Counter\r | |
4948 | ///< Enable.\r | |
4949 | UINT32 OSFXSR : 1; ///< Operating System Support for\r | |
4950 | ///< FXSAVE and FXRSTOR instructions\r | |
4951 | UINT32 OSXMMEXCPT : 1; ///< Operating System Support for\r | |
4952 | ///< Unmasked SIMD Floating Point\r | |
4953 | ///< Exceptions.\r | |
4954 | UINT32 UMIP : 1; ///< User-Mode Instruction Prevention.\r | |
4955 | UINT32 LA57 : 1; ///< Linear Address 57bit.\r | |
4956 | UINT32 VMXE : 1; ///< VMX Enable.\r | |
4957 | UINT32 SMXE : 1; ///< SMX Enable.\r | |
4958 | UINT32 Reserved_3 : 1; ///< Reserved.\r | |
4959 | UINT32 FSGSBASE : 1; ///< FSGSBASE Enable.\r | |
4960 | UINT32 PCIDE : 1; ///< PCID Enable.\r | |
4961 | UINT32 OSXSAVE : 1; ///< XSAVE and Processor Extended States Enable.\r | |
4962 | UINT32 Reserved_4 : 1; ///< Reserved.\r | |
4963 | UINT32 SMEP : 1; ///< SMEP Enable.\r | |
4964 | UINT32 SMAP : 1; ///< SMAP Enable.\r | |
4965 | UINT32 PKE : 1; ///< Protection-Key Enable.\r | |
4966 | UINT32 Reserved_5 : 9; ///< Reserved.\r | |
ac644614 | 4967 | } Bits;\r |
2f88bd3a | 4968 | UINTN UintN;\r |
ac644614 | 4969 | } IA32_CR4;\r |
4970 | \r | |
6088db38 | 4971 | ///\r |
4972 | /// Byte packed structure for a segment descriptor in a GDT/LDT.\r | |
4973 | ///\r | |
4974 | typedef union {\r | |
4975 | struct {\r | |
2f88bd3a MK |
4976 | UINT32 LimitLow : 16;\r |
4977 | UINT32 BaseLow : 16;\r | |
4978 | UINT32 BaseMid : 8;\r | |
4979 | UINT32 Type : 4;\r | |
4980 | UINT32 S : 1;\r | |
4981 | UINT32 DPL : 2;\r | |
4982 | UINT32 P : 1;\r | |
4983 | UINT32 LimitHigh : 4;\r | |
4984 | UINT32 AVL : 1;\r | |
4985 | UINT32 L : 1;\r | |
4986 | UINT32 DB : 1;\r | |
4987 | UINT32 G : 1;\r | |
4988 | UINT32 BaseHigh : 8;\r | |
6088db38 | 4989 | } Bits;\r |
2f88bd3a | 4990 | UINT64 Uint64;\r |
6088db38 | 4991 | } IA32_SEGMENT_DESCRIPTOR;\r |
4992 | \r | |
1106ffe1 | 4993 | ///\r |
af2dc6a7 | 4994 | /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.\r |
1106ffe1 | 4995 | ///\r |
2f88bd3a | 4996 | #pragma pack (1)\r |
ac644614 | 4997 | typedef struct {\r |
2f88bd3a MK |
4998 | UINT16 Limit;\r |
4999 | UINTN Base;\r | |
ac644614 | 5000 | } IA32_DESCRIPTOR;\r |
2f88bd3a | 5001 | #pragma pack ()\r |
ac644614 | 5002 | \r |
5003 | #define IA32_IDT_GATE_TYPE_TASK 0x85\r | |
5004 | #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r | |
5005 | #define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r | |
5006 | #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r | |
5007 | #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r | |
5008 | \r | |
2f88bd3a MK |
5009 | #define IA32_GDT_TYPE_TSS 0x9\r |
5010 | #define IA32_GDT_ALIGNMENT 8\r | |
6f4aad3b | 5011 | \r |
2f88bd3a | 5012 | #if defined (MDE_CPU_IA32)\r |
1106ffe1 | 5013 | ///\r |
af2dc6a7 | 5014 | /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.\r |
1106ffe1 | 5015 | ///\r |
dc317713 | 5016 | typedef union {\r |
5017 | struct {\r | |
2f88bd3a MK |
5018 | UINT32 OffsetLow : 16; ///< Offset bits 15..0.\r |
5019 | UINT32 Selector : 16; ///< Selector.\r | |
5020 | UINT32 Reserved_0 : 8; ///< Reserved.\r | |
5021 | UINT32 GateType : 8; ///< Gate Type. See #defines above.\r | |
5022 | UINT32 OffsetHigh : 16; ///< Offset bits 31..16.\r | |
dc317713 | 5023 | } Bits;\r |
2f88bd3a | 5024 | UINT64 Uint64;\r |
dc317713 | 5025 | } IA32_IDT_GATE_DESCRIPTOR;\r |
5026 | \r | |
2f88bd3a | 5027 | #pragma pack (1)\r |
364a5474 JW |
5028 | //\r |
5029 | // IA32 Task-State Segment Definition\r | |
5030 | //\r | |
5031 | typedef struct {\r | |
5032 | UINT16 PreviousTaskLink;\r | |
5033 | UINT16 Reserved_2;\r | |
3ab032fc JW |
5034 | UINT32 ESP0;\r |
5035 | UINT16 SS0;\r | |
364a5474 | 5036 | UINT16 Reserved_10;\r |
3ab032fc JW |
5037 | UINT32 ESP1;\r |
5038 | UINT16 SS1;\r | |
364a5474 | 5039 | UINT16 Reserved_18;\r |
3ab032fc JW |
5040 | UINT32 ESP2;\r |
5041 | UINT16 SS2;\r | |
364a5474 | 5042 | UINT16 Reserved_26;\r |
3ab032fc JW |
5043 | UINT32 CR3;\r |
5044 | UINT32 EIP;\r | |
5045 | UINT32 EFLAGS;\r | |
5046 | UINT32 EAX;\r | |
5047 | UINT32 ECX;\r | |
5048 | UINT32 EDX;\r | |
5049 | UINT32 EBX;\r | |
5050 | UINT32 ESP;\r | |
5051 | UINT32 EBP;\r | |
5052 | UINT32 ESI;\r | |
5053 | UINT32 EDI;\r | |
5054 | UINT16 ES;\r | |
364a5474 | 5055 | UINT16 Reserved_74;\r |
3ab032fc | 5056 | UINT16 CS;\r |
364a5474 | 5057 | UINT16 Reserved_78;\r |
3ab032fc | 5058 | UINT16 SS;\r |
364a5474 | 5059 | UINT16 Reserved_82;\r |
3ab032fc | 5060 | UINT16 DS;\r |
364a5474 | 5061 | UINT16 Reserved_86;\r |
3ab032fc | 5062 | UINT16 FS;\r |
364a5474 | 5063 | UINT16 Reserved_90;\r |
3ab032fc | 5064 | UINT16 GS;\r |
364a5474 JW |
5065 | UINT16 Reserved_94;\r |
5066 | UINT16 LDTSegmentSelector;\r | |
5067 | UINT16 Reserved_98;\r | |
3ab032fc | 5068 | UINT16 T;\r |
364a5474 JW |
5069 | UINT16 IOMapBaseAddress;\r |
5070 | } IA32_TASK_STATE_SEGMENT;\r | |
5071 | \r | |
5072 | typedef union {\r | |
5073 | struct {\r | |
2f88bd3a MK |
5074 | UINT32 LimitLow : 16; ///< Segment Limit 15..00\r |
5075 | UINT32 BaseLow : 16; ///< Base Address 15..00\r | |
5076 | UINT32 BaseMid : 8; ///< Base Address 23..16\r | |
5077 | UINT32 Type : 4; ///< Type (1 0 B 1)\r | |
5078 | UINT32 Reserved_43 : 1; ///< 0\r | |
5079 | UINT32 DPL : 2; ///< Descriptor Privilege Level\r | |
5080 | UINT32 P : 1; ///< Segment Present\r | |
5081 | UINT32 LimitHigh : 4; ///< Segment Limit 19..16\r | |
5082 | UINT32 AVL : 1; ///< Available for use by system software\r | |
5083 | UINT32 Reserved_52 : 2; ///< 0 0\r | |
5084 | UINT32 G : 1; ///< Granularity\r | |
5085 | UINT32 BaseHigh : 8; ///< Base Address 31..24\r | |
364a5474 | 5086 | } Bits;\r |
2f88bd3a | 5087 | UINT64 Uint64;\r |
364a5474 | 5088 | } IA32_TSS_DESCRIPTOR;\r |
2f88bd3a | 5089 | #pragma pack ()\r |
364a5474 | 5090 | \r |
2f88bd3a | 5091 | #endif // defined (MDE_CPU_IA32)\r |
dc317713 | 5092 | \r |
2f88bd3a | 5093 | #if defined (MDE_CPU_X64)\r |
6f4aad3b | 5094 | ///\r |
af2dc6a7 | 5095 | /// Byte packed structure for an x64 Interrupt Gate Descriptor.\r |
6f4aad3b | 5096 | ///\r |
ac644614 | 5097 | typedef union {\r |
5098 | struct {\r | |
2f88bd3a MK |
5099 | UINT32 OffsetLow : 16; ///< Offset bits 15..0.\r |
5100 | UINT32 Selector : 16; ///< Selector.\r | |
5101 | UINT32 Reserved_0 : 8; ///< Reserved.\r | |
5102 | UINT32 GateType : 8; ///< Gate Type. See #defines above.\r | |
5103 | UINT32 OffsetHigh : 16; ///< Offset bits 31..16.\r | |
5104 | UINT32 OffsetUpper : 32; ///< Offset bits 63..32.\r | |
5105 | UINT32 Reserved_1 : 32; ///< Reserved.\r | |
ac644614 | 5106 | } Bits;\r |
6f4aad3b | 5107 | struct {\r |
2f88bd3a MK |
5108 | UINT64 Uint64;\r |
5109 | UINT64 Uint64_1;\r | |
9095d37b | 5110 | } Uint128;\r |
ac644614 | 5111 | } IA32_IDT_GATE_DESCRIPTOR;\r |
5112 | \r | |
2f88bd3a | 5113 | #pragma pack (1)\r |
364a5474 JW |
5114 | //\r |
5115 | // IA32 Task-State Segment Definition\r | |
5116 | //\r | |
5117 | typedef struct {\r | |
5118 | UINT32 Reserved_0;\r | |
3ab032fc JW |
5119 | UINT64 RSP0;\r |
5120 | UINT64 RSP1;\r | |
5121 | UINT64 RSP2;\r | |
364a5474 | 5122 | UINT64 Reserved_28;\r |
3ab032fc | 5123 | UINT64 IST[7];\r |
364a5474 JW |
5124 | UINT64 Reserved_92;\r |
5125 | UINT16 Reserved_100;\r | |
5126 | UINT16 IOMapBaseAddress;\r | |
5127 | } IA32_TASK_STATE_SEGMENT;\r | |
5128 | \r | |
5129 | typedef union {\r | |
5130 | struct {\r | |
2f88bd3a MK |
5131 | UINT32 LimitLow : 16; ///< Segment Limit 15..00\r |
5132 | UINT32 BaseLow : 16; ///< Base Address 15..00\r | |
5133 | UINT32 BaseMidl : 8; ///< Base Address 23..16\r | |
5134 | UINT32 Type : 4; ///< Type (1 0 B 1)\r | |
5135 | UINT32 Reserved_43 : 1; ///< 0\r | |
5136 | UINT32 DPL : 2; ///< Descriptor Privilege Level\r | |
5137 | UINT32 P : 1; ///< Segment Present\r | |
5138 | UINT32 LimitHigh : 4; ///< Segment Limit 19..16\r | |
5139 | UINT32 AVL : 1; ///< Available for use by system software\r | |
5140 | UINT32 Reserved_52 : 2; ///< 0 0\r | |
5141 | UINT32 G : 1; ///< Granularity\r | |
5142 | UINT32 BaseMidh : 8; ///< Base Address 31..24\r | |
5143 | UINT32 BaseHigh : 32; ///< Base Address 63..32\r | |
5144 | UINT32 Reserved_96 : 32; ///< Reserved\r | |
364a5474 JW |
5145 | } Bits;\r |
5146 | struct {\r | |
2f88bd3a MK |
5147 | UINT64 Uint64;\r |
5148 | UINT64 Uint64_1;\r | |
364a5474 JW |
5149 | } Uint128;\r |
5150 | } IA32_TSS_DESCRIPTOR;\r | |
2f88bd3a | 5151 | #pragma pack ()\r |
364a5474 | 5152 | \r |
2f88bd3a | 5153 | #endif // defined (MDE_CPU_X64)\r |
dc317713 | 5154 | \r |
1106ffe1 | 5155 | ///\r |
af2dc6a7 | 5156 | /// Byte packed structure for an FP/SSE/SSE2 context.\r |
1106ffe1 | 5157 | ///\r |
ac644614 | 5158 | typedef struct {\r |
2f88bd3a | 5159 | UINT8 Buffer[512];\r |
ac644614 | 5160 | } IA32_FX_BUFFER;\r |
5161 | \r | |
1106ffe1 | 5162 | ///\r |
af2dc6a7 | 5163 | /// Structures for the 16-bit real mode thunks.\r |
1106ffe1 | 5164 | ///\r |
ac644614 | 5165 | typedef struct {\r |
2f88bd3a MK |
5166 | UINT32 Reserved1;\r |
5167 | UINT32 Reserved2;\r | |
5168 | UINT32 Reserved3;\r | |
5169 | UINT32 Reserved4;\r | |
5170 | UINT8 BL;\r | |
5171 | UINT8 BH;\r | |
5172 | UINT16 Reserved5;\r | |
5173 | UINT8 DL;\r | |
5174 | UINT8 DH;\r | |
5175 | UINT16 Reserved6;\r | |
5176 | UINT8 CL;\r | |
5177 | UINT8 CH;\r | |
5178 | UINT16 Reserved7;\r | |
5179 | UINT8 AL;\r | |
5180 | UINT8 AH;\r | |
5181 | UINT16 Reserved8;\r | |
ac644614 | 5182 | } IA32_BYTE_REGS;\r |
5183 | \r | |
5184 | typedef struct {\r | |
2f88bd3a MK |
5185 | UINT16 DI;\r |
5186 | UINT16 Reserved1;\r | |
5187 | UINT16 SI;\r | |
5188 | UINT16 Reserved2;\r | |
5189 | UINT16 BP;\r | |
5190 | UINT16 Reserved3;\r | |
5191 | UINT16 SP;\r | |
5192 | UINT16 Reserved4;\r | |
5193 | UINT16 BX;\r | |
5194 | UINT16 Reserved5;\r | |
5195 | UINT16 DX;\r | |
5196 | UINT16 Reserved6;\r | |
5197 | UINT16 CX;\r | |
5198 | UINT16 Reserved7;\r | |
5199 | UINT16 AX;\r | |
5200 | UINT16 Reserved8;\r | |
ac644614 | 5201 | } IA32_WORD_REGS;\r |
5202 | \r | |
5203 | typedef struct {\r | |
2f88bd3a MK |
5204 | UINT32 EDI;\r |
5205 | UINT32 ESI;\r | |
5206 | UINT32 EBP;\r | |
5207 | UINT32 ESP;\r | |
5208 | UINT32 EBX;\r | |
5209 | UINT32 EDX;\r | |
5210 | UINT32 ECX;\r | |
5211 | UINT32 EAX;\r | |
5212 | UINT16 DS;\r | |
5213 | UINT16 ES;\r | |
5214 | UINT16 FS;\r | |
5215 | UINT16 GS;\r | |
5216 | IA32_EFLAGS32 EFLAGS;\r | |
5217 | UINT32 Eip;\r | |
5218 | UINT16 CS;\r | |
5219 | UINT16 SS;\r | |
ac644614 | 5220 | } IA32_DWORD_REGS;\r |
5221 | \r | |
5222 | typedef union {\r | |
2f88bd3a MK |
5223 | IA32_DWORD_REGS E;\r |
5224 | IA32_WORD_REGS X;\r | |
5225 | IA32_BYTE_REGS H;\r | |
ac644614 | 5226 | } IA32_REGISTER_SET;\r |
5227 | \r | |
1106ffe1 | 5228 | ///\r |
af2dc6a7 | 5229 | /// Byte packed structure for an 16-bit real mode thunks.\r |
1106ffe1 | 5230 | ///\r |
ac644614 | 5231 | typedef struct {\r |
2f88bd3a MK |
5232 | IA32_REGISTER_SET *RealModeState;\r |
5233 | VOID *RealModeBuffer;\r | |
5234 | UINT32 RealModeBufferSize;\r | |
5235 | UINT32 ThunkAttributes;\r | |
ac644614 | 5236 | } THUNK_CONTEXT;\r |
5237 | \r | |
2f88bd3a MK |
5238 | #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r |
5239 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r | |
5240 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r | |
ac644614 | 5241 | \r |
8596c140 LE |
5242 | ///\r |
5243 | /// Type definition for representing labels in NASM source code that allow for\r | |
5244 | /// the patching of immediate operands of IA32 and X64 instructions.\r | |
5245 | ///\r | |
5246 | /// While the type is technically defined as a function type (note: not a\r | |
5247 | /// pointer-to-function type), such labels in NASM source code never stand for\r | |
5248 | /// actual functions, and identifiers declared with this function type should\r | |
5249 | /// never be called. This is also why the EFIAPI calling convention specifier\r | |
5250 | /// is missing from the typedef, and why the typedef does not follow the usual\r | |
5251 | /// edk2 coding style for function (or pointer-to-function) typedefs. The VOID\r | |
5252 | /// return type and the VOID argument list are merely artifacts.\r | |
5253 | ///\r | |
2f88bd3a MK |
5254 | typedef VOID (X86_ASSEMBLY_PATCH_LABEL) (\r |
5255 | VOID\r | |
5256 | );\r | |
8596c140 | 5257 | \r |
ac644614 | 5258 | /**\r |
5259 | Retrieves CPUID information.\r | |
5260 | \r | |
5261 | Executes the CPUID instruction with EAX set to the value specified by Index.\r | |
5262 | This function always returns Index.\r | |
5263 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
5264 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
5265 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
5266 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
030cd1a2 | 5267 | This function is only available on IA-32 and x64.\r |
ac644614 | 5268 | \r |
5269 | @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r | |
5270 | instruction.\r | |
af2dc6a7 | 5271 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 5272 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5273 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 5274 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5275 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 5276 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5277 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 5278 | instruction. This is an optional parameter that may be NULL.\r |
5279 | \r | |
2fe241a2 | 5280 | @return Index.\r |
ac644614 | 5281 | \r |
5282 | **/\r | |
5283 | UINT32\r | |
5284 | EFIAPI\r | |
5285 | AsmCpuid (\r | |
2f88bd3a MK |
5286 | IN UINT32 Index,\r |
5287 | OUT UINT32 *Eax OPTIONAL,\r | |
5288 | OUT UINT32 *Ebx OPTIONAL,\r | |
5289 | OUT UINT32 *Ecx OPTIONAL,\r | |
5290 | OUT UINT32 *Edx OPTIONAL\r | |
ac644614 | 5291 | );\r |
5292 | \r | |
ac644614 | 5293 | /**\r |
5294 | Retrieves CPUID information using an extended leaf identifier.\r | |
5295 | \r | |
5296 | Executes the CPUID instruction with EAX set to the value specified by Index\r | |
5297 | and ECX set to the value specified by SubIndex. This function always returns\r | |
5298 | Index. This function is only available on IA-32 and x64.\r | |
5299 | \r | |
5300 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
5301 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
5302 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
5303 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
5304 | \r | |
5305 | @param Index The 32-bit value to load into EAX prior to invoking the\r | |
5306 | CPUID instruction.\r | |
5307 | @param SubIndex The 32-bit value to load into ECX prior to invoking the\r | |
5308 | CPUID instruction.\r | |
af2dc6a7 | 5309 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 5310 | instruction. This is an optional parameter that may be\r |
5311 | NULL.\r | |
af2dc6a7 | 5312 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 5313 | instruction. This is an optional parameter that may be\r |
5314 | NULL.\r | |
af2dc6a7 | 5315 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 5316 | instruction. This is an optional parameter that may be\r |
5317 | NULL.\r | |
af2dc6a7 | 5318 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 5319 | instruction. This is an optional parameter that may be\r |
5320 | NULL.\r | |
5321 | \r | |
2fe241a2 | 5322 | @return Index.\r |
ac644614 | 5323 | \r |
5324 | **/\r | |
5325 | UINT32\r | |
5326 | EFIAPI\r | |
5327 | AsmCpuidEx (\r | |
2f88bd3a MK |
5328 | IN UINT32 Index,\r |
5329 | IN UINT32 SubIndex,\r | |
5330 | OUT UINT32 *Eax OPTIONAL,\r | |
5331 | OUT UINT32 *Ebx OPTIONAL,\r | |
5332 | OUT UINT32 *Ecx OPTIONAL,\r | |
5333 | OUT UINT32 *Edx OPTIONAL\r | |
ac644614 | 5334 | );\r |
5335 | \r | |
be5f1614 | 5336 | /**\r |
5337 | Set CD bit and clear NW bit of CR0 followed by a WBINVD.\r | |
5338 | \r | |
5339 | Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,\r | |
5340 | and executing a WBINVD instruction. This function is only available on IA-32 and x64.\r | |
5341 | \r | |
5342 | **/\r | |
5343 | VOID\r | |
5344 | EFIAPI\r | |
5345 | AsmDisableCache (\r | |
5346 | VOID\r | |
5347 | );\r | |
5348 | \r | |
be5f1614 | 5349 | /**\r |
5350 | Perform a WBINVD and clear both the CD and NW bits of CR0.\r | |
5351 | \r | |
5352 | Enables the caches by executing a WBINVD instruction and then clear both the CD and NW\r | |
5353 | bits of CR0 to 0. This function is only available on IA-32 and x64.\r | |
5354 | \r | |
5355 | **/\r | |
5356 | VOID\r | |
5357 | EFIAPI\r | |
5358 | AsmEnableCache (\r | |
5359 | VOID\r | |
5360 | );\r | |
5361 | \r | |
ac644614 | 5362 | /**\r |
5363 | Returns the lower 32-bits of a Machine Specific Register(MSR).\r | |
5364 | \r | |
5365 | Reads and returns the lower 32-bits of the MSR specified by Index.\r | |
5366 | No parameter checking is performed on Index, and some Index values may cause\r | |
5367 | CPU exceptions. The caller must either guarantee that Index is valid, or the\r | |
5368 | caller must set up exception handlers to catch the exceptions. This function\r | |
030cd1a2 | 5369 | is only available on IA-32 and x64.\r |
ac644614 | 5370 | \r |
5371 | @param Index The 32-bit MSR index to read.\r | |
5372 | \r | |
5373 | @return The lower 32 bits of the MSR identified by Index.\r | |
5374 | \r | |
5375 | **/\r | |
5376 | UINT32\r | |
5377 | EFIAPI\r | |
5378 | AsmReadMsr32 (\r | |
2f88bd3a | 5379 | IN UINT32 Index\r |
ac644614 | 5380 | );\r |
5381 | \r | |
ac644614 | 5382 | /**\r |
17f695ed | 5383 | Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.\r |
5384 | The upper 32-bits of the MSR are set to zero.\r | |
ac644614 | 5385 | \r |
5386 | Writes the 32-bit value specified by Value to the MSR specified by Index. The\r | |
5387 | upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r | |
5388 | the MSR is returned. No parameter checking is performed on Index or Value,\r | |
5389 | and some of these may cause CPU exceptions. The caller must either guarantee\r | |
5390 | that Index and Value are valid, or the caller must establish proper exception\r | |
030cd1a2 | 5391 | handlers. This function is only available on IA-32 and x64.\r |
ac644614 | 5392 | \r |
5393 | @param Index The 32-bit MSR index to write.\r | |
5394 | @param Value The 32-bit value to write to the MSR.\r | |
5395 | \r | |
5396 | @return Value\r | |
5397 | \r | |
5398 | **/\r | |
5399 | UINT32\r | |
5400 | EFIAPI\r | |
5401 | AsmWriteMsr32 (\r | |
2f88bd3a MK |
5402 | IN UINT32 Index,\r |
5403 | IN UINT32 Value\r | |
ac644614 | 5404 | );\r |
5405 | \r | |
ac644614 | 5406 | /**\r |
62991af2 | 5407 | Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and\r |
ac644614 | 5408 | writes the result back to the 64-bit MSR.\r |
5409 | \r | |
62991af2 | 5410 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 5411 | between the lower 32-bits of the read result and the value specified by\r |
5412 | OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r | |
5413 | 32-bits of the value written to the MSR is returned. No parameter checking is\r | |
5414 | performed on Index or OrData, and some of these may cause CPU exceptions. The\r | |
5415 | caller must either guarantee that Index and OrData are valid, or the caller\r | |
5416 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 5417 | IA-32 and x64.\r |
ac644614 | 5418 | \r |
5419 | @param Index The 32-bit MSR index to write.\r | |
5420 | @param OrData The value to OR with the read value from the MSR.\r | |
5421 | \r | |
5422 | @return The lower 32-bit value written to the MSR.\r | |
5423 | \r | |
5424 | **/\r | |
5425 | UINT32\r | |
5426 | EFIAPI\r | |
5427 | AsmMsrOr32 (\r | |
2f88bd3a MK |
5428 | IN UINT32 Index,\r |
5429 | IN UINT32 OrData\r | |
ac644614 | 5430 | );\r |
5431 | \r | |
ac644614 | 5432 | /**\r |
5433 | Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r | |
5434 | the result back to the 64-bit MSR.\r | |
5435 | \r | |
5436 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5437 | lower 32-bits of the read result and the value specified by AndData, and\r | |
5438 | writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r | |
5439 | the value written to the MSR is returned. No parameter checking is performed\r | |
5440 | on Index or AndData, and some of these may cause CPU exceptions. The caller\r | |
5441 | must either guarantee that Index and AndData are valid, or the caller must\r | |
5442 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 5443 | and x64.\r |
ac644614 | 5444 | \r |
5445 | @param Index The 32-bit MSR index to write.\r | |
5446 | @param AndData The value to AND with the read value from the MSR.\r | |
5447 | \r | |
5448 | @return The lower 32-bit value written to the MSR.\r | |
5449 | \r | |
5450 | **/\r | |
5451 | UINT32\r | |
5452 | EFIAPI\r | |
5453 | AsmMsrAnd32 (\r | |
2f88bd3a MK |
5454 | IN UINT32 Index,\r |
5455 | IN UINT32 AndData\r | |
ac644614 | 5456 | );\r |
5457 | \r | |
ac644614 | 5458 | /**\r |
62991af2 | 5459 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR\r |
ac644614 | 5460 | on the lower 32-bits, and writes the result back to the 64-bit MSR.\r |
5461 | \r | |
5462 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5463 | lower 32-bits of the read result and the value specified by AndData\r | |
62991af2 | 5464 | preserving the upper 32-bits, performs a bitwise OR between the\r |
ac644614 | 5465 | result of the AND operation and the value specified by OrData, and writes the\r |
5466 | result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r | |
5467 | written to the MSR is returned. No parameter checking is performed on Index,\r | |
5468 | AndData, or OrData, and some of these may cause CPU exceptions. The caller\r | |
5469 | must either guarantee that Index, AndData, and OrData are valid, or the\r | |
5470 | caller must establish proper exception handlers. This function is only\r | |
030cd1a2 | 5471 | available on IA-32 and x64.\r |
ac644614 | 5472 | \r |
5473 | @param Index The 32-bit MSR index to write.\r | |
5474 | @param AndData The value to AND with the read value from the MSR.\r | |
5475 | @param OrData The value to OR with the result of the AND operation.\r | |
5476 | \r | |
5477 | @return The lower 32-bit value written to the MSR.\r | |
5478 | \r | |
5479 | **/\r | |
5480 | UINT32\r | |
5481 | EFIAPI\r | |
5482 | AsmMsrAndThenOr32 (\r | |
2f88bd3a MK |
5483 | IN UINT32 Index,\r |
5484 | IN UINT32 AndData,\r | |
5485 | IN UINT32 OrData\r | |
ac644614 | 5486 | );\r |
5487 | \r | |
ac644614 | 5488 | /**\r |
5489 | Reads a bit field of an MSR.\r | |
5490 | \r | |
5491 | Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r | |
5492 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
5493 | returned. The caller must either guarantee that Index is valid, or the caller\r | |
5494 | must set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 5495 | available on IA-32 and x64.\r |
ac644614 | 5496 | \r |
5497 | If StartBit is greater than 31, then ASSERT().\r | |
5498 | If EndBit is greater than 31, then ASSERT().\r | |
5499 | If EndBit is less than StartBit, then ASSERT().\r | |
5500 | \r | |
5501 | @param Index The 32-bit MSR index to read.\r | |
5502 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5503 | Range 0..31.\r | |
5504 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5505 | Range 0..31.\r | |
5506 | \r | |
5507 | @return The bit field read from the MSR.\r | |
5508 | \r | |
5509 | **/\r | |
5510 | UINT32\r | |
5511 | EFIAPI\r | |
5512 | AsmMsrBitFieldRead32 (\r | |
2f88bd3a MK |
5513 | IN UINT32 Index,\r |
5514 | IN UINTN StartBit,\r | |
5515 | IN UINTN EndBit\r | |
ac644614 | 5516 | );\r |
5517 | \r | |
ac644614 | 5518 | /**\r |
5519 | Writes a bit field to an MSR.\r | |
5520 | \r | |
2fe241a2 | 5521 | Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r |
ac644614 | 5522 | field is specified by the StartBit and the EndBit. All other bits in the\r |
5523 | destination MSR are preserved. The lower 32-bits of the MSR written is\r | |
9095d37b LG |
5524 | returned. The caller must either guarantee that Index and the data written\r |
5525 | is valid, or the caller must set up exception handlers to catch the exceptions.\r | |
62991af2 | 5526 | This function is only available on IA-32 and x64.\r |
ac644614 | 5527 | \r |
5528 | If StartBit is greater than 31, then ASSERT().\r | |
5529 | If EndBit is greater than 31, then ASSERT().\r | |
5530 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5531 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5532 | \r |
5533 | @param Index The 32-bit MSR index to write.\r | |
5534 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5535 | Range 0..31.\r | |
5536 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5537 | Range 0..31.\r | |
5538 | @param Value New value of the bit field.\r | |
5539 | \r | |
5540 | @return The lower 32-bit of the value written to the MSR.\r | |
5541 | \r | |
5542 | **/\r | |
5543 | UINT32\r | |
5544 | EFIAPI\r | |
5545 | AsmMsrBitFieldWrite32 (\r | |
2f88bd3a MK |
5546 | IN UINT32 Index,\r |
5547 | IN UINTN StartBit,\r | |
5548 | IN UINTN EndBit,\r | |
5549 | IN UINT32 Value\r | |
ac644614 | 5550 | );\r |
5551 | \r | |
ac644614 | 5552 | /**\r |
5553 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r | |
5554 | result back to the bit field in the 64-bit MSR.\r | |
5555 | \r | |
62991af2 | 5556 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 5557 | between the read result and the value specified by OrData, and writes the\r |
5558 | result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r | |
5559 | written to the MSR are returned. Extra left bits in OrData are stripped. The\r | |
5560 | caller must either guarantee that Index and the data written is valid, or\r | |
5561 | the caller must set up exception handlers to catch the exceptions. This\r | |
030cd1a2 | 5562 | function is only available on IA-32 and x64.\r |
ac644614 | 5563 | \r |
5564 | If StartBit is greater than 31, then ASSERT().\r | |
5565 | If EndBit is greater than 31, then ASSERT().\r | |
5566 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5567 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5568 | \r |
5569 | @param Index The 32-bit MSR index to write.\r | |
5570 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5571 | Range 0..31.\r | |
5572 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5573 | Range 0..31.\r | |
5574 | @param OrData The value to OR with the read value from the MSR.\r | |
5575 | \r | |
5576 | @return The lower 32-bit of the value written to the MSR.\r | |
5577 | \r | |
5578 | **/\r | |
5579 | UINT32\r | |
5580 | EFIAPI\r | |
5581 | AsmMsrBitFieldOr32 (\r | |
2f88bd3a MK |
5582 | IN UINT32 Index,\r |
5583 | IN UINTN StartBit,\r | |
5584 | IN UINTN EndBit,\r | |
5585 | IN UINT32 OrData\r | |
ac644614 | 5586 | );\r |
5587 | \r | |
ac644614 | 5588 | /**\r |
5589 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
5590 | result back to the bit field in the 64-bit MSR.\r | |
5591 | \r | |
5592 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5593 | read result and the value specified by AndData, and writes the result to the\r | |
5594 | 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r | |
5595 | MSR are returned. Extra left bits in AndData are stripped. The caller must\r | |
5596 | either guarantee that Index and the data written is valid, or the caller must\r | |
5597 | set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 5598 | available on IA-32 and x64.\r |
ac644614 | 5599 | \r |
5600 | If StartBit is greater than 31, then ASSERT().\r | |
5601 | If EndBit is greater than 31, then ASSERT().\r | |
5602 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5603 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5604 | \r |
5605 | @param Index The 32-bit MSR index to write.\r | |
5606 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5607 | Range 0..31.\r | |
5608 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5609 | Range 0..31.\r | |
5610 | @param AndData The value to AND with the read value from the MSR.\r | |
5611 | \r | |
5612 | @return The lower 32-bit of the value written to the MSR.\r | |
5613 | \r | |
5614 | **/\r | |
5615 | UINT32\r | |
5616 | EFIAPI\r | |
5617 | AsmMsrBitFieldAnd32 (\r | |
2f88bd3a MK |
5618 | IN UINT32 Index,\r |
5619 | IN UINTN StartBit,\r | |
5620 | IN UINTN EndBit,\r | |
5621 | IN UINT32 AndData\r | |
ac644614 | 5622 | );\r |
5623 | \r | |
ac644614 | 5624 | /**\r |
5625 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 5626 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 5627 | 64-bit MSR.\r |
5628 | \r | |
5629 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r | |
62991af2 | 5630 | bitwise OR between the read result and the value specified by\r |
ac644614 | 5631 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
5632 | lower 32-bits of the value written to the MSR are returned. Extra left bits\r | |
5633 | in both AndData and OrData are stripped. The caller must either guarantee\r | |
5634 | that Index and the data written is valid, or the caller must set up exception\r | |
5635 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 5636 | and x64.\r |
ac644614 | 5637 | \r |
5638 | If StartBit is greater than 31, then ASSERT().\r | |
5639 | If EndBit is greater than 31, then ASSERT().\r | |
5640 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
5641 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
5642 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 5643 | \r |
5644 | @param Index The 32-bit MSR index to write.\r | |
5645 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5646 | Range 0..31.\r | |
5647 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5648 | Range 0..31.\r | |
5649 | @param AndData The value to AND with the read value from the MSR.\r | |
5650 | @param OrData The value to OR with the result of the AND operation.\r | |
5651 | \r | |
5652 | @return The lower 32-bit of the value written to the MSR.\r | |
5653 | \r | |
5654 | **/\r | |
5655 | UINT32\r | |
5656 | EFIAPI\r | |
5657 | AsmMsrBitFieldAndThenOr32 (\r | |
2f88bd3a MK |
5658 | IN UINT32 Index,\r |
5659 | IN UINTN StartBit,\r | |
5660 | IN UINTN EndBit,\r | |
5661 | IN UINT32 AndData,\r | |
5662 | IN UINT32 OrData\r | |
ac644614 | 5663 | );\r |
5664 | \r | |
ac644614 | 5665 | /**\r |
5666 | Returns a 64-bit Machine Specific Register(MSR).\r | |
5667 | \r | |
5668 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r | |
5669 | performed on Index, and some Index values may cause CPU exceptions. The\r | |
5670 | caller must either guarantee that Index is valid, or the caller must set up\r | |
5671 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 5672 | on IA-32 and x64.\r |
ac644614 | 5673 | \r |
5674 | @param Index The 32-bit MSR index to read.\r | |
5675 | \r | |
5676 | @return The value of the MSR identified by Index.\r | |
5677 | \r | |
5678 | **/\r | |
5679 | UINT64\r | |
5680 | EFIAPI\r | |
5681 | AsmReadMsr64 (\r | |
2f88bd3a | 5682 | IN UINT32 Index\r |
ac644614 | 5683 | );\r |
5684 | \r | |
ac644614 | 5685 | /**\r |
5686 | Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r | |
5687 | value.\r | |
5688 | \r | |
5689 | Writes the 64-bit value specified by Value to the MSR specified by Index. The\r | |
5690 | 64-bit value written to the MSR is returned. No parameter checking is\r | |
5691 | performed on Index or Value, and some of these may cause CPU exceptions. The\r | |
5692 | caller must either guarantee that Index and Value are valid, or the caller\r | |
5693 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 5694 | IA-32 and x64.\r |
ac644614 | 5695 | \r |
5696 | @param Index The 32-bit MSR index to write.\r | |
5697 | @param Value The 64-bit value to write to the MSR.\r | |
5698 | \r | |
5699 | @return Value\r | |
5700 | \r | |
5701 | **/\r | |
5702 | UINT64\r | |
5703 | EFIAPI\r | |
5704 | AsmWriteMsr64 (\r | |
2f88bd3a MK |
5705 | IN UINT32 Index,\r |
5706 | IN UINT64 Value\r | |
ac644614 | 5707 | );\r |
5708 | \r | |
ac644614 | 5709 | /**\r |
62991af2 | 5710 | Reads a 64-bit MSR, performs a bitwise OR, and writes the result\r |
ac644614 | 5711 | back to the 64-bit MSR.\r |
5712 | \r | |
62991af2 | 5713 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 5714 | between the read result and the value specified by OrData, and writes the\r |
5715 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
5716 | returned. No parameter checking is performed on Index or OrData, and some of\r | |
5717 | these may cause CPU exceptions. The caller must either guarantee that Index\r | |
5718 | and OrData are valid, or the caller must establish proper exception handlers.\r | |
030cd1a2 | 5719 | This function is only available on IA-32 and x64.\r |
ac644614 | 5720 | \r |
5721 | @param Index The 32-bit MSR index to write.\r | |
5722 | @param OrData The value to OR with the read value from the MSR.\r | |
5723 | \r | |
5724 | @return The value written back to the MSR.\r | |
5725 | \r | |
5726 | **/\r | |
5727 | UINT64\r | |
5728 | EFIAPI\r | |
5729 | AsmMsrOr64 (\r | |
2f88bd3a MK |
5730 | IN UINT32 Index,\r |
5731 | IN UINT64 OrData\r | |
ac644614 | 5732 | );\r |
5733 | \r | |
ac644614 | 5734 | /**\r |
5735 | Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r | |
5736 | 64-bit MSR.\r | |
5737 | \r | |
5738 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5739 | read result and the value specified by OrData, and writes the result to the\r | |
5740 | 64-bit MSR specified by Index. The value written to the MSR is returned. No\r | |
5741 | parameter checking is performed on Index or OrData, and some of these may\r | |
5742 | cause CPU exceptions. The caller must either guarantee that Index and OrData\r | |
5743 | are valid, or the caller must establish proper exception handlers. This\r | |
030cd1a2 | 5744 | function is only available on IA-32 and x64.\r |
ac644614 | 5745 | \r |
5746 | @param Index The 32-bit MSR index to write.\r | |
5747 | @param AndData The value to AND with the read value from the MSR.\r | |
5748 | \r | |
5749 | @return The value written back to the MSR.\r | |
5750 | \r | |
5751 | **/\r | |
5752 | UINT64\r | |
5753 | EFIAPI\r | |
5754 | AsmMsrAnd64 (\r | |
2f88bd3a MK |
5755 | IN UINT32 Index,\r |
5756 | IN UINT64 AndData\r | |
ac644614 | 5757 | );\r |
5758 | \r | |
ac644614 | 5759 | /**\r |
9095d37b | 5760 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise\r |
ac644614 | 5761 | OR, and writes the result back to the 64-bit MSR.\r |
5762 | \r | |
5763 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r | |
62991af2 | 5764 | result and the value specified by AndData, performs a bitwise OR\r |
ac644614 | 5765 | between the result of the AND operation and the value specified by OrData,\r |
5766 | and writes the result to the 64-bit MSR specified by Index. The value written\r | |
5767 | to the MSR is returned. No parameter checking is performed on Index, AndData,\r | |
5768 | or OrData, and some of these may cause CPU exceptions. The caller must either\r | |
5769 | guarantee that Index, AndData, and OrData are valid, or the caller must\r | |
5770 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 5771 | and x64.\r |
ac644614 | 5772 | \r |
5773 | @param Index The 32-bit MSR index to write.\r | |
5774 | @param AndData The value to AND with the read value from the MSR.\r | |
5775 | @param OrData The value to OR with the result of the AND operation.\r | |
5776 | \r | |
5777 | @return The value written back to the MSR.\r | |
5778 | \r | |
5779 | **/\r | |
5780 | UINT64\r | |
5781 | EFIAPI\r | |
5782 | AsmMsrAndThenOr64 (\r | |
2f88bd3a MK |
5783 | IN UINT32 Index,\r |
5784 | IN UINT64 AndData,\r | |
5785 | IN UINT64 OrData\r | |
ac644614 | 5786 | );\r |
5787 | \r | |
ac644614 | 5788 | /**\r |
5789 | Reads a bit field of an MSR.\r | |
5790 | \r | |
5791 | Reads the bit field in the 64-bit MSR. The bit field is specified by the\r | |
5792 | StartBit and the EndBit. The value of the bit field is returned. The caller\r | |
5793 | must either guarantee that Index is valid, or the caller must set up\r | |
5794 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 5795 | on IA-32 and x64.\r |
ac644614 | 5796 | \r |
5797 | If StartBit is greater than 63, then ASSERT().\r | |
5798 | If EndBit is greater than 63, then ASSERT().\r | |
5799 | If EndBit is less than StartBit, then ASSERT().\r | |
5800 | \r | |
5801 | @param Index The 32-bit MSR index to read.\r | |
5802 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5803 | Range 0..63.\r | |
5804 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5805 | Range 0..63.\r | |
5806 | \r | |
5807 | @return The value read from the MSR.\r | |
5808 | \r | |
5809 | **/\r | |
5810 | UINT64\r | |
5811 | EFIAPI\r | |
5812 | AsmMsrBitFieldRead64 (\r | |
2f88bd3a MK |
5813 | IN UINT32 Index,\r |
5814 | IN UINTN StartBit,\r | |
5815 | IN UINTN EndBit\r | |
ac644614 | 5816 | );\r |
5817 | \r | |
ac644614 | 5818 | /**\r |
5819 | Writes a bit field to an MSR.\r | |
5820 | \r | |
5821 | Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r | |
5822 | the StartBit and the EndBit. All other bits in the destination MSR are\r | |
9095d37b LG |
5823 | preserved. The MSR written is returned. The caller must either guarantee\r |
5824 | that Index and the data written is valid, or the caller must set up exception\r | |
62991af2 | 5825 | handlers to catch the exceptions. This function is only available on IA-32 and x64.\r |
ac644614 | 5826 | \r |
5827 | If StartBit is greater than 63, then ASSERT().\r | |
5828 | If EndBit is greater than 63, then ASSERT().\r | |
5829 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5830 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5831 | \r |
5832 | @param Index The 32-bit MSR index to write.\r | |
5833 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5834 | Range 0..63.\r | |
5835 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5836 | Range 0..63.\r | |
5837 | @param Value New value of the bit field.\r | |
5838 | \r | |
5839 | @return The value written back to the MSR.\r | |
5840 | \r | |
5841 | **/\r | |
5842 | UINT64\r | |
5843 | EFIAPI\r | |
5844 | AsmMsrBitFieldWrite64 (\r | |
2f88bd3a MK |
5845 | IN UINT32 Index,\r |
5846 | IN UINTN StartBit,\r | |
5847 | IN UINTN EndBit,\r | |
5848 | IN UINT64 Value\r | |
ac644614 | 5849 | );\r |
5850 | \r | |
ac644614 | 5851 | /**\r |
62991af2 | 5852 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and\r |
ac644614 | 5853 | writes the result back to the bit field in the 64-bit MSR.\r |
5854 | \r | |
62991af2 | 5855 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 5856 | between the read result and the value specified by OrData, and writes the\r |
5857 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
5858 | returned. Extra left bits in OrData are stripped. The caller must either\r | |
5859 | guarantee that Index and the data written is valid, or the caller must set up\r | |
5860 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 5861 | on IA-32 and x64.\r |
ac644614 | 5862 | \r |
5863 | If StartBit is greater than 63, then ASSERT().\r | |
5864 | If EndBit is greater than 63, then ASSERT().\r | |
5865 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5866 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5867 | \r |
5868 | @param Index The 32-bit MSR index to write.\r | |
5869 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5870 | Range 0..63.\r | |
5871 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5872 | Range 0..63.\r | |
5873 | @param OrData The value to OR with the read value from the bit field.\r | |
5874 | \r | |
5875 | @return The value written back to the MSR.\r | |
5876 | \r | |
5877 | **/\r | |
5878 | UINT64\r | |
5879 | EFIAPI\r | |
5880 | AsmMsrBitFieldOr64 (\r | |
2f88bd3a MK |
5881 | IN UINT32 Index,\r |
5882 | IN UINTN StartBit,\r | |
5883 | IN UINTN EndBit,\r | |
5884 | IN UINT64 OrData\r | |
ac644614 | 5885 | );\r |
5886 | \r | |
ac644614 | 5887 | /**\r |
5888 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
5889 | result back to the bit field in the 64-bit MSR.\r | |
5890 | \r | |
5891 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5892 | read result and the value specified by AndData, and writes the result to the\r | |
5893 | 64-bit MSR specified by Index. The value written to the MSR is returned.\r | |
5894 | Extra left bits in AndData are stripped. The caller must either guarantee\r | |
5895 | that Index and the data written is valid, or the caller must set up exception\r | |
5896 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 5897 | and x64.\r |
ac644614 | 5898 | \r |
5899 | If StartBit is greater than 63, then ASSERT().\r | |
5900 | If EndBit is greater than 63, then ASSERT().\r | |
5901 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5902 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5903 | \r |
5904 | @param Index The 32-bit MSR index to write.\r | |
5905 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5906 | Range 0..63.\r | |
5907 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5908 | Range 0..63.\r | |
5909 | @param AndData The value to AND with the read value from the bit field.\r | |
5910 | \r | |
5911 | @return The value written back to the MSR.\r | |
5912 | \r | |
5913 | **/\r | |
5914 | UINT64\r | |
5915 | EFIAPI\r | |
5916 | AsmMsrBitFieldAnd64 (\r | |
2f88bd3a MK |
5917 | IN UINT32 Index,\r |
5918 | IN UINTN StartBit,\r | |
5919 | IN UINTN EndBit,\r | |
5920 | IN UINT64 AndData\r | |
ac644614 | 5921 | );\r |
5922 | \r | |
ac644614 | 5923 | /**\r |
5924 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 5925 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 5926 | 64-bit MSR.\r |
5927 | \r | |
5928 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r | |
62991af2 | 5929 | a bitwise OR between the read result and the value specified by\r |
ac644614 | 5930 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
5931 | value written to the MSR is returned. Extra left bits in both AndData and\r | |
5932 | OrData are stripped. The caller must either guarantee that Index and the data\r | |
5933 | written is valid, or the caller must set up exception handlers to catch the\r | |
030cd1a2 | 5934 | exceptions. This function is only available on IA-32 and x64.\r |
ac644614 | 5935 | \r |
5936 | If StartBit is greater than 63, then ASSERT().\r | |
5937 | If EndBit is greater than 63, then ASSERT().\r | |
5938 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
5939 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
5940 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 5941 | \r |
5942 | @param Index The 32-bit MSR index to write.\r | |
5943 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5944 | Range 0..63.\r | |
5945 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5946 | Range 0..63.\r | |
5947 | @param AndData The value to AND with the read value from the bit field.\r | |
5948 | @param OrData The value to OR with the result of the AND operation.\r | |
5949 | \r | |
5950 | @return The value written back to the MSR.\r | |
5951 | \r | |
5952 | **/\r | |
5953 | UINT64\r | |
5954 | EFIAPI\r | |
5955 | AsmMsrBitFieldAndThenOr64 (\r | |
2f88bd3a MK |
5956 | IN UINT32 Index,\r |
5957 | IN UINTN StartBit,\r | |
5958 | IN UINTN EndBit,\r | |
5959 | IN UINT64 AndData,\r | |
5960 | IN UINT64 OrData\r | |
ac644614 | 5961 | );\r |
5962 | \r | |
ac644614 | 5963 | /**\r |
5964 | Reads the current value of the EFLAGS register.\r | |
5965 | \r | |
5966 | Reads and returns the current value of the EFLAGS register. This function is\r | |
030cd1a2 | 5967 | only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a\r |
5968 | 64-bit value on x64.\r | |
ac644614 | 5969 | \r |
030cd1a2 | 5970 | @return EFLAGS on IA-32 or RFLAGS on x64.\r |
ac644614 | 5971 | \r |
5972 | **/\r | |
5973 | UINTN\r | |
5974 | EFIAPI\r | |
5975 | AsmReadEflags (\r | |
5976 | VOID\r | |
5977 | );\r | |
5978 | \r | |
ac644614 | 5979 | /**\r |
5980 | Reads the current value of the Control Register 0 (CR0).\r | |
5981 | \r | |
5982 | Reads and returns the current value of CR0. This function is only available\r | |
030cd1a2 | 5983 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
5984 | x64.\r | |
ac644614 | 5985 | \r |
5986 | @return The value of the Control Register 0 (CR0).\r | |
5987 | \r | |
5988 | **/\r | |
5989 | UINTN\r | |
5990 | EFIAPI\r | |
5991 | AsmReadCr0 (\r | |
5992 | VOID\r | |
5993 | );\r | |
5994 | \r | |
ac644614 | 5995 | /**\r |
5996 | Reads the current value of the Control Register 2 (CR2).\r | |
5997 | \r | |
5998 | Reads and returns the current value of CR2. This function is only available\r | |
030cd1a2 | 5999 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6000 | x64.\r | |
ac644614 | 6001 | \r |
6002 | @return The value of the Control Register 2 (CR2).\r | |
6003 | \r | |
6004 | **/\r | |
6005 | UINTN\r | |
6006 | EFIAPI\r | |
6007 | AsmReadCr2 (\r | |
6008 | VOID\r | |
6009 | );\r | |
6010 | \r | |
ac644614 | 6011 | /**\r |
6012 | Reads the current value of the Control Register 3 (CR3).\r | |
6013 | \r | |
6014 | Reads and returns the current value of CR3. This function is only available\r | |
030cd1a2 | 6015 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6016 | x64.\r | |
ac644614 | 6017 | \r |
6018 | @return The value of the Control Register 3 (CR3).\r | |
6019 | \r | |
6020 | **/\r | |
6021 | UINTN\r | |
6022 | EFIAPI\r | |
6023 | AsmReadCr3 (\r | |
6024 | VOID\r | |
6025 | );\r | |
6026 | \r | |
ac644614 | 6027 | /**\r |
6028 | Reads the current value of the Control Register 4 (CR4).\r | |
6029 | \r | |
6030 | Reads and returns the current value of CR4. This function is only available\r | |
030cd1a2 | 6031 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6032 | x64.\r | |
ac644614 | 6033 | \r |
6034 | @return The value of the Control Register 4 (CR4).\r | |
6035 | \r | |
6036 | **/\r | |
6037 | UINTN\r | |
6038 | EFIAPI\r | |
6039 | AsmReadCr4 (\r | |
6040 | VOID\r | |
6041 | );\r | |
6042 | \r | |
ac644614 | 6043 | /**\r |
6044 | Writes a value to Control Register 0 (CR0).\r | |
6045 | \r | |
6046 | Writes and returns a new value to CR0. This function is only available on\r | |
030cd1a2 | 6047 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6048 | \r |
6049 | @param Cr0 The value to write to CR0.\r | |
6050 | \r | |
6051 | @return The value written to CR0.\r | |
6052 | \r | |
6053 | **/\r | |
6054 | UINTN\r | |
6055 | EFIAPI\r | |
6056 | AsmWriteCr0 (\r | |
6057 | UINTN Cr0\r | |
6058 | );\r | |
6059 | \r | |
ac644614 | 6060 | /**\r |
6061 | Writes a value to Control Register 2 (CR2).\r | |
6062 | \r | |
6063 | Writes and returns a new value to CR2. This function is only available on\r | |
030cd1a2 | 6064 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6065 | \r |
6066 | @param Cr2 The value to write to CR2.\r | |
6067 | \r | |
6068 | @return The value written to CR2.\r | |
6069 | \r | |
6070 | **/\r | |
6071 | UINTN\r | |
6072 | EFIAPI\r | |
6073 | AsmWriteCr2 (\r | |
6074 | UINTN Cr2\r | |
6075 | );\r | |
6076 | \r | |
ac644614 | 6077 | /**\r |
6078 | Writes a value to Control Register 3 (CR3).\r | |
6079 | \r | |
6080 | Writes and returns a new value to CR3. This function is only available on\r | |
030cd1a2 | 6081 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6082 | \r |
6083 | @param Cr3 The value to write to CR3.\r | |
6084 | \r | |
6085 | @return The value written to CR3.\r | |
6086 | \r | |
6087 | **/\r | |
6088 | UINTN\r | |
6089 | EFIAPI\r | |
6090 | AsmWriteCr3 (\r | |
6091 | UINTN Cr3\r | |
6092 | );\r | |
6093 | \r | |
ac644614 | 6094 | /**\r |
6095 | Writes a value to Control Register 4 (CR4).\r | |
6096 | \r | |
6097 | Writes and returns a new value to CR4. This function is only available on\r | |
030cd1a2 | 6098 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6099 | \r |
6100 | @param Cr4 The value to write to CR4.\r | |
6101 | \r | |
6102 | @return The value written to CR4.\r | |
6103 | \r | |
6104 | **/\r | |
6105 | UINTN\r | |
6106 | EFIAPI\r | |
6107 | AsmWriteCr4 (\r | |
6108 | UINTN Cr4\r | |
6109 | );\r | |
6110 | \r | |
ac644614 | 6111 | /**\r |
6112 | Reads the current value of Debug Register 0 (DR0).\r | |
6113 | \r | |
6114 | Reads and returns the current value of DR0. This function is only available\r | |
030cd1a2 | 6115 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6116 | x64.\r | |
ac644614 | 6117 | \r |
6118 | @return The value of Debug Register 0 (DR0).\r | |
6119 | \r | |
6120 | **/\r | |
6121 | UINTN\r | |
6122 | EFIAPI\r | |
6123 | AsmReadDr0 (\r | |
6124 | VOID\r | |
6125 | );\r | |
6126 | \r | |
ac644614 | 6127 | /**\r |
6128 | Reads the current value of Debug Register 1 (DR1).\r | |
6129 | \r | |
6130 | Reads and returns the current value of DR1. This function is only available\r | |
030cd1a2 | 6131 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6132 | x64.\r | |
ac644614 | 6133 | \r |
6134 | @return The value of Debug Register 1 (DR1).\r | |
6135 | \r | |
6136 | **/\r | |
6137 | UINTN\r | |
6138 | EFIAPI\r | |
6139 | AsmReadDr1 (\r | |
6140 | VOID\r | |
6141 | );\r | |
6142 | \r | |
ac644614 | 6143 | /**\r |
6144 | Reads the current value of Debug Register 2 (DR2).\r | |
6145 | \r | |
6146 | Reads and returns the current value of DR2. This function is only available\r | |
030cd1a2 | 6147 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6148 | x64.\r | |
ac644614 | 6149 | \r |
6150 | @return The value of Debug Register 2 (DR2).\r | |
6151 | \r | |
6152 | **/\r | |
6153 | UINTN\r | |
6154 | EFIAPI\r | |
6155 | AsmReadDr2 (\r | |
6156 | VOID\r | |
6157 | );\r | |
6158 | \r | |
ac644614 | 6159 | /**\r |
6160 | Reads the current value of Debug Register 3 (DR3).\r | |
6161 | \r | |
6162 | Reads and returns the current value of DR3. This function is only available\r | |
030cd1a2 | 6163 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6164 | x64.\r | |
ac644614 | 6165 | \r |
6166 | @return The value of Debug Register 3 (DR3).\r | |
6167 | \r | |
6168 | **/\r | |
6169 | UINTN\r | |
6170 | EFIAPI\r | |
6171 | AsmReadDr3 (\r | |
6172 | VOID\r | |
6173 | );\r | |
6174 | \r | |
ac644614 | 6175 | /**\r |
6176 | Reads the current value of Debug Register 4 (DR4).\r | |
6177 | \r | |
6178 | Reads and returns the current value of DR4. This function is only available\r | |
030cd1a2 | 6179 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6180 | x64.\r | |
ac644614 | 6181 | \r |
6182 | @return The value of Debug Register 4 (DR4).\r | |
6183 | \r | |
6184 | **/\r | |
6185 | UINTN\r | |
6186 | EFIAPI\r | |
6187 | AsmReadDr4 (\r | |
6188 | VOID\r | |
6189 | );\r | |
6190 | \r | |
ac644614 | 6191 | /**\r |
6192 | Reads the current value of Debug Register 5 (DR5).\r | |
6193 | \r | |
6194 | Reads and returns the current value of DR5. This function is only available\r | |
030cd1a2 | 6195 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6196 | x64.\r | |
ac644614 | 6197 | \r |
6198 | @return The value of Debug Register 5 (DR5).\r | |
6199 | \r | |
6200 | **/\r | |
6201 | UINTN\r | |
6202 | EFIAPI\r | |
6203 | AsmReadDr5 (\r | |
6204 | VOID\r | |
6205 | );\r | |
6206 | \r | |
ac644614 | 6207 | /**\r |
6208 | Reads the current value of Debug Register 6 (DR6).\r | |
6209 | \r | |
6210 | Reads and returns the current value of DR6. This function is only available\r | |
030cd1a2 | 6211 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6212 | x64.\r | |
ac644614 | 6213 | \r |
6214 | @return The value of Debug Register 6 (DR6).\r | |
6215 | \r | |
6216 | **/\r | |
6217 | UINTN\r | |
6218 | EFIAPI\r | |
6219 | AsmReadDr6 (\r | |
6220 | VOID\r | |
6221 | );\r | |
6222 | \r | |
ac644614 | 6223 | /**\r |
6224 | Reads the current value of Debug Register 7 (DR7).\r | |
6225 | \r | |
6226 | Reads and returns the current value of DR7. This function is only available\r | |
030cd1a2 | 6227 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6228 | x64.\r | |
ac644614 | 6229 | \r |
6230 | @return The value of Debug Register 7 (DR7).\r | |
6231 | \r | |
6232 | **/\r | |
6233 | UINTN\r | |
6234 | EFIAPI\r | |
6235 | AsmReadDr7 (\r | |
6236 | VOID\r | |
6237 | );\r | |
6238 | \r | |
ac644614 | 6239 | /**\r |
6240 | Writes a value to Debug Register 0 (DR0).\r | |
6241 | \r | |
6242 | Writes and returns a new value to DR0. This function is only available on\r | |
030cd1a2 | 6243 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6244 | \r |
6245 | @param Dr0 The value to write to Dr0.\r | |
6246 | \r | |
6247 | @return The value written to Debug Register 0 (DR0).\r | |
6248 | \r | |
6249 | **/\r | |
6250 | UINTN\r | |
6251 | EFIAPI\r | |
6252 | AsmWriteDr0 (\r | |
6253 | UINTN Dr0\r | |
6254 | );\r | |
6255 | \r | |
ac644614 | 6256 | /**\r |
6257 | Writes a value to Debug Register 1 (DR1).\r | |
6258 | \r | |
6259 | Writes and returns a new value to DR1. This function is only available on\r | |
030cd1a2 | 6260 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6261 | \r |
6262 | @param Dr1 The value to write to Dr1.\r | |
6263 | \r | |
6264 | @return The value written to Debug Register 1 (DR1).\r | |
6265 | \r | |
6266 | **/\r | |
6267 | UINTN\r | |
6268 | EFIAPI\r | |
6269 | AsmWriteDr1 (\r | |
6270 | UINTN Dr1\r | |
6271 | );\r | |
6272 | \r | |
ac644614 | 6273 | /**\r |
6274 | Writes a value to Debug Register 2 (DR2).\r | |
6275 | \r | |
6276 | Writes and returns a new value to DR2. This function is only available on\r | |
030cd1a2 | 6277 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6278 | \r |
6279 | @param Dr2 The value to write to Dr2.\r | |
6280 | \r | |
6281 | @return The value written to Debug Register 2 (DR2).\r | |
6282 | \r | |
6283 | **/\r | |
6284 | UINTN\r | |
6285 | EFIAPI\r | |
6286 | AsmWriteDr2 (\r | |
6287 | UINTN Dr2\r | |
6288 | );\r | |
6289 | \r | |
ac644614 | 6290 | /**\r |
6291 | Writes a value to Debug Register 3 (DR3).\r | |
6292 | \r | |
6293 | Writes and returns a new value to DR3. This function is only available on\r | |
030cd1a2 | 6294 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6295 | \r |
6296 | @param Dr3 The value to write to Dr3.\r | |
6297 | \r | |
6298 | @return The value written to Debug Register 3 (DR3).\r | |
6299 | \r | |
6300 | **/\r | |
6301 | UINTN\r | |
6302 | EFIAPI\r | |
6303 | AsmWriteDr3 (\r | |
6304 | UINTN Dr3\r | |
6305 | );\r | |
6306 | \r | |
ac644614 | 6307 | /**\r |
6308 | Writes a value to Debug Register 4 (DR4).\r | |
6309 | \r | |
6310 | Writes and returns a new value to DR4. This function is only available on\r | |
030cd1a2 | 6311 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6312 | \r |
6313 | @param Dr4 The value to write to Dr4.\r | |
6314 | \r | |
6315 | @return The value written to Debug Register 4 (DR4).\r | |
6316 | \r | |
6317 | **/\r | |
6318 | UINTN\r | |
6319 | EFIAPI\r | |
6320 | AsmWriteDr4 (\r | |
6321 | UINTN Dr4\r | |
6322 | );\r | |
6323 | \r | |
ac644614 | 6324 | /**\r |
6325 | Writes a value to Debug Register 5 (DR5).\r | |
6326 | \r | |
6327 | Writes and returns a new value to DR5. This function is only available on\r | |
030cd1a2 | 6328 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6329 | \r |
6330 | @param Dr5 The value to write to Dr5.\r | |
6331 | \r | |
6332 | @return The value written to Debug Register 5 (DR5).\r | |
6333 | \r | |
6334 | **/\r | |
6335 | UINTN\r | |
6336 | EFIAPI\r | |
6337 | AsmWriteDr5 (\r | |
6338 | UINTN Dr5\r | |
6339 | );\r | |
6340 | \r | |
ac644614 | 6341 | /**\r |
6342 | Writes a value to Debug Register 6 (DR6).\r | |
6343 | \r | |
6344 | Writes and returns a new value to DR6. This function is only available on\r | |
030cd1a2 | 6345 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6346 | \r |
6347 | @param Dr6 The value to write to Dr6.\r | |
6348 | \r | |
6349 | @return The value written to Debug Register 6 (DR6).\r | |
6350 | \r | |
6351 | **/\r | |
6352 | UINTN\r | |
6353 | EFIAPI\r | |
6354 | AsmWriteDr6 (\r | |
6355 | UINTN Dr6\r | |
6356 | );\r | |
6357 | \r | |
ac644614 | 6358 | /**\r |
6359 | Writes a value to Debug Register 7 (DR7).\r | |
6360 | \r | |
6361 | Writes and returns a new value to DR7. This function is only available on\r | |
030cd1a2 | 6362 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6363 | \r |
6364 | @param Dr7 The value to write to Dr7.\r | |
6365 | \r | |
6366 | @return The value written to Debug Register 7 (DR7).\r | |
6367 | \r | |
6368 | **/\r | |
6369 | UINTN\r | |
6370 | EFIAPI\r | |
6371 | AsmWriteDr7 (\r | |
6372 | UINTN Dr7\r | |
6373 | );\r | |
6374 | \r | |
ac644614 | 6375 | /**\r |
6376 | Reads the current value of Code Segment Register (CS).\r | |
6377 | \r | |
6378 | Reads and returns the current value of CS. This function is only available on\r | |
030cd1a2 | 6379 | IA-32 and x64.\r |
ac644614 | 6380 | \r |
6381 | @return The current value of CS.\r | |
6382 | \r | |
6383 | **/\r | |
6384 | UINT16\r | |
6385 | EFIAPI\r | |
6386 | AsmReadCs (\r | |
6387 | VOID\r | |
6388 | );\r | |
6389 | \r | |
ac644614 | 6390 | /**\r |
6391 | Reads the current value of Data Segment Register (DS).\r | |
6392 | \r | |
6393 | Reads and returns the current value of DS. This function is only available on\r | |
030cd1a2 | 6394 | IA-32 and x64.\r |
ac644614 | 6395 | \r |
6396 | @return The current value of DS.\r | |
6397 | \r | |
6398 | **/\r | |
6399 | UINT16\r | |
6400 | EFIAPI\r | |
6401 | AsmReadDs (\r | |
6402 | VOID\r | |
6403 | );\r | |
6404 | \r | |
ac644614 | 6405 | /**\r |
6406 | Reads the current value of Extra Segment Register (ES).\r | |
6407 | \r | |
6408 | Reads and returns the current value of ES. This function is only available on\r | |
030cd1a2 | 6409 | IA-32 and x64.\r |
ac644614 | 6410 | \r |
6411 | @return The current value of ES.\r | |
6412 | \r | |
6413 | **/\r | |
6414 | UINT16\r | |
6415 | EFIAPI\r | |
6416 | AsmReadEs (\r | |
6417 | VOID\r | |
6418 | );\r | |
6419 | \r | |
ac644614 | 6420 | /**\r |
6421 | Reads the current value of FS Data Segment Register (FS).\r | |
6422 | \r | |
6423 | Reads and returns the current value of FS. This function is only available on\r | |
030cd1a2 | 6424 | IA-32 and x64.\r |
ac644614 | 6425 | \r |
6426 | @return The current value of FS.\r | |
6427 | \r | |
6428 | **/\r | |
6429 | UINT16\r | |
6430 | EFIAPI\r | |
6431 | AsmReadFs (\r | |
6432 | VOID\r | |
6433 | );\r | |
6434 | \r | |
ac644614 | 6435 | /**\r |
6436 | Reads the current value of GS Data Segment Register (GS).\r | |
6437 | \r | |
6438 | Reads and returns the current value of GS. This function is only available on\r | |
030cd1a2 | 6439 | IA-32 and x64.\r |
ac644614 | 6440 | \r |
6441 | @return The current value of GS.\r | |
6442 | \r | |
6443 | **/\r | |
6444 | UINT16\r | |
6445 | EFIAPI\r | |
6446 | AsmReadGs (\r | |
6447 | VOID\r | |
6448 | );\r | |
6449 | \r | |
ac644614 | 6450 | /**\r |
6451 | Reads the current value of Stack Segment Register (SS).\r | |
6452 | \r | |
6453 | Reads and returns the current value of SS. This function is only available on\r | |
030cd1a2 | 6454 | IA-32 and x64.\r |
ac644614 | 6455 | \r |
6456 | @return The current value of SS.\r | |
6457 | \r | |
6458 | **/\r | |
6459 | UINT16\r | |
6460 | EFIAPI\r | |
6461 | AsmReadSs (\r | |
6462 | VOID\r | |
6463 | );\r | |
6464 | \r | |
ac644614 | 6465 | /**\r |
6466 | Reads the current value of Task Register (TR).\r | |
6467 | \r | |
6468 | Reads and returns the current value of TR. This function is only available on\r | |
030cd1a2 | 6469 | IA-32 and x64.\r |
ac644614 | 6470 | \r |
6471 | @return The current value of TR.\r | |
6472 | \r | |
6473 | **/\r | |
6474 | UINT16\r | |
6475 | EFIAPI\r | |
6476 | AsmReadTr (\r | |
6477 | VOID\r | |
6478 | );\r | |
6479 | \r | |
ac644614 | 6480 | /**\r |
6481 | Reads the current Global Descriptor Table Register(GDTR) descriptor.\r | |
6482 | \r | |
6483 | Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r | |
030cd1a2 | 6484 | function is only available on IA-32 and x64.\r |
ac644614 | 6485 | \r |
6486 | If Gdtr is NULL, then ASSERT().\r | |
6487 | \r | |
af2dc6a7 | 6488 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 6489 | \r |
6490 | **/\r | |
6491 | VOID\r | |
6492 | EFIAPI\r | |
6493 | AsmReadGdtr (\r | |
2f88bd3a | 6494 | OUT IA32_DESCRIPTOR *Gdtr\r |
ac644614 | 6495 | );\r |
6496 | \r | |
ac644614 | 6497 | /**\r |
6498 | Writes the current Global Descriptor Table Register (GDTR) descriptor.\r | |
6499 | \r | |
6500 | Writes and the current GDTR descriptor specified by Gdtr. This function is\r | |
030cd1a2 | 6501 | only available on IA-32 and x64.\r |
ac644614 | 6502 | \r |
6503 | If Gdtr is NULL, then ASSERT().\r | |
6504 | \r | |
af2dc6a7 | 6505 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 6506 | \r |
6507 | **/\r | |
6508 | VOID\r | |
6509 | EFIAPI\r | |
6510 | AsmWriteGdtr (\r | |
2f88bd3a | 6511 | IN CONST IA32_DESCRIPTOR *Gdtr\r |
ac644614 | 6512 | );\r |
6513 | \r | |
ac644614 | 6514 | /**\r |
17f695ed | 6515 | Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 6516 | \r |
6517 | Reads and returns the current IDTR descriptor and returns it in Idtr. This\r | |
030cd1a2 | 6518 | function is only available on IA-32 and x64.\r |
ac644614 | 6519 | \r |
6520 | If Idtr is NULL, then ASSERT().\r | |
6521 | \r | |
af2dc6a7 | 6522 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 6523 | \r |
6524 | **/\r | |
6525 | VOID\r | |
6526 | EFIAPI\r | |
6527 | AsmReadIdtr (\r | |
2f88bd3a | 6528 | OUT IA32_DESCRIPTOR *Idtr\r |
ac644614 | 6529 | );\r |
6530 | \r | |
ac644614 | 6531 | /**\r |
17f695ed | 6532 | Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 6533 | \r |
6534 | Writes the current IDTR descriptor and returns it in Idtr. This function is\r | |
030cd1a2 | 6535 | only available on IA-32 and x64.\r |
ac644614 | 6536 | \r |
6537 | If Idtr is NULL, then ASSERT().\r | |
6538 | \r | |
af2dc6a7 | 6539 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 6540 | \r |
6541 | **/\r | |
6542 | VOID\r | |
6543 | EFIAPI\r | |
6544 | AsmWriteIdtr (\r | |
2f88bd3a | 6545 | IN CONST IA32_DESCRIPTOR *Idtr\r |
ac644614 | 6546 | );\r |
6547 | \r | |
ac644614 | 6548 | /**\r |
6549 | Reads the current Local Descriptor Table Register(LDTR) selector.\r | |
6550 | \r | |
6551 | Reads and returns the current 16-bit LDTR descriptor value. This function is\r | |
030cd1a2 | 6552 | only available on IA-32 and x64.\r |
ac644614 | 6553 | \r |
6554 | @return The current selector of LDT.\r | |
6555 | \r | |
6556 | **/\r | |
6557 | UINT16\r | |
6558 | EFIAPI\r | |
6559 | AsmReadLdtr (\r | |
6560 | VOID\r | |
6561 | );\r | |
6562 | \r | |
ac644614 | 6563 | /**\r |
17f695ed | 6564 | Writes the current Local Descriptor Table Register (LDTR) selector.\r |
ac644614 | 6565 | \r |
6566 | Writes and the current LDTR descriptor specified by Ldtr. This function is\r | |
030cd1a2 | 6567 | only available on IA-32 and x64.\r |
ac644614 | 6568 | \r |
6569 | @param Ldtr 16-bit LDTR selector value.\r | |
6570 | \r | |
6571 | **/\r | |
6572 | VOID\r | |
6573 | EFIAPI\r | |
6574 | AsmWriteLdtr (\r | |
2f88bd3a | 6575 | IN UINT16 Ldtr\r |
ac644614 | 6576 | );\r |
6577 | \r | |
ac644614 | 6578 | /**\r |
6579 | Save the current floating point/SSE/SSE2 context to a buffer.\r | |
6580 | \r | |
6581 | Saves the current floating point/SSE/SSE2 state to the buffer specified by\r | |
6582 | Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r | |
030cd1a2 | 6583 | available on IA-32 and x64.\r |
ac644614 | 6584 | \r |
6585 | If Buffer is NULL, then ASSERT().\r | |
6586 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
6587 | \r | |
af2dc6a7 | 6588 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 6589 | \r |
6590 | **/\r | |
6591 | VOID\r | |
6592 | EFIAPI\r | |
6593 | AsmFxSave (\r | |
2f88bd3a | 6594 | OUT IA32_FX_BUFFER *Buffer\r |
ac644614 | 6595 | );\r |
6596 | \r | |
ac644614 | 6597 | /**\r |
6598 | Restores the current floating point/SSE/SSE2 context from a buffer.\r | |
6599 | \r | |
6600 | Restores the current floating point/SSE/SSE2 state from the buffer specified\r | |
6601 | by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r | |
030cd1a2 | 6602 | only available on IA-32 and x64.\r |
ac644614 | 6603 | \r |
6604 | If Buffer is NULL, then ASSERT().\r | |
6605 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
6606 | If Buffer was not saved with AsmFxSave(), then ASSERT().\r | |
6607 | \r | |
af2dc6a7 | 6608 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 6609 | \r |
6610 | **/\r | |
6611 | VOID\r | |
6612 | EFIAPI\r | |
6613 | AsmFxRestore (\r | |
2f88bd3a | 6614 | IN CONST IA32_FX_BUFFER *Buffer\r |
ac644614 | 6615 | );\r |
6616 | \r | |
ac644614 | 6617 | /**\r |
6618 | Reads the current value of 64-bit MMX Register #0 (MM0).\r | |
6619 | \r | |
6620 | Reads and returns the current value of MM0. This function is only available\r | |
030cd1a2 | 6621 | on IA-32 and x64.\r |
ac644614 | 6622 | \r |
6623 | @return The current value of MM0.\r | |
6624 | \r | |
6625 | **/\r | |
6626 | UINT64\r | |
6627 | EFIAPI\r | |
6628 | AsmReadMm0 (\r | |
6629 | VOID\r | |
6630 | );\r | |
6631 | \r | |
ac644614 | 6632 | /**\r |
6633 | Reads the current value of 64-bit MMX Register #1 (MM1).\r | |
6634 | \r | |
6635 | Reads and returns the current value of MM1. This function is only available\r | |
030cd1a2 | 6636 | on IA-32 and x64.\r |
ac644614 | 6637 | \r |
6638 | @return The current value of MM1.\r | |
6639 | \r | |
6640 | **/\r | |
6641 | UINT64\r | |
6642 | EFIAPI\r | |
6643 | AsmReadMm1 (\r | |
6644 | VOID\r | |
6645 | );\r | |
6646 | \r | |
ac644614 | 6647 | /**\r |
6648 | Reads the current value of 64-bit MMX Register #2 (MM2).\r | |
6649 | \r | |
6650 | Reads and returns the current value of MM2. This function is only available\r | |
030cd1a2 | 6651 | on IA-32 and x64.\r |
ac644614 | 6652 | \r |
6653 | @return The current value of MM2.\r | |
6654 | \r | |
6655 | **/\r | |
6656 | UINT64\r | |
6657 | EFIAPI\r | |
6658 | AsmReadMm2 (\r | |
6659 | VOID\r | |
6660 | );\r | |
6661 | \r | |
ac644614 | 6662 | /**\r |
6663 | Reads the current value of 64-bit MMX Register #3 (MM3).\r | |
6664 | \r | |
6665 | Reads and returns the current value of MM3. This function is only available\r | |
030cd1a2 | 6666 | on IA-32 and x64.\r |
ac644614 | 6667 | \r |
6668 | @return The current value of MM3.\r | |
6669 | \r | |
6670 | **/\r | |
6671 | UINT64\r | |
6672 | EFIAPI\r | |
6673 | AsmReadMm3 (\r | |
6674 | VOID\r | |
6675 | );\r | |
6676 | \r | |
ac644614 | 6677 | /**\r |
6678 | Reads the current value of 64-bit MMX Register #4 (MM4).\r | |
6679 | \r | |
6680 | Reads and returns the current value of MM4. This function is only available\r | |
030cd1a2 | 6681 | on IA-32 and x64.\r |
ac644614 | 6682 | \r |
6683 | @return The current value of MM4.\r | |
6684 | \r | |
6685 | **/\r | |
6686 | UINT64\r | |
6687 | EFIAPI\r | |
6688 | AsmReadMm4 (\r | |
6689 | VOID\r | |
6690 | );\r | |
6691 | \r | |
ac644614 | 6692 | /**\r |
6693 | Reads the current value of 64-bit MMX Register #5 (MM5).\r | |
6694 | \r | |
6695 | Reads and returns the current value of MM5. This function is only available\r | |
030cd1a2 | 6696 | on IA-32 and x64.\r |
ac644614 | 6697 | \r |
6698 | @return The current value of MM5.\r | |
6699 | \r | |
6700 | **/\r | |
6701 | UINT64\r | |
6702 | EFIAPI\r | |
6703 | AsmReadMm5 (\r | |
6704 | VOID\r | |
6705 | );\r | |
6706 | \r | |
ac644614 | 6707 | /**\r |
6708 | Reads the current value of 64-bit MMX Register #6 (MM6).\r | |
6709 | \r | |
6710 | Reads and returns the current value of MM6. This function is only available\r | |
030cd1a2 | 6711 | on IA-32 and x64.\r |
ac644614 | 6712 | \r |
6713 | @return The current value of MM6.\r | |
6714 | \r | |
6715 | **/\r | |
6716 | UINT64\r | |
6717 | EFIAPI\r | |
6718 | AsmReadMm6 (\r | |
6719 | VOID\r | |
6720 | );\r | |
6721 | \r | |
ac644614 | 6722 | /**\r |
6723 | Reads the current value of 64-bit MMX Register #7 (MM7).\r | |
6724 | \r | |
6725 | Reads and returns the current value of MM7. This function is only available\r | |
030cd1a2 | 6726 | on IA-32 and x64.\r |
ac644614 | 6727 | \r |
6728 | @return The current value of MM7.\r | |
6729 | \r | |
6730 | **/\r | |
6731 | UINT64\r | |
6732 | EFIAPI\r | |
6733 | AsmReadMm7 (\r | |
6734 | VOID\r | |
6735 | );\r | |
6736 | \r | |
ac644614 | 6737 | /**\r |
6738 | Writes the current value of 64-bit MMX Register #0 (MM0).\r | |
6739 | \r | |
6740 | Writes the current value of MM0. This function is only available on IA32 and\r | |
030cd1a2 | 6741 | x64.\r |
ac644614 | 6742 | \r |
6743 | @param Value The 64-bit value to write to MM0.\r | |
6744 | \r | |
6745 | **/\r | |
6746 | VOID\r | |
6747 | EFIAPI\r | |
6748 | AsmWriteMm0 (\r | |
2f88bd3a | 6749 | IN UINT64 Value\r |
ac644614 | 6750 | );\r |
6751 | \r | |
ac644614 | 6752 | /**\r |
6753 | Writes the current value of 64-bit MMX Register #1 (MM1).\r | |
6754 | \r | |
6755 | Writes the current value of MM1. This function is only available on IA32 and\r | |
030cd1a2 | 6756 | x64.\r |
ac644614 | 6757 | \r |
6758 | @param Value The 64-bit value to write to MM1.\r | |
6759 | \r | |
6760 | **/\r | |
6761 | VOID\r | |
6762 | EFIAPI\r | |
6763 | AsmWriteMm1 (\r | |
2f88bd3a | 6764 | IN UINT64 Value\r |
ac644614 | 6765 | );\r |
6766 | \r | |
ac644614 | 6767 | /**\r |
6768 | Writes the current value of 64-bit MMX Register #2 (MM2).\r | |
6769 | \r | |
6770 | Writes the current value of MM2. This function is only available on IA32 and\r | |
030cd1a2 | 6771 | x64.\r |
ac644614 | 6772 | \r |
6773 | @param Value The 64-bit value to write to MM2.\r | |
6774 | \r | |
6775 | **/\r | |
6776 | VOID\r | |
6777 | EFIAPI\r | |
6778 | AsmWriteMm2 (\r | |
2f88bd3a | 6779 | IN UINT64 Value\r |
ac644614 | 6780 | );\r |
6781 | \r | |
ac644614 | 6782 | /**\r |
6783 | Writes the current value of 64-bit MMX Register #3 (MM3).\r | |
6784 | \r | |
6785 | Writes the current value of MM3. This function is only available on IA32 and\r | |
030cd1a2 | 6786 | x64.\r |
ac644614 | 6787 | \r |
6788 | @param Value The 64-bit value to write to MM3.\r | |
6789 | \r | |
6790 | **/\r | |
6791 | VOID\r | |
6792 | EFIAPI\r | |
6793 | AsmWriteMm3 (\r | |
2f88bd3a | 6794 | IN UINT64 Value\r |
ac644614 | 6795 | );\r |
6796 | \r | |
ac644614 | 6797 | /**\r |
6798 | Writes the current value of 64-bit MMX Register #4 (MM4).\r | |
6799 | \r | |
6800 | Writes the current value of MM4. This function is only available on IA32 and\r | |
030cd1a2 | 6801 | x64.\r |
ac644614 | 6802 | \r |
6803 | @param Value The 64-bit value to write to MM4.\r | |
6804 | \r | |
6805 | **/\r | |
6806 | VOID\r | |
6807 | EFIAPI\r | |
6808 | AsmWriteMm4 (\r | |
2f88bd3a | 6809 | IN UINT64 Value\r |
ac644614 | 6810 | );\r |
6811 | \r | |
ac644614 | 6812 | /**\r |
6813 | Writes the current value of 64-bit MMX Register #5 (MM5).\r | |
6814 | \r | |
6815 | Writes the current value of MM5. This function is only available on IA32 and\r | |
030cd1a2 | 6816 | x64.\r |
ac644614 | 6817 | \r |
6818 | @param Value The 64-bit value to write to MM5.\r | |
6819 | \r | |
6820 | **/\r | |
6821 | VOID\r | |
6822 | EFIAPI\r | |
6823 | AsmWriteMm5 (\r | |
2f88bd3a | 6824 | IN UINT64 Value\r |
ac644614 | 6825 | );\r |
6826 | \r | |
ac644614 | 6827 | /**\r |
6828 | Writes the current value of 64-bit MMX Register #6 (MM6).\r | |
6829 | \r | |
6830 | Writes the current value of MM6. This function is only available on IA32 and\r | |
030cd1a2 | 6831 | x64.\r |
ac644614 | 6832 | \r |
6833 | @param Value The 64-bit value to write to MM6.\r | |
6834 | \r | |
6835 | **/\r | |
6836 | VOID\r | |
6837 | EFIAPI\r | |
6838 | AsmWriteMm6 (\r | |
2f88bd3a | 6839 | IN UINT64 Value\r |
ac644614 | 6840 | );\r |
6841 | \r | |
ac644614 | 6842 | /**\r |
6843 | Writes the current value of 64-bit MMX Register #7 (MM7).\r | |
6844 | \r | |
6845 | Writes the current value of MM7. This function is only available on IA32 and\r | |
030cd1a2 | 6846 | x64.\r |
ac644614 | 6847 | \r |
6848 | @param Value The 64-bit value to write to MM7.\r | |
6849 | \r | |
6850 | **/\r | |
6851 | VOID\r | |
6852 | EFIAPI\r | |
6853 | AsmWriteMm7 (\r | |
2f88bd3a | 6854 | IN UINT64 Value\r |
ac644614 | 6855 | );\r |
6856 | \r | |
ac644614 | 6857 | /**\r |
6858 | Reads the current value of Time Stamp Counter (TSC).\r | |
6859 | \r | |
6860 | Reads and returns the current value of TSC. This function is only available\r | |
030cd1a2 | 6861 | on IA-32 and x64.\r |
ac644614 | 6862 | \r |
6863 | @return The current value of TSC\r | |
6864 | \r | |
6865 | **/\r | |
6866 | UINT64\r | |
6867 | EFIAPI\r | |
6868 | AsmReadTsc (\r | |
6869 | VOID\r | |
6870 | );\r | |
6871 | \r | |
ac644614 | 6872 | /**\r |
6873 | Reads the current value of a Performance Counter (PMC).\r | |
6874 | \r | |
6875 | Reads and returns the current value of performance counter specified by\r | |
030cd1a2 | 6876 | Index. This function is only available on IA-32 and x64.\r |
ac644614 | 6877 | \r |
6878 | @param Index The 32-bit Performance Counter index to read.\r | |
6879 | \r | |
6880 | @return The value of the PMC specified by Index.\r | |
6881 | \r | |
6882 | **/\r | |
6883 | UINT64\r | |
6884 | EFIAPI\r | |
6885 | AsmReadPmc (\r | |
2f88bd3a | 6886 | IN UINT32 Index\r |
ac644614 | 6887 | );\r |
6888 | \r | |
ac644614 | 6889 | /**\r |
6890 | Sets up a monitor buffer that is used by AsmMwait().\r | |
6891 | \r | |
6892 | Executes a MONITOR instruction with the register state specified by Eax, Ecx\r | |
030cd1a2 | 6893 | and Edx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 6894 | \r |
6895 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
6896 | instruction.\r | |
6897 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
6898 | instruction.\r | |
6899 | @param Edx The value to load into EDX or RDX before executing the MONITOR\r | |
6900 | instruction.\r | |
6901 | \r | |
6902 | @return Eax\r | |
6903 | \r | |
6904 | **/\r | |
6905 | UINTN\r | |
6906 | EFIAPI\r | |
6907 | AsmMonitor (\r | |
2f88bd3a MK |
6908 | IN UINTN Eax,\r |
6909 | IN UINTN Ecx,\r | |
6910 | IN UINTN Edx\r | |
ac644614 | 6911 | );\r |
6912 | \r | |
ac644614 | 6913 | /**\r |
6914 | Executes an MWAIT instruction.\r | |
6915 | \r | |
6916 | Executes an MWAIT instruction with the register state specified by Eax and\r | |
030cd1a2 | 6917 | Ecx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 6918 | \r |
6919 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
6920 | instruction.\r | |
6921 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
6922 | instruction.\r | |
6923 | \r | |
6924 | @return Eax\r | |
6925 | \r | |
6926 | **/\r | |
6927 | UINTN\r | |
6928 | EFIAPI\r | |
6929 | AsmMwait (\r | |
2f88bd3a MK |
6930 | IN UINTN Eax,\r |
6931 | IN UINTN Ecx\r | |
ac644614 | 6932 | );\r |
6933 | \r | |
ac644614 | 6934 | /**\r |
6935 | Executes a WBINVD instruction.\r | |
6936 | \r | |
6937 | Executes a WBINVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 6938 | x64.\r |
ac644614 | 6939 | \r |
6940 | **/\r | |
6941 | VOID\r | |
6942 | EFIAPI\r | |
6943 | AsmWbinvd (\r | |
6944 | VOID\r | |
6945 | );\r | |
6946 | \r | |
ac644614 | 6947 | /**\r |
6948 | Executes a INVD instruction.\r | |
6949 | \r | |
6950 | Executes a INVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 6951 | x64.\r |
ac644614 | 6952 | \r |
6953 | **/\r | |
6954 | VOID\r | |
6955 | EFIAPI\r | |
6956 | AsmInvd (\r | |
6957 | VOID\r | |
6958 | );\r | |
6959 | \r | |
ac644614 | 6960 | /**\r |
6961 | Flushes a cache line from all the instruction and data caches within the\r | |
6962 | coherency domain of the CPU.\r | |
6963 | \r | |
6964 | Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r | |
030cd1a2 | 6965 | This function is only available on IA-32 and x64.\r |
ac644614 | 6966 | \r |
6967 | @param LinearAddress The address of the cache line to flush. If the CPU is\r | |
6968 | in a physical addressing mode, then LinearAddress is a\r | |
6969 | physical address. If the CPU is in a virtual\r | |
6970 | addressing mode, then LinearAddress is a virtual\r | |
6971 | address.\r | |
6972 | \r | |
af2dc6a7 | 6973 | @return LinearAddress.\r |
ac644614 | 6974 | **/\r |
6975 | VOID *\r | |
6976 | EFIAPI\r | |
6977 | AsmFlushCacheLine (\r | |
2f88bd3a | 6978 | IN VOID *LinearAddress\r |
ac644614 | 6979 | );\r |
6980 | \r | |
ac644614 | 6981 | /**\r |
6982 | Enables the 32-bit paging mode on the CPU.\r | |
6983 | \r | |
6984 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
6985 | must be properly initialized prior to calling this service. This function\r | |
6986 | assumes the current execution mode is 32-bit protected mode. This function is\r | |
6987 | only available on IA-32. After the 32-bit paging mode is enabled, control is\r | |
6988 | transferred to the function specified by EntryPoint using the new stack\r | |
6989 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
6990 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
6991 | EntryPoint must never return.\r | |
6992 | \r | |
6993 | If the current execution mode is not 32-bit protected mode, then ASSERT().\r | |
6994 | If EntryPoint is NULL, then ASSERT().\r | |
6995 | If NewStack is NULL, then ASSERT().\r | |
6996 | \r | |
6997 | There are a number of constraints that must be followed before calling this\r | |
6998 | function:\r | |
6999 | 1) Interrupts must be disabled.\r | |
7000 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r | |
7001 | means all descriptors must have a base of 0 and a limit of 4GB.\r | |
7002 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r | |
7003 | descriptors.\r | |
7004 | 4) CR3 must point to valid page tables that will be used once the transition\r | |
7005 | is complete, and those page tables must guarantee that the pages for this\r | |
7006 | function and the stack are identity mapped.\r | |
7007 | \r | |
7008 | @param EntryPoint A pointer to function to call with the new stack after\r | |
7009 | paging is enabled.\r | |
7010 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
7011 | function as the first parameter after paging is enabled.\r | |
7012 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
7013 | function as the second parameter after paging is enabled.\r | |
7014 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
7015 | function after paging is enabled.\r | |
7016 | \r | |
7017 | **/\r | |
7018 | VOID\r | |
7019 | EFIAPI\r | |
7020 | AsmEnablePaging32 (\r | |
7021 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
d0e2f823 MK |
7022 | IN VOID *Context1 OPTIONAL,\r |
7023 | IN VOID *Context2 OPTIONAL,\r | |
ac644614 | 7024 | IN VOID *NewStack\r |
7025 | );\r | |
7026 | \r | |
ac644614 | 7027 | /**\r |
7028 | Disables the 32-bit paging mode on the CPU.\r | |
7029 | \r | |
7030 | Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r | |
7031 | mode. This function assumes the current execution mode is 32-paged protected\r | |
7032 | mode. This function is only available on IA-32. After the 32-bit paging mode\r | |
7033 | is disabled, control is transferred to the function specified by EntryPoint\r | |
7034 | using the new stack specified by NewStack and passing in the parameters\r | |
7035 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
7036 | may be NULL. The function EntryPoint must never return.\r | |
7037 | \r | |
7038 | If the current execution mode is not 32-bit paged mode, then ASSERT().\r | |
7039 | If EntryPoint is NULL, then ASSERT().\r | |
7040 | If NewStack is NULL, then ASSERT().\r | |
7041 | \r | |
7042 | There are a number of constraints that must be followed before calling this\r | |
7043 | function:\r | |
7044 | 1) Interrupts must be disabled.\r | |
7045 | 2) The caller must be in 32-bit paged mode.\r | |
7046 | 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r | |
7047 | 4) CR3 must point to valid page tables that guarantee that the pages for\r | |
7048 | this function and the stack are identity mapped.\r | |
7049 | \r | |
7050 | @param EntryPoint A pointer to function to call with the new stack after\r | |
7051 | paging is disabled.\r | |
7052 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
7053 | function as the first parameter after paging is disabled.\r | |
7054 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
7055 | function as the second parameter after paging is\r | |
7056 | disabled.\r | |
7057 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
7058 | function after paging is disabled.\r | |
7059 | \r | |
7060 | **/\r | |
7061 | VOID\r | |
7062 | EFIAPI\r | |
7063 | AsmDisablePaging32 (\r | |
7064 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
d0e2f823 MK |
7065 | IN VOID *Context1 OPTIONAL,\r |
7066 | IN VOID *Context2 OPTIONAL,\r | |
ac644614 | 7067 | IN VOID *NewStack\r |
7068 | );\r | |
7069 | \r | |
ac644614 | 7070 | /**\r |
7071 | Enables the 64-bit paging mode on the CPU.\r | |
7072 | \r | |
7073 | Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
7074 | must be properly initialized prior to calling this service. This function\r | |
7075 | assumes the current execution mode is 32-bit protected mode with flat\r | |
7076 | descriptors. This function is only available on IA-32. After the 64-bit\r | |
7077 | paging mode is enabled, control is transferred to the function specified by\r | |
7078 | EntryPoint using the new stack specified by NewStack and passing in the\r | |
7079 | parameters specified by Context1 and Context2. Context1 and Context2 are\r | |
7080 | optional and may be 0. The function EntryPoint must never return.\r | |
7081 | \r | |
7082 | If the current execution mode is not 32-bit protected mode with flat\r | |
7083 | descriptors, then ASSERT().\r | |
7084 | If EntryPoint is 0, then ASSERT().\r | |
7085 | If NewStack is 0, then ASSERT().\r | |
7086 | \r | |
17f695ed | 7087 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 7088 | is called. The descriptor in the GDT that this selector\r |
7089 | references must be setup for long mode.\r | |
7090 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
7091 | the new stack after paging is enabled.\r | |
7092 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
7093 | the EntryPoint function as the first parameter after\r | |
7094 | paging is enabled.\r | |
7095 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
7096 | the EntryPoint function as the second parameter after\r | |
7097 | paging is enabled.\r | |
7098 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
7099 | the EntryPoint function after paging is enabled.\r | |
7100 | \r | |
7101 | **/\r | |
7102 | VOID\r | |
7103 | EFIAPI\r | |
7104 | AsmEnablePaging64 (\r | |
2f88bd3a MK |
7105 | IN UINT16 Cs,\r |
7106 | IN UINT64 EntryPoint,\r | |
7107 | IN UINT64 Context1 OPTIONAL,\r | |
7108 | IN UINT64 Context2 OPTIONAL,\r | |
7109 | IN UINT64 NewStack\r | |
ac644614 | 7110 | );\r |
7111 | \r | |
ac644614 | 7112 | /**\r |
7113 | Disables the 64-bit paging mode on the CPU.\r | |
7114 | \r | |
7115 | Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r | |
7116 | mode. This function assumes the current execution mode is 64-paging mode.\r | |
030cd1a2 | 7117 | This function is only available on x64. After the 64-bit paging mode is\r |
ac644614 | 7118 | disabled, control is transferred to the function specified by EntryPoint\r |
7119 | using the new stack specified by NewStack and passing in the parameters\r | |
7120 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
7121 | may be 0. The function EntryPoint must never return.\r | |
7122 | \r | |
7123 | If the current execution mode is not 64-bit paged mode, then ASSERT().\r | |
7124 | If EntryPoint is 0, then ASSERT().\r | |
7125 | If NewStack is 0, then ASSERT().\r | |
7126 | \r | |
17f695ed | 7127 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 7128 | is called. The descriptor in the GDT that this selector\r |
7129 | references must be setup for 32-bit protected mode.\r | |
7130 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
7131 | the new stack after paging is disabled.\r | |
7132 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
7133 | the EntryPoint function as the first parameter after\r | |
7134 | paging is disabled.\r | |
7135 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
7136 | the EntryPoint function as the second parameter after\r | |
7137 | paging is disabled.\r | |
7138 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
7139 | the EntryPoint function after paging is disabled.\r | |
7140 | \r | |
7141 | **/\r | |
7142 | VOID\r | |
7143 | EFIAPI\r | |
7144 | AsmDisablePaging64 (\r | |
2f88bd3a MK |
7145 | IN UINT16 Cs,\r |
7146 | IN UINT32 EntryPoint,\r | |
7147 | IN UINT32 Context1 OPTIONAL,\r | |
7148 | IN UINT32 Context2 OPTIONAL,\r | |
7149 | IN UINT32 NewStack\r | |
ac644614 | 7150 | );\r |
7151 | \r | |
ac644614 | 7152 | //\r |
7153 | // 16-bit thunking services\r | |
7154 | //\r | |
7155 | \r | |
7156 | /**\r | |
7157 | Retrieves the properties for 16-bit thunk functions.\r | |
7158 | \r | |
7159 | Computes the size of the buffer and stack below 1MB required to use the\r | |
7160 | AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r | |
7161 | buffer size is returned in RealModeBufferSize, and the stack size is returned\r | |
7162 | in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r | |
7163 | then the actual minimum stack size is ExtraStackSize plus the maximum number\r | |
7164 | of bytes that need to be passed to the 16-bit real mode code.\r | |
9095d37b | 7165 | \r |
ac644614 | 7166 | If RealModeBufferSize is NULL, then ASSERT().\r |
7167 | If ExtraStackSize is NULL, then ASSERT().\r | |
7168 | \r | |
7169 | @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r | |
7170 | required to use the 16-bit thunk functions.\r | |
7171 | @param ExtraStackSize A pointer to the extra size of stack below 1MB\r | |
7172 | that the 16-bit thunk functions require for\r | |
7173 | temporary storage in the transition to and from\r | |
7174 | 16-bit real mode.\r | |
7175 | \r | |
7176 | **/\r | |
7177 | VOID\r | |
7178 | EFIAPI\r | |
7179 | AsmGetThunk16Properties (\r | |
2f88bd3a MK |
7180 | OUT UINT32 *RealModeBufferSize,\r |
7181 | OUT UINT32 *ExtraStackSize\r | |
ac644614 | 7182 | );\r |
7183 | \r | |
ac644614 | 7184 | /**\r |
7185 | Prepares all structures a code required to use AsmThunk16().\r | |
7186 | \r | |
7187 | Prepares all structures and code required to use AsmThunk16().\r | |
9095d37b | 7188 | \r |
8243b089 | 7189 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
7190 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
ac644614 | 7191 | \r |
7192 | If ThunkContext is NULL, then ASSERT().\r | |
7193 | \r | |
7194 | @param ThunkContext A pointer to the context structure that describes the\r | |
7195 | 16-bit real mode code to call.\r | |
7196 | \r | |
7197 | **/\r | |
7198 | VOID\r | |
7199 | EFIAPI\r | |
7200 | AsmPrepareThunk16 (\r | |
2f88bd3a | 7201 | IN OUT THUNK_CONTEXT *ThunkContext\r |
ac644614 | 7202 | );\r |
7203 | \r | |
ac644614 | 7204 | /**\r |
7205 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
7206 | \r | |
7207 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
17f695ed | 7208 | AsmPrepareThunk16() must be called with ThunkContext before this function is used.\r |
7209 | This function must be called with interrupts disabled.\r | |
7210 | \r | |
9095d37b LG |
7211 | The register state from the RealModeState field of ThunkContext is restored just prior\r |
7212 | to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,\r | |
17f695ed | 7213 | which is used to set the interrupt state when a 16-bit real mode entry point is called.\r |
7214 | Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.\r | |
9095d37b LG |
7215 | The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to\r |
7216 | the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.\r | |
17f695ed | 7217 | The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,\r |
9095d37b LG |
7218 | so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment\r |
7219 | and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry\r | |
7220 | point must exit with a RETF instruction. The register state is captured into RealModeState immediately\r | |
17f695ed | 7221 | after the RETF instruction is executed.\r |
9095d37b LG |
7222 | \r |
7223 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,\r | |
7224 | or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure\r | |
7225 | the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.\r | |
7226 | \r | |
7227 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,\r | |
7228 | then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.\r | |
17f695ed | 7229 | This includes the base vectors, the interrupt masks, and the edge/level trigger mode.\r |
9095d37b LG |
7230 | \r |
7231 | If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code\r | |
17f695ed | 7232 | is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.\r |
9095d37b LG |
7233 | \r |
7234 | If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in\r | |
7235 | ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to\r | |
17f695ed | 7236 | disable the A20 mask.\r |
9095d37b LG |
7237 | \r |
7238 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in\r | |
7239 | ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,\r | |
17f695ed | 7240 | then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r |
9095d37b LG |
7241 | \r |
7242 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in\r | |
17f695ed | 7243 | ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r |
9095d37b | 7244 | \r |
ac644614 | 7245 | If ThunkContext is NULL, then ASSERT().\r |
7246 | If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r | |
9095d37b | 7247 | If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in\r |
17f695ed | 7248 | ThunkAttributes, then ASSERT().\r |
ac644614 | 7249 | \r |
8243b089 | 7250 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
af2dc6a7 | 7251 | virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.\r |
52fa075c | 7252 | \r |
ac644614 | 7253 | @param ThunkContext A pointer to the context structure that describes the\r |
7254 | 16-bit real mode code to call.\r | |
7255 | \r | |
7256 | **/\r | |
7257 | VOID\r | |
7258 | EFIAPI\r | |
7259 | AsmThunk16 (\r | |
2f88bd3a | 7260 | IN OUT THUNK_CONTEXT *ThunkContext\r |
ac644614 | 7261 | );\r |
7262 | \r | |
ac644614 | 7263 | /**\r |
7264 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
7265 | control to a 16-bit real mode entry point, and returns the results.\r | |
7266 | \r | |
7267 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
7268 | control to a 16-bit real mode entry point, and returns the results. If the\r | |
7269 | caller only need to perform a single 16-bit real mode thunk, then this\r | |
7270 | service should be used. If the caller intends to make more than one 16-bit\r | |
7271 | real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r | |
7272 | once and AsmThunk16() can be called for each 16-bit real mode thunk.\r | |
7273 | \r | |
8243b089 | 7274 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
7275 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
52fa075c | 7276 | \r |
17f695ed | 7277 | See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.\r |
ac644614 | 7278 | \r |
7279 | @param ThunkContext A pointer to the context structure that describes the\r | |
7280 | 16-bit real mode code to call.\r | |
7281 | \r | |
7282 | **/\r | |
7283 | VOID\r | |
7284 | EFIAPI\r | |
7285 | AsmPrepareAndThunk16 (\r | |
2f88bd3a | 7286 | IN OUT THUNK_CONTEXT *ThunkContext\r |
ac644614 | 7287 | );\r |
7288 | \r | |
3cfc7813 QL |
7289 | /**\r |
7290 | Generates a 16-bit random number through RDRAND instruction.\r | |
7291 | \r | |
7292 | if Rand is NULL, then ASSERT().\r | |
7293 | \r | |
7294 | @param[out] Rand Buffer pointer to store the random result.\r | |
7295 | \r | |
7296 | @retval TRUE RDRAND call was successful.\r | |
7297 | @retval FALSE Failed attempts to call RDRAND.\r | |
7298 | \r | |
7299 | **/\r | |
7300 | BOOLEAN\r | |
7301 | EFIAPI\r | |
7302 | AsmRdRand16 (\r | |
2f88bd3a | 7303 | OUT UINT16 *Rand\r |
3cfc7813 QL |
7304 | );\r |
7305 | \r | |
7306 | /**\r | |
7307 | Generates a 32-bit random number through RDRAND instruction.\r | |
7308 | \r | |
7309 | if Rand is NULL, then ASSERT().\r | |
7310 | \r | |
7311 | @param[out] Rand Buffer pointer to store the random result.\r | |
7312 | \r | |
7313 | @retval TRUE RDRAND call was successful.\r | |
7314 | @retval FALSE Failed attempts to call RDRAND.\r | |
7315 | \r | |
7316 | **/\r | |
7317 | BOOLEAN\r | |
7318 | EFIAPI\r | |
7319 | AsmRdRand32 (\r | |
2f88bd3a | 7320 | OUT UINT32 *Rand\r |
3cfc7813 QL |
7321 | );\r |
7322 | \r | |
7323 | /**\r | |
7324 | Generates a 64-bit random number through RDRAND instruction.\r | |
7325 | \r | |
7326 | if Rand is NULL, then ASSERT().\r | |
7327 | \r | |
7328 | @param[out] Rand Buffer pointer to store the random result.\r | |
7329 | \r | |
7330 | @retval TRUE RDRAND call was successful.\r | |
7331 | @retval FALSE Failed attempts to call RDRAND.\r | |
7332 | \r | |
7333 | **/\r | |
7334 | BOOLEAN\r | |
7335 | EFIAPI\r | |
7336 | AsmRdRand64 (\r | |
2f88bd3a | 7337 | OUT UINT64 *Rand\r |
3cfc7813 QL |
7338 | );\r |
7339 | \r | |
364a5474 | 7340 | /**\r |
47595ac0 | 7341 | Load given selector into TR register.\r |
364a5474 JW |
7342 | \r |
7343 | @param[in] Selector Task segment selector\r | |
7344 | **/\r | |
7345 | VOID\r | |
7346 | EFIAPI\r | |
7347 | AsmWriteTr (\r | |
2f88bd3a | 7348 | IN UINT16 Selector\r |
364a5474 JW |
7349 | );\r |
7350 | \r | |
2ecd8299 HW |
7351 | /**\r |
7352 | Performs a serializing operation on all load-from-memory instructions that\r | |
7353 | were issued prior the AsmLfence function.\r | |
7354 | \r | |
7355 | Executes a LFENCE instruction. This function is only available on IA-32 and x64.\r | |
7356 | \r | |
7357 | **/\r | |
7358 | VOID\r | |
7359 | EFIAPI\r | |
7360 | AsmLfence (\r | |
7361 | VOID\r | |
7362 | );\r | |
7363 | \r | |
9b3ca509 TL |
7364 | /**\r |
7365 | Executes a XGETBV instruction\r | |
7366 | \r | |
7367 | Executes a XGETBV instruction. This function is only available on IA-32 and\r | |
7368 | x64.\r | |
7369 | \r | |
7370 | @param[in] Index Extended control register index\r | |
7371 | \r | |
7372 | @return The current value of the extended control register\r | |
7373 | **/\r | |
7374 | UINT64\r | |
7375 | EFIAPI\r | |
7376 | AsmXGetBv (\r | |
7377 | IN UINT32 Index\r | |
7378 | );\r | |
7379 | \r | |
4ac02962 JW |
7380 | /**\r |
7381 | Executes a XSETBV instruction to write a 64-bit value to a Extended Control\r | |
7382 | Register(XCR), and returns the value.\r | |
7383 | \r | |
7384 | Writes the 64-bit value specified by Value to the XCR specified by Index. The\r | |
7385 | 64-bit value written to the XCR is returned. No parameter checking is\r | |
7386 | performed on Index or Value, and some of these may cause CPU exceptions. The\r | |
7387 | caller must either guarantee that Index and Value are valid, or the caller\r | |
7388 | must establish proper exception handlers. This function is only available on\r | |
7389 | IA-32 and x64.\r | |
7390 | \r | |
7391 | @param Index The 32-bit XCR index to write.\r | |
7392 | @param Value The 64-bit value to write to the XCR.\r | |
7393 | \r | |
7394 | @return Value\r | |
7395 | \r | |
7396 | **/\r | |
7397 | UINT64\r | |
7398 | EFIAPI\r | |
7399 | AsmXSetBv (\r | |
7400 | IN UINT32 Index,\r | |
7401 | IN UINT64 Value\r | |
7402 | );\r | |
9b3ca509 | 7403 | \r |
f8422f1e TL |
7404 | /**\r |
7405 | Executes a VMGEXIT instruction (VMMCALL with a REP prefix)\r | |
7406 | \r | |
7407 | Executes a VMGEXIT instruction. This function is only available on IA-32 and\r | |
7408 | x64.\r | |
7409 | \r | |
7410 | **/\r | |
7411 | VOID\r | |
7412 | EFIAPI\r | |
7413 | AsmVmgExit (\r | |
7414 | VOID\r | |
7415 | );\r | |
7416 | \r | |
8596c140 LE |
7417 | /**\r |
7418 | Patch the immediate operand of an IA32 or X64 instruction such that the byte,\r | |
7419 | word, dword or qword operand is encoded at the end of the instruction's\r | |
7420 | binary representation.\r | |
7421 | \r | |
7422 | This function should be used to update object code that was compiled with\r | |
7423 | NASM from assembly source code. Example:\r | |
7424 | \r | |
7425 | NASM source code:\r | |
7426 | \r | |
7427 | mov eax, strict dword 0 ; the imm32 zero operand will be patched\r | |
7428 | ASM_PFX(gPatchCr3):\r | |
7429 | mov cr3, eax\r | |
7430 | \r | |
7431 | C source code:\r | |
7432 | \r | |
7433 | X86_ASSEMBLY_PATCH_LABEL gPatchCr3;\r | |
7434 | PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);\r | |
7435 | \r | |
7436 | @param[out] InstructionEnd Pointer right past the instruction to patch. The\r | |
7437 | immediate operand to patch is expected to\r | |
7438 | comprise the trailing bytes of the instruction.\r | |
7439 | If InstructionEnd is closer to address 0 than\r | |
7440 | ValueSize permits, then ASSERT().\r | |
7441 | \r | |
7442 | @param[in] PatchValue The constant to write to the immediate operand.\r | |
7443 | The caller is responsible for ensuring that\r | |
7444 | PatchValue can be represented in the byte, word,\r | |
7445 | dword or qword operand (as indicated through\r | |
7446 | ValueSize); otherwise ASSERT().\r | |
7447 | \r | |
7448 | @param[in] ValueSize The size of the operand in bytes; must be 1, 2,\r | |
7449 | 4, or 8. ASSERT() otherwise.\r | |
7450 | **/\r | |
7451 | VOID\r | |
7452 | EFIAPI\r | |
7453 | PatchInstructionX86 (\r | |
2f88bd3a MK |
7454 | OUT X86_ASSEMBLY_PATCH_LABEL *InstructionEnd,\r |
7455 | IN UINT64 PatchValue,\r | |
7456 | IN UINTN ValueSize\r | |
8596c140 LE |
7457 | );\r |
7458 | \r | |
de4f7f52 LE |
7459 | #endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
7460 | #endif // !defined (__BASE_LIB__)\r |