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