00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
#include "ki.h"
00028
00029
00030
00031
00032
00033
VOID
00034
KiFlushEntireTbTarget (
00035 IN PULONG SignalDone,
00036 IN PVOID Parameter1,
00037 IN PVOID Parameter2,
00038 IN PVOID Parameter3
00039 );
00040
00041
VOID
00042
KiFlushMultipleTbTarget (
00043 IN PULONG SignalDone,
00044 IN PVOID Number,
00045 IN PVOID Virtual,
00046 IN PVOID Pid
00047 );
00048
00049
VOID
00050
KiFlushSingleTbTarget (
00051 IN PULONG SignalDone,
00052 IN PVOID Virtual,
00053 IN PVOID Pid,
00054 IN PVOID Parameter3
00055 );
00056
00057
VOID
00058
KiFlushMultipleTbTarget64 (
00059 IN PULONG SignalDone,
00060 IN PVOID Number,
00061 IN PVOID Virtual,
00062 IN PVOID Pid
00063 );
00064
00065
VOID
00066
KiFlushSingleTbTarget64 (
00067 IN PULONG SignalDone,
00068 IN PVOID Virtual,
00069 IN PVOID Pid,
00070 IN PVOID Parameter3
00071 );
00072
00073
VOID
00074 KeFlushEntireTb (
00075 IN BOOLEAN Invalid,
00076 IN BOOLEAN AllProcessors
00077 )
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 {
00103
00104 KIRQL OldIrql;
00105
PKPROCESS Process;
00106 KAFFINITY TargetProcessors;
00107
PKTHREAD Thread;
00108
00109
ASSERT(KeGetCurrentIrql() <=
DISPATCH_LEVEL);
00110
00111
00112
00113
00114
00115
00116
00117
#if defined(NT_UP)
00118
00119 OldIrql = KeRaiseIrqlToSynchLevel();
00120
00121
#else
00122
00123
if (AllProcessors !=
FALSE) {
00124 OldIrql = KeRaiseIrqlToSynchLevel();
00125 TargetProcessors =
KeActiveProcessors;
00126
00127 }
else {
00128 Thread =
KeGetCurrentThread();
00129 Process = Thread->
ApcState.
Process;
00130
KiLockContextSwap(&OldIrql);
00131 TargetProcessors = Process->
ActiveProcessors;
00132 }
00133
00134 TargetProcessors &= PCR->NotMember;
00135
if (TargetProcessors != 0) {
00136
KiIpiSendPacket(TargetProcessors,
00137
KiFlushEntireTbTarget,
00138
NULL,
00139
NULL,
00140
NULL);
00141 }
00142
00143
#endif
00144
00145
00146
00147
00148
00149
KeFlushCurrentTb();
00150
00151
00152
00153
00154
00155
#if defined(NT_UP)
00156
00157
KeLowerIrql(OldIrql);
00158
00159
#else
00160
00161
if (TargetProcessors != 0) {
00162
KiIpiStallOnPacketTargets();
00163 }
00164
00165
if (AllProcessors !=
FALSE) {
00166
KeLowerIrql(OldIrql);
00167
00168 }
else {
00169
KiUnlockContextSwap(OldIrql);
00170 }
00171
00172
#endif
00173
00174
return;
00175 }
00176
00177
#if !defined(NT_UP)
00178
00179
00180
VOID
00181
KiFlushEntireTbTarget (
00182 IN PULONG SignalDone,
00183 IN PVOID Parameter1,
00184 IN PVOID Parameter2,
00185 IN PVOID Parameter3
00186 )
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207 {
00208
00209
00210
00211
00212
00213
KiIpiSignalPacketDone(SignalDone);
00214
KeFlushCurrentTb();
00215
return;
00216 }
00217
00218
#endif
00219
00220
00221
VOID
00222 KeFlushMultipleTb (
00223 IN ULONG Number,
00224 IN PVOID *Virtual,
00225 IN BOOLEAN Invalid,
00226 IN BOOLEAN AllProcessors,
00227 IN PHARDWARE_PTE *PtePointer OPTIONAL,
00228 IN HARDWARE_PTE PteValue
00229 )
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 {
00268
00269 ULONG
Index;
00270 KIRQL OldIrql;
00271
PKPROCESS Process;
00272 KAFFINITY TargetProcessors;
00273
PKTHREAD Thread;
00274
00275
ASSERT(KeGetCurrentIrql() ==
DISPATCH_LEVEL);
00276
ASSERT(Number <= FLUSH_MULTIPLE_MAXIMUM);
00277
00278
00279
00280
00281
00282
#if !defined(NT_UP)
00283
00284
if (AllProcessors !=
FALSE) {
00285 OldIrql = KeRaiseIrqlToSynchLevel();
00286 TargetProcessors =
KeActiveProcessors;
00287
00288 }
else {
00289 Thread =
KeGetCurrentThread();
00290 Process = Thread->
ApcState.
Process;
00291
KiLockContextSwap(&OldIrql);
00292 TargetProcessors = Process->
ActiveProcessors;
00293 }
00294
00295 TargetProcessors &= PCR->NotMember;
00296
00297
#endif
00298
00299
00300
00301
00302
00303
00304
if (ARGUMENT_PRESENT(PtePointer)) {
00305
for (
Index = 0;
Index < Number;
Index += 1) {
00306 *PtePointer[
Index] = PteValue;
00307 }
00308 }
00309
00310
00311
00312
00313
00314
00315
#if !defined(NT_UP)
00316
00317
if (TargetProcessors != 0) {
00318
KiIpiSendPacket(TargetProcessors,
00319
KiFlushMultipleTbTarget,
00320 (PVOID)Number,
00321 (PVOID)
Virtual,
00322
NULL);
00323 }
00324
00325
#endif
00326
00327
00328
00329
00330
00331
KiFlushMultipleTb(Invalid, &
Virtual[0], Number);
00332
00333
00334
00335
00336
00337
#if !defined(NT_UP)
00338
00339
if (TargetProcessors != 0) {
00340
KiIpiStallOnPacketTargets();
00341 }
00342
00343
if (AllProcessors !=
FALSE) {
00344
KeLowerIrql(OldIrql);
00345
00346 }
else {
00347
KiUnlockContextSwap(OldIrql);
00348 }
00349
00350
#endif
00351
00352
return;
00353 }
00354
00355
#if !defined(NT_UP)
00356
00357
00358
VOID
00359 KiFlushMultipleTbTarget (
00360 IN PULONG SignalDone,
00361 IN PVOID Number,
00362 IN PVOID Virtual,
00363 IN PVOID Pid
00364 )
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391 {
00392
00393 ULONG
Index;
00394 PVOID Array[FLUSH_MULTIPLE_MAXIMUM];
00395
00396
ASSERT((ULONG)Number <= FLUSH_MULTIPLE_MAXIMUM);
00397
00398
00399
00400
00401
00402
00403
for (
Index = 0;
Index < (ULONG)Number;
Index += 1) {
00404 Array[
Index] = ((PVOID *)(
Virtual))[
Index];
00405 }
00406
00407
KiIpiSignalPacketDone(SignalDone);
00408
00409
00410
00411
00412
00413
00414
KiFlushMultipleTb(
TRUE, &Array[0], (ULONG)Number);
00415
return;
00416 }
00417
00418
#endif
00419
00420
00421
VOID
00422 KeFlushMultipleTb64 (
00423 IN ULONG Number,
00424 IN PULONG *Virtual,
00425 IN BOOLEAN Invalid,
00426 IN BOOLEAN AllProcessors,
00427 IN PHARDWARE_PTE *PtePointer OPTIONAL,
00428 IN HARDWARE_PTE PteValue
00429 )
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466 {
00467
00468 ULONG
Index;
00469 KIRQL OldIrql;
00470
PKPROCESS Process;
00471 KAFFINITY TargetProcessors;
00472
PKTHREAD Thread;
00473
00474
ASSERT(KeGetCurrentIrql() ==
DISPATCH_LEVEL);
00475
ASSERT(Number <= FLUSH_MULTIPLE_MAXIMUM);
00476
00477
00478
00479
00480
00481
#if !defined(NT_UP)
00482
00483
if (AllProcessors !=
FALSE) {
00484 OldIrql = KeRaiseIrqlToSynchLevel();
00485 TargetProcessors =
KeActiveProcessors;
00486
00487 }
else {
00488 Thread =
KeGetCurrentThread();
00489 Process = Thread->
ApcState.
Process;
00490
KiLockContextSwap(&OldIrql);
00491 TargetProcessors = Process->
ActiveProcessors;
00492 }
00493
00494 TargetProcessors &= PCR->NotMember;
00495
00496
#endif
00497
00498
00499
00500
00501
00502
00503
if (ARGUMENT_PRESENT(PtePointer)) {
00504
for (
Index = 0;
Index < Number;
Index += 1) {
00505 *PtePointer[
Index] = PteValue;
00506 }
00507 }
00508
00509
00510
00511
00512
00513
00514
#if !defined(NT_UP)
00515
00516
if (TargetProcessors != 0) {
00517
KiIpiSendPacket(TargetProcessors,
00518
KiFlushMultipleTbTarget64,
00519 (PVOID)Number,
00520 (PVOID)
Virtual,
00521
NULL);
00522 }
00523
00524
#endif
00525
00526
00527
00528
00529
00530 KiFlushMultipleTb64(Invalid, &
Virtual[0], Number);
00531
00532
00533
00534
00535
00536
#if !defined(NT_UP)
00537
00538
if (TargetProcessors != 0) {
00539
KiIpiStallOnPacketTargets();
00540 }
00541
00542
if (AllProcessors !=
FALSE) {
00543
KeLowerIrql(OldIrql);
00544
00545 }
else {
00546
KiUnlockContextSwap(OldIrql);
00547 }
00548
00549
#endif
00550
00551
return;
00552 }
00553
00554
#if !defined(NT_UP)
00555
00556
00557
VOID
00558 KiFlushMultipleTbTarget64 (
00559 IN PULONG SignalDone,
00560 IN PVOID Number,
00561 IN PVOID Virtual,
00562 IN PVOID Pid
00563 )
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589 {
00590
00591 ULONG
Index;
00592 PULONG Array[FLUSH_MULTIPLE_MAXIMUM];
00593
00594
ASSERT((ULONG)Number <= FLUSH_MULTIPLE_MAXIMUM);
00595
00596
00597
00598
00599
00600
00601
for (
Index = 0;
Index < (ULONG)Number;
Index += 1) {
00602 Array[
Index] = ((PULONG *)(
Virtual))[
Index];
00603 }
00604
00605
KiIpiSignalPacketDone(SignalDone);
00606
00607
00608
00609
00610
00611
00612 KiFlushMultipleTb64(
TRUE, &Array[0], (ULONG)Number);
00613
return;
00614 }
00615
00616
#endif
00617
00618
00619 HARDWARE_PTE
00620 KeFlushSingleTb (
00621 IN PVOID Virtual,
00622 IN BOOLEAN Invalid,
00623 IN BOOLEAN AllProcessors,
00624 IN PHARDWARE_PTE PtePointer,
00625 IN HARDWARE_PTE PteValue
00626 )
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660 {
00661
00662 KIRQL OldIrql;
00663 HARDWARE_PTE OldPte;
00664
PKPROCESS Process;
00665 KAFFINITY TargetProcessors;
00666
PKTHREAD Thread;
00667
00668
ASSERT(KeGetCurrentIrql() ==
DISPATCH_LEVEL);
00669
00670
00671
00672
00673
00674
#if !defined(NT_UP)
00675
00676
if (AllProcessors !=
FALSE) {
00677 OldIrql = KeRaiseIrqlToSynchLevel();
00678 TargetProcessors =
KeActiveProcessors;
00679
00680 }
else {
00681 Thread =
KeGetCurrentThread();
00682 Process = Thread->
ApcState.
Process;
00683
KiLockContextSwap(&OldIrql);
00684 TargetProcessors = Process->
ActiveProcessors;
00685 }
00686
00687 TargetProcessors &= PCR->NotMember;
00688
00689
#endif
00690
00691
00692
00693
00694
00695
00696 OldPte = *PtePointer;
00697 *PtePointer = PteValue;
00698
00699
00700
00701
00702
00703
#if !defined(NT_UP)
00704
00705
if (TargetProcessors != 0) {
00706
KiIpiSendPacket(TargetProcessors,
00707
KiFlushSingleTbTarget,
00708 (PVOID)
Virtual,
00709
NULL,
00710
NULL);
00711 }
00712
00713
#endif
00714
00715
00716
00717
00718
00719
KiFlushSingleTb(Invalid,
Virtual);
00720
00721
00722
00723
00724
00725
#if !defined(NT_UP)
00726
00727
if (TargetProcessors != 0) {
00728
KiIpiStallOnPacketTargets();
00729 }
00730
00731
if (AllProcessors !=
FALSE) {
00732
KeLowerIrql(OldIrql);
00733
00734 }
else {
00735
KiUnlockContextSwap(OldIrql);
00736 }
00737
00738
#endif
00739
00740
return OldPte;
00741 }
00742
00743
#if !defined(NT_UP)
00744
00745
00746
VOID
00747 KiFlushSingleTbTarget (
00748 IN PULONG SignalDone,
00749 IN PVOID Virtual,
00750 IN PVOID Pid,
00751 IN PVOID Parameter3
00752 )
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780 {
00781
00782
00783
00784
00785
00786
KiIpiSignalPacketDone(SignalDone);
00787
KiFlushSingleTb(
TRUE,
Virtual);
00788
return;
00789 }
00790
00791
#endif
00792
00793
00794 HARDWARE_PTE
00795 KeFlushSingleTb64 (
00796 IN ULONG Virtual,
00797 IN BOOLEAN Invalid,
00798 IN BOOLEAN AllProcessors,
00799 IN PHARDWARE_PTE PtePointer,
00800 IN HARDWARE_PTE PteValue
00801 )
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834 {
00835
00836 KIRQL OldIrql;
00837 HARDWARE_PTE OldPte;
00838
PKPROCESS Process;
00839 KAFFINITY TargetProcessors;
00840
PKTHREAD Thread;
00841
00842
ASSERT(KeGetCurrentIrql() ==
DISPATCH_LEVEL);
00843
00844
00845
00846
00847
00848
#if !defined(NT_UP)
00849
00850
if (AllProcessors !=
FALSE) {
00851 OldIrql = KeRaiseIrqlToSynchLevel();
00852 TargetProcessors =
KeActiveProcessors;
00853
00854 }
else {
00855 Thread =
KeGetCurrentThread();
00856 Process = Thread->
ApcState.
Process;
00857
KiLockContextSwap(&OldIrql);
00858 TargetProcessors = Process->
ActiveProcessors;
00859 }
00860
00861 TargetProcessors &= PCR->NotMember;
00862
00863
#endif
00864
00865
00866
00867
00868
00869
00870 OldPte = *PtePointer;
00871 *PtePointer = PteValue;
00872
00873
00874
00875
00876
00877
#if !defined(NT_UP)
00878
00879
if (TargetProcessors != 0) {
00880
KiIpiSendPacket(TargetProcessors,
00881
KiFlushSingleTbTarget64,
00882 (PVOID)
Virtual,
00883
NULL,
00884
NULL);
00885 }
00886
00887
#endif
00888
00889
00890
00891
00892
00893 KiFlushSingleTb64(Invalid,
Virtual);
00894
00895
00896
00897
00898
00899
#if !defined(NT_UP)
00900
00901
if (TargetProcessors != 0) {
00902
KiIpiStallOnPacketTargets();
00903 }
00904
00905
if (AllProcessors !=
FALSE) {
00906
KeLowerIrql(OldIrql);
00907
00908 }
else {
00909
KiUnlockContextSwap(OldIrql);
00910 }
00911
00912
#endif
00913
00914
return OldPte;
00915 }
00916
00917
#if !defined(NT_UP)
00918
00919
00920
VOID
00921 KiFlushSingleTbTarget64 (
00922 IN PULONG SignalDone,
00923 IN PVOID Virtual,
00924 IN PVOID Pid,
00925 IN PVOID Parameter3
00926 )
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953 {
00954
00955
00956
00957
00958
00959
KiIpiSignalPacketDone(SignalDone);
00960 KiFlushSingleTb64(
TRUE, (ULONG)
Virtual);
00961
return;
00962 }
00963
00964
#endif