summaryrefslogtreecommitdiff
path: root/UnixPkg/Library/UnixBaseLib/BaseLibInternals.h
blob: a60310ab6f14978d5099d82f5a40b7607839ea9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
/** @file
  Declaration of internal functions in BaseLib.

  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php.

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#ifndef __BASE_LIB_INTERNALS__
#define __BASE_LIB_INTERNALS__

#include <Base.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>

//
// Math functions
//

/**
  Shifts a 64-bit integer left between 0 and 63 bits. The low bits
  are filled with zeros. The shifted value is returned.

  This function shifts the 64-bit value Operand to the left by Count bits. The
  low Count bits are set to zero. The shifted value is returned.

  @param  Operand The 64-bit operand to shift left.
  @param  Count   The number of bits to shift left.

  @return Operand << Count

**/
UINT64
EFIAPI
InternalMathLShiftU64 (
  IN      UINT64                    Operand,
  IN      UINTN                     Count
  );

/**
  Shifts a 64-bit integer right between 0 and 63 bits. The high bits
  are filled with zeros. The shifted value is returned.

  This function shifts the 64-bit value Operand to the right by Count bits. The
  high Count bits are set to zero. The shifted value is returned.

  @param  Operand The 64-bit operand to shift right.
  @param  Count   The number of bits to shift right.

  @return Operand >> Count

**/
UINT64
EFIAPI
InternalMathRShiftU64 (
  IN      UINT64                    Operand,
  IN      UINTN                     Count
  );

/**
  Shifts a 64-bit integer right between 0 and 63 bits. The high bits
  are filled with original integer's bit 63. The shifted value is returned.

  This function shifts the 64-bit value Operand to the right by Count bits. The
  high Count bits are set to bit 63 of Operand.  The shifted value is returned.

  @param  Operand The 64-bit operand to shift right.
  @param  Count   The number of bits to shift right.

  @return Operand arithmetically shifted right by Count

**/
UINT64
EFIAPI
InternalMathARShiftU64 (
  IN      UINT64                    Operand,
  IN      UINTN                     Count
  );

/**
  Rotates a 64-bit integer left between 0 and 63 bits, filling
  the low bits with the high bits that were rotated.

  This function rotates the 64-bit value Operand to the left by Count bits. The
  low Count bits are filled with the high Count bits of Operand. The rotated
  value is returned.

  @param  Operand The 64-bit operand to rotate left.
  @param  Count   The number of bits to rotate left.

  @return Operand <<< Count

**/
UINT64
EFIAPI
InternalMathLRotU64 (
  IN      UINT64                    Operand,
  IN      UINTN                     Count
  );

/**
  Rotates a 64-bit integer right between 0 and 63 bits, filling
  the high bits with the high low bits that were rotated.

  This function rotates the 64-bit value Operand to the right by Count bits.
  The high Count bits are filled with the low Count bits of Operand. The rotated
  value is returned.

  @param  Operand The 64-bit operand to rotate right.
  @param  Count   The number of bits to rotate right.

  @return Operand >>> Count

**/
UINT64
EFIAPI
InternalMathRRotU64 (
  IN      UINT64                    Operand,
  IN      UINTN                     Count
  );

/**
  Switches the endianess of a 64-bit integer.

  This function swaps the bytes in a 64-bit unsigned value to switch the value
  from little endian to big endian or vice versa. The byte swapped value is
  returned.

  @param  Operand A 64-bit unsigned value.

  @return The byte swapped Operand.

**/
UINT64
EFIAPI
InternalMathSwapBytes64 (
  IN      UINT64                    Operand
  );

/**
  Multiplies a 64-bit unsigned integer by a 32-bit unsigned integer
  and generates a 64-bit unsigned result.

  This function multiplies the 64-bit unsigned value Multiplicand by the 32-bit
  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
  bit unsigned result is returned.

  @param  Multiplicand  A 64-bit unsigned value.
  @param  Multiplier    A 32-bit unsigned value.

  @return Multiplicand * Multiplier

**/
UINT64
EFIAPI
InternalMathMultU64x32 (
  IN      UINT64                    Multiplicand,
  IN      UINT32                    Multiplier
  );

/**
  Multiplies a 64-bit unsigned integer by a 64-bit unsigned integer
  and generates a 64-bit unsigned result.

  This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
  bit unsigned result is returned.

  @param  Multiplicand  A 64-bit unsigned value.
  @param  Multiplier    A 64-bit unsigned value.

  @return Multiplicand * Multiplier

**/
UINT64
EFIAPI
InternalMathMultU64x64 (
  IN      UINT64                    Multiplicand,
  IN      UINT64                    Multiplier
  );

/**
  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
  generates a 64-bit unsigned result.

  This function divides the 64-bit unsigned value Dividend by the 32-bit
  unsigned value Divisor and generates a 64-bit unsigned quotient. This
  function returns the 64-bit unsigned quotient.

  @param  Dividend  A 64-bit unsigned value.
  @param  Divisor   A 32-bit unsigned value.

  @return Dividend / Divisor

**/
UINT64
EFIAPI
InternalMathDivU64x32 (
  IN      UINT64                    Dividend,
  IN      UINT32                    Divisor
  );

/**
  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
  generates a 32-bit unsigned remainder.

  This function divides the 64-bit unsigned value Dividend by the 32-bit
  unsigned value Divisor and generates a 32-bit remainder. This function
  returns the 32-bit unsigned remainder.

  @param  Dividend  A 64-bit unsigned value.
  @param  Divisor   A 32-bit unsigned value.

  @return Dividend % Divisor

**/
UINT32
EFIAPI
InternalMathModU64x32 (
  IN      UINT64                    Dividend,
  IN      UINT32                    Divisor
  );

/**
  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
  generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.

  This function divides the 64-bit unsigned value Dividend by the 32-bit
  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
  is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
  This function returns the 64-bit unsigned quotient.

  @param  Dividend  A 64-bit unsigned value.
  @param  Divisor   A 32-bit unsigned value.
  @param  Remainder A pointer to a 32-bit unsigned value. This parameter is
                    optional and may be NULL.

  @return Dividend / Divisor

**/
UINT64
EFIAPI
InternalMathDivRemU64x32 (
  IN      UINT64                    Dividend,
  IN      UINT32                    Divisor,
  OUT     UINT32                    *Remainder OPTIONAL
  );

/**
  Divides a 64-bit unsigned integer by a 64-bit unsigned integer and
  generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.

  This function divides the 64-bit unsigned value Dividend by the 64-bit
  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
  This function returns the 64-bit unsigned quotient.

  @param  Dividend  A 64-bit unsigned value.
  @param  Divisor   A 64-bit unsigned value.
  @param  Remainder A pointer to a 64-bit unsigned value. This parameter is
                    optional and may be NULL.

  @return Dividend / Divisor

**/
UINT64
EFIAPI
InternalMathDivRemU64x64 (
  IN      UINT64                    Dividend,
  IN      UINT64                    Divisor,
  OUT     UINT64                    *Remainder OPTIONAL
  );

/**
  Divides a 64-bit signed integer by a 64-bit signed integer and
  generates a 64-bit signed result and an optional 64-bit signed remainder.

  This function divides the 64-bit signed value Dividend by the 64-bit
  signed value Divisor and generates a 64-bit signed quotient. If Remainder
  is not NULL, then the 64-bit signed remainder is returned in Remainder.
  This function returns the 64-bit signed quotient.

  @param  Dividend  A 64-bit signed value.
  @param  Divisor   A 64-bit signed value.
  @param  Remainder A pointer to a 64-bit signed value. This parameter is
                    optional and may be NULL.

  @return Dividend / Divisor

**/
INT64
EFIAPI
InternalMathDivRemS64x64 (
  IN      INT64                     Dividend,
  IN      INT64                     Divisor,
  OUT     INT64                     *Remainder  OPTIONAL
  );

/**
  Transfers control to a function starting with a new stack.

  Transfers control to the function specified by EntryPoint using the
  new stack specified by NewStack and passing in the parameters specified
  by Context1 and Context2.  Context1 and Context2 are optional and may
  be NULL.  The function EntryPoint must never return.
  Marker will be ignored on IA-32, x64, and EBC.
  IPF CPUs expect one additional parameter of type VOID * that specifies
  the new backing store pointer.

  If EntryPoint is NULL, then ASSERT().
  If NewStack is NULL, then ASSERT().

  @param  EntryPoint  A pointer to function to call with the new stack.
  @param  Context1    A pointer to the context to pass into the EntryPoint
                      function.
  @param  Context2    A pointer to the context to pass into the EntryPoint
                      function.
  @param  NewStack    A pointer to the new stack to use for the EntryPoint
                      function.
  @param  Marker      VA_LIST marker for the variable argument list.

**/
VOID
EFIAPI
InternalSwitchStack (
  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,
  IN      VOID                      *Context1,   OPTIONAL
  IN      VOID                      *Context2,   OPTIONAL
  IN      VOID                      *NewStack,
  IN      VA_LIST                   Marker
  );


/**
  Worker function that locates the Node in the List.

  By searching the List, finds the location of the Node in List. At the same time,
  verifies the validity of this list.

  If List is NULL, then ASSERT().
  If List->ForwardLink is NULL, then ASSERT().
  If List->backLink is NULL, then ASSERT().
  If Node is NULL, then ASSERT();
  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
  of nodes in ListHead, including the ListHead node, is greater than or
  equal to PcdMaximumLinkedListLength, then ASSERT().

  @param  List  A pointer to a node in a linked list.
  @param  Node  A pointer to one nod.

  @retval TRUE   Node is in List.
  @retval FALSE  Node isn't in List, or List is invalid.

**/
BOOLEAN
EFIAPI
IsNodeInList (
  IN      CONST LIST_ENTRY      *List,
  IN      CONST LIST_ENTRY      *Node
  );

/**
  Worker function that returns a bit field from Operand.

  Returns the bitfield specified by the StartBit and the EndBit from Operand.

  @param  Operand   Operand on which to perform the bitfield operation.
  @param  StartBit  The ordinal of the least significant bit in the bit field.
  @param  EndBit    The ordinal of the most significant bit in the bit field.

  @return The bit field read.

**/
UINTN
EFIAPI
BitFieldReadUint (
  IN      UINTN                     Operand,
  IN      UINTN                     StartBit,
  IN      UINTN                     EndBit
  );


/**
  Worker function that reads a bit field from Operand, performs a bitwise OR,
  and returns the result.

  Performs a bitwise OR between the bit field specified by StartBit and EndBit
  in Operand and the value specified by AndData. All other bits in Operand are
  preserved. The new value is returned.

  @param  Operand   Operand on which to perform the bitfield operation.
  @param  StartBit  The ordinal of the least significant bit in the bit field.
  @param  EndBit    The ordinal of the most significant bit in the bit field.
  @param  OrData    The value to OR with the read value from the value

  @return The new value.

**/
UINTN
EFIAPI
BitFieldOrUint (
  IN      UINTN                     Operand,
  IN      UINTN                     StartBit,
  IN      UINTN                     EndBit,
  IN      UINTN                     OrData
  );


/**
  Worker function that reads a bit field from Operand, performs a bitwise AND,
  and returns the result.

  Performs a bitwise AND between the bit field specified by StartBit and EndBit
  in Operand and the value specified by AndData. All other bits in Operand are
  preserved. The new value is returned.

  @param  Operand   Operand on which to perform the bitfield operation.
  @param  StartBit  The ordinal of the least significant bit in the bit field.
  @param  EndBit    The ordinal of the most significant bit in the bit field.
  @param  AndData    The value to And with the read value from the value

  @return The new value.

**/
UINTN
EFIAPI
BitFieldAndUint (
  IN      UINTN                     Operand,
  IN      UINTN                     StartBit,
  IN      UINTN                     EndBit,
  IN      UINTN                     AndData
  );


/**
  Worker function that checks ASSERT condition for JumpBuffer

  Checks ASSERT condition for JumpBuffer.

  If JumpBuffer is NULL, then ASSERT().
  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().

  @param  JumpBuffer    A pointer to CPU context buffer.

**/
VOID
EFIAPI
InternalAssertJumpBuffer (
  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer
  );


/**
  Restores the CPU context that was saved with SetJump().

  Restores the CPU context from the buffer specified by JumpBuffer.
  This function never returns to the caller.
  Instead is resumes execution based on the state of JumpBuffer.

  @param  JumpBuffer    A pointer to CPU context buffer.
  @param  Value         The value to return when the SetJump() context is restored.

**/
VOID
EFIAPI
InternalLongJump (
  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer,
  IN      UINTN                     Value
  );


//
// Ia32 and x64 specific functions
//
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)

/**
  Reads the current Global Descriptor Table Register(GDTR) descriptor.

  Reads and returns the current GDTR descriptor and returns it in Gdtr. This
  function is only available on IA-32 and x64.

  @param  Gdtr  The pointer to a GDTR descriptor.

**/
VOID
EFIAPI
InternalX86ReadGdtr (
  OUT     IA32_DESCRIPTOR           *Gdtr
  );

/**
  Writes the current Global Descriptor Table Register (GDTR) descriptor.

  Writes and the current GDTR descriptor specified by Gdtr. This function is
  only available on IA-32 and x64.

  @param  Gdtr  The pointer to a GDTR descriptor.

**/
VOID
EFIAPI
InternalX86WriteGdtr (
  IN      CONST IA32_DESCRIPTOR     *Gdtr
  );

/**
  Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.

  Reads and returns the current IDTR descriptor and returns it in Idtr. This
  function is only available on IA-32 and x64.

  @param  Idtr  The pointer to an IDTR descriptor.

**/
VOID
EFIAPI
InternalX86ReadIdtr (
  OUT     IA32_DESCRIPTOR           *Idtr
  );

/**
  Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.

  Writes the current IDTR descriptor and returns it in Idtr. This function is
  only available on IA-32 and x64.

  @param  Idtr  The pointer to an IDTR descriptor.

**/
VOID
EFIAPI
InternalX86WriteIdtr (
  IN      CONST IA32_DESCRIPTOR     *Idtr
  );

/**
  Save the current floating point/SSE/SSE2 context to a buffer.

  Saves the current floating point/SSE/SSE2 state to the buffer specified by
  Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
  available on IA-32 and x64.

  @param  Buffer  The pointer to a buffer to save the floating point/SSE/SSE2 context.

**/
VOID
EFIAPI
InternalX86FxSave (
  OUT     IA32_FX_BUFFER            *Buffer
  );

/**
  Restores the current floating point/SSE/SSE2 context from a buffer.

  Restores the current floating point/SSE/SSE2 state from the buffer specified
  by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
  only available on IA-32 and x64.

  @param  Buffer  The pointer to a buffer to save the floating point/SSE/SSE2 context.

**/
VOID
EFIAPI
InternalX86FxRestore (
  IN      CONST IA32_FX_BUFFER      *Buffer
  );

/**
  Enables the 32-bit paging mode on the CPU.

  Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
  must be properly initialized prior to calling this service. This function
  assumes the current execution mode is 32-bit protected mode. This function is
  only available on IA-32. After the 32-bit paging mode is enabled, control is
  transferred to the function specified by EntryPoint using the new stack
  specified by NewStack and passing in the parameters specified by Context1 and
  Context2. Context1 and Context2 are optional and may be NULL. The function
  EntryPoint must never return.

  There are a number of constraints that must be followed before calling this
  function:
  1)  Interrupts must be disabled.
  2)  The caller must be in 32-bit protected mode with flat descriptors. This
      means all descriptors must have a base of 0 and a limit of 4GB.
  3)  CR0 and CR4 must be compatible with 32-bit protected mode with flat
      descriptors.
  4)  CR3 must point to valid page tables that will be used once the transition
      is complete, and those page tables must guarantee that the pages for this
      function and the stack are identity mapped.

  @param  EntryPoint  A pointer to function to call with the new stack after
                      paging is enabled.
  @param  Context1    A pointer to the context to pass into the EntryPoint
                      function as the first parameter after paging is enabled.
  @param  Context2    A pointer to the context to pass into the EntryPoint
                      function as the second parameter after paging is enabled.
  @param  NewStack    A pointer to the new stack to use for the EntryPoint
                      function after paging is enabled.

**/
VOID
EFIAPI
InternalX86EnablePaging32 (
  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,
  IN      VOID                      *Context1,  OPTIONAL
  IN      VOID                      *Context2,  OPTIONAL
  IN      VOID                      *NewStack
  );

/**
  Disables the 32-bit paging mode on the CPU.

  Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
  mode. This function assumes the current execution mode is 32-paged protected
  mode. This function is only available on IA-32. After the 32-bit paging mode
  is disabled, control is transferred to the function specified by EntryPoint
  using the new stack specified by NewStack and passing in the parameters
  specified by Context1 and Context2. Context1 and Context2 are optional and
  may be NULL. The function EntryPoint must never return.

  There are a number of constraints that must be followed before calling this
  function:
  1)  Interrupts must be disabled.
  2)  The caller must be in 32-bit paged mode.
  3)  CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
  4)  CR3 must point to valid page tables that guarantee that the pages for
      this function and the stack are identity mapped.

  @param  EntryPoint  A pointer to function to call with the new stack after
                      paging is disabled.
  @param  Context1    A pointer to the context to pass into the EntryPoint
                      function as the first parameter after paging is disabled.
  @param  Context2    A pointer to the context to pass into the EntryPoint
                      function as the second parameter after paging is
                      disabled.
  @param  NewStack    A pointer to the new stack to use for the EntryPoint
                      function after paging is disabled.

**/
VOID
EFIAPI
InternalX86DisablePaging32 (
  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,
  IN      VOID                      *Context1,  OPTIONAL
  IN      VOID                      *Context2,  OPTIONAL
  IN      VOID                      *NewStack
  );

/**
  Enables the 64-bit paging mode on the CPU.

  Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
  must be properly initialized prior to calling this service. This function
  assumes the current execution mode is 32-bit protected mode with flat
  descriptors. This function is only available on IA-32. After the 64-bit
  paging mode is enabled, control is transferred to the function specified by
  EntryPoint using the new stack specified by NewStack and passing in the
  parameters specified by Context1 and Context2. Context1 and Context2 are
  optional and may be 0. The function EntryPoint must never return.

  @param  Cs          The 16-bit selector to load in the CS before EntryPoint
                      is called. The descriptor in the GDT that this selector
                      references must be setup for long mode.
  @param  EntryPoint  The 64-bit virtual address of the function to call with
                      the new stack after paging is enabled.
  @param  Context1    The 64-bit virtual address of the context to pass into
                      the EntryPoint function as the first parameter after
                      paging is enabled.
  @param  Context2    The 64-bit virtual address of the context to pass into
                      the EntryPoint function as the second parameter after
                      paging is enabled.
  @param  NewStack    The 64-bit virtual address of the new stack to use for
                      the EntryPoint function after paging is enabled.

**/
VOID
EFIAPI
InternalX86EnablePaging64 (
  IN      UINT16                    Cs,
  IN      UINT64                    EntryPoint,
  IN      UINT64                    Context1,  OPTIONAL
  IN      UINT64                    Context2,  OPTIONAL
  IN      UINT64                    NewStack
  );

/**
  Disables the 64-bit paging mode on the CPU.

  Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
  mode. This function assumes the current execution mode is 64-paging mode.
  This function is only available on x64. After the 64-bit paging mode is
  disabled, control is transferred to the function specified by EntryPoint
  using the new stack specified by NewStack and passing in the parameters
  specified by Context1 and Context2. Context1 and Context2 are optional and
  may be 0. The function EntryPoint must never return.

  @param  Cs          The 16-bit selector to load in the CS before EntryPoint
                      is called. The descriptor in the GDT that this selector
                      references must be setup for 32-bit protected mode.
  @param  EntryPoint  The 64-bit virtual address of the function to call with
                      the new stack after paging is disabled.
  @param  Context1    The 64-bit virtual address of the context to pass into
                      the EntryPoint function as the first parameter after
                      paging is disabled.
  @param  Context2    The 64-bit virtual address of the context to pass into
                      the EntryPoint function as the second parameter after
                      paging is disabled.
  @param  NewStack    The 64-bit virtual address of the new stack to use for
                      the EntryPoint function after paging is disabled.

**/
VOID
EFIAPI
InternalX86DisablePaging64 (
  IN      UINT16                    Cs,
  IN      UINT32                    EntryPoint,
  IN      UINT32                    Context1,  OPTIONAL
  IN      UINT32                    Context2,  OPTIONAL
  IN      UINT32                    NewStack
  );


#elif defined (MDE_CPU_IPF)
//
//
// IPF specific functions
//

/**
  Reads control register DCR.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_DCR.

  @return The 64-bit control register DCR.

**/
UINT64
EFIAPI
AsmReadControlRegisterDcr (
  VOID
  );


/**
  Reads control register ITM.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_ITM.

  @return The 64-bit control register ITM.

**/
UINT64
EFIAPI
AsmReadControlRegisterItm (
  VOID
  );


/**
  Reads control register IVA.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IVA.

  @return The 64-bit control register IVA.

**/
UINT64
EFIAPI
AsmReadControlRegisterIva (
  VOID
  );


/**
  Reads control register PTA.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_PTA.

  @return The 64-bit control register PTA.

**/
UINT64
EFIAPI
AsmReadControlRegisterPta (
  VOID
  );


/**
  Reads control register IPSR.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IPSR.

  @return The 64-bit control register IPSR.

**/
UINT64
EFIAPI
AsmReadControlRegisterIpsr (
  VOID
  );


/**
  Reads control register ISR.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_ISR.

  @return The 64-bit control register ISR.

**/
UINT64
EFIAPI
AsmReadControlRegisterIsr (
  VOID
  );


/**
  Reads control register IIP.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IIP.

  @return The 64-bit control register IIP.

**/
UINT64
EFIAPI
AsmReadControlRegisterIip (
  VOID
  );


/**
  Reads control register IFA.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IFA.

  @return The 64-bit control register IFA.

**/
UINT64
EFIAPI
AsmReadControlRegisterIfa (
  VOID
  );


/**
  Reads control register ITIR.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_ITIR.

  @return The 64-bit control register ITIR.

**/
UINT64
EFIAPI
AsmReadControlRegisterItir (
  VOID
  );


/**
  Reads control register IIPA.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IIPA.

  @return The 64-bit control register IIPA.

**/
UINT64
EFIAPI
AsmReadControlRegisterIipa (
  VOID
  );


/**
  Reads control register IFS.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IFS.

  @return The 64-bit control register IFS.

**/
UINT64
EFIAPI
AsmReadControlRegisterIfs (
  VOID
  );


/**
  Reads control register IIM.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IIM.

  @return The 64-bit control register IIM.

**/
UINT64
EFIAPI
AsmReadControlRegisterIim (
  VOID
  );


/**
  Reads control register IHA.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IHA.

  @return The 64-bit control register IHA.

**/
UINT64
EFIAPI
AsmReadControlRegisterIha (
  VOID
  );


/**
  Reads control register LID.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_LID.

  @return The 64-bit control register LID.

**/
UINT64
EFIAPI
AsmReadControlRegisterLid (
  VOID
  );


/**
  Reads control register IVR.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IVR.

  @return The 64-bit control register IVR.

**/
UINT64
EFIAPI
AsmReadControlRegisterIvr (
  VOID
  );


/**
  Reads control register TPR.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_TPR.

  @return The 64-bit control register TPR.

**/
UINT64
EFIAPI
AsmReadControlRegisterTpr (
  VOID
  );


/**
  Reads control register EOI.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_EOI.

  @return The 64-bit control register EOI.

**/
UINT64
EFIAPI
AsmReadControlRegisterEoi (
  VOID
  );


/**
  Reads control register IRR0.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IRR0.

  @return The 64-bit control register IRR0.

**/
UINT64
EFIAPI
AsmReadControlRegisterIrr0 (
  VOID
  );


/**
  Reads control register IRR1.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IRR1.

  @return The 64-bit control register IRR1.

**/
UINT64
EFIAPI
AsmReadControlRegisterIrr1 (
  VOID
  );


/**
  Reads control register IRR2.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IRR2.

  @return The 64-bit control register IRR2.

**/
UINT64
EFIAPI
AsmReadControlRegisterIrr2 (
  VOID
  );


/**
  Reads control register IRR3.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_IRR3.

  @return The 64-bit control register IRR3.

**/
UINT64
EFIAPI
AsmReadControlRegisterIrr3 (
  VOID
  );


/**
  Reads control register ITV.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_ITV.

  @return The 64-bit control register ITV.

**/
UINT64
EFIAPI
AsmReadControlRegisterItv (
  VOID
  );


/**
  Reads control register PMV.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_PMV.

  @return The 64-bit control register PMV.

**/
UINT64
EFIAPI
AsmReadControlRegisterPmv (
  VOID
  );


/**
  Reads control register CMCV.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_CMCV.

  @return The 64-bit control register CMCV.

**/
UINT64
EFIAPI
AsmReadControlRegisterCmcv (
  VOID
  );


/**
  Reads control register LRR0.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_LRR0.

  @return The 64-bit control register LRR0.

**/
UINT64
EFIAPI
AsmReadControlRegisterLrr0 (
  VOID
  );


/**
  Reads control register LRR1.

  This is a worker function for AsmReadControlRegister()
  when its parameter Index is IPF_CONTROL_REGISTER_LRR1.

  @return The 64-bit control register LRR1.

**/
UINT64
EFIAPI
AsmReadControlRegisterLrr1 (
  VOID
  );


/**
  Reads application register K0.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_K0.

  @return The 64-bit application register K0.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterK0 (
  VOID
  );



/**
  Reads application register K1.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_K1.

  @return The 64-bit application register K1.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterK1 (
  VOID
  );


/**
  Reads application register K2.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_K2.

  @return The 64-bit application register K2.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterK2 (
  VOID
  );


/**
  Reads application register K3.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_K3.

  @return The 64-bit application register K3.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterK3 (
  VOID
  );


/**
  Reads application register K4.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_K4.

  @return The 64-bit application register K4.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterK4 (
  VOID
  );


/**
  Reads application register K5.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_K5.

  @return The 64-bit application register K5.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterK5 (
  VOID
  );


/**
  Reads application register K6.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_K6.

  @return The 64-bit application register K6.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterK6 (
  VOID
  );


/**
  Reads application register K7.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_K7.

  @return The 64-bit application register K7.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterK7 (
  VOID
  );


/**
  Reads application register RSC.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_RSC.

  @return The 64-bit application register RSC.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterRsc (
  VOID
  );


/**
  Reads application register BSP.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_BSP.

  @return The 64-bit application register BSP.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterBsp (
  VOID
  );


/**
  Reads application register BSPSTORE.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_BSPSTORE.

  @return The 64-bit application register BSPSTORE.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterBspstore (
  VOID
  );


/**
  Reads application register RNAT.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_RNAT.

  @return The 64-bit application register RNAT.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterRnat (
  VOID
  );


/**
  Reads application register FCR.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_FCR.

  @return The 64-bit application register FCR.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterFcr (
  VOID
  );


/**
  Reads application register EFLAG.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_EFLAG.

  @return The 64-bit application register EFLAG.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterEflag (
  VOID
  );


/**
  Reads application register CSD.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_CSD.

  @return The 64-bit application register CSD.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterCsd (
  VOID
  );


/**
  Reads application register SSD.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_SSD.

  @return The 64-bit application register SSD.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterSsd (
  VOID
  );


/**
  Reads application register CFLG.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_CFLG.

  @return The 64-bit application register CFLG.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterCflg (
  VOID
  );


/**
  Reads application register FSR.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_FSR.

  @return The 64-bit application register FSR.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterFsr (
  VOID
  );


/**
  Reads application register FIR.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_FIR.

  @return The 64-bit application register FIR.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterFir (
  VOID
  );


/**
  Reads application register FDR.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_FDR.

  @return The 64-bit application register FDR.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterFdr (
  VOID
  );


/**
  Reads application register CCV.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_CCV.

  @return The 64-bit application register CCV.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterCcv (
  VOID
  );


/**
  Reads application register UNAT.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_UNAT.

  @return The 64-bit application register UNAT.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterUnat (
  VOID
  );


/**
  Reads application register FPSR.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_FPSR.

  @return The 64-bit application register FPSR.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterFpsr (
  VOID
  );


/**
  Reads application register ITC.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_ITC.

  @return The 64-bit application register ITC.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterItc (
  VOID
  );


/**
  Reads application register PFS.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_PFS.

  @return The 64-bit application register PFS.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterPfs (
  VOID
  );


/**
  Reads application register LC.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_LC.

  @return The 64-bit application register LC.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterLc (
  VOID
  );


/**
  Reads application register EC.

  This is a worker function for AsmReadApplicationRegister()
  when its parameter Index is IPF_APPLICATION_REGISTER_EC.

  @return The 64-bit application register EC.

**/
UINT64
EFIAPI
AsmReadApplicationRegisterEc (
  VOID
  );



/**
  Transfers control to a function starting with a new stack.

  Transfers control to the function specified by EntryPoint using the new stack
  specified by NewStack and passing in the parameters specified by Context1 and
  Context2. Context1 and Context2 are optional and may be NULL. The function
  EntryPoint must never return.

  If EntryPoint is NULL, then ASSERT().
  If NewStack is NULL, then ASSERT().

  @param  EntryPoint  A pointer to function to call with the new stack.
  @param  Context1    A pointer to the context to pass into the EntryPoint
                      function.
  @param  Context2    A pointer to the context to pass into the EntryPoint
                      function.
  @param  NewStack    A pointer to the new stack to use for the EntryPoint
                      function.
  @param  NewBsp      A pointer to the new memory location for RSE backing
                      store.

**/
VOID
EFIAPI
AsmSwitchStackAndBackingStore (
  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,
  IN      VOID                      *Context1,  OPTIONAL
  IN      VOID                      *Context2,  OPTIONAL
  IN      VOID                      *NewStack,
  IN      VOID                      *NewBsp
  );

/**
  Internal worker function to invalidate a range of instruction cache lines
  in the cache coherency domain of the calling CPU.

  Internal worker function to invalidate the instruction cache lines specified
  by Address and Length. If Address is not aligned on a cache line boundary,
  then entire instruction cache line containing Address is invalidated. If
  Address + Length is not aligned on a cache line boundary, then the entire
  instruction cache line containing Address + Length -1 is invalidated. This
  function may choose to invalidate the entire instruction cache if that is more
  efficient than invalidating the specified range. If Length is 0, the no instruction
  cache lines are invalidated. Address is returned.
  This function is only available on IPF.

  @param  Address The base address of the instruction cache lines to
                  invalidate. If the CPU is in a physical addressing mode, then
                  Address is a physical address. If the CPU is in a virtual
                  addressing mode, then Address is a virtual address.

  @param  Length  The number of bytes to invalidate from the instruction cache.

  @return Address

**/
VOID *
EFIAPI
InternalFlushCacheRange (
  IN      VOID                      *Address,
  IN      UINTN                     Length
  );

#else

#endif

#endif