]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / BaseLib / BaseLibInternal.h
CommitLineData
3eb9473e 1/*++\r
2\r
3Copyright (c) 2004 - 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12\r
13Module Name:\r
14\r
15 BaseLibInternal.h\r
16 \r
17Abstract: \r
18\r
19 Declaration of internal functions in BaseLib.\r
20\r
21--*/\r
22\r
23#ifndef __BASE_LIB_INTERNAL_H__\r
24#define __BASE_LIB_INTERNAL_H__\r
25\r
26#include "EdkIIGlueBase.h"\r
27\r
28#define QUIENT_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 / 10)\r
29#define REMINDER_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 % 10)\r
30\r
31#define QUIENT_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 / 16)\r
32#define REMINDER_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 % 16)\r
33\r
34#define QUIENT_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 / 10)\r
35#define REMINDER_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 % 10)\r
36\r
37#define QUIENT_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 / 16)\r
38#define REMINDER_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 % 16)\r
39\r
40//\r
41// Math functions\r
42//\r
43\r
44/**\r
45 Shifts a 64-bit integer left between 0 and 63 bits. The low bits\r
46 are filled with zeros. The shifted value is returned.\r
47\r
48 This function shifts the 64-bit value Operand to the left by Count bits. The\r
49 low Count bits are set to zero. The shifted value is returned.\r
50\r
51 @param Operand The 64-bit operand to shift left.\r
52 @param Count The number of bits to shift left.\r
53\r
54 @return Operand << Count\r
55\r
56**/\r
57UINT64\r
58EFIAPI\r
59InternalMathLShiftU64 (\r
60 IN UINT64 Operand,\r
61 IN UINTN Count\r
62 );\r
63\r
64/**\r
65 Shifts a 64-bit integer right between 0 and 63 bits. This high bits\r
66 are filled with zeros. The shifted value is returned.\r
67\r
68 This function shifts the 64-bit value Operand to the right by Count bits. The\r
69 high Count bits are set to zero. The shifted value is returned.\r
70\r
71 @param Operand The 64-bit operand to shift right.\r
72 @param Count The number of bits to shift right.\r
73\r
74 @return Operand >> Count\r
75\r
76**/\r
77UINT64\r
78EFIAPI\r
79InternalMathRShiftU64 (\r
80 IN UINT64 Operand,\r
81 IN UINTN Count\r
82 );\r
83\r
84/**\r
85 Shifts a 64-bit integer right between 0 and 63 bits. The high bits\r
86 are filled with original integer's bit 63. The shifted value is returned.\r
87\r
88 This function shifts the 64-bit value Operand to the right by Count bits. The\r
89 high Count bits are set to bit 63 of Operand. The shifted value is returned.\r
90\r
91 @param Operand The 64-bit operand to shift right.\r
92 @param Count The number of bits to shift right.\r
93\r
94 @return Operand arithmetically shifted right by Count\r
95\r
96**/\r
97UINT64\r
98EFIAPI\r
99InternalMathARShiftU64 (\r
100 IN UINT64 Operand,\r
101 IN UINTN Count\r
102 );\r
103\r
104/**\r
105 Rotates a 64-bit integer left between 0 and 63 bits, filling\r
106 the low bits with the high bits that were rotated.\r
107\r
108 This function rotates the 64-bit value Operand to the left by Count bits. The\r
109 low Count bits are fill with the high Count bits of Operand. The rotated\r
110 value is returned.\r
111\r
112 @param Operand The 64-bit operand to rotate left.\r
113 @param Count The number of bits to rotate left.\r
114\r
115 @return Operand <<< Count\r
116\r
117**/\r
118UINT64\r
119EFIAPI\r
120InternalMathLRotU64 (\r
121 IN UINT64 Operand,\r
122 IN UINTN Count\r
123 );\r
124\r
125/**\r
126 Rotates a 64-bit integer right between 0 and 63 bits, filling\r
127 the high bits with the high low bits that were rotated.\r
128\r
129 This function rotates the 64-bit value Operand to the right by Count bits.\r
130 The high Count bits are fill with the low Count bits of Operand. The rotated\r
131 value is returned.\r
132\r
133 @param Operand The 64-bit operand to rotate right.\r
134 @param Count The number of bits to rotate right.\r
135\r
136 @return Operand >>> Count\r
137\r
138**/\r
139UINT64\r
140EFIAPI\r
141InternalMathRRotU64 (\r
142 IN UINT64 Operand,\r
143 IN UINTN Count\r
144 );\r
145\r
146/**\r
147 Switches the endianess of a 64-bit integer.\r
148\r
149 This function swaps the bytes in a 64-bit unsigned value to switch the value\r
150 from little endian to big endian or vice versa. The byte swapped value is\r
151 returned.\r
152\r
153 @param Operand A 64-bit unsigned value.\r
154\r
155 @return The byte swaped Operand.\r
156\r
157**/\r
158UINT64\r
159EFIAPI\r
160InternalMathSwapBytes64 (\r
161 IN UINT64 Operand\r
162 );\r
163\r
164/**\r
165 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer\r
166 and generates a 64-bit unsigned result.\r
167\r
168 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r
169 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
170 bit unsigned result is returned.\r
171\r
172 @param Multiplicand A 64-bit unsigned value.\r
173 @param Multiplier A 32-bit unsigned value.\r
174\r
175 @return Multiplicand * Multiplier\r
176\r
177**/\r
178UINT64\r
179EFIAPI\r
180InternalMathMultU64x32 (\r
181 IN UINT64 Multiplicand,\r
182 IN UINT32 Multiplier\r
183 );\r
184\r
185/**\r
186 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer\r
187 and generates a 64-bit unsigned result.\r
188\r
189 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
190 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
191 bit unsigned result is returned.\r
192\r
193 @param Multiplicand A 64-bit unsigned value.\r
194 @param Multiplier A 64-bit unsigned value.\r
195\r
196 @return Multiplicand * Multiplier\r
197\r
198**/\r
199UINT64\r
200EFIAPI\r
201InternalMathMultU64x64 (\r
202 IN UINT64 Multiplicand,\r
203 IN UINT64 Multiplier\r
204 );\r
205\r
206/**\r
207 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
208 generates a 64-bit unsigned result.\r
209\r
210 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
211 unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
212 function returns the 64-bit unsigned quotient.\r
213\r
214 @param Dividend A 64-bit unsigned value.\r
215 @param Divisor A 32-bit unsigned value.\r
216\r
217 @return Dividend / Divisor\r
218\r
219**/\r
220UINT64\r
221EFIAPI\r
222InternalMathDivU64x32 (\r
223 IN UINT64 Dividend,\r
224 IN UINT32 Divisor\r
225 );\r
226\r
227/**\r
228 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
229 generates a 32-bit unsigned remainder.\r
230\r
231 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
232 unsigned value Divisor and generates a 32-bit remainder. This function\r
233 returns the 32-bit unsigned remainder.\r
234\r
235 @param Dividend A 64-bit unsigned value.\r
236 @param Divisor A 32-bit unsigned value.\r
237\r
238 @return Dividend % Divisor\r
239\r
240**/\r
241UINT32\r
242EFIAPI\r
243InternalMathModU64x32 (\r
244 IN UINT64 Dividend,\r
245 IN UINT32 Divisor\r
246 );\r
247\r
248/**\r
249 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
250 generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
251\r
252 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
253 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
254 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r
255 This function returns the 64-bit unsigned quotient.\r
256\r
257 @param Dividend A 64-bit unsigned value.\r
258 @param Divisor A 32-bit unsigned value.\r
259 @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r
260 optional and may be NULL.\r
261\r
262 @return Dividend / Divisor\r
263\r
264**/\r
265UINT64\r
266EFIAPI\r
267InternalMathDivRemU64x32 (\r
268 IN UINT64 Dividend,\r
269 IN UINT32 Divisor,\r
270 OUT UINT32 *Remainder\r
271 );\r
272\r
273/**\r
274 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and\r
275 generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
276\r
277 This function divides the 64-bit unsigned value Dividend by the 64-bit\r
278 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
279 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
280 This function returns the 64-bit unsigned quotient.\r
281\r
282 @param Dividend A 64-bit unsigned value.\r
283 @param Divisor A 64-bit unsigned value.\r
284 @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r
285 optional and may be NULL.\r
286\r
287 @return Dividend / Divisor\r
288\r
289**/\r
290UINT64\r
291EFIAPI\r
292InternalMathDivRemU64x64 (\r
293 IN UINT64 Dividend,\r
294 IN UINT64 Divisor,\r
295 OUT UINT64 *Remainder\r
296 );\r
297\r
298/**\r
299 Divides a 64-bit signed integer by a 64-bit signed integer and\r
300 generates a 64-bit signed result and a optional 64-bit signed remainder.\r
301\r
302 This function divides the 64-bit unsigned value Dividend by the 64-bit\r
303 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
304 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
305 This function returns the 64-bit unsigned quotient.\r
306\r
307 @param Dividend A 64-bit signed value.\r
308 @param Divisor A 64-bit signed value.\r
309 @param Remainder A pointer to a 64-bit signed value. This parameter is\r
310 optional and may be NULL.\r
311\r
312 @return Dividend / Divisor\r
313\r
314**/\r
315INT64\r
316InternalMathDivRemS64x64 (\r
317 IN INT64 Dividend,\r
318 IN INT64 Divisor,\r
319 OUT INT64 *Remainder OPTIONAL\r
320 );\r
321\r
322/**\r
323 Transfers control to a function starting with a new stack.\r
324\r
325 Transfers control to the function specified by EntryPoint using the new stack\r
326 specified by NewStack and passing in the parameters specified by Context1 and\r
327 Context2. Context1 and Context2 are optional and may be NULL. The function\r
328 EntryPoint must never return.\r
329\r
330 @param EntryPoint A pointer to function to call with the new stack.\r
331 @param Context1 A pointer to the context to pass into the EntryPoint\r
332 function.\r
333 @param Context2 A pointer to the context to pass into the EntryPoint\r
334 function.\r
335 @param NewStack A pointer to the new stack to use for the EntryPoint\r
336 function.\r
337\r
338**/\r
339VOID\r
340EFIAPI\r
341InternalSwitchStack (\r
342 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
343 IN VOID *Context1,\r
344 IN VOID *Context2,\r
345 IN VOID *NewStack\r
346 );\r
347\r
348//\r
349// Ia32 and x64 specific functions\r
350//\r
351\r
352/**\r
353 Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
354\r
355 Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
356 function is only available on IA-32 and X64.\r
357\r
358 @param Gdtr Pointer to a GDTR descriptor.\r
359\r
360**/\r
361VOID\r
362EFIAPI\r
363InternalX86ReadGdtr (\r
364 OUT IA32_DESCRIPTOR *Gdtr\r
365 );\r
366\r
367/**\r
368 Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
369\r
370 Writes and the current GDTR descriptor specified by Gdtr. This function is\r
371 only available on IA-32 and X64.\r
372\r
373 @param Gdtr Pointer to a GDTR descriptor.\r
374\r
375**/\r
376VOID\r
377EFIAPI\r
378InternalX86WriteGdtr (\r
379 IN CONST IA32_DESCRIPTOR *Gdtr\r
380 );\r
381\r
382/**\r
383 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
384\r
385 Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
386 function is only available on IA-32 and X64.\r
387\r
388 @param Idtr Pointer to a IDTR descriptor.\r
389\r
390**/\r
391VOID\r
392EFIAPI\r
393InternalX86ReadIdtr (\r
394 OUT IA32_DESCRIPTOR *Idtr\r
395 );\r
396\r
397/**\r
398 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
399\r
400 Writes the current IDTR descriptor and returns it in Idtr. This function is\r
401 only available on IA-32 and X64.\r
402\r
403 @param Idtr Pointer to a IDTR descriptor.\r
404\r
405**/\r
406VOID\r
407EFIAPI\r
408InternalX86WriteIdtr (\r
409 IN CONST IA32_DESCRIPTOR *Idtr\r
410 );\r
411\r
412/**\r
413 Save the current floating point/SSE/SSE2 context to a buffer.\r
414\r
415 Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
416 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
417 available on IA-32 and X64.\r
418\r
419 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
420\r
421**/\r
422VOID\r
423EFIAPI\r
424InternalX86FxSave (\r
425 OUT IA32_FX_BUFFER *Buffer\r
426 );\r
427\r
428/**\r
429 Restores the current floating point/SSE/SSE2 context from a buffer.\r
430\r
431 Restores the current floating point/SSE/SSE2 state from the buffer specified\r
432 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
433 only available on IA-32 and X64.\r
434\r
435 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
436\r
437**/\r
438VOID\r
439EFIAPI\r
440InternalX86FxRestore (\r
441 IN CONST IA32_FX_BUFFER *Buffer\r
442 );\r
443\r
444/**\r
445 Enables the 32-bit paging mode on the CPU.\r
446\r
447 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
448 must be properly initialized prior to calling this service. This function\r
449 assumes the current execution mode is 32-bit protected mode. This function is\r
450 only available on IA-32. After the 32-bit paging mode is enabled, control is\r
451 transferred to the function specified by EntryPoint using the new stack\r
452 specified by NewStack and passing in the parameters specified by Context1 and\r
453 Context2. Context1 and Context2 are optional and may be NULL. The function\r
454 EntryPoint must never return.\r
455\r
456 There are a number of constraints that must be followed before calling this\r
457 function:\r
458 1) Interrupts must be disabled.\r
459 2) The caller must be in 32-bit protected mode with flat descriptors. This\r
460 means all descriptors must have a base of 0 and a limit of 4GB.\r
461 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
462 descriptors.\r
463 4) CR3 must point to valid page tables that will be used once the transition\r
464 is complete, and those page tables must guarantee that the pages for this\r
465 function and the stack are identity mapped.\r
466\r
467 @param EntryPoint A pointer to function to call with the new stack after\r
468 paging is enabled.\r
469 @param Context1 A pointer to the context to pass into the EntryPoint\r
470 function as the first parameter after paging is enabled.\r
471 @param Context2 A pointer to the context to pass into the EntryPoint\r
472 function as the second parameter after paging is enabled.\r
473 @param NewStack A pointer to the new stack to use for the EntryPoint\r
474 function after paging is enabled.\r
475\r
476**/\r
477VOID\r
478EFIAPI\r
479InternalX86EnablePaging32 (\r
480 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
481 IN VOID *Context1, OPTIONAL\r
482 IN VOID *Context2, OPTIONAL\r
483 IN VOID *NewStack\r
484 );\r
485\r
486/**\r
487 Disables the 32-bit paging mode on the CPU.\r
488\r
489 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
490 mode. This function assumes the current execution mode is 32-paged protected\r
491 mode. This function is only available on IA-32. After the 32-bit paging mode\r
492 is disabled, control is transferred to the function specified by EntryPoint\r
493 using the new stack specified by NewStack and passing in the parameters\r
494 specified by Context1 and Context2. Context1 and Context2 are optional and\r
495 may be NULL. The function EntryPoint must never return.\r
496\r
497 There are a number of constraints that must be followed before calling this\r
498 function:\r
499 1) Interrupts must be disabled.\r
500 2) The caller must be in 32-bit paged mode.\r
501 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
502 4) CR3 must point to valid page tables that guarantee that the pages for\r
503 this function and the stack are identity mapped.\r
504\r
505 @param EntryPoint A pointer to function to call with the new stack after\r
506 paging is disabled.\r
507 @param Context1 A pointer to the context to pass into the EntryPoint\r
508 function as the first parameter after paging is disabled.\r
509 @param Context2 A pointer to the context to pass into the EntryPoint\r
510 function as the second parameter after paging is\r
511 disabled.\r
512 @param NewStack A pointer to the new stack to use for the EntryPoint\r
513 function after paging is disabled.\r
514\r
515**/\r
516VOID\r
517EFIAPI\r
518InternalX86DisablePaging32 (\r
519 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
520 IN VOID *Context1, OPTIONAL\r
521 IN VOID *Context2, OPTIONAL\r
522 IN VOID *NewStack\r
523 );\r
524\r
525/**\r
526 Enables the 64-bit paging mode on the CPU.\r
527\r
528 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
529 must be properly initialized prior to calling this service. This function\r
530 assumes the current execution mode is 32-bit protected mode with flat\r
531 descriptors. This function is only available on IA-32. After the 64-bit\r
532 paging mode is enabled, control is transferred to the function specified by\r
533 EntryPoint using the new stack specified by NewStack and passing in the\r
534 parameters specified by Context1 and Context2. Context1 and Context2 are\r
535 optional and may be 0. The function EntryPoint must never return.\r
536\r
537 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
538 is called. The descriptor in the GDT that this selector\r
539 references must be setup for long mode.\r
540 @param EntryPoint The 64-bit virtual address of the function to call with\r
541 the new stack after paging is enabled.\r
542 @param Context1 The 64-bit virtual address of the context to pass into\r
543 the EntryPoint function as the first parameter after\r
544 paging is enabled.\r
545 @param Context2 The 64-bit virtual address of the context to pass into\r
546 the EntryPoint function as the second parameter after\r
547 paging is enabled.\r
548 @param NewStack The 64-bit virtual address of the new stack to use for\r
549 the EntryPoint function after paging is enabled.\r
550\r
551**/\r
552VOID\r
553EFIAPI\r
554InternalX86EnablePaging64 (\r
555 IN UINT16 Cs,\r
556 IN UINT64 EntryPoint,\r
557 IN UINT64 Context1, OPTIONAL\r
558 IN UINT64 Context2, OPTIONAL\r
559 IN UINT64 NewStack\r
560 );\r
561\r
562/**\r
563 Disables the 64-bit paging mode on the CPU.\r
564\r
565 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
566 mode. This function assumes the current execution mode is 64-paging mode.\r
567 This function is only available on X64. After the 64-bit paging mode is\r
568 disabled, control is transferred to the function specified by EntryPoint\r
569 using the new stack specified by NewStack and passing in the parameters\r
570 specified by Context1 and Context2. Context1 and Context2 are optional and\r
571 may be 0. The function EntryPoint must never return.\r
572\r
573 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
574 is called. The descriptor in the GDT that this selector\r
575 references must be setup for 32-bit protected mode.\r
576 @param EntryPoint The 64-bit virtual address of the function to call with\r
577 the new stack after paging is disabled.\r
578 @param Context1 The 64-bit virtual address of the context to pass into\r
579 the EntryPoint function as the first parameter after\r
580 paging is disabled.\r
581 @param Context2 The 64-bit virtual address of the context to pass into\r
582 the EntryPoint function as the second parameter after\r
583 paging is disabled.\r
584 @param NewStack The 64-bit virtual address of the new stack to use for\r
585 the EntryPoint function after paging is disabled.\r
586\r
587**/\r
588VOID\r
589EFIAPI\r
590InternalX86DisablePaging64 (\r
591 IN UINT16 Cs,\r
592 IN UINT32 EntryPoint,\r
593 IN UINT32 Context1, OPTIONAL\r
594 IN UINT32 Context2, OPTIONAL\r
595 IN UINT32 NewStack\r
596 );\r
597\r
598/**\r
599 Worker function that locates the Node in the List\r
600\r
601 By searching the List, finds the location of the Node in List. At the same time,\r
602 verifies the validity of this list.\r
603\r
604 If List is NULL, then ASSERT().\r
605 If List->ForwardLink is NULL, then ASSERT().\r
606 If List->backLink is NULL, then ASSERT().\r
607 If Node is NULL, then ASSERT();\r
608 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
609 of nodes in ListHead, including the ListHead node, is greater than or\r
610 equal to PcdMaximumLinkedListLength, then ASSERT().\r
611\r
612 @param List A pointer to a node in a linked list.\r
613 @param Node A pointer to one nod.\r
614\r
615 @retval TRUE Node is in List\r
616 @retval FALSE Node isn't in List, or List is invalid\r
617\r
618**/\r
619BOOLEAN\r
620IsNodeInList (\r
621 IN CONST LIST_ENTRY *List,\r
622 IN CONST LIST_ENTRY *Node\r
623 );\r
624\r
625/**\r
626 Performs an atomic increment of an 32-bit unsigned integer.\r
627\r
628 Performs an atomic increment of the 32-bit unsigned integer specified by\r
629 Value and returns the incremented value. The increment operation must be\r
630 performed using MP safe mechanisms. The state of the return value is not\r
631 guaranteed to be MP safe.\r
632\r
633 @param Value A pointer to the 32-bit value to increment.\r
634\r
635 @return The incremented value.\r
636\r
637**/\r
638UINT32\r
639EFIAPI\r
640InternalSyncIncrement (\r
641 IN volatile UINT32 *Value\r
642 );\r
643\r
644/**\r
645 Performs an atomic decrement of an 32-bit unsigned integer.\r
646\r
647 Performs an atomic decrement of the 32-bit unsigned integer specified by\r
648 Value and returns the decrement value. The decrement operation must be\r
649 performed using MP safe mechanisms. The state of the return value is not\r
650 guaranteed to be MP safe.\r
651\r
652 @param Value A pointer to the 32-bit value to decrement.\r
653\r
654 @return The decrement value.\r
655\r
656**/\r
657UINT32\r
658EFIAPI\r
659InternalSyncDecrement (\r
660 IN volatile UINT32 *Value\r
661 );\r
662\r
663/**\r
664 Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
665\r
666 Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
667 specified by Value. If Value is equal to CompareValue, then Value is set to \r
668 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r
669 then Value is returned. The compare exchange operation must be performed using \r
670 MP safe mechanisms.\r
671\r
672 @param Value A pointer to the 32-bit value for the compare exchange\r
673 operation.\r
674 @param CompareValue 32-bit value used in compare operation.\r
675 @param ExchangeValue 32-bit value used in exchange operation.\r
676\r
677 @return The original *Value before exchange.\r
678\r
679**/\r
680UINT32\r
681EFIAPI\r
682InternalSyncCompareExchange32 (\r
683 IN volatile UINT32 *Value,\r
684 IN UINT32 CompareValue,\r
685 IN UINT32 ExchangeValue\r
686 );\r
687\r
688/**\r
689 Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
690\r
691 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r
692 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and \r
693 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. \r
694 The compare exchange operation must be performed using MP safe mechanisms.\r
695\r
696 @param Value A pointer to the 64-bit value for the compare exchange\r
697 operation.\r
698 @param CompareValue 64-bit value used in compare operation.\r
699 @param ExchangeValue 64-bit value used in exchange operation.\r
700\r
701 @return The original *Value before exchange.\r
702\r
703**/\r
704UINT64\r
705EFIAPI\r
706InternalSyncCompareExchange64 (\r
707 IN volatile UINT64 *Value,\r
708 IN UINT64 CompareValue,\r
709 IN UINT64 ExchangeValue\r
710 );\r
711\r
712/**\r
713 Worker function that returns a bit field from Operand\r
714\r
715 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
716\r
717 @param Operand Operand on which to perform the bitfield operation.\r
718 @param StartBit The ordinal of the least significant bit in the bit field.\r
719 @param EndBit The ordinal of the most significant bit in the bit field.\r
720\r
721 @return The bit field read.\r
722\r
723**/\r
724unsigned int\r
725BitFieldReadUint (\r
726 IN unsigned int Operand,\r
727 IN UINTN StartBit,\r
728 IN UINTN EndBit\r
729 );\r
730\r
731/**\r
732 Worker function that reads a bit field from Operand, performs a bitwise OR, \r
733 and returns the result.\r
734\r
735 Performs a bitwise OR between the bit field specified by StartBit and EndBit\r
736 in Operand and the value specified by AndData. All other bits in Operand are\r
737 preserved. The new value is returned.\r
738\r
739 @param Operand Operand on which to perform the bitfield operation.\r
740 @param StartBit The ordinal of the least significant bit in the bit field.\r
741 @param EndBit The ordinal of the most significant bit in the bit field.\r
742 @param OrData The value to OR with the read value from the value\r
743\r
744 @return The new value.\r
745\r
746**/\r
747unsigned int\r
748BitFieldOrUint (\r
749 IN unsigned int Operand,\r
750 IN UINTN StartBit,\r
751 IN UINTN EndBit,\r
752 IN unsigned int OrData\r
753 );\r
754\r
755/**\r
756 Worker function that reads a bit field from Operand, performs a bitwise AND, \r
757 and returns the result.\r
758\r
759 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
760 in Operand and the value specified by AndData. All other bits in Operand are\r
761 preserved. The new value is returned.\r
762\r
763 @param Operand Operand on which to perform the bitfield operation.\r
764 @param StartBit The ordinal of the least significant bit in the bit field.\r
765 @param EndBit The ordinal of the most significant bit in the bit field.\r
766 @param AndData The value to And with the read value from the value\r
767\r
768 @return The new value.\r
769\r
770**/\r
771unsigned int\r
772BitFieldAndUint (\r
773 IN unsigned int Operand,\r
774 IN UINTN StartBit,\r
775 IN UINTN EndBit,\r
776 IN unsigned int AndData\r
777 );\r
778\r
779/**\r
780 Worker function that checks ASSERT condition for JumpBuffer\r
781\r
782 Checks ASSERT condition for JumpBuffer.\r
783\r
784 If JumpBuffer is NULL, then ASSERT().\r
785 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
786\r
787 @param JumpBuffer A pointer to CPU context buffer.\r
788\r
789**/\r
790VOID\r
791InternalAssertJumpBuffer (\r
792 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
793 );\r
794\r
795/**\r
796 Restores the CPU context that was saved with SetJump().\r
797\r
798 Restores the CPU context from the buffer specified by JumpBuffer.\r
799 This function never returns to the caller.\r
800 Instead is resumes execution based on the state of JumpBuffer.\r
801\r
802 @param JumpBuffer A pointer to CPU context buffer.\r
803 @param Value The value to return when the SetJump() context is restored.\r
804\r
805**/\r
806VOID\r
807EFIAPI\r
808InternalLongJump (\r
809 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
810 IN UINTN Value\r
811 );\r
812\r
813#endif\r