00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef _IA64H_
00022
#define _IA64H_
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 typedef struct _IHISTORY_RECORD {
00035 ULONGLONG
InterruptionType;
00036 ULONGLONG
IIP;
00037 ULONGLONG
IPSR;
00038 ULONGLONG
Extra0;
00039 }
IHISTORY_RECORD;
00040
00041 #define MAX_NUMBER_OF_IHISTORY_RECORDS 128
00042
00043
00044
00045
00046
#include "kxia64.h"
00047
00048
00049
00050
00051
#if defined(_IA64_)
00052
00053
00054
00055
00056
00057
typedef ULONG PFN_COUNT;
00058
00059
typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
00060
typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
00061
00062
00063
00064
00065
00066
#define FLUSH_MULTIPLE_MAXIMUM 100
00067
00068
00069
00070
00071
00072
#define ALLOC_PRAGMA 1
00073
00074
00075
00076
00077
00078
#include "ia64reg.h"
00079
00080
00081
00082
00083
unsigned __int64 __getReg (
int);
00084
void __setReg (
int,
unsigned __int64);
00085
void __isrlz (
void);
00086
void __dsrlz (
void);
00087
void __fwb (
void);
00088
void __mf (
void);
00089
void __mfa (
void);
00090
void __synci (
void);
00091 __int64 __thash (__int64);
00092 __int64 __ttag (__int64);
00093
void __ptcl (__int64, __int64);
00094
void __ptcg (__int64, __int64);
00095
void __ptcga (__int64, __int64);
00096
void __ptri (__int64, __int64);
00097
void __ptrd (__int64, __int64);
00098
void __invalat (
void);
00099
void __break (
int);
00100
void __fc (__int64);
00101
void __sum (
int);
00102
void __rsm (
int);
00103
00104
#ifdef _M_IA64
00105
#pragma intrinsic (__getReg) // Intel-IA64-Filler
00106
#pragma intrinsic (__setReg) // Intel-IA64-Filler
00107
#pragma intrinsic (__isrlz) // Intel-IA64-Filler
00108
#pragma intrinsic (__dsrlz) // Intel-IA64-Filler
00109
#pragma intrinsic (__fwb) // Intel-IA64-Filler
00110
#pragma intrinsic (__mf) // Intel-IA64-Filler
00111
#pragma intrinsic (__mfa) // Intel-IA64-Filler
00112
#pragma intrinsic (__synci) // Intel-IA64-Filler
00113
#pragma intrinsic (__thash) // Intel-IA64-Filler
00114
#pragma intrinsic (__ttag) // Intel-IA64-Filler
00115
#pragma intrinsic (__ptcl) // Intel-IA64-Filler
00116
#pragma intrinsic (__ptcg) // Intel-IA64-Filler
00117
#pragma intrinsic (__ptcga) // Intel-IA64-Filler
00118
#pragma intrinsic (__ptri) // Intel-IA64-Filler
00119
#pragma intrinsic (__ptrd) // Intel-IA64-Filler
00120
#pragma intrinsic (__invalat) // Intel-IA64-Filler
00121
#pragma intrinsic (__break) // Intel-IA64-Filler
00122
#pragma intrinsic (__fc) // Intel-IA64-Filler
00123
#pragma intrinsic (__sum) // Intel-IA64-Filler
00124
#pragma intrinsic (__rsm) // Intel-IA64-Filler
00125
#endif // _M_IA64
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
#define IMPORT_NAME(name) __imp_##name
00136
00137
00138
00139
00140
00141
00142
00143
00144
#define MAXIMUM_VECTOR 256
00145
00146
00147
00148
00149
00150
00151
00152
00153
#define RESULT_ZERO 0
00154
#define RESULT_NEGATIVE 1
00155
#define RESULT_POSITIVE 2
00156
00157
00158
00159
00160
00161
00162
typedef enum _INTERLOCKED_RESULT {
00163 ResultNegative = RESULT_NEGATIVE,
00164 ResultZero = RESULT_ZERO,
00165 ResultPositive = RESULT_POSITIVE
00166 } INTERLOCKED_RESULT;
00167
00168
00169
00170
00171
00172
#define ExInterlockedIncrementLong(Addend, Lock) \
00173
ExIa64InterlockedIncrementLong(Addend)
00174
00175
#define ExInterlockedDecrementLong(Addend, Lock) \
00176
ExIa64InterlockedDecrementLong(Addend)
00177
00178
#define ExInterlockedExchangeAddLargeInteger(Target, Value, Lock) \
00179
ExpInterlockedExchangeAddLargeInteger(Target, Value)
00180
00181
#define ExInterlockedExchangeUlong(Target, Value, Lock) \
00182
ExIa64InterlockedExchangeUlong(Target, Value)
00183
00184
NTKERNELAPI
00185 INTERLOCKED_RESULT
00186 ExIa64InterlockedIncrementLong (
00187 IN PLONG Addend
00188 );
00189
00190
NTKERNELAPI
00191 INTERLOCKED_RESULT
00192 ExIa64InterlockedDecrementLong (
00193 IN PLONG Addend
00194 );
00195
00196
NTKERNELAPI
00197 LARGE_INTEGER
00198 ExpInterlockedExchangeAddLargeInteger (
00199 IN PLARGE_INTEGER Addend,
00200 IN LARGE_INTEGER Increment
00201 );
00202
00203
NTKERNELAPI
00204 ULONG
00205 ExIa64InterlockedExchangeUlong (
00206 IN PULONG Target,
00207 IN ULONG Value
00208 );
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
#define DISPATCH_LENGTH 2*2 // Intel-IA64-Filler ; Length of dispatch code template in 32-bit words
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
#define PASSIVE_LEVEL 0 // Passive release level
00232
#define LOW_LEVEL 0 // Lowest interrupt level
00233
#define APC_LEVEL 1 // APC interrupt level
00234
#define DISPATCH_LEVEL 2 // Dispatcher level
00235
#define CMC_LEVEL 3 // Correctable machine check level
00236
#define DEVICE_LEVEL_BASE 4 // 4 - 11 - Device IRQLs
00237
#define PROFILE_LEVEL 12 // Profiling level
00238
#define PC_LEVEL 12 // Performance Counter IRQL
00239
#define SYNCH_LEVEL (IPI_LEVEL-1) // Synchronization level
00240
#define IPI_LEVEL 14 // IPI IRQL
00241
#define CLOCK_LEVEL 13 // Clock Timer IRQL
00242
#define POWER_LEVEL 15 // Power failure level
00243
#define HIGH_LEVEL 15 // Highest interrupt level
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
#define TPR_MIC 4 // Intel-IA64-Filler
00254
#define TPR_IRQL_SHIFT TPR_MIC // Intel-IA64-Filler
00255
00256
00257
#define VECTOR_IRQL_SHIFT TPR_IRQL_SHIFT // Intel-IA64-Filler
00258
00259
00260
00261
00262
00263
#define APC_VECTOR APC_LEVEL << VECTOR_IRQL_SHIFT // Intel-IA64-Filler
00264
#define DISPATCH_VECTOR DISPATCH_LEVEL << VECTOR_IRQL_SHIFT // Intel-IA64-Filler
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
#define DEFAULT_PROFILE_COUNT 0x40000000 // ~= 20 seconds @50mhz
00277
#define DEFAULT_PROFILE_INTERVAL (10 * 500) // 500 microseconds
00278
#define MAXIMUM_PROFILE_INTERVAL (10 * 1000 * 1000) // 1 second
00279
#define MINIMUM_PROFILE_INTERVAL (10 * 40) // 40 microseconds
00280
00281
#if defined(_M_IA64) && !defined(RC_INVOKED)
00282
00283
#define InterlockedAdd _InterlockedAdd
00284
#define InterlockedIncrement _InterlockedIncrement
00285
#define InterlockedDecrement _InterlockedDecrement
00286
#define InterlockedExchange _InterlockedExchange
00287
#define InterlockedExchangeAdd _InterlockedExchangeAdd
00288
00289
#define InterlockedAdd64 _InterlockedAdd64
00290
#define InterlockedIncrement64 _InterlockedIncrement64
00291
#define InterlockedDecrement64 _InterlockedDecrement64
00292
#define InterlockedExchange64 _InterlockedExchange64
00293
#define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
00294
#define InterlockedCompareExchange64 _InterlockedCompareExchange64
00295
00296
#define InterlockedCompareExchange _InterlockedCompareExchange
00297
#define InterlockedExchangePointer _InterlockedExchangePointer
00298
#define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
00299
00300 LONG
00301 __cdecl
00302 InterlockedAdd (
00303 LONG *Addend,
00304 LONG Value
00305 );
00306
00307 LONGLONG
00308 __cdecl
00309 InterlockedAdd64 (
00310 LONGLONG *Addend,
00311 LONGLONG Value
00312 );
00313
00314 LONG
00315 __cdecl
00316 InterlockedIncrement(
00317 IN OUT PLONG Addend
00318 );
00319
00320 LONG
00321 __cdecl
00322 InterlockedDecrement(
00323 IN OUT PLONG Addend
00324 );
00325
00326 LONG
00327 __cdecl
00328 InterlockedExchange(
00329 IN OUT PLONG Target,
00330 IN LONG Value
00331 );
00332
00333 LONG
00334 __cdecl
00335 InterlockedExchangeAdd(
00336 IN OUT PLONG Addend,
00337 IN LONG Value
00338 );
00339
00340 LONG
00341 __cdecl
00342 InterlockedCompareExchange (
00343 IN OUT PLONG Destination,
00344 IN LONG ExChange,
00345 IN LONG Comperand
00346 );
00347
00348 LONGLONG
00349 __cdecl
00350 InterlockedIncrement64(
00351 IN OUT PLONGLONG Addend
00352 );
00353
00354 LONGLONG
00355 __cdecl
00356 InterlockedDecrement64(
00357 IN OUT PLONGLONG Addend
00358 );
00359
00360 LONGLONG
00361 __cdecl
00362 InterlockedExchange64(
00363 IN OUT PLONGLONG Target,
00364 IN LONGLONG Value
00365 );
00366
00367 LONGLONG
00368 __cdecl
00369 InterlockedExchangeAdd64(
00370 IN OUT PLONGLONG Addend,
00371 IN LONGLONG Value
00372 );
00373
00374 LONGLONG
00375 __cdecl
00376 InterlockedCompareExchange64 (
00377 IN OUT PLONGLONG Destination,
00378 IN LONGLONG ExChange,
00379 IN LONGLONG Comperand
00380 );
00381
00382 PVOID
00383 __cdecl
00384 InterlockedCompareExchangePointer (
00385 IN OUT PVOID *Destination,
00386 IN PVOID Exchange,
00387 IN PVOID Comperand
00388 );
00389
00390 PVOID
00391 __cdecl
00392 InterlockedExchangePointer(
00393 IN OUT PVOID *Target,
00394 IN PVOID Value
00395 );
00396
00397
#pragma intrinsic(_InterlockedAdd)
00398
#pragma intrinsic(_InterlockedIncrement)
00399
#pragma intrinsic(_InterlockedDecrement)
00400
#pragma intrinsic(_InterlockedExchange)
00401
#pragma intrinsic(_InterlockedCompareExchange)
00402
#pragma intrinsic(_InterlockedExchangeAdd)
00403
#pragma intrinsic(_InterlockedAdd64)
00404
#pragma intrinsic(_InterlockedIncrement64)
00405
#pragma intrinsic(_InterlockedDecrement64)
00406
#pragma intrinsic(_InterlockedExchange64)
00407
#pragma intrinsic(_InterlockedCompareExchange64)
00408
#pragma intrinsic(_InterlockedExchangeAdd64)
00409
#pragma intrinsic(_InterlockedExchangePointer)
00410
#pragma intrinsic(_InterlockedCompareExchangePointer)
00411
00412
#endif // defined(_M_IA64) && !defined(RC_INVOKED)
00413
00414
00415
00416
#define KiSynchIrql SYNCH_LEVEL // enable portable code
00417
#define KiProfileIrql PROFILE_LEVEL // enable portable code
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
#define SANITIZE_FSR(fsr, mode) ( \
00433 ((mode) == KernelMode ? \
00434 ((0x0000000000000000UL) | ((fsr) & ~(MASK_IA64(FPSR_MBZ0,FPSR_MBZ0_V)))) : \
00435 ((0x0000000000000000UL) | ((fsr) & ~(MASK_IA64(FPSR_MBZ0,FPSR_MBZ0_V)))) \
00436 ) \
00437 ) // Intel-IA64-Filler
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
#define PSR_KERNEL_CLR (MASK_IA64(PSR_BE,1i64) | MASK_IA64(PSR_SP,1i64) | MASK_IA64(PSR_PK,1i64) | \
00453 MASK_IA64(PSR_CPL,0x3i64) | MASK_IA64(PSR_MC,1i64) | MASK_IA64(PSR_MBZ0,PSR_MBZ0_V) | \
00454 MASK_IA64(PSR_MBZ1,PSR_MBZ1_V) | MASK_IA64(PSR_MBZ2,PSR_MBZ2) | \
00455 MASK_IA64(PSR_DFL, 1i64)) // Intel-IA64-Filler
00456
00457
#define PSR_KERNEL_SET (MASK_IA64(PSR_IC,1i64) | MASK_IA64(PSR_DT,1i64) | MASK_IA64(PSR_DFH,1i64) | \
00458 MASK_IA64(PSR_DI,1i64) | MASK_IA64(PSR_IT,1i64) | \
00459 MASK_IA64(PSR_RT,1i64)) // Intel-IA64-Filler
00460
00461
#define PSR_KERNEL_CPY (MASK_IA64(PSR_UP,1i64) | MASK_IA64(PSR_AC,1i64) | \
00462 MASK_IA64(PSR_I,1i64) | MASK_IA64(PSR_BN,1i64) | \
00463 MASK_IA64(PSR_PP,1i64) | MASK_IA64(PSR_SI,1i64) | MASK_IA64(PSR_DB,1i64) | \
00464 MASK_IA64(PSR_TB,1i64) | MASK_IA64(PSR_IS,1i64) | MASK_IA64(PSR_ID,1i64) | \
00465 MASK_IA64(PSR_DA,1i64) | MASK_IA64(PSR_DD,1i64) | MASK_IA64(PSR_SS,1i64) | \
00466 MASK_IA64(PSR_RI,0x3i64) | MASK_IA64(PSR_ED,1i64) | MASK_IA64(PSR_LP,1i64)) // Intel-IA64-Filler
00467
00468
#define PSR_USER_CLR (MASK_IA64(PSR_MC,1i64) | \
00469 MASK_IA64(PSR_MBZ0,PSR_MBZ0_V) | MASK_IA64(PSR_PK,1i64) | \
00470 MASK_IA64(PSR_MBZ1,PSR_MBZ1_V) | MASK_IA64(PSR_MBZ2,PSR_MBZ2) | \
00471 MASK_IA64(PSR_LP,1i64)) // Intel-IA64-Filler
00472
00473
#define PSR_USER_SET (MASK_IA64(PSR_IC,1i64) | MASK_IA64(PSR_I,1i64) | \
00474 MASK_IA64(PSR_DT,1i64) | MASK_IA64(PSR_BN,1i64) | \
00475 MASK_IA64(PSR_RT,1i64) | \
00476 MASK_IA64(PSR_CPL,0x3i64) | MASK_IA64(PSR_IT,1i64)) // Intel-IA64-Filler
00477
00478
#define PSR_USER_CPY (MASK_IA64(PSR_BE,1i64) | MASK_IA64(PSR_UP,1i64) | MASK_IA64(PSR_PP,1i64) | \
00479 MASK_IA64(PSR_AC,1i64) | MASK_IA64(PSR_DFL,1i64) | MASK_IA64(PSR_DFH,1i64) | \
00480 MASK_IA64(PSR_SP,1i64) | MASK_IA64(PSR_DI,1i64) | MASK_IA64(PSR_DB,1i64) | \
00481 MASK_IA64(PSR_TB,1i64) | MASK_IA64(PSR_IS,1i64) | MASK_IA64(PSR_ID,1i64) | \
00482 MASK_IA64(PSR_DA,1i64) | MASK_IA64(PSR_DD,1i64) | MASK_IA64(PSR_SS, 1i64) | \
00483 MASK_IA64(PSR_RI,0x3i64) | MASK_IA64(PSR_ED,1i64) | MASK_IA64(PSR_SI,1i64))
00484
00485
#define PSR_DEBUG_SET (MASK_IA64(PSR_DB,1i64) | MASK_IA64(PSR_SS,1i64) | MASK_IA64(PSR_TB,1i64) | \
00486 MASK_IA64(PSR_ID,1i64) | MASK_IA64(PSR_DD,1i64)) // Intel-IA64-Filler
00487
00488
#define SANITIZE_PSR(psr, mode) ( \
00489 ((mode) == KernelMode ? \
00490 (PSR_KERNEL_SET | ((psr) & (PSR_KERNEL_CPY | ~PSR_KERNEL_CLR))) : \
00491 (PSR_USER_SET | ((psr) & (PSR_USER_CPY | ~PSR_USER_CLR))) \
00492 ) \
00493 ) // Intel-IA64-Filler
00494
00495
00496
00497
00498
00499
#define SANITIZE_IFS(ifs, mode) ( \
00500 ((mode) == KernelMode ? \
00501 ((ifs) | (MASK_IA64(IFS_V,1i64))) : \
00502 (((ifs) | (MASK_IA64(IFS_V,1i64))) & (~MASK_IA64(IFS_MBZ0, (ULONGLONG)IFS_MBZ0_V))) \
00503 ) \
00504 ) // Intel-IA64-Filler
00505
00506
#define SANITIZE_DCR(dcr, mode) \
00507 ((mode) == KernelMode ? dcr : USER_DCR_INITIAL) // Intel-IA64-Filler
00508
00509
00510
00511
00512
00513
#define SANITIZE_DR(dr, mode) \
00514 ((mode) == KernelMode ? \
00515 (dr) : \
00516 (dr & ~(0x7i64 << DR_PLM0)) \
00517 )
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
#define INTERRUPT_REQUEST_PHYSICAL_ADDRESS 0xFFE00000 // Intel-IA64-Filler
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
#define KIPCR ((ULONG_PTR)(KADDRESS_BASE + 0xFFFF0000)) // kernel address of first PCR
00542
#define PCR ((volatile KPCR * const)KIPCR)
00543
00544
00545
00546
00547
#define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000))
00548
#define SharedUserData ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
00549
00550
00551
00552
00553
00554
NTKERNELAPI
00555 KIRQL
00556 KeGetCurrentIrql();
00557
00558
00559
00560
00561
00562
00563
00564
#define KeGetCurrentPrcb() PCR->Prcb
00565
00566
00567
00568
00569
00570
#define KeGetPcr() PCR
00571
00572
00573
00574
00575
00576
#define KeGetCurrentThread() PCR->CurrentThread
00577
00578
00579
00580
00581
00582
#define KeGetCurrentProcessorNumber() PCR->Number
00583
00584
00585
00586
00587
00588
#define KeGetDcacheFillSize() PCR->DcacheFillSize
00589
00590
00591
00592
00593
00594
00595
00596
#define KeGetPreviousMode() (KPROCESSOR_MODE)PCR->CurrentThread->PreviousMode
00597
00598
00599
00600
00601
00602
#define KeIsExecutingDpc() (PCR->Prcb->DpcRoutineActive != 0)
00603
00604
00605
00606
00607
00608
00609
#define KeSaveFloatingPointState(a) STATUS_SUCCESS
00610
#define KeRestoreFloatingPointState(a) STATUS_SUCCESS
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
#define PAGE_SIZE 0x2000
00622
00623
00624
00625
00626
00627
00628
00629
#define PAGE_SHIFT 13L
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
#define _HARDWARE_PTE_WORKING_SET_BITS 11 // Intel-IA64-Filler
00646
00647
typedef struct _HARDWARE_PTE {
00648 ULONG64 Valid : 1;
00649 ULONG64 Rsvd0 : 1;
00650 ULONG64 Cache : 3;
00651 ULONG64 Accessed : 1;
00652 ULONG64 Dirty : 1;
00653 ULONG64
Owner : 2;
00654 ULONG64 Execute : 1;
00655 ULONG64 Write : 1;
00656 ULONG64 Rsvd1 :
PAGE_SHIFT - 12;
00657 ULONG64 CopyOnWrite : 1;
00658 ULONG64 PageFrameNumber : 50 -
PAGE_SHIFT;
00659 ULONG64 Rsvd2 : 2;
00660 ULONG64 Exception : 1;
00661 ULONGLONG SoftwareWsIndex :
_HARDWARE_PTE_WORKING_SET_BITS;
00662 } HARDWARE_PTE, *PHARDWARE_PTE;
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
#define KiVhptEntry(va) ((PVOID)__thash((__int64)va)) // Intel-IA64-Filler
00674
#define KiVhptEntryTag(va) ((ULONGLONG)__ttag((__int64)va)) // Intel-IA64-Filler
00675
00676
#define KiFlushSingleTb(Invalid, va) \
00677 __ptcl((__int64)va,PAGE_SHIFT << 2); __isrlz() // Intel-IA64-Filler
00678
00679
#define KeFillEntryTb(PointerPte, Virtual, Invalid) \
00680 if (Invalid != FALSE) { \
00681 KiFlushSingleTb(0, Virtual); \
00682 } // Intel-IA64-Filler
00683
00684
#define KiFlushFixedInstTb(Invalid, va) \
00685 __ptri((__int64)va, PAGE_SHIFT << 2); __isrlz() // Intel-IA64-Filler
00686
00687
#define KiFlushFixedDataTb(Invalid, va) \
00688 __ptrd((__int64)va, PAGE_SHIFT << 2); __dsrlz() // Intel-IA64-Filler
00689
00690
00691
00692
NTKERNELAPI
00693
VOID
00694 KeFillLargeEntryTb (
00695 IN HARDWARE_PTE Pte[2],
00696 IN PVOID Virtual,
00697 IN ULONG PageSize
00698 );
00699
00700
00701
00702
00703
00704
NTKERNELAPI
00705
VOID
00706 KeFillFixedEntryTb (
00707 IN HARDWARE_PTE Pte[2],
00708 IN PVOID Virtual,
00709 IN ULONG Index
00710 );
00711
00712
NTKERNELAPI
00713
VOID
00714 KeFillFixedLargeEntryTb (
00715 IN HARDWARE_PTE Pte[2],
00716 IN PVOID Virtual,
00717 IN ULONG PageSize,
00718 IN ULONG Index
00719 );
00720
00721
00722
00723
00724
00725
NTKERNELAPI
00726
VOID
00727 KeFillInstEntryTb (
00728 IN HARDWARE_PTE Pte,
00729 IN PVOID Virtual
00730 );
00731
00732
00733
00734
00735
00736 PVOID
00737 KiVhptEntry64(
00738 IN ULONG VirtualPageNumber
00739 );
00740
00741
00742
00743
00744
00745 ULONGLONG
00746 KiVhptEntryTag64(
00747 IN ULONG VirtualPageNumber
00748 );
00749
00750
00751
00752
00753
00754
VOID
00755 KiFillEntryVhpt(
00756 IN PHARDWARE_PTE PointerPte,
00757 IN PVOID Virtual
00758 );
00759
00760
00761
00762
00763
00764
00765
00766
VOID
00767 KeFlushKernelTb(
00768 IN BOOLEAN AllProcessors
00769 );
00770
00771
00772
00773
00774
00775
VOID
00776 KeFlushUserTb(
00777 IN BOOLEAN AllProcessors
00778 );
00779
00780
00781
00782
00783
00784
00785
00786
00787
NTKERNELAPI
00788
VOID
00789
KeChangeColorPage (
00790 IN PVOID NewColor,
00791 IN PVOID OldColor,
00792 IN ULONG PageFrame
00793 );
00794
00795
NTKERNELAPI
00796
VOID
00797
KeSweepDcache (
00798 IN BOOLEAN AllProcessors
00799 );
00800
00801
#define KeSweepCurrentDcache()
00802
00803
NTKERNELAPI
00804
VOID
00805
KeSweepIcache (
00806 IN BOOLEAN AllProcessors
00807 );
00808
00809
#define KeSweepCurrentIcache()
00810
00811
NTKERNELAPI
00812
VOID
00813
KeSweepIcacheRange (
00814 IN BOOLEAN AllProcessors,
00815 IN PVOID BaseAddress,
00816 IN ULONG Length
00817 );
00818
00819
NTKERNELAPI
00820
VOID
00821
KeSweepCacheRangeWithDrain (
00822 IN BOOLEAN AllProcessors,
00823 IN PVOID BaseAddress,
00824 IN ULONG Length
00825 );
00826
00827
00828
00829
00830
00831
00832
NTKERNELAPI
00833
VOID
00834
KeFlushIoBuffers (
00835 IN
PMDL Mdl,
00836 IN BOOLEAN ReadOperation,
00837 IN BOOLEAN DmaOperation
00838 );
00839
00840
00841
00842
00843
00844
00845
00846
struct _KEXCEPTION_FRAME;
00847
struct _KTRAP_FRAME;
00848
00849
NTKERNELAPI
00850
VOID
00851 KeIpiInterrupt (
00852 IN
struct _KTRAP_FRAME *TrapFrame
00853 );
00854
00855
#define KeYieldProcessor()
00856
00857
NTKERNELAPI
00858
VOID
00859
KeProfileInterrupt (
00860 IN
struct _KTRAP_FRAME *TrapFrame
00861 );
00862
00863
NTKERNELAPI
00864
VOID
00865
KeProfileInterruptWithSource (
00866 IN
struct _KTRAP_FRAME *TrapFrame,
00867 IN KPROFILE_SOURCE ProfileSource
00868 );
00869
00870
NTKERNELAPI
00871
VOID
00872
KeUpdateRunTime (
00873 IN
struct _KTRAP_FRAME *TrapFrame
00874 );
00875
00876
NTKERNELAPI
00877
VOID
00878
KeUpdateSystemTime (
00879 IN
struct _KTRAP_FRAME *TrapFrame,
00880 IN ULONG Increment
00881 );
00882
00883
00884
00885
00886
00887
#if defined(NT_UP)
00888
00889
#define KiAcquireSpinLock(SpinLock)
00890
00891
#else
00892
00893
NTKERNELAPI
00894
VOID
00895 KiAcquireSpinLock (
00896 IN PKSPIN_LOCK SpinLock
00897 );
00898
00899
#endif
00900
00901
#if defined(NT_UP)
00902
00903
#define KiReleaseSpinLock(SpinLock)
00904
00905
#else
00906
00907
#define KiReleaseSpinLock(SpinLock) _ReleaseSpinLock(SpinLock)
00908
00909
#endif
00910
00911
00912
00913
00914
00915
00916
00917
#if defined(NT_UP)
00918
00919
#define KeTestSpinLock(SpinLock) (TRUE)
00920
00921
#else
00922
00923 BOOLEAN
00924 KeTestSpinLock (
00925 IN PKSPIN_LOCK SpinLock
00926 );
00927
00928
#endif
00929
00930
00931
00932
00933
00934
typedef
00935
VOID
00936 (*PKCACHE_ERROR_ROUTINE) (
00937
VOID
00938 );
00939
00940
NTKERNELAPI
00941
VOID
00942
KeSetCacheErrorRoutine (
00943 IN PKCACHE_ERROR_ROUTINE Routine
00944 );
00945
00946
00947
00948
00949
00950
00951
00952
VOID
00953 KeBreakinBreakpoint (
00954 VOID
00955 );
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
#if defined(NT_UP) && !defined(_NTDDK_) && !defined(_NTIFS_)
00967
#define ExAcquireSpinLock(Lock, OldIrql) KeRaiseIrql(DISPATCH_LEVEL, (OldIrql))
00968
#define ExReleaseSpinLock(Lock, OldIrql) KeLowerIrql((OldIrql))
00969
#define ExAcquireSpinLockAtDpcLevel(Lock)
00970
#define ExReleaseSpinLockFromDpcLevel(Lock)
00971
#else
00972
00973
00974
00975
#define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
00976
#define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
00977
#define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
00978
#define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
00979
00980
00981
00982
#endif
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
#if defined(_M_IA64)
00993
00994
VOID
00995 _disable (
00996 VOID
00997 );
00998
00999
VOID
01000 _enable (
01001 VOID
01002 );
01003
01004
#pragma intrinsic(_disable)
01005
#pragma intrinsic(_enable)
01006
01007
#endif
01008
01009
#if defined(NT_UP) && !DBG
01010
#define ExAcquireFastLock(Lock, OldIrql) _disable()
01011
#else
01012
#define ExAcquireFastLock(Lock, OldIrql) \
01013
ExAcquireSpinLock(Lock, OldIrql)
01014
#endif
01015
01016
#if defined(NT_UP) && !DBG
01017
#define ExReleaseFastLock(Lock, OldIrql) _enable()
01018
#else
01019
#define ExReleaseFastLock(Lock, OldIrql) \
01020
ExReleaseSpinLock(Lock, OldIrql)
01021
#endif
01022
01023
01024
01025
01026
01027 BOOLEAN
01028
KeBusError (
01029 IN PEXCEPTION_RECORD ExceptionRecord,
01030 IN
struct _KEXCEPTION_FRAME *ExceptionFrame,
01031 IN
struct _KTRAP_FRAME *TrapFrame,
01032 IN PVOID VirtualAddress,
01033 IN PHYSICAL_ADDRESS PhysicalAddress
01034 );
01035
01036
VOID
01037
KiDataBusError (
01038 IN PEXCEPTION_RECORD ExceptionRecord,
01039 IN
struct _KEXCEPTION_FRAME *ExceptionFrame,
01040 IN
struct _KTRAP_FRAME *TrapFrame
01041 );
01042
01043
VOID
01044
KiInstructionBusError (
01045 IN PEXCEPTION_RECORD ExceptionRecord,
01046 IN
struct _KEXCEPTION_FRAME *ExceptionFrame,
01047 IN
struct _KTRAP_FRAME *TrapFrame
01048 );
01049
01050
01051
01052
01053
01054
#define KiQuerySystemTime(CurrentTime) \
01055
while (TRUE) { \
01056
(CurrentTime)->HighPart = SharedUserData->SystemHigh1Time; \
01057
(CurrentTime)->LowPart = SharedUserData->SystemLowTime; \
01058
if ((CurrentTime)->HighPart == SharedUserData->SystemHigh2Time) break; \
01059
}
01060
01061
01062
01063
01064
01065
01066
#if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
01067
01068
01069
01070
#define KeQueryTickCount(CurrentCount ) \
01071
*(PULONGLONG)(CurrentCount) = **((volatile ULONGLONG **)(&KeTickCount));
01072
01073
01074
01075
#else
01076
01077
#define KiQueryTickCount(CurrentCount) \
01078
*(PULONGLONG)(CurrentCount) = KeTickCount;
01079
01080
NTKERNELAPI
01081
VOID
01082
KeQueryTickCount (
01083 OUT PLARGE_INTEGER CurrentCount
01084 );
01085
01086
#endif // defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
01087
01088
01089
01090
#define KiQueryLowTickCount() (ULONG)KeTickCount
01091
01092
01093
01094
01095
01096
#define KiQueryInterruptTime(CurrentTime) \
01097
*(PULONGLONG)(CurrentTime) = SharedUserData->InterruptTime
01098
01099
01100
01101
01102
01103
01104 ULONG
01105
KiEmulateBranch (
01106 IN
struct _KEXCEPTION_FRAME *ExceptionFrame,
01107 IN
struct _KTRAP_FRAME *TrapFrame
01108 );
01109
01110 BOOLEAN
01111
KiEmulateFloating (
01112 IN OUT PEXCEPTION_RECORD ExceptionRecord,
01113 IN OUT
struct _KEXCEPTION_FRAME *ExceptionFrame,
01114 IN OUT
struct _KTRAP_FRAME *TrapFrame
01115 );
01116
01117 BOOLEAN
01118
KiEmulateReference (
01119 IN OUT PEXCEPTION_RECORD ExceptionRecord,
01120 IN OUT
struct _KEXCEPTION_FRAME *ExceptionFrame,
01121 IN OUT
struct _KTRAP_FRAME *TrapFrame
01122 );
01123
01124 ULONGLONG
01125
KiGetRegisterValue (
01126 IN ULONG Register,
01127 IN
struct _KEXCEPTION_FRAME *ExceptionFrame,
01128 IN
struct _KTRAP_FRAME *TrapFrame
01129 );
01130
01131
VOID
01132
KiSetRegisterValue (
01133 IN ULONG Register,
01134 IN ULONGLONG Value,
01135 OUT
struct _KEXCEPTION_FRAME *ExceptionFrame,
01136 OUT
struct _KTRAP_FRAME *TrapFrame
01137 );
01138
01139 FLOAT128
01140
KiGetFloatRegisterValue (
01141 IN ULONG Register,
01142 IN
struct _KEXCEPTION_FRAME *ExceptionFrame,
01143 IN
struct _KTRAP_FRAME *TrapFrame
01144 );
01145
01146
VOID
01147
KiSetFloatRegisterValue (
01148 IN ULONG Register,
01149 IN FLOAT128 Value,
01150 OUT
struct _KEXCEPTION_FRAME *ExceptionFrame,
01151 OUT
struct _KTRAP_FRAME *TrapFrame
01152 );
01153
01154
VOID
01155
KiAdvanceInstPointer(
01156 IN OUT
struct _KTRAP_FRAME *TrapFrame
01157 );
01158
01159
VOID
01160
KiRequestSoftwareInterrupt (
01161 KIRQL RequestIrql
01162 );
01163
01164
01165
01166
01167
01168
01169
NTHALAPI
01170 UCHAR
01171 READ_PORT_UCHAR (
01172 PUCHAR RegisterAddress
01173 );
01174
01175
NTHALAPI
01176
USHORT
01177 READ_PORT_USHORT (
01178 PUSHORT RegisterAddress
01179 );
01180
01181
NTHALAPI
01182 ULONG
01183 READ_PORT_ULONG (
01184 PULONG RegisterAddress
01185 );
01186
01187
NTHALAPI
01188
VOID
01189 READ_PORT_BUFFER_UCHAR (
01190 PUCHAR portAddress,
01191 PUCHAR readBuffer,
01192 ULONG readCount
01193 );
01194
01195
NTHALAPI
01196
VOID
01197 READ_PORT_BUFFER_USHORT (
01198 PUSHORT portAddress,
01199 PUSHORT readBuffer,
01200 ULONG readCount
01201 );
01202
01203
NTHALAPI
01204
VOID
01205 READ_PORT_BUFFER_ULONG (
01206 PULONG portAddress,
01207 PULONG readBuffer,
01208 ULONG readCount
01209 );
01210
01211
NTHALAPI
01212
VOID
01213 WRITE_PORT_UCHAR (
01214 PUCHAR portAddress,
01215 UCHAR Data
01216 );
01217
01218
NTHALAPI
01219
VOID
01220 WRITE_PORT_USHORT (
01221 PUSHORT portAddress,
01222 USHORT Data
01223 );
01224
01225
NTHALAPI
01226
VOID
01227 WRITE_PORT_ULONG (
01228 PULONG portAddress,
01229 ULONG Data
01230 );
01231
01232
NTHALAPI
01233
VOID
01234 WRITE_PORT_BUFFER_UCHAR (
01235 PUCHAR portAddress,
01236 PUCHAR writeBuffer,
01237 ULONG writeCount
01238 );
01239
01240
NTHALAPI
01241
VOID
01242 WRITE_PORT_BUFFER_USHORT (
01243 PUSHORT portAddress,
01244 PUSHORT writeBuffer,
01245 ULONG writeCount
01246 );
01247
01248
NTHALAPI
01249
VOID
01250 WRITE_PORT_BUFFER_ULONG (
01251 PULONG portAddress,
01252 PULONG writeBuffer,
01253 ULONG writeCount
01254 );
01255
01256
01257
#define READ_REGISTER_UCHAR(x) \
01258
(__mf(), *(volatile UCHAR * const)(x))
01259
01260
#define READ_REGISTER_USHORT(x) \
01261
(__mf(), *(volatile USHORT * const)(x))
01262
01263
#define READ_REGISTER_ULONG(x) \
01264
(__mf(), *(volatile ULONG * const)(x))
01265
01266
#define READ_REGISTER_BUFFER_UCHAR(x, y, z) { \
01267
PUCHAR registerBuffer = x; \
01268
PUCHAR readBuffer = y; \
01269
ULONG readCount; \
01270
__mf(); \
01271
for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
01272
*readBuffer = *(volatile UCHAR * const)(registerBuffer); \
01273
} \
01274
}
01275
01276
#define READ_REGISTER_BUFFER_USHORT(x, y, z) { \
01277
PUSHORT registerBuffer = x; \
01278
PUSHORT readBuffer = y; \
01279
ULONG readCount; \
01280
__mf(); \
01281
for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
01282
*readBuffer = *(volatile USHORT * const)(registerBuffer); \
01283
} \
01284
}
01285
01286
#define READ_REGISTER_BUFFER_ULONG(x, y, z) { \
01287
PULONG registerBuffer = x; \
01288
PULONG readBuffer = y; \
01289
ULONG readCount; \
01290
__mf(); \
01291
for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
01292
*readBuffer = *(volatile ULONG * const)(registerBuffer); \
01293
} \
01294
}
01295
01296
#define WRITE_REGISTER_UCHAR(x, y) { \
01297
*(volatile UCHAR * const)(x) = y; \
01298
KeFlushWriteBuffer(); \
01299
}
01300
01301
#define WRITE_REGISTER_USHORT(x, y) { \
01302
*(volatile USHORT * const)(x) = y; \
01303
KeFlushWriteBuffer(); \
01304
}
01305
01306
#define WRITE_REGISTER_ULONG(x, y) { \
01307
*(volatile ULONG * const)(x) = y; \
01308
KeFlushWriteBuffer(); \
01309
}
01310
01311
#define WRITE_REGISTER_BUFFER_UCHAR(x, y, z) { \
01312
PUCHAR registerBuffer = x; \
01313
PUCHAR writeBuffer = y; \
01314
ULONG writeCount; \
01315
for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
01316
*(volatile UCHAR * const)(registerBuffer) = *writeBuffer; \
01317
} \
01318
KeFlushWriteBuffer(); \
01319
}
01320
01321
#define WRITE_REGISTER_BUFFER_USHORT(x, y, z) { \
01322
PUSHORT registerBuffer = x; \
01323
PUSHORT writeBuffer = y; \
01324
ULONG writeCount; \
01325
for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
01326
*(volatile USHORT * const)(registerBuffer) = *writeBuffer; \
01327
} \
01328
KeFlushWriteBuffer(); \
01329
}
01330
01331
#define WRITE_REGISTER_BUFFER_ULONG(x, y, z) { \
01332
PULONG registerBuffer = x; \
01333
PULONG writeBuffer = y; \
01334
ULONG writeCount; \
01335
for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
01336
*(volatile ULONG * const)(registerBuffer) = *writeBuffer; \
01337
} \
01338
KeFlushWriteBuffer(); \
01339
}
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
typedef struct _KHIGHER_FP_VOLATILE {
01354
01355 FLOAT128 FltF32;
01356 FLOAT128 FltF33;
01357 FLOAT128 FltF34;
01358 FLOAT128 FltF35;
01359 FLOAT128 FltF36;
01360 FLOAT128 FltF37;
01361 FLOAT128 FltF38;
01362 FLOAT128 FltF39;
01363 FLOAT128 FltF40;
01364 FLOAT128 FltF41;
01365 FLOAT128 FltF42;
01366 FLOAT128 FltF43;
01367 FLOAT128 FltF44;
01368 FLOAT128 FltF45;
01369 FLOAT128 FltF46;
01370 FLOAT128 FltF47;
01371 FLOAT128 FltF48;
01372 FLOAT128 FltF49;
01373 FLOAT128 FltF50;
01374 FLOAT128 FltF51;
01375 FLOAT128 FltF52;
01376 FLOAT128 FltF53;
01377 FLOAT128 FltF54;
01378 FLOAT128 FltF55;
01379 FLOAT128 FltF56;
01380 FLOAT128 FltF57;
01381 FLOAT128 FltF58;
01382 FLOAT128 FltF59;
01383 FLOAT128 FltF60;
01384 FLOAT128 FltF61;
01385 FLOAT128 FltF62;
01386 FLOAT128 FltF63;
01387 FLOAT128 FltF64;
01388 FLOAT128 FltF65;
01389 FLOAT128 FltF66;
01390 FLOAT128 FltF67;
01391 FLOAT128 FltF68;
01392 FLOAT128 FltF69;
01393 FLOAT128 FltF70;
01394 FLOAT128 FltF71;
01395 FLOAT128 FltF72;
01396 FLOAT128 FltF73;
01397 FLOAT128 FltF74;
01398 FLOAT128 FltF75;
01399 FLOAT128 FltF76;
01400 FLOAT128 FltF77;
01401 FLOAT128 FltF78;
01402 FLOAT128 FltF79;
01403 FLOAT128 FltF80;
01404 FLOAT128 FltF81;
01405 FLOAT128 FltF82;
01406 FLOAT128 FltF83;
01407 FLOAT128 FltF84;
01408 FLOAT128 FltF85;
01409 FLOAT128 FltF86;
01410 FLOAT128 FltF87;
01411 FLOAT128 FltF88;
01412 FLOAT128 FltF89;
01413 FLOAT128 FltF90;
01414 FLOAT128 FltF91;
01415 FLOAT128 FltF92;
01416 FLOAT128 FltF93;
01417 FLOAT128 FltF94;
01418 FLOAT128 FltF95;
01419 FLOAT128 FltF96;
01420 FLOAT128 FltF97;
01421 FLOAT128 FltF98;
01422 FLOAT128 FltF99;
01423 FLOAT128 FltF100;
01424 FLOAT128 FltF101;
01425 FLOAT128 FltF102;
01426 FLOAT128 FltF103;
01427 FLOAT128 FltF104;
01428 FLOAT128 FltF105;
01429 FLOAT128 FltF106;
01430 FLOAT128 FltF107;
01431 FLOAT128 FltF108;
01432 FLOAT128 FltF109;
01433 FLOAT128 FltF110;
01434 FLOAT128 FltF111;
01435 FLOAT128 FltF112;
01436 FLOAT128 FltF113;
01437 FLOAT128 FltF114;
01438 FLOAT128 FltF115;
01439 FLOAT128 FltF116;
01440 FLOAT128 FltF117;
01441 FLOAT128 FltF118;
01442 FLOAT128 FltF119;
01443 FLOAT128 FltF120;
01444 FLOAT128 FltF121;
01445 FLOAT128 FltF122;
01446 FLOAT128 FltF123;
01447 FLOAT128 FltF124;
01448 FLOAT128 FltF125;
01449 FLOAT128 FltF126;
01450 FLOAT128 FltF127;
01451
01452 } KHIGHER_FP_VOLATILE, *PKHIGHER_FP_VOLATILE;
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
typedef struct _KDEBUG_REGISTERS {
01463
01464 ULONGLONG DbI0;
01465 ULONGLONG DbI1;
01466 ULONGLONG DbI2;
01467 ULONGLONG DbI3;
01468 ULONGLONG DbI4;
01469 ULONGLONG DbI5;
01470 ULONGLONG DbI6;
01471 ULONGLONG DbI7;
01472
01473 ULONGLONG DbD0;
01474 ULONGLONG DbD1;
01475 ULONGLONG DbD2;
01476 ULONGLONG DbD3;
01477 ULONGLONG DbD4;
01478 ULONGLONG DbD5;
01479 ULONGLONG DbD6;
01480 ULONGLONG DbD7;
01481
01482 } KDEBUG_REGISTERS, *PKDEBUG_REGISTERS;
01483
01484
01485
01486
01487
01488
typedef struct _KAPPLICATION_REGISTERS {
01489 ULONGLONG Ar21;
01490 ULONGLONG Ar24;
01491 ULONGLONG Ar25;
01492 ULONGLONG Ar26;
01493 ULONGLONG Ar27;
01494 ULONGLONG Ar28;
01495 ULONGLONG Ar29;
01496 ULONGLONG Ar30;
01497 } KAPPLICATION_REGISTERS, *PKAPPLICATION_REGISTERS;
01498
01499
01500
01501
01502
01503
typedef struct _KPERFORMANCE_REGISTERS {
01504 ULONGLONG Perfr0;
01505 ULONGLONG Perfr1;
01506 ULONGLONG Perfr2;
01507 ULONGLONG Perfr3;
01508 ULONGLONG Perfr4;
01509 ULONGLONG Perfr5;
01510 ULONGLONG Perfr6;
01511 ULONGLONG Perfr7;
01512 } KPERFORMANCE_REGISTERS, *PKPERFORMANCE_REGISTERS;
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
typedef struct _KTHREAD_STATE_SAVEAREA {
01526
01527 KAPPLICATION_REGISTERS AppRegisters;
01528 KPERFORMANCE_REGISTERS PerfRegisters;
01529 KHIGHER_FP_VOLATILE HigherFPVolatile;
01530 KDEBUG_REGISTERS DebugRegisters;
01531
01532 } KTHREAD_STATE_SAVEAREA, *PKTHREAD_STATE_SAVEAREA;
01533
01534
#define KTHREAD_STATE_SAVEAREA_LENGTH ((sizeof(KTHREAD_STATE_SAVEAREA) + 15) & ~((ULONG_PTR)15))
01535
01536
#define GET_HIGH_FLOATING_POINT_REGISTER_SAVEAREA() \
01537
(PKHIGHER_FP_VOLATILE) &(((PKTHREAD_STATE_SAVEAREA)(((ULONG_PTR)PCR->InitialStack - sizeof(KTHREAD_STATE_SAVEAREA)) & ~((ULONG_PTR)15)))->HigherFPVolatile)
01538
01539
#define GET_DEBUG_REGISTER_SAVEAREA() \
01540
(PKDEBUG_REGISTERS) &(((PKTHREAD_STATE_SAVEAREA)(((ULONG_PTR)KeGetCurrentThread()->StackBase - sizeof(KTHREAD_STATE_SAVEAREA)) & ~((ULONG_PTR)15)))->DebugRegisters)
01541
01542
#define GET_APPLICATION_REGISTER_SAVEAREA(StackBase) \
01543
(PKAPPLICATION_REGISTERS) &(((PKTHREAD_STATE_SAVEAREA)(((ULONG_PTR)StackBase - sizeof(KTHREAD_STATE_SAVEAREA)) & ~((ULONG_PTR)15)))->AppRegisters)
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
typedef struct _KEXCEPTION_FRAME {
01559
01560
01561
01562
01563
01564 ULONGLONG ApEC;
01565 ULONGLONG ApLC;
01566 ULONGLONG IntNats;
01567
01568
01569 ULONGLONG IntS0;
01570 ULONGLONG IntS1;
01571 ULONGLONG IntS2;
01572 ULONGLONG IntS3;
01573
01574
01575 ULONGLONG BrS0;
01576 ULONGLONG BrS1;
01577 ULONGLONG BrS2;
01578 ULONGLONG BrS3;
01579 ULONGLONG BrS4;
01580
01581
01582 FLOAT128 FltS0;
01583 FLOAT128 FltS1;
01584 FLOAT128 FltS2;
01585 FLOAT128 FltS3;
01586 FLOAT128 FltS4;
01587 FLOAT128 FltS5;
01588 FLOAT128 FltS6;
01589 FLOAT128 FltS7;
01590 FLOAT128 FltS8;
01591 FLOAT128 FltS9;
01592 FLOAT128 FltS10;
01593 FLOAT128 FltS11;
01594 FLOAT128 FltS12;
01595 FLOAT128 FltS13;
01596 FLOAT128 FltS14;
01597 FLOAT128 FltS15;
01598 FLOAT128 FltS16;
01599 FLOAT128 FltS17;
01600 FLOAT128 FltS18;
01601 FLOAT128 FltS19;
01602
01603
01604
01605 } KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
typedef struct _KSWITCH_FRAME {
01622
01623 ULONGLONG SwitchPredicates;
01624 ULONGLONG SwitchRp;
01625 ULONGLONG SwitchPFS;
01626 ULONGLONG SwitchFPSR;
01627 ULONGLONG SwitchBsp;
01628 ULONGLONG SwitchRnat;
01629
01630
01631 KEXCEPTION_FRAME SwitchExceptionFrame;
01632
01633 } KSWITCH_FRAME, *PKSWITCH_FRAME;
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
#define KTRAP_FRAME_ARGUMENTS (8 * 8) // up to 8 in-memory syscall args // Intel-IA64-Filler
01645
01646
01647
01648
typedef struct _KTRAP_FRAME {
01649
01650
01651
01652
01653
01654
01655
01656
01657 ULONGLONG Reserved[(KTRAP_FRAME_ARGUMENTS+16)/8];
01658
01659
01660 FLOAT128 FltT0;
01661 FLOAT128 FltT1;
01662 FLOAT128 FltT2;
01663 FLOAT128 FltT3;
01664 FLOAT128 FltT4;
01665 FLOAT128 FltT5;
01666 FLOAT128 FltT6;
01667 FLOAT128 FltT7;
01668 FLOAT128 FltT8;
01669 FLOAT128 FltT9;
01670
01671
01672 ULONGLONG IntGp;
01673 ULONGLONG IntT0;
01674 ULONGLONG IntT1;
01675
01676 ULONGLONG ApUNAT;
01677 ULONGLONG ApCCV;
01678 ULONGLONG ApDCR;
01679 ULONGLONG Preds;
01680
01681 ULONGLONG IntV0;
01682 ULONGLONG IntT2;
01683 ULONGLONG IntT3;
01684 ULONGLONG IntT4;
01685 ULONGLONG IntSp;
01686 ULONGLONG IntTeb;
01687 ULONGLONG IntT5;
01688 ULONGLONG IntT6;
01689 ULONGLONG IntT7;
01690 ULONGLONG IntT8;
01691 ULONGLONG IntT9;
01692 ULONGLONG IntT10;
01693 ULONGLONG IntT11;
01694 ULONGLONG IntT12;
01695 ULONGLONG IntT13;
01696 ULONGLONG IntT14;
01697 ULONGLONG IntT15;
01698 ULONGLONG IntT16;
01699 ULONGLONG IntT17;
01700 ULONGLONG IntT18;
01701 ULONGLONG IntT19;
01702 ULONGLONG IntT20;
01703 ULONGLONG IntT21;
01704 ULONGLONG IntT22;
01705
01706 ULONGLONG IntNats;
01707
01708 ULONGLONG BrRp;
01709
01710 ULONGLONG BrT0;
01711 ULONGLONG BrT1;
01712
01713
01714 ULONGLONG RsRSC;
01715 ULONGLONG RsBSP;
01716 ULONGLONG RsBSPSTORE;
01717 ULONGLONG RsRNAT;
01718 ULONGLONG RsPFS;
01719
01720
01721 ULONGLONG StIPSR;
01722 ULONGLONG StIIP;
01723 ULONGLONG StIFS;
01724 ULONGLONG StFPSR;
01725 ULONGLONG StISR;
01726 ULONGLONG StIFA;
01727 ULONGLONG StIIPA;
01728 ULONGLONG StIIM;
01729 ULONGLONG StIHA;
01730
01731 ULONG OldIrql;
01732 ULONG PreviousMode;
01733 ULONGLONG TrapFrame;
01734
01735
01736 UCHAR ExceptionRecord[(
sizeof(EXCEPTION_RECORD) + 15) & (~15)];
01737
01738
01739 ULONGLONG Handler;
01740 ULONGLONG EOFMarker;
01741 } KTRAP_FRAME, *PKTRAP_FRAME;
01742
01743
#define KTRAP_FRAME_LENGTH ((sizeof(KTRAP_FRAME) + 15) & (~15))
01744
#define KTRAP_FRAME_ALIGN (16)
01745
#define KTRAP_FRAME_ROUND (KTRAP_FRAME_ALIGN - 1)
01746
#define KTRAP_FRAME_EOF 0xe0f0e0f0e0f0e000i64
01747
01748
01749
01750
01751
01752
#define SYSCALL_FRAME 0
01753
#define INTERRUPT_FRAME 1
01754
#define EXCEPTION_FRAME 2
01755
#define CONTEXT_FRAME 10
01756
01757
#define TRAP_FRAME_TYPE(tf) (tf->EOFMarker & 0xf)
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
typedef struct _KCALLOUT_FRAME {
01773
01774
01775
01776
01777 ULONGLONG BrRp;
01778 ULONGLONG RsPFS;
01779 ULONGLONG Preds;
01780 ULONGLONG ApUNAT;
01781 ULONGLONG ApLC;
01782 ULONGLONG RsRNAT;
01783 ULONGLONG IntNats;
01784
01785 ULONGLONG IntS0;
01786 ULONGLONG IntS1;
01787 ULONGLONG IntS2;
01788 ULONGLONG IntS3;
01789
01790 ULONGLONG BrS0;
01791 ULONGLONG BrS1;
01792 ULONGLONG BrS2;
01793 ULONGLONG BrS3;
01794 ULONGLONG BrS4;
01795
01796 FLOAT128 FltS0;
01797 FLOAT128 FltS1;
01798 FLOAT128 FltS2;
01799 FLOAT128 FltS3;
01800 FLOAT128 FltS4;
01801 FLOAT128 FltS5;
01802 FLOAT128 FltS6;
01803 FLOAT128 FltS7;
01804 FLOAT128 FltS8;
01805 FLOAT128 FltS9;
01806 FLOAT128 FltS10;
01807 FLOAT128 FltS11;
01808 FLOAT128 FltS12;
01809 FLOAT128 FltS13;
01810 FLOAT128 FltS14;
01811 FLOAT128 FltS15;
01812 FLOAT128 FltS16;
01813 FLOAT128 FltS17;
01814 FLOAT128 FltS18;
01815 FLOAT128 FltS19;
01816
01817 ULONGLONG A0;
01818 ULONGLONG
A1;
01819 ULONGLONG CbStk;
01820 ULONGLONG InStack;
01821 ULONGLONG CbBStore;
01822 ULONGLONG InBStore;
01823 ULONGLONG TrFrame;
01824 ULONGLONG TrStIIP;
01825
01826
01827
01828 } KCALLOUT_FRAME, *PKCALLOUT_FRAME;
01829
01830
01831
typedef struct _UCALLOUT_FRAME {
01832
01833
01834 PVOID
Buffer;
01835 ULONG Length;
01836 ULONG ApiNumber;
01837 ULONGLONG IntSp;
01838 ULONGLONG RsPFS;
01839 ULONGLONG BrRp;
01840 ULONGLONG Pad;
01841
01842 } UCALLOUT_FRAME, *PUCALLOUT_FRAME;
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
typedef struct _KFLOATING_SAVE {
01853 ULONG Reserved;
01854 } KFLOATING_SAVE, *PKFLOATING_SAVE;
01855
01856
01857
01858
#define STATUS_IA64_INVALID_STACK STATUS_BAD_STACK
01859
01860
01861
01862
01863
01864
01865
01866
01867
#define CR0_PG 0x80000000 // paging
01868
#define CR0_ET 0x00000010 // extension type (80387)
01869
#define CR0_TS 0x00000008 // task switched
01870
#define CR0_EM 0x00000004 // emulate math coprocessor
01871
#define CR0_MP 0x00000002 // math present
01872
#define CR0_PE 0x00000001 // protection enable
01873
01874
01875
01876
01877
01878
#define CR0_CD 0x40000000 // cache disable
01879
#define CR0_NW 0x20000000 // not write-through
01880
#define CR0_AM 0x00040000 // alignment mask
01881
#define CR0_WP 0x00010000 // write protect
01882
#define CR0_NE 0x00000020 // numeric error
01883
01884
01885
01886
01887
#define CFLG_IO 0x00000040 // IO bit map checking on
01888
#define CFLG_IF 0x00000080 // EFLAG.if to control external interrupt
01889
#define CFLG_II 0x00000100 // enable EFLAG.if interception
01890
#define CFLG_NM 0x00000200 // NMI intercept
01891
01892
01893
01894
01895
#define CR4_VME 0x00000001 // V86 mode extensions
01896
#define CR4_PVI 0x00000002 // Protected mode virtual interrupts
01897
#define CR4_TSD 0x00000004 // Time stamp disable
01898
#define CR4_DE 0x00000008 // Debugging Extensions
01899
#define CR4_PSE 0x00000010 // Page size extensions
01900
#define CR4_MCE 0x00000040 // Machine check enable
01901
01902
01903
01904
01905
01906
#define NPX_STATE_NOT_LOADED (CR0_TS | CR0_MP)
01907
#define NPX_STATE_LOADED 0
01908
01909
01910
01911
01912
01913
01914
01915
typedef union _MCI_STATS {
01916
struct {
01917
USHORT McaCod;
01918
USHORT MsCod;
01919 ULONG OtherInfo : 25;
01920 ULONG Damage : 1;
01921 ULONG AddressValid : 1;
01922 ULONG MiscValid : 1;
01923 ULONG Enabled : 1;
01924 ULONG UnCorrected : 1;
01925 ULONG OverFlow : 1;
01926 ULONG Valid : 1;
01927 } MciStats;
01928
01929 ULONGLONG QuadPart;
01930
01931 } MCI_STATS, *PMCI_STATS;
01932
01933
01934
01935
01936
01937
01938
01939
#define MACHINE_TYPE_ISA 0
01940
#define MACHINE_TYPE_EISA 1
01941
#define MACHINE_TYPE_MCA 2
01942
01943
01944
01945
01946
01947
01948
01949
01950
#define PAL_CACHE_FLUSH 1I64
01951
#define PAL_CACHE_INFO 2I64
01952
#define PAL_CACHE_INIT 3I64
01953
#define PAL_CACHE_SUMMARY 4I64
01954
#define PAL_PTCE_INFO 6I64
01955
#define PAL_MEM_ATTRIB 5I64
01956
#define PAL_VM_INFO 7I64
01957
#define PAL_VM_SUMMARY 8I64
01958
#define PAL_BUS_GET_FEATURES 9I64
01959
#define PAL_BUS_SET_FEATURES 10I64
01960
#define PAL_DEBUG_INFO 11I64
01961
#define PAL_FIXED_ADDR 12I64
01962
#define PAL_FREQ_BASE 13I64
01963
#define PAL_FREQ_RATIOS 14I64
01964
#define PAL_PERF_MON_INFO 15I64
01965
#define PAL_PLATFORM_ADDR 16I64
01966
#define PAL_PROC_GET_FEATURES 17I64
01967
#define PAL_PROC_SET_FEATURES 18I64
01968
#define PAL_RSE_INFO 19I64
01969
#define PAL_VERSION 20I64
01970
#define PAL_MC_CLEAR_LOG 21I64
01971
#define PAL_MC_DRAIN 22I64
01972
#define PAL_MC_EXPECTED 23I64
01973
#define PAL_MC_DYNAMIC_STATE 24I64
01974
#define PAL_MC_ERROR_INFO 25I64
01975
#define PAL_MC_RESUME 26I64
01976
#define PAL_MC_REGISTER_MEM 27I64
01977
#define PAL_HALT 28I64
01978
#define PAL_HALT_LIGHT 29I64
01979
#define PAL_COPY_INFO 30I64
01980
#define PAL_CACHE_LINE_INIT 31I64
01981
#define PAL_PMI_ENTRYPOINT 32I64
01982
#define PAL_ENTER_IA_32_ENV 33I64
01983
#define PAL_VM_PAGE_SIZE 34I64
01984
#define PAL_MEM_FOR_TEST 37I64
01985
#define PAL_CACHE_PROT_INFO 38I64
01986
#define PAL_REGISTER_INFO 39I64
01987
#define PAL_SHUTDOWN 44I64
01988
#define PAL_PREFETCH_VISIBILITY 41I64
01989
01990
#define PAL_COPY_PAL 256I64
01991
#define PAL_HALT_INFO 257I64
01992
#define PAL_TEST_PROC 258I64
01993
#define PAL_CACHE_READ 259I64
01994
#define PAL_CACHE_WRITE 260I64
01995
#define PAL_VM_TR_READ 261I64
01996
01997
01998
01999
02000
02001
#define PAL_STATUS_INVALID_CACHELINE 1I64
02002
#define PAL_STATUS_SUPPORT_NOT_NEEDED 1I64
02003
#define PAL_STATUS_SUCCESS 0
02004
#define PAL_STATUS_NOT_IMPLEMENTED -1I64
02005
#define PAL_STATUS_INVALID_ARGUMENT -2I64
02006
#define PAL_STATUS_ERROR -3I64
02007
#define PAL_STATUS_UNABLE_TO_INIT_CACHE_LEVEL_AND_TYPE -4I64
02008
#define PAL_STATUS_NOT_FOUND_IN_CACHE -5I64
02009
#define PAL_STATUS_NO_ERROR_INFO_AVAILABLE -6I64
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
#define MODE_MASK 1
02026
#define RPL_MASK 3
02027
02028
02029
02030
02031
02032
02033
02034
#define SEGMENT_MASK 0xffff
02035
02036
typedef struct _LDTINFORMATION {
02037 ULONG
Size;
02038 ULONG AllocatedSize;
02039 PLDT_ENTRY Ldt;
02040 } LDTINFORMATION, *PLDTINFORMATION;
02041
02042
02043
02044
02045
02046
typedef struct _PROCESS_IO_PORT_HANDLER_INFORMATION {
02047 BOOLEAN Install;
02048 ULONG NumEntries;
02049 ULONG Context;
02050
PEMULATOR_ACCESS_ENTRY EmulatorAccessEntries;
02051 } PROCESS_IO_PORT_HANDLER_INFORMATION, *PPROCESS_IO_PORT_HANDLER_INFORMATION;
02052
02053
02054
02055
02056
02057
02058
typedef struct _KGDTENTRY {
02059
USHORT LimitLow;
02060
USHORT BaseLow;
02061
union {
02062
struct {
02063 UCHAR BaseMid;
02064 UCHAR Flags1;
02065 UCHAR Flags2;
02066 UCHAR BaseHi;
02067 } Bytes;
02068
struct {
02069 ULONG BaseMid : 8;
02070 ULONG Type : 5;
02071 ULONG Dpl : 2;
02072 ULONG Pres : 1;
02073 ULONG LimitHi : 4;
02074 ULONG Sys : 1;
02075 ULONG Reserved_0 : 1;
02076 ULONG Default_Big : 1;
02077 ULONG Granularity : 1;
02078 ULONG BaseHi : 8;
02079 } Bits;
02080 } HighWord;
02081 } KGDTENTRY, *PKGDTENTRY;
02082
02083
#define TYPE_TSS 0x01 // 01001 = NonBusy TSS
02084
#define TYPE_LDT 0x02 // 00010 = LDT
02085
02086
02087
02088
02089
typedef struct _KDESCRIPTOR_UNSCRAM {
02090
union {
02091 ULONGLONG DescriptorWords;
02092
struct {
02093 ULONGLONG Base : 32;
02094 ULONGLONG Limit : 20;
02095 ULONGLONG Type : 5;
02096 ULONGLONG Dpl : 2;
02097 ULONGLONG Pres : 1;
02098 ULONGLONG Sys : 1;
02099 ULONGLONG Reserved_0 : 1;
02100 ULONGLONG Default_Big : 1;
02101 ULONGLONG Granularity : 1;
02102 } Bits;
02103 } Words;
02104 } KXDESCRIPTOR, *PKXDESCRIPTOR;
02105
02106
#define TYPE_CODE_USER 0x1A // 0x11011 = Code, Readable, Accessed
02107
#define TYPE_DATA_USER 0x13 // 0x10011 = Data, ReadWrite, Accessed
02108
02109
#define DESCRIPTOR_EXPAND_DOWN 0x14
02110
#define DESCRIPTOR_DATA_READWRITE (0x8|0x2) // Data, Read/Write
02111
02112
#define DPL_USER 3
02113
#define DPL_SYSTEM 0
02114
02115
#define GRAN_BYTE 0
02116
#define GRAN_PAGE 1
02117
02118
#define SELECTOR_TABLE_INDEX 0x04
02119
02120
02121
02122
02123
02124
typedef struct _KIDTENTRY {
02125
USHORT Offset;
02126
USHORT Selector;
02127
USHORT Access;
02128
USHORT ExtendedOffset;
02129 } KIDTENTRY;
02130
02131
typedef KIDTENTRY *PKIDTENTRY;
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
#define EFLAGS_DF_MASK 0x00000400L
02142
#define EFLAGS_INTERRUPT_MASK 0x00000200L
02143
#define EFLAGS_V86_MASK 0x00020000L
02144
#define EFLAGS_ALIGN_CHECK 0x00040000L
02145
#define EFLAGS_IOPL_MASK 0x00003000L
02146
#define EFLAGS_VIF 0x00080000L
02147
#define EFLAGS_VIP 0x00100000L
02148
#define EFLAGS_USER_SANITIZE 0x003e0dd7L
02149
02150
#define SANITIZE_FLAGS(eFlags, mode) (\
02151
((mode) == KernelMode ? \
02152
((0x00000000L) | ((eFlags) & 0x003e0fd7)) : \
02153
((EFLAGS_INTERRUPT_MASK) | ((eFlags) & EFLAGS_USER_SANITIZE))))
02154
02155
02156
02157
02158
#define USER_CODE_DESCRIPTOR 0xCFBFFFFF00000000i64
02159
#define USER_DATA_DESCRIPTOR 0xCF3FFFFF00000000i64
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
#define PREFIX_ES 0x00000100
02172
#define PREFIX_CS 0x00000200
02173
#define PREFIX_SS 0x00000400
02174
#define PREFIX_DS 0x00000800
02175
#define PREFIX_FS 0x00001000
02176
#define PREFIX_GS 0x00002000
02177
#define PREFIX_OPER32 0x00004000
02178
#define PREFIX_ADDR32 0x00008000
02179
#define PREFIX_LOCK 0x00010000
02180
#define PREFIX_REPNE 0x00020000
02181
#define PREFIX_REP 0x00040000
02182
#define PREFIX_SEG_ALL 0x00003f00
02183
02184
02185
02186
02187
02188
02189
#define DR6_LEGAL 0x0000e00f
02190
02191
#define DR7_LEGAL 0xffff0155 // R/W, LEN for Dr0-Dr4,
02192
02193
02194
02195
#define DR7_ACTIVE 0x00000055 // If any of these bits are set, a Dr is active
02196
02197
#define SANITIZE_DR6(Dr6, mode) ((Dr6 & DR6_LEGAL));
02198
02199
#define SANITIZE_DR7(Dr7, mode) ((Dr7 & DR7_LEGAL));
02200
02201
#define SANITIZE_DRADDR(DrReg, mode) ( \
02202
(mode) == KernelMode ? \
02203
(DrReg) : \
02204
(((PVOID)DrReg <= MM_HIGHEST_USER_ADDRESS) ? \
02205
(DrReg) : \
02206
(0) \
02207
) \
02208
)
02209
02210
02211
02212
#ifdef _IA64_
02213
02214
02215
02216
02217
02218
02219
02220
typedef struct _STACK_REGISTERS {
02221
02222
02223
02224
02225 ULONGLONG IntR32;
02226 ULONGLONG IntR33;
02227 ULONGLONG IntR34;
02228 ULONGLONG IntR35;
02229 ULONGLONG IntR36;
02230 ULONGLONG IntR37;
02231 ULONGLONG IntR38;
02232 ULONGLONG IntR39;
02233
02234 ULONGLONG IntR40;
02235 ULONGLONG IntR41;
02236 ULONGLONG IntR42;
02237 ULONGLONG IntR43;
02238 ULONGLONG IntR44;
02239 ULONGLONG IntR45;
02240 ULONGLONG IntR46;
02241 ULONGLONG IntR47;
02242 ULONGLONG IntR48;
02243 ULONGLONG IntR49;
02244
02245 ULONGLONG IntR50;
02246 ULONGLONG IntR51;
02247 ULONGLONG IntR52;
02248 ULONGLONG IntR53;
02249 ULONGLONG IntR54;
02250 ULONGLONG IntR55;
02251 ULONGLONG IntR56;
02252 ULONGLONG IntR57;
02253 ULONGLONG IntR58;
02254 ULONGLONG IntR59;
02255
02256 ULONGLONG IntR60;
02257 ULONGLONG IntR61;
02258 ULONGLONG IntR62;
02259 ULONGLONG IntR63;
02260 ULONGLONG IntR64;
02261 ULONGLONG IntR65;
02262 ULONGLONG IntR66;
02263 ULONGLONG IntR67;
02264 ULONGLONG IntR68;
02265 ULONGLONG IntR69;
02266
02267 ULONGLONG IntR70;
02268 ULONGLONG IntR71;
02269 ULONGLONG IntR72;
02270 ULONGLONG IntR73;
02271 ULONGLONG IntR74;
02272 ULONGLONG IntR75;
02273 ULONGLONG IntR76;
02274 ULONGLONG IntR77;
02275 ULONGLONG IntR78;
02276 ULONGLONG IntR79;
02277
02278 ULONGLONG IntR80;
02279 ULONGLONG IntR81;
02280 ULONGLONG IntR82;
02281 ULONGLONG IntR83;
02282 ULONGLONG IntR84;
02283 ULONGLONG IntR85;
02284 ULONGLONG IntR86;
02285 ULONGLONG IntR87;
02286 ULONGLONG IntR88;
02287 ULONGLONG IntR89;
02288
02289 ULONGLONG IntR90;
02290 ULONGLONG IntR91;
02291 ULONGLONG IntR92;
02292 ULONGLONG IntR93;
02293 ULONGLONG IntR94;
02294 ULONGLONG IntR95;
02295 ULONGLONG IntR96;
02296 ULONGLONG IntR97;
02297 ULONGLONG IntR98;
02298 ULONGLONG IntR99;
02299
02300 ULONGLONG IntR100;
02301 ULONGLONG IntR101;
02302 ULONGLONG IntR102;
02303 ULONGLONG IntR103;
02304 ULONGLONG IntR104;
02305 ULONGLONG IntR105;
02306 ULONGLONG IntR106;
02307 ULONGLONG IntR107;
02308 ULONGLONG IntR108;
02309 ULONGLONG IntR109;
02310
02311 ULONGLONG IntR110;
02312 ULONGLONG IntR111;
02313 ULONGLONG IntR112;
02314 ULONGLONG IntR113;
02315 ULONGLONG IntR114;
02316 ULONGLONG IntR115;
02317 ULONGLONG IntR116;
02318 ULONGLONG IntR117;
02319 ULONGLONG IntR118;
02320 ULONGLONG IntR119;
02321
02322 ULONGLONG IntR120;
02323 ULONGLONG IntR121;
02324 ULONGLONG IntR122;
02325 ULONGLONG IntR123;
02326 ULONGLONG IntR124;
02327 ULONGLONG IntR125;
02328 ULONGLONG IntR126;
02329 ULONGLONG IntR127;
02330
02331 ULONGLONG IntNats2;
02332 ULONGLONG IntNats3;
02333
02334
02335
02336 } STACK_REGISTERS, *PSTACK_REGISTERS;
02337
02338
02339
02340
02341
02342
02343
02344
02345
02346
typedef struct _KSPECIAL_REGISTERS {
02347
02348
02349
02350 ULONGLONG KernelDbI0;
02351 ULONGLONG KernelDbI1;
02352 ULONGLONG KernelDbI2;
02353 ULONGLONG KernelDbI3;
02354 ULONGLONG KernelDbI4;
02355 ULONGLONG KernelDbI5;
02356 ULONGLONG KernelDbI6;
02357 ULONGLONG KernelDbI7;
02358
02359 ULONGLONG KernelDbD0;
02360 ULONGLONG KernelDbD1;
02361 ULONGLONG KernelDbD2;
02362 ULONGLONG KernelDbD3;
02363 ULONGLONG KernelDbD4;
02364 ULONGLONG KernelDbD5;
02365 ULONGLONG KernelDbD6;
02366 ULONGLONG KernelDbD7;
02367
02368
02369
02370 ULONGLONG KernelPfC0;
02371 ULONGLONG KernelPfC1;
02372 ULONGLONG KernelPfC2;
02373 ULONGLONG KernelPfC3;
02374 ULONGLONG KernelPfC4;
02375 ULONGLONG KernelPfC5;
02376 ULONGLONG KernelPfC6;
02377 ULONGLONG KernelPfC7;
02378
02379 ULONGLONG KernelPfD0;
02380 ULONGLONG KernelPfD1;
02381 ULONGLONG KernelPfD2;
02382 ULONGLONG KernelPfD3;
02383 ULONGLONG KernelPfD4;
02384 ULONGLONG KernelPfD5;
02385 ULONGLONG KernelPfD6;
02386 ULONGLONG KernelPfD7;
02387
02388
02389
02390 ULONGLONG IntH16;
02391 ULONGLONG IntH17;
02392 ULONGLONG IntH18;
02393 ULONGLONG IntH19;
02394 ULONGLONG IntH20;
02395 ULONGLONG IntH21;
02396 ULONGLONG IntH22;
02397 ULONGLONG IntH23;
02398 ULONGLONG IntH24;
02399 ULONGLONG IntH25;
02400 ULONGLONG IntH26;
02401 ULONGLONG IntH27;
02402 ULONGLONG IntH28;
02403 ULONGLONG IntH29;
02404 ULONGLONG IntH30;
02405 ULONGLONG IntH31;
02406
02407
02408
02409
02410 ULONGLONG ApCPUID0;
02411 ULONGLONG ApCPUID1;
02412 ULONGLONG ApCPUID2;
02413 ULONGLONG ApCPUID3;
02414 ULONGLONG ApCPUID4;
02415 ULONGLONG ApCPUID5;
02416 ULONGLONG ApCPUID6;
02417 ULONGLONG ApCPUID7;
02418
02419
02420 ULONGLONG ApKR0;
02421 ULONGLONG ApKR1;
02422 ULONGLONG ApKR2;
02423 ULONGLONG ApKR3;
02424 ULONGLONG ApKR4;
02425 ULONGLONG ApKR5;
02426 ULONGLONG ApKR6;
02427 ULONGLONG ApKR7;
02428
02429 ULONGLONG ApITC;
02430
02431
02432
02433 ULONGLONG ApITM;
02434 ULONGLONG ApIVA;
02435 ULONGLONG ApPTA;
02436 ULONGLONG ApGPTA;
02437
02438 ULONGLONG StISR;
02439 ULONGLONG StIFA;
02440 ULONGLONG StITIR;
02441 ULONGLONG StIIPA;
02442 ULONGLONG StIIM;
02443 ULONGLONG StIHA;
02444
02445
02446 ULONGLONG SaLID;
02447 ULONGLONG SaIVR;
02448 ULONGLONG SaTPR;
02449 ULONGLONG SaEOI;
02450 ULONGLONG SaIRR0;
02451 ULONGLONG SaIRR1;
02452 ULONGLONG SaIRR2;
02453 ULONGLONG SaIRR3;
02454 ULONGLONG SaITV;
02455 ULONGLONG SaPMV;
02456 ULONGLONG SaCMCV;
02457 ULONGLONG SaLRR0;
02458 ULONGLONG SaLRR1;
02459
02460
02461
02462 ULONGLONG Rr0;
02463 ULONGLONG Rr1;
02464 ULONGLONG Rr2;
02465 ULONGLONG Rr3;
02466 ULONGLONG Rr4;
02467 ULONGLONG Rr5;
02468 ULONGLONG Rr6;
02469 ULONGLONG Rr7;
02470
02471
02472 ULONGLONG Pkr0;
02473 ULONGLONG Pkr1;
02474 ULONGLONG Pkr2;
02475 ULONGLONG Pkr3;
02476 ULONGLONG Pkr4;
02477 ULONGLONG Pkr5;
02478 ULONGLONG Pkr6;
02479 ULONGLONG Pkr7;
02480 ULONGLONG Pkr8;
02481 ULONGLONG Pkr9;
02482 ULONGLONG Pkr10;
02483 ULONGLONG Pkr11;
02484 ULONGLONG Pkr12;
02485 ULONGLONG Pkr13;
02486 ULONGLONG Pkr14;
02487 ULONGLONG Pkr15;
02488
02489
02490 ULONGLONG TrI0;
02491 ULONGLONG TrI1;
02492 ULONGLONG TrI2;
02493 ULONGLONG TrI3;
02494 ULONGLONG TrI4;
02495 ULONGLONG TrI5;
02496 ULONGLONG TrI6;
02497 ULONGLONG TrI7;
02498
02499 ULONGLONG TrD0;
02500 ULONGLONG TrD1;
02501 ULONGLONG TrD2;
02502 ULONGLONG TrD3;
02503 ULONGLONG TrD4;
02504 ULONGLONG TrD5;
02505 ULONGLONG TrD6;
02506 ULONGLONG TrD7;
02507
02508
02509 ULONGLONG SrMSR0;
02510 ULONGLONG SrMSR1;
02511 ULONGLONG SrMSR2;
02512 ULONGLONG SrMSR3;
02513 ULONGLONG SrMSR4;
02514 ULONGLONG SrMSR5;
02515 ULONGLONG SrMSR6;
02516 ULONGLONG SrMSR7;
02517
02518 } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
02519
02520
02521
02522
02523
02524
02525
typedef struct _KPROCESSOR_STATE {
02526
struct _CONTEXT ContextFrame;
02527
struct _KSPECIAL_REGISTERS SpecialRegisters;
02528 } KPROCESSOR_STATE, *PKPROCESSOR_STATE;
02529
02530
02531
02532
02533
02534
#endif // _IA64_
02535
02536
02537
02538
02539
02540
02541
02542
02543
02544
#define PRCB_MINOR_VERSION 1
02545
#define PRCB_MAJOR_VERSION 1
02546
#define PRCB_BUILD_DEBUG 0x0001
02547
#define PRCB_BUILD_UNIPROCESSOR 0x0002
02548
02549
struct _RESTART_BLOCK;
02550
02551
typedef struct _KPRCB {
02552
02553
02554
02555
02556
02557
USHORT MinorVersion;
02558
USHORT MajorVersion;
02559
02560
02561
02562
02563
02564
02565
02566
02567
struct _KTHREAD *CurrentThread;
02568
struct _KTHREAD *RESTRICTED_POINTER NextThread;
02569
struct _KTHREAD *IdleThread;
02570 CCHAR Number;
02571 CCHAR Reserved;
02572
USHORT BuildType;
02573 KAFFINITY
SetMember;
02574
struct _RESTART_BLOCK *RestartBlock;
02575 ULONG_PTR PcrPage;
02576 ULONG Spares1[4];
02577
02578
02579
02580
02581
02582 ULONGLONG SystemReserved[8];
02583
02584
02585
02586
02587
02588 ULONGLONG HalReserved[16];
02589
02590
02591
02592
02593
02594
02595 ULONG DpcTime;
02596 ULONG InterruptTime;
02597 ULONG KernelTime;
02598 ULONG UserTime;
02599 ULONG InterruptCount;
02600 ULONG DispatchInterruptCount;
02601 ULONG ApcBypassCount;
02602 ULONG DpcBypassCount;
02603 ULONG Spare0[4];
02604
02605
02606
02607
02608
02609 PVOID Spare1;
02610 PVOID
Spare2;
02611 PVOID
Spare3;
02612
volatile ULONG IpiFrozen;
02613
struct _KPROCESSOR_STATE ProcessorState;
02614
02615
02616
02617
02618
02619
02620
02621
02622
02623
02624
02625
02626 PVOID SpareHotData[2];
02627
02628
02629
02630
02631
02632 ULONG
CcFastReadNoWait;
02633 ULONG
CcFastReadWait;
02634 ULONG
CcFastReadNotPossible;
02635 ULONG
CcCopyReadNoWait;
02636 ULONG
CcCopyReadWait;
02637 ULONG
CcCopyReadNoWaitMiss;
02638
02639
02640
02641
02642
02643 ULONG KeAlignmentFixupCount;
02644 ULONG KeContextSwitches;
02645 ULONG
KeDcacheFlushCount;
02646 ULONG KeExceptionDispatchCount;
02647 ULONG KeFirstLevelTbFills;
02648 ULONG KeFloatingEmulationCount;
02649 ULONG
KeIcacheFlushCount;
02650 ULONG KeSecondLevelTbFills;
02651 ULONG KeSystemCalls;
02652
02653
02654
02655
02656
02657 ULONG ReservedCounter[8];
02658
02659
02660
02661
02662
02663 PVOID SmallIrpFreeEntry;
02664 PVOID LargeIrpFreeEntry;
02665 PVOID MdlFreeEntry;
02666
02667
02668
02669
02670
02671 PVOID CreateInfoFreeEntry;
02672 PVOID NameBufferFreeEntry;
02673
02674
02675
02676
02677
02678 PVOID SharedCacheMapEntry;
02679
02680
02681
02682
02683
02684 PVOID MoreSpareHotData[2];
02685
02686
02687
02688
02689
02690
PP_LOOKASIDE_LIST PPLookasideList[16];
02691
02692
02693
02694
02695
02696
PP_LOOKASIDE_LIST PPNPagedLookasideList[
POOL_SMALL_LISTS];
02697
02698
02699
02700
02701
02702
PP_LOOKASIDE_LIST PPPagedLookasideList[
POOL_SMALL_LISTS];
02703
02704
02705
02706
02707
02708
KSPIN_LOCK_QUEUE LockQueue[16];
02709
02710
02711
02712
02713
02714
02715
02716
volatile PVOID CurrentPacket[3];
02717
volatile KAFFINITY TargetSet;
02718
volatile PKIPI_WORKER WorkerRoutine;
02719 ULONGLONG CachePad1[11];
02720
02721
02722
02723
02724
02725
volatile ULONG RequestSummary;
02726
volatile struct _KPRCB *SignalDone;
02727
02728
02729
02730
02731
02732 ULONGLONG
Spare4[14];
02733
02734
02735
02736
02737
02738 ULONG DpcInterruptRequested;
02739 ULONGLONG
Spare5[15];
02740 ULONG MaximumDpcQueueDepth;
02741 ULONG MinimumDpcRate;
02742 ULONG AdjustDpcThreshold;
02743 ULONG DpcRequestRate;
02744 LARGE_INTEGER StartCount;
02745
02746
02747
02748
02749
02750 LIST_ENTRY DpcListHead;
02751 KSPIN_LOCK DpcLock;
02752 ULONG DpcCount;
02753 ULONG DpcLastCount;
02754 ULONG QuantumEnd;
02755 ULONG DpcRoutineActive;
02756 ULONG DpcQueueDepth;
02757 BOOLEAN SkipTick;
02758
02759
02760
02761
02762
02763
PKIPI_COUNTS IpiCounts;
02764
02765
02766
02767
02768 PROCESSOR_POWER_STATE PowerState;
02769
02770
02771 } KPRCB, *PKPRCB, *RESTRICTED_POINTER PRKPRCB;
02772
02773
02774
02775
02776
02777
02778
02779
#define PCR_MINOR_VERSION 1
02780
#define PCR_MAJOR_VERSION 1
02781
02782
typedef struct _KPCR {
02783
02784
02785
02786
02787 ULONG MinorVersion;
02788 ULONG MajorVersion;
02789
02790
02791
02792
02793
02794
02795
02796
02797
02798
02799
02800 ULONG FirstLevelDcacheSize;
02801 ULONG FirstLevelDcacheFillSize;
02802 ULONG FirstLevelIcacheSize;
02803 ULONG FirstLevelIcacheFillSize;
02804 ULONG SecondLevelDcacheSize;
02805 ULONG SecondLevelDcacheFillSize;
02806 ULONG SecondLevelIcacheSize;
02807 ULONG SecondLevelIcacheFillSize;
02808
02809
02810
02811
02812
02813
02814
02815 ULONG DcacheAlignment;
02816 ULONG DcacheFillSize;
02817
02818
02819
02820
02821
02822
02823
02824 ULONG IcacheAlignment;
02825 ULONG IcacheFillSize;
02826
02827
02828
02829
02830
02831 ULONG ProcessorId;
02832
02833
02834
02835
02836
02837 ULONG ProfileInterval;
02838 ULONG ProfileCount;
02839
02840
02841
02842
02843
02844 ULONG StallExecutionCount;
02845 ULONG StallScaleFactor;
02846
02847 ULONG InterruptionCount;
02848
02849
02850
02851
02852
02853 ULONGLONG SystemReserved[6];
02854
02855
02856
02857
02858
02859 ULONGLONG HalReserved[64];
02860
02861
02862
02863
02864
02865 UCHAR IrqlMask[64];
02866 UCHAR IrqlTable[64];
02867
02868
02869
02870
02871
02872 PKINTERRUPT_ROUTINE InterruptRoutine[MAXIMUM_VECTOR];
02873
02874
02875
02876
02877
02878 ULONG ReservedVectors;
02879
02880
02881
02882
02883
02884 KAFFINITY
SetMember;
02885
02886
02887
02888
02889
02890 KAFFINITY NotMember;
02891
02892
02893
02894
02895
02896
struct _KPRCB *Prcb;
02897
02898
02899
02900
02901
02902
struct _KTHREAD *CurrentThread;
02903
02904
02905
02906
02907
02908 CCHAR Number;
02909 UCHAR DebugActive;
02910 UCHAR KernelDebugActive;
02911 UCHAR CurrentIrql;
02912
union {
02913
USHORT SoftwareInterruptPending;
02914
struct {
02915 UCHAR ApcInterrupt;
02916 UCHAR DispatchInterrupt;
02917 };
02918 };
02919
02920
02921
02922
02923
02924
02925
02926
02927
02928
02929
02930
02931
02932
02933
02934
02935 ULONGLONG KernelGP;
02936
02937 ULONGLONG InitialStack;
02938
02939 ULONGLONG InitialBStore;
02940
02941 ULONGLONG StackLimit;
02942
02943 ULONGLONG BStoreLimit;
02944
02945 ULONGLONG PanicStack;
02946
02947
02948
02949
02950 ULONGLONG SavedIIM;
02951 ULONGLONG SavedIFA;
02952
02953 ULONGLONG ForwardProgressBuffer[16];
02954
02955
02956
02957
02958 } KPCR, *PKPCR;
02959
02960
02961
02962
02963
02964
02965
02966
02967
02968
02969
02970
02971
#define PTI_SHIFT PAGE_SHIFT // Intel-IA64-Filler
02972
02973
02974
02975
02976
02977
02978
#define PDI_SHIFT (PTI_SHIFT + PAGE_SHIFT - PTE_SHIFT) // Intel-IA64-Filler
02979
#define PDI1_SHIFT (PDI_SHIFT + PAGE_SHIFT - PTE_SHIFT) // Intel-IA64-Filler
02980
#define PDI_MASK ((1 << (PAGE_SHIFT - PTE_SHIFT)) - 1) // Intel-IA64-Filler
02981
02982
02983
02984
02985
02986
02987
#define PTE_SHIFT 3 // Intel-IA64-Filler
02988
02989
02990
02991
02992
02993
02994
#define VHPT_PDE_BITS 40 // Intel-IA64-Filler
02995
02996
02997
02998
02999
03000
#define RR_IO_PORT 6 // Intel-IA64-Filler
03001
03002
03003
03004
03005
03006
03007
03008
03009
03010
03011
03012
#define MM_HIGHEST_USER_ADDRESS (PVOID) (ULONG_PTR)((UADDRESS_BASE + 0x3FFFFFEFFFF)) // highest user address
03013
#define MM_USER_PROBE_ADDRESS ((ULONG_PTR)(UADDRESS_BASE + 0x3FFFFFF0000UI64)) // starting address of guard page
03014
#define MM_SYSTEM_RANGE_START (PVOID) (KSEG0_BASE) // start of system space
03015
03016
03017
03018
03019
03020
extern PVOID
MmHighestUserAddress;
03021
extern PVOID
MmSystemRangeStart;
03022
extern ULONG_PTR
MmUserProbeAddress;
03023
03024
03025
03026
03027
03028
#define MM_LOWEST_USER_ADDRESS (PVOID)((ULONG_PTR)(UADDRESS_BASE+0x00010000))
03029
03030
03031
03032
#define MmGetProcedureAddress(Address) (Address)
03033
#define MmLockPagableCodeSection(PLabelAddress) \
03034
MmLockPagableDataSection((PVOID)(*((PULONGLONG)PLabelAddress)))
03035
03036
03037
03038
03039
03040
03041
03042
#define VA_SIGN 0x0002000000000000UI64 // MSB of implemented virtual address
03043
#define VA_FILL 0x1FFC000000000000UI64 // singed fill for unimplemented virtual address
03044
#define VRN_MASK 0xE000000000000000UI64 // Virtual Region Number mask
03045
#define PTA_BASE0 0x1FFC000000000000UI64 // Page Table Address BASE 0
03046
#define PTA_SIGN (VA_SIGN >> (PAGE_SHIFT - PTE_SHIFT)) // MSB of VPN offset
03047
#define PTA_FILL (VA_FILL >> (PAGE_SHIFT - PTE_SHIFT)) // signed fill for PTA base0
03048
#define PTA_BASE (PTA_BASE0|PTA_FILL) // PTA_BASE address
03049
03050
03051
03052
03053
03054
#define SADDRESS_BASE 0x2000000000000000UI64 // session base address
03055
03056
#define PTE_UBASE (UADDRESS_BASE|PTA_BASE)
03057
#define PTE_KBASE (KADDRESS_BASE|PTA_BASE)
03058
#define PTE_SBASE (SADDRESS_BASE|PTA_BASE)
03059
03060
#define PTE_UTOP (PTE_UBASE|(((ULONG_PTR)1 << PDI1_SHIFT) - 1)) // top level PDR address (user)
03061
#define PTE_KTOP (PTE_KBASE|(((ULONG_PTR)1 << PDI1_SHIFT) - 1)) // top level PDR address (kernel)
03062
#define PTE_STOP (PTE_SBASE|(((ULONG_PTR)1 << PDI1_SHIFT) - 1)) // top level PDR address (session)
03063
03064
03065
03066
03067
03068
#define PDE_UBASE (PTE_UBASE|(PTE_UBASE>>(PTI_SHIFT-PTE_SHIFT)))
03069
#define PDE_KBASE (PTE_KBASE|(PTE_KBASE>>(PTI_SHIFT-PTE_SHIFT)))
03070
#define PDE_SBASE (PTE_SBASE|(PTE_SBASE>>(PTI_SHIFT-PTE_SHIFT)))
03071
03072
#define PDE_UTOP (PDE_UBASE|(((ULONG_PTR)1 << PDI_SHIFT) - 1)) // second level PDR address (user)
03073
#define PDE_KTOP (PDE_KBASE|(((ULONG_PTR)1 << PDI_SHIFT) - 1)) // second level PDR address (kernel)
03074
#define PDE_STOP (PDE_SBASE|(((ULONG_PTR)1 << PDI_SHIFT) - 1)) // second level PDR address (session)
03075
03076
03077
03078
03079
03080
#define PDE_UTBASE (PTE_UBASE|(PDE_UBASE>>(PTI_SHIFT-PTE_SHIFT)))
03081
#define PDE_KTBASE (PTE_KBASE|(PDE_KBASE>>(PTI_SHIFT-PTE_SHIFT)))
03082
#define PDE_STBASE (PTE_SBASE|(PDE_SBASE>>(PTI_SHIFT-PTE_SHIFT)))
03083
03084
#define PDE_USELFMAP (PDE_UTBASE|(PAGE_SIZE - (1<<PTE_SHIFT))) // self mapped PPE address (user)
03085
#define PDE_KSELFMAP (PDE_KTBASE|(PAGE_SIZE - (1<<PTE_SHIFT))) // self mapped PPE address (kernel)
03086
#define PDE_SSELFMAP (PDE_STBASE|(PAGE_SIZE - (1<<PTE_SHIFT))) // self mapped PPE address (kernel)
03087
03088
#define PTE_BASE PTE_UBASE
03089
#define PDE_BASE PDE_UBASE
03090
#define PDE_TBASE PDE_UTBASE
03091
#define PDE_SELFMAP PDE_USELFMAP
03092
03093
#define KSEG3_BASE 0x8000000000000000UI64
03094
#define KSEG3_LIMIT 0x8000100000000000UI64
03095
03096
03097
03098
03099
03100
03101
03102
03103
03104
03105
03106
03107
03108
03109
03110
03111
03112
03113
03114
03115
03116
03117
#define KSEG_ADDRESS(PAGE) ((PVOID)(KSEG3_BASE | ((ULONG_PTR)(PAGE) << PAGE_SHIFT)))
03118
03119
#define MAXIMUM_FWP_BUFFER_ENTRY 8
03120
03121
typedef struct _REGION_MAP_INFO {
03122 ULONG RegionId;
03123 ULONG PageSize;
03124 ULONGLONG SequenceNumber;
03125 } REGION_MAP_INFO, *PREGION_MAP_INFO;
03126
03127
03128
03129
03130
03131
03132
#define MM_LOWEST_SYSTEM_ADDRESS ((PVOID)((ULONG_PTR)(KADDRESS_BASE + 0xC0C00000)))
03133
03134
03135
#define SYSTEM_BASE (KADDRESS_BASE + 0xC3000000) // start of system space (no typecast)
03136
03137
03138
03139
03140
03141
03142
03143
#define INITIALIZE_DIRECTORY_TABLE_BASE(dirbase, pfn) \
03144 *((PULONGLONG)(dirbase)) = 0; \
03145 ((PHARDWARE_PTE)(dirbase))->PageFrameNumber = pfn; \
03146 ((PHARDWARE_PTE)(dirbase))->Accessed = 1; \
03147 ((PHARDWARE_PTE)(dirbase))->Dirty = 1; \
03148 ((PHARDWARE_PTE)(dirbase))->Cache = 0; \
03149 ((PHARDWARE_PTE)(dirbase))->Write = 1; \
03150 ((PHARDWARE_PTE)(dirbase))->Valid = 1; // Intel-IA64-Filler
03151
03152
03153
03154
03155
03156
03157
03158
03159
03160
03161
03162
03163
03164
03165
03166
03167
03168
03169
03170
#define KiIsThreadNumericStateSaved(a) TRUE
03171
03172
03173
03174
03175
03176
03177
03178
03179
03180
#define KiRundownThread(a)
03181
03182
03183
03184
03185
03186
03187
03188
#define Isx86FeaturePresent(_f_) TRUE
03189
03190
03191
03192
#endif // defined(_IA64_)
03193
03194
03195
#endif // _IA64H_