Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3544 lines
86 KiB

  1. /*++
  2. Module Name:
  3. ia64.h
  4. Abstract:
  5. This module contains the IA64 hardware specific header file.
  6. Author:
  7. David N. Cutler (davec) 31-Mar-1990
  8. Revision History:
  9. Bernard Lint 6-Jun-1995: IA64 version based on MIPS version.
  10. --*/
  11. #ifndef _IA64H_
  12. #define _IA64H_
  13. #if !(defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_)) && !defined(_BLDR_)
  14. #define ExRaiseException RtlRaiseException
  15. #define ExRaiseStatus RtlRaiseStatus
  16. #endif
  17. //
  18. // Interruption history
  19. //
  20. // N.B. Currently the history records are saved in the 2nd half of the 8K
  21. // PCR page. Therefore, we can only keep track of up to the latest
  22. // 128 interruption records, each of 32 bytes in size. Also, the PCR
  23. // structure cannot be greater than 4K. In the future, the interruption
  24. // history records may become part of the KPCR structure.
  25. //
  26. typedef struct _IHISTORY_RECORD {
  27. ULONGLONG InterruptionType;
  28. ULONGLONG IIP;
  29. ULONGLONG IPSR;
  30. ULONGLONG Extra0;
  31. } IHISTORY_RECORD;
  32. #define MAX_NUMBER_OF_IHISTORY_RECORDS 128
  33. //
  34. // For PSR bit field definitions
  35. //
  36. #include "kxia64.h"
  37. // begin_ntddk begin_wdm begin_nthal begin_ntndis begin_ntosp
  38. #if defined(_IA64_)
  39. //
  40. // Types to use to contain PFNs and their counts.
  41. //
  42. typedef ULONG PFN_COUNT;
  43. typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
  44. typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
  45. //
  46. // Define maximum size of flush multiple TB request.
  47. //
  48. #define FLUSH_MULTIPLE_MAXIMUM 100
  49. //
  50. // Indicate that the IA64 compiler supports the pragma textout construct.
  51. //
  52. #define ALLOC_PRAGMA 1
  53. //
  54. // Define intrinsic calls and their prototypes
  55. //
  56. #include "ia64reg.h"
  57. #ifdef __cplusplus
  58. extern "C" {
  59. #endif
  60. unsigned __int64 __getReg (int);
  61. void __setReg (int, unsigned __int64);
  62. void __isrlz (void);
  63. void __dsrlz (void);
  64. void __fwb (void);
  65. void __mf (void);
  66. void __mfa (void);
  67. void __synci (void);
  68. __int64 __thash (__int64);
  69. __int64 __ttag (__int64);
  70. void __ptcl (__int64, __int64);
  71. void __ptcg (__int64, __int64);
  72. void __ptcga (__int64, __int64);
  73. void __ptri (__int64, __int64);
  74. void __ptrd (__int64, __int64);
  75. void __invalat (void);
  76. void __break (int);
  77. void __fc (__int64);
  78. void __sum (int);
  79. void __rsm (int);
  80. void _ReleaseSpinLock( unsigned __int64 *);
  81. #ifdef _M_IA64
  82. #pragma intrinsic (__getReg)
  83. #pragma intrinsic (__setReg)
  84. #pragma intrinsic (__isrlz)
  85. #pragma intrinsic (__dsrlz)
  86. #pragma intrinsic (__fwb)
  87. #pragma intrinsic (__mf)
  88. #pragma intrinsic (__mfa)
  89. #pragma intrinsic (__synci)
  90. #pragma intrinsic (__thash)
  91. #pragma intrinsic (__ttag)
  92. #pragma intrinsic (__ptcl)
  93. #pragma intrinsic (__ptcg)
  94. #pragma intrinsic (__ptcga)
  95. #pragma intrinsic (__ptri)
  96. #pragma intrinsic (__ptrd)
  97. #pragma intrinsic (__invalat)
  98. #pragma intrinsic (__break)
  99. #pragma intrinsic (__fc)
  100. #pragma intrinsic (__sum)
  101. #pragma intrinsic (__rsm)
  102. #pragma intrinsic (_ReleaseSpinLock)
  103. #endif // _M_IA64
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. // end_wdm end_ntndis
  108. //
  109. // Define macro to generate import names.
  110. //
  111. #define IMPORT_NAME(name) __imp_##name
  112. // begin_wdm
  113. //
  114. // Define length of interrupt vector table.
  115. //
  116. #define MAXIMUM_VECTOR 256
  117. // end_wdm
  118. //
  119. // IA64 specific interlocked operation result values.
  120. //
  121. #define RESULT_ZERO 0
  122. #define RESULT_NEGATIVE 1
  123. #define RESULT_POSITIVE 2
  124. //
  125. // Interlocked result type is portable, but its values are machine specific.
  126. // Constants for values are in i386.h, mips.h, etc.
  127. //
  128. typedef enum _INTERLOCKED_RESULT {
  129. ResultNegative = RESULT_NEGATIVE,
  130. ResultZero = RESULT_ZERO,
  131. ResultPositive = RESULT_POSITIVE
  132. } INTERLOCKED_RESULT;
  133. //
  134. // Convert portable interlock interfaces to architecture specific interfaces.
  135. //
  136. #if PRAGMA_DEPRECATED_DDK
  137. #pragma deprecated(ExInterlockedIncrementLong) // Use InterlockedIncrement
  138. #pragma deprecated(ExInterlockedDecrementLong) // Use InterlockedDecrement
  139. #pragma deprecated(ExInterlockedExchangeUlong) // Use InterlockedExchange
  140. #endif
  141. #define ExInterlockedIncrementLong(Addend, Lock) \
  142. ExIa64InterlockedIncrementLong(Addend)
  143. #define ExInterlockedDecrementLong(Addend, Lock) \
  144. ExIa64InterlockedDecrementLong(Addend)
  145. #define ExInterlockedExchangeUlong(Target, Value, Lock) \
  146. ExIa64InterlockedExchangeUlong(Target, Value)
  147. NTKERNELAPI
  148. INTERLOCKED_RESULT
  149. ExIa64InterlockedIncrementLong (
  150. IN PLONG Addend
  151. );
  152. NTKERNELAPI
  153. INTERLOCKED_RESULT
  154. ExIa64InterlockedDecrementLong (
  155. IN PLONG Addend
  156. );
  157. NTKERNELAPI
  158. ULONG
  159. ExIa64InterlockedExchangeUlong (
  160. IN PULONG Target,
  161. IN ULONG Value
  162. );
  163. // begin_wdm
  164. //
  165. // IA64 Interrupt Definitions.
  166. //
  167. // Define length of interrupt object dispatch code in longwords.
  168. //
  169. #define DISPATCH_LENGTH 2*2 // Length of dispatch code template in 32-bit words
  170. //
  171. // Begin of a block of definitions that must be synchronized with kxia64.h.
  172. //
  173. //
  174. // Define Interrupt Request Levels.
  175. //
  176. #define PASSIVE_LEVEL 0 // Passive release level
  177. #define LOW_LEVEL 0 // Lowest interrupt level
  178. #define APC_LEVEL 1 // APC interrupt level
  179. #define DISPATCH_LEVEL 2 // Dispatcher level
  180. #define CMC_LEVEL 3 // Correctable machine check level
  181. #define DEVICE_LEVEL_BASE 4 // 4 - 11 - Device IRQLs
  182. #define PC_LEVEL 12 // Performance Counter IRQL
  183. #define IPI_LEVEL 14 // IPI IRQL
  184. #define CLOCK_LEVEL 13 // Clock Timer IRQL
  185. #define POWER_LEVEL 15 // Power failure level
  186. #define PROFILE_LEVEL 15 // Profiling level
  187. #define HIGH_LEVEL 15 // Highest interrupt level
  188. #if defined(NT_UP)
  189. #define SYNCH_LEVEL DISPATCH_LEVEL // Synchronization level - UP
  190. #else
  191. #define SYNCH_LEVEL (IPI_LEVEL-1) // Synchronization level - MP
  192. #endif
  193. //
  194. // The current IRQL is maintained in the TPR.mic field. The
  195. // shift count is the number of bits to shift right to extract the
  196. // IRQL from the TPR. See the GET/SET_IRQL macros.
  197. //
  198. #define TPR_MIC 4
  199. #define TPR_IRQL_SHIFT TPR_MIC
  200. // To go from vector number <-> IRQL we just do a shift
  201. #define VECTOR_IRQL_SHIFT TPR_IRQL_SHIFT
  202. //
  203. // Interrupt Vector Definitions
  204. //
  205. #define APC_VECTOR APC_LEVEL << VECTOR_IRQL_SHIFT
  206. #define DISPATCH_VECTOR DISPATCH_LEVEL << VECTOR_IRQL_SHIFT
  207. //
  208. // End of a block of definitions that must be synchronized with kxia64.h.
  209. //
  210. //
  211. // Define profile intervals.
  212. //
  213. #define DEFAULT_PROFILE_COUNT 0x40000000 // ~= 20 seconds @50mhz
  214. #define DEFAULT_PROFILE_INTERVAL (10 * 500) // 500 microseconds
  215. #define MAXIMUM_PROFILE_INTERVAL (10 * 1000 * 1000) // 1 second
  216. #define MINIMUM_PROFILE_INTERVAL (10 * 40) // 40 microseconds
  217. #if defined(_M_IA64) && !defined(RC_INVOKED)
  218. #define InterlockedAdd _InterlockedAdd
  219. #define InterlockedIncrement _InterlockedIncrement
  220. #define InterlockedDecrement _InterlockedDecrement
  221. #define InterlockedExchange _InterlockedExchange
  222. #define InterlockedExchangeAdd _InterlockedExchangeAdd
  223. #define InterlockedAdd64 _InterlockedAdd64
  224. #define InterlockedIncrement64 _InterlockedIncrement64
  225. #define InterlockedDecrement64 _InterlockedDecrement64
  226. #define InterlockedExchange64 _InterlockedExchange64
  227. #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
  228. #define InterlockedCompareExchange64 _InterlockedCompareExchange64
  229. #define InterlockedCompareExchange _InterlockedCompareExchange
  230. #define InterlockedExchangePointer _InterlockedExchangePointer
  231. #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
  232. #ifdef __cplusplus
  233. extern "C" {
  234. #endif
  235. LONG
  236. __cdecl
  237. InterlockedAdd (
  238. LONG volatile *Addend,
  239. LONG Value
  240. );
  241. LONGLONG
  242. __cdecl
  243. InterlockedAdd64 (
  244. LONGLONG volatile *Addend,
  245. LONGLONG Value
  246. );
  247. LONG
  248. __cdecl
  249. InterlockedIncrement(
  250. IN OUT LONG volatile *Addend
  251. );
  252. LONG
  253. __cdecl
  254. InterlockedDecrement(
  255. IN OUT LONG volatile *Addend
  256. );
  257. LONG
  258. __cdecl
  259. InterlockedExchange(
  260. IN OUT LONG volatile *Target,
  261. IN LONG Value
  262. );
  263. LONG
  264. __cdecl
  265. InterlockedExchangeAdd(
  266. IN OUT LONG volatile *Addend,
  267. IN LONG Value
  268. );
  269. LONG
  270. __cdecl
  271. InterlockedCompareExchange (
  272. IN OUT LONG volatile *Destination,
  273. IN LONG ExChange,
  274. IN LONG Comperand
  275. );
  276. LONGLONG
  277. __cdecl
  278. InterlockedIncrement64(
  279. IN OUT LONGLONG volatile *Addend
  280. );
  281. LONGLONG
  282. __cdecl
  283. InterlockedDecrement64(
  284. IN OUT LONGLONG volatile *Addend
  285. );
  286. LONGLONG
  287. __cdecl
  288. InterlockedExchange64(
  289. IN OUT LONGLONG volatile *Target,
  290. IN LONGLONG Value
  291. );
  292. LONGLONG
  293. __cdecl
  294. InterlockedExchangeAdd64(
  295. IN OUT LONGLONG volatile *Addend,
  296. IN LONGLONG Value
  297. );
  298. LONGLONG
  299. __cdecl
  300. InterlockedCompareExchange64 (
  301. IN OUT LONGLONG volatile *Destination,
  302. IN LONGLONG ExChange,
  303. IN LONGLONG Comperand
  304. );
  305. PVOID
  306. __cdecl
  307. InterlockedCompareExchangePointer (
  308. IN OUT PVOID volatile *Destination,
  309. IN PVOID Exchange,
  310. IN PVOID Comperand
  311. );
  312. PVOID
  313. __cdecl
  314. InterlockedExchangePointer(
  315. IN OUT PVOID volatile *Target,
  316. IN PVOID Value
  317. );
  318. #pragma intrinsic(_InterlockedAdd)
  319. #pragma intrinsic(_InterlockedIncrement)
  320. #pragma intrinsic(_InterlockedDecrement)
  321. #pragma intrinsic(_InterlockedExchange)
  322. #pragma intrinsic(_InterlockedCompareExchange)
  323. #pragma intrinsic(_InterlockedExchangeAdd)
  324. #pragma intrinsic(_InterlockedAdd64)
  325. #pragma intrinsic(_InterlockedIncrement64)
  326. #pragma intrinsic(_InterlockedDecrement64)
  327. #pragma intrinsic(_InterlockedExchange64)
  328. #pragma intrinsic(_InterlockedCompareExchange64)
  329. #pragma intrinsic(_InterlockedExchangeAdd64)
  330. #pragma intrinsic(_InterlockedExchangePointer)
  331. #pragma intrinsic(_InterlockedCompareExchangePointer)
  332. #ifdef __cplusplus
  333. }
  334. #endif
  335. #endif // defined(_M_IA64) && !defined(RC_INVOKED)
  336. // end_ntddk end_nthal end_wdm end_ntosp
  337. // begin_ntddk
  338. __inline
  339. LONG
  340. InterlockedAnd (
  341. IN OUT LONG volatile *Target,
  342. LONG Set
  343. )
  344. {
  345. LONG i;
  346. LONG j;
  347. j = *Target;
  348. do {
  349. i = j;
  350. j = InterlockedCompareExchange(Target,
  351. i & Set,
  352. i);
  353. } while (i != j);
  354. return j;
  355. }
  356. __inline
  357. LONG
  358. InterlockedOr (
  359. IN OUT LONG volatile *Target,
  360. IN LONG Set
  361. )
  362. {
  363. LONG i;
  364. LONG j;
  365. j = *Target;
  366. do {
  367. i = j;
  368. j = InterlockedCompareExchange(Target,
  369. i | Set,
  370. i);
  371. } while (i != j);
  372. return j;
  373. }
  374. // end_ntddk
  375. #define KiSynchIrql SYNCH_LEVEL // enable portable code
  376. #define KiProfileIrql PROFILE_LEVEL // enable portable code
  377. //
  378. // Sanitize FPSR based on processor mode.
  379. //
  380. // If kernel mode, then
  381. // let caller specify all bits, except reserved
  382. //
  383. // If user mode, then
  384. // let the caller specify all bits, except reserved
  385. //
  386. __inline
  387. ULONG64
  388. SANITIZE_FSR(ULONG64 fsr, MODE mode)
  389. {
  390. UNREFERENCED_PARAMETER(mode);
  391. fsr &= ~(MASK_IA64(FPSR_MBZ0,FPSR_MBZ0_V)| MASK_IA64(FPSR_TD0, 1));
  392. if (((fsr >> FPSR_PC0) & 3i64) == 1) {
  393. fsr = fsr | (3i64 << FPSR_PC0);
  394. }
  395. if (((fsr >> FPSR_PC1) & 3i64) == 1) {
  396. fsr = fsr | (3i64 << FPSR_PC1);
  397. }
  398. if (((fsr >> FPSR_PC2) & 3i64) == 1) {
  399. fsr = fsr | (3i64 << FPSR_PC2);
  400. }
  401. if (((fsr >> FPSR_PC3) & 3i64) == 1) {
  402. fsr = fsr | (3i64 << FPSR_PC3);
  403. }
  404. return fsr;
  405. }
  406. //
  407. // Define SANITIZE_PSR for IA64
  408. //
  409. // If kernel mode, then
  410. // force clearing of BE, SP, CPL, MC, PK, DFL, reserved (MBZ)
  411. // force the setting of IC, DT, DFH, DI, LP, RT, IT
  412. // let caller specify UP, AC, I, BN, PP, SI, DB, TB, IS, ID, DA, DD, SS, RI, ED
  413. //
  414. // If user mode, then
  415. // force clearing of MC, PK, LP, reserved
  416. // force the setting of BN, IC, I, DT, RT, CPL, IT
  417. // let caller specify BE, UP, PP, AC, DFL, DFH, SP, SI, DI, DB, TB, IS, ID, DA, DD, SS, RI, ED
  418. //
  419. #define PSR_KERNEL_CLR (MASK_IA64(PSR_BE,1i64) | MASK_IA64(PSR_SP,1i64) | MASK_IA64(PSR_PK,1i64) | \
  420. MASK_IA64(PSR_CPL,0x3i64) | MASK_IA64(PSR_MC,1i64) | MASK_IA64(PSR_MBZ0,PSR_MBZ0_V) | \
  421. MASK_IA64(PSR_MBZ1,PSR_MBZ1_V) | MASK_IA64(PSR_MBZ2,PSR_MBZ2) | \
  422. MASK_IA64(PSR_DFL, 1i64))
  423. #if defined(_IA64_PSR_DI_X86_)
  424. #define PSR_KERNEL_SET (MASK_IA64(PSR_IC,1i64) | MASK_IA64(PSR_DT,1i64) | \
  425. MASK_IA64(PSR_IT,1i64) | MASK_IA64(PSR_RT,1i64))
  426. #define PSR_KERNEL_CPY (MASK_IA64(PSR_UP,1i64) | MASK_IA64(PSR_AC,1i64) | MASK_IA64(PSR_DI,1i64) | \
  427. MASK_IA64(PSR_I,1i64) | MASK_IA64(PSR_BN,1i64) | MASK_IA64(PSR_DFH,1i64) | \
  428. MASK_IA64(PSR_PP,1i64) | MASK_IA64(PSR_SI,1i64) | MASK_IA64(PSR_DB,1i64) | \
  429. MASK_IA64(PSR_TB,1i64) | MASK_IA64(PSR_IS,1i64) | MASK_IA64(PSR_ID,1i64) | \
  430. MASK_IA64(PSR_DA,1i64) | MASK_IA64(PSR_DD,1i64) | MASK_IA64(PSR_SS,1i64) | \
  431. MASK_IA64(PSR_RI,0x3i64) | MASK_IA64(PSR_ED,1i64) | MASK_IA64(PSR_LP,1i64))
  432. #else // !_IA64_PSR_DI_X86_
  433. #define PSR_KERNEL_SET (MASK_IA64(PSR_IC,1i64) | MASK_IA64(PSR_DT,1i64) | \
  434. MASK_IA64(PSR_DI,1i64) | MASK_IA64(PSR_IT,1i64) | \
  435. MASK_IA64(PSR_RT,1i64))
  436. #define PSR_KERNEL_CPY (MASK_IA64(PSR_UP,1i64) | MASK_IA64(PSR_AC,1i64) | \
  437. MASK_IA64(PSR_I,1i64) | MASK_IA64(PSR_BN,1i64) | MASK_IA64(PSR_DFH,1i64) | \
  438. MASK_IA64(PSR_PP,1i64) | MASK_IA64(PSR_SI,1i64) | MASK_IA64(PSR_DB,1i64) | \
  439. MASK_IA64(PSR_TB,1i64) | MASK_IA64(PSR_IS,1i64) | MASK_IA64(PSR_ID,1i64) | \
  440. MASK_IA64(PSR_DA,1i64) | MASK_IA64(PSR_DD,1i64) | MASK_IA64(PSR_SS,1i64) | \
  441. MASK_IA64(PSR_RI,0x3i64) | MASK_IA64(PSR_ED,1i64) | MASK_IA64(PSR_LP,1i64))
  442. #endif // !_IA64_PSR_DI_X86_
  443. #define PSR_USER_CLR (MASK_IA64(PSR_MC,1i64) | \
  444. MASK_IA64(PSR_MBZ0,PSR_MBZ0_V) | MASK_IA64(PSR_PK,1i64) | \
  445. MASK_IA64(PSR_MBZ1,PSR_MBZ1_V) | MASK_IA64(PSR_MBZ2,PSR_MBZ2) | \
  446. MASK_IA64(PSR_LP,1i64))
  447. #define PSR_USER_SET (MASK_IA64(PSR_IC,1i64) | MASK_IA64(PSR_I,1i64) | \
  448. MASK_IA64(PSR_DT,1i64) | MASK_IA64(PSR_BN,1i64) | \
  449. MASK_IA64(PSR_RT,1i64) | \
  450. MASK_IA64(PSR_CPL,0x3i64) | MASK_IA64(PSR_IT,1i64))
  451. #define PSR_USER_CPY (MASK_IA64(PSR_BE,1i64) | MASK_IA64(PSR_UP,1i64) | MASK_IA64(PSR_PP,1i64) | \
  452. MASK_IA64(PSR_AC,1i64) | MASK_IA64(PSR_DFL,1i64) | MASK_IA64(PSR_DFH,1i64) | \
  453. MASK_IA64(PSR_SP,1i64) | MASK_IA64(PSR_DI,1i64) | MASK_IA64(PSR_DB,1i64) | \
  454. MASK_IA64(PSR_TB,1i64) | MASK_IA64(PSR_IS,1i64) | MASK_IA64(PSR_ID,1i64) | \
  455. MASK_IA64(PSR_DA,1i64) | MASK_IA64(PSR_DD,1i64) | MASK_IA64(PSR_SS, 1i64) | \
  456. MASK_IA64(PSR_RI,0x3i64) | MASK_IA64(PSR_ED,1i64) | MASK_IA64(PSR_SI,1i64))
  457. #define PSR_DEBUG_SET (MASK_IA64(PSR_DB,1i64) | MASK_IA64(PSR_SS,1i64) | MASK_IA64(PSR_TB,1i64) | \
  458. MASK_IA64(PSR_ID,1i64) | MASK_IA64(PSR_DD,1i64))
  459. __inline
  460. ULONG64
  461. SANITIZE_PSR(ULONG64 psr, MODE mode){
  462. psr = (mode) == KernelMode ?
  463. (PSR_KERNEL_SET | ((psr) & (PSR_KERNEL_CPY | ~PSR_KERNEL_CLR))) :
  464. (PSR_USER_SET | ((psr) & (PSR_USER_CPY | ~PSR_USER_CLR)));
  465. if (((psr >> PSR_RI) & 3) == 3) {
  466. //
  467. // 3 is an invalid slot number; sanitize it to zero
  468. //
  469. psr &= ~(3i64 << PSR_RI);
  470. }
  471. return(psr);
  472. }
  473. //
  474. // Define SANITIZE_IFS for IA64
  475. //
  476. __inline
  477. ULONG64
  478. SANITIZE_IFS(ULONG64 pfsarg, MODE mode){
  479. IA64_PFS pfs;
  480. ULONGLONG sof;
  481. UNREFERENCED_PARAMETER(mode);
  482. pfs.ull = pfsarg;
  483. //
  484. // There is no previous EC or previous privilege level in IFS
  485. //
  486. pfs.sb.pfs_pec = 0;
  487. pfs.sb.pfs_ppl = 0;
  488. pfs.sb.pfs_reserved1 = 0;
  489. pfs.sb.pfs_reserved2 = 0;
  490. //
  491. // Set the valid bit.
  492. //
  493. pfs.ull |= MASK_IA64(IFS_V,1i64);
  494. //
  495. // Verify the size of frame is not greater than allowed.
  496. //
  497. sof = pfs.sb.pfs_sof;
  498. if (sof > PFS_MAXIMUM_REGISTER_SIZE) {
  499. sof = PFS_MAXIMUM_REGISTER_SIZE;
  500. pfs.sb.pfs_sof = PFS_MAXIMUM_REGISTER_SIZE;
  501. }
  502. //
  503. // Verify the size of locals is not greater than size of frame.
  504. //
  505. if (sof < pfs.sb.pfs_sol) {
  506. pfs.sb.pfs_sol = sof;
  507. }
  508. //
  509. // Verify the size of locals is not greater than size of frame.
  510. //
  511. if (sof < (pfs.sb.pfs_sor * 8)) {
  512. pfs.sb.pfs_sor = sof / 8;
  513. }
  514. //
  515. // Verify rename bases are less than the size of the rotaing regions.
  516. //
  517. if (pfs.sb.pfs_rrb_gr >= (pfs.sb.pfs_sor * 8)) {
  518. pfs.sb.pfs_rrb_gr = 0;
  519. }
  520. if (pfs.sb.pfs_rrb_fr >= PFS_MAXIMUM_REGISTER_SIZE) {
  521. pfs.sb.pfs_rrb_fr = 0;
  522. }
  523. if (pfs.sb.pfs_rrb_pr >= PFS_MAXIMUM_PREDICATE_SIZE) {
  524. pfs.sb.pfs_rrb_pr = 0;
  525. }
  526. return(pfs.ull);
  527. }
  528. __inline
  529. ULONG64
  530. SANITIZE_PFS(ULONG64 pfsarg, MODE mode){
  531. IA64_PFS pfs;
  532. ULONGLONG sof;
  533. pfs.ull = pfsarg;
  534. if (mode != KernelMode) {
  535. pfs.sb.pfs_ppl = IA64_USER_PL;
  536. }
  537. pfs.sb.pfs_reserved1 = 0;
  538. pfs.sb.pfs_reserved2 = 0;
  539. //
  540. // Verify the size of frame is not greater than allowed.
  541. //
  542. sof = pfs.sb.pfs_sof;
  543. if (sof > PFS_MAXIMUM_REGISTER_SIZE) {
  544. sof = PFS_MAXIMUM_REGISTER_SIZE;
  545. pfs.sb.pfs_sof = PFS_MAXIMUM_REGISTER_SIZE;
  546. }
  547. //
  548. // Verify the size of locals is not greater than size of frame.
  549. //
  550. if (sof < pfs.sb.pfs_sol) {
  551. pfs.sb.pfs_sol = sof;
  552. }
  553. //
  554. // Verify the size of locals is not greater than size of frame.
  555. //
  556. if (sof < (pfs.sb.pfs_sor * 8)) {
  557. pfs.sb.pfs_sor = sof / 8;
  558. }
  559. //
  560. // Verify rename bases are less than the size of the rotaing regions.
  561. //
  562. if (pfs.sb.pfs_rrb_gr >= (pfs.sb.pfs_sor * 8)) {
  563. pfs.sb.pfs_rrb_gr = 0;
  564. }
  565. if (pfs.sb.pfs_rrb_fr >= PFS_MAXIMUM_REGISTER_SIZE) {
  566. pfs.sb.pfs_rrb_fr = 0;
  567. }
  568. if (pfs.sb.pfs_rrb_pr >= PFS_MAXIMUM_PREDICATE_SIZE) {
  569. pfs.sb.pfs_rrb_pr = 0;
  570. }
  571. return(pfs.ull);
  572. }
  573. //
  574. // Macro used to zero the software field of RSC that contains the size of
  575. // RSE frame to be preloaded on kernel exit
  576. //
  577. #define ZERO_PRELOAD_SIZE(RseRsc) \
  578. (RseRsc & ~(((1i64 << RSC_LOADRS_LEN)-1) << RSC_MBZ1))
  579. //
  580. // Macro used to sanitize the RSC
  581. //
  582. #define SANITIZE_RSC(RseRsc)
  583. extern ULONGLONG KiIA64DCR;
  584. #define SANITIZE_DCR(dcr, mode) \
  585. ((mode) == KernelMode ? dcr : KiIA64DCR)
  586. //
  587. // Macro to sanitize debug registers
  588. //
  589. #define SANITIZE_DR(dr, mode) \
  590. ((mode) == KernelMode ? \
  591. (dr) : \
  592. (dr & ~(0x7i64 << DR_PLM0)) /* disable pl 0-2 */ \
  593. )
  594. #define SANITIZE_AR21_FCR(FCR,mode) \
  595. (((FCR)&0x0000FFBF00001F3Fi64)|0x40i64)
  596. #define SANITIZE_AR24_EFLAGS(EFLAGS,mode) \
  597. (((EFLAGS)&0x00000000003E0DD7i64)|0x02i64)
  598. #define SANITIZE_AR27_CFLG(CFLG,mode) \
  599. ((CFLG)&(0x000007FFE005003Fi64))
  600. #define SANITIZE_AR28_FSR(FSR,mode) \
  601. ((FSR)&0x0000FFBF5555FFFFi64)
  602. #define SANITIZE_AR29_FIR(FIR,mode) \
  603. ((FIR)&0x07FFFFFFFFFFFFFFi64)
  604. #define SANITIZE_AR30_FDR(FDR,mode) \
  605. ((FDR)&0x0000FFFFFFFFFFFFi64)
  606. // begin_nthal
  607. //
  608. // Define interrupt request physical address (maps to HAL virtual address)
  609. //
  610. #define INTERRUPT_REQUEST_PHYSICAL_ADDRESS 0xFFE00000
  611. //
  612. // Define Address of Processor Control Registers.
  613. //
  614. //
  615. // Define Pointer to Processor Control Registers.
  616. //
  617. #define KIPCR ((ULONG_PTR)(KADDRESS_BASE + 0xFFFF0000)) // kernel address of first PCR
  618. #define PCR ((volatile KPCR * const)KIPCR)
  619. //
  620. // Define address for epc system calls
  621. //
  622. #define MM_EPC_VA (KADDRESS_BASE + 0xFFA00000)
  623. //
  624. // Define Base Address of PAL Mapping
  625. //
  626. //
  627. #define HAL_PAL_VIRTUAL_ADDRESS (KADDRESS_BASE + 0xE0000000)
  628. // begin_ntddk begin_wdm begin_ntosp
  629. #define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000))
  630. #define SharedUserData ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
  631. //
  632. // Prototype for get current IRQL. **** TBD (read TPR)
  633. //
  634. NTKERNELAPI
  635. KIRQL
  636. KeGetCurrentIrql();
  637. // end_wdm
  638. //
  639. // Get address of current processor block.
  640. //
  641. #define KeGetCurrentPrcb() PCR->Prcb
  642. //
  643. // Get address of processor control region.
  644. //
  645. #define KeGetPcr() PCR
  646. //
  647. // Get address of current kernel thread object.
  648. //
  649. #if defined(_M_IA64)
  650. #define KeGetCurrentThread() PCR->CurrentThread
  651. #endif
  652. //
  653. // Get current processor number.
  654. //
  655. #define KeGetCurrentProcessorNumber() PCR->Number
  656. //
  657. // Get data cache fill size.
  658. //
  659. #if PRAGMA_DEPRECATED_DDK
  660. #pragma deprecated(KeGetDcacheFillSize) // Use GetDmaAlignment
  661. #endif
  662. #define KeGetDcacheFillSize() PCR->DcacheFillSize
  663. // end_ntddk end_nthal end_ntosp
  664. //
  665. // Test if executing a DPC.
  666. //
  667. BOOLEAN
  668. KeIsExecutingDpc (
  669. VOID
  670. );
  671. //
  672. // Save & Restore floating point state
  673. //
  674. // begin_ntddk begin_wdm begin_ntosp
  675. #define KeSaveFloatingPointState(a) STATUS_SUCCESS
  676. #define KeRestoreFloatingPointState(a) STATUS_SUCCESS
  677. // end_ntddk end_wdm end_ntosp
  678. //++
  679. //
  680. //
  681. // VOID
  682. // KeMemoryBarrier (
  683. // VOID
  684. // )
  685. //
  686. //
  687. // Routine Description:
  688. //
  689. // This function cases ordering of memory acceses as seen by other processors.
  690. //
  691. //
  692. // Arguments:
  693. //
  694. // None.
  695. //
  696. // Return Value:
  697. //
  698. // None.
  699. //--
  700. #if defined (NT_UP)
  701. #define KeMemoryBarrier()
  702. #else
  703. #define KE_MEMORY_BARRIER_REQUIRED
  704. #define KeMemoryBarrier() __mf ()
  705. #endif
  706. // begin_ntddk begin_nthal begin_ntndis begin_wdm begin_ntosp
  707. //
  708. // Define the page size
  709. //
  710. #define PAGE_SIZE 0x2000
  711. //
  712. // Define the number of trailing zeroes in a page aligned virtual address.
  713. // This is used as the shift count when shifting virtual addresses to
  714. // virtual page numbers.
  715. //
  716. #define PAGE_SHIFT 13L
  717. // end_ntddk end_nthal end_ntndis end_wdm end_ntosp
  718. // begin_nthal
  719. //
  720. // IA64 hardware structures
  721. //
  722. //
  723. // A Page Table Entry on an IA64 has the following definition.
  724. //
  725. #define _HARDWARE_PTE_WORKING_SET_BITS 11
  726. typedef struct _HARDWARE_PTE {
  727. ULONG64 Valid : 1;
  728. ULONG64 Rsvd0 : 1;
  729. ULONG64 Cache : 3;
  730. ULONG64 Accessed : 1;
  731. ULONG64 Dirty : 1;
  732. ULONG64 Owner : 2;
  733. ULONG64 Execute : 1;
  734. ULONG64 Write : 1;
  735. ULONG64 Rsvd1 : PAGE_SHIFT - 12;
  736. ULONG64 CopyOnWrite : 1;
  737. ULONG64 PageFrameNumber : 50 - PAGE_SHIFT;
  738. ULONG64 Rsvd2 : 2;
  739. ULONG64 Exception : 1;
  740. ULONGLONG SoftwareWsIndex : _HARDWARE_PTE_WORKING_SET_BITS;
  741. } HARDWARE_PTE, *PHARDWARE_PTE;
  742. //
  743. // Fill TB entry
  744. //
  745. // Filling TB entry on demand by VHPT H/W seems faster than done by s/w.
  746. // Determining I/D side of TLB, disabling/enabling PSR.i and ic bits,
  747. // serialization, writing to IIP, IDA, IDTR and IITR seem just too much
  748. // compared to VHPT searching it automatically.
  749. //
  750. #define KiVhptEntry(va) ((PVOID)__thash((__int64)va))
  751. #define KiVhptEntryTag(va) ((ULONGLONG)__ttag((__int64)va))
  752. #define KiFlushSingleTb(Invalid, va) \
  753. __ptcl((__int64)va,PAGE_SHIFT << 2); __isrlz()
  754. #define KeFillEntryTb(PointerPte, Virtual, Invalid) \
  755. KiFlushSingleTb(0, Virtual); \
  756. #define KiFlushFixedInstTb(Invalid, va) \
  757. __ptri((__int64)va, PAGE_SHIFT << 2); __isrlz()
  758. #define KiFlushFixedDataTb(Invalid, va) \
  759. __ptrd((__int64)va, PAGE_SHIFT << 2); __dsrlz()
  760. NTKERNELAPI
  761. VOID
  762. KeFillLargeEntryTb (
  763. IN HARDWARE_PTE Pte[2],
  764. IN PVOID Virtual,
  765. IN ULONG PageSize
  766. );
  767. //
  768. // Fill TB fixed entry
  769. //
  770. NTKERNELAPI
  771. VOID
  772. KeFillFixedEntryTb (
  773. IN HARDWARE_PTE Pte[2],
  774. IN PVOID Virtual,
  775. IN ULONG PageSize,
  776. IN ULONG Index
  777. );
  778. NTKERNELAPI
  779. VOID
  780. KeFillFixedLargeEntryTb (
  781. IN HARDWARE_PTE Pte[2],
  782. IN PVOID Virtual,
  783. IN ULONG PageSize,
  784. IN ULONG Index
  785. );
  786. #define INST_TB_BASE 0x80000000
  787. #define DATA_TB_BASE 0
  788. #define INST_TB_KERNEL_INDEX (INST_TB_BASE|ITR_KERNEL_INDEX)
  789. #define INST_TB_EPC_INDEX (INST_TB_BASE|ITR_EPC_INDEX)
  790. #define INST_TB_HAL_INDEX (INST_TB_BASE|ITR_HAL_INDEX)
  791. #define INST_TB_PAL_INDEX (INST_TB_BASE|ITR_PAL_INDEX)
  792. #define DATA_TB_DRIVER0_INDEX (DATA_TB_BASE|DTR_DRIVER0_INDEX)
  793. #define DATA_TB_DRIVER1_INDEX (DATA_TB_BASE|DTR_DRIVER1_INDEX)
  794. #define DATA_TB_KTBASE_INDEX (DATA_TB_BASE|DTR_KTBASE_INDEX)
  795. #define DATA_TB_UTBASE_INDEX (DATA_TB_BASE|DTR_UTBASE_INDEX)
  796. #define DATA_TB_STBASE_INDEX (DATA_TB_BASE|DTR_STBASE_INDEX)
  797. #define DATA_TB_IOPORT_INDEX (DATA_TB_BASE|DTR_IO_PORT_INDEX)
  798. #define DATA_TB_KTBASE_TMP_INDEX (DATA_TB_BASE|DTR_KTBASE_INDEX_TMP)
  799. #define DATA_TB_UTBASE_TMP_INDEX (DATA_TB_BASE|DTR_UTBASE_INDEX_TMP)
  800. #define DATA_TB_HAL_INDEX (DATA_TB_BASE|DTR_HAL_INDEX)
  801. #define DATA_TB_PAL_INDEX (DATA_TB_BASE|DTR_PAL_INDEX)
  802. //
  803. // Fill Inst TB entry
  804. //
  805. NTKERNELAPI
  806. VOID
  807. KeFillInstEntryTb (
  808. IN HARDWARE_PTE Pte,
  809. IN PVOID Virtual
  810. );
  811. NTKERNELAPI
  812. VOID
  813. KeFlushCurrentTb (
  814. VOID
  815. );
  816. //
  817. // Get a VHPT entry address
  818. //
  819. PVOID
  820. KiVhptEntry64(
  821. IN ULONG VirtualPageNumber
  822. );
  823. //
  824. // Get a VHPT entry TAG value
  825. //
  826. ULONGLONG
  827. KiVhptEntryTag64(
  828. IN ULONG VirtualPageNumber
  829. );
  830. //
  831. // Fill a VHPT entry
  832. //
  833. VOID
  834. KiFillEntryVhpt(
  835. IN PHARDWARE_PTE PointerPte,
  836. IN PVOID Virtual
  837. );
  838. //
  839. // Flush the kernel portions of Tb
  840. //
  841. VOID
  842. KeFlushKernelTb(
  843. IN BOOLEAN AllProcessors
  844. );
  845. //
  846. // Flush the user portions of Tb
  847. //
  848. VOID
  849. KeFlushUserTb(
  850. IN BOOLEAN AllProcessors
  851. );
  852. //
  853. // Data cache, instruction cache, I/O buffer, and write buffer flush routine
  854. // prototypes.
  855. //
  856. NTKERNELAPI
  857. VOID
  858. KeChangeColorPage (
  859. IN PVOID NewColor,
  860. IN PVOID OldColor,
  861. IN ULONG PageFrame
  862. );
  863. NTKERNELAPI
  864. VOID
  865. KeSweepDcache (
  866. IN BOOLEAN AllProcessors
  867. );
  868. #define KeSweepCurrentDcache()
  869. NTKERNELAPI
  870. VOID
  871. KeSweepIcache (
  872. IN BOOLEAN AllProcessors
  873. );
  874. NTKERNELAPI
  875. VOID
  876. KeSweepIcacheRange (
  877. IN BOOLEAN AllProcessors,
  878. IN PVOID BaseAddress,
  879. IN SIZE_T Length
  880. );
  881. NTKERNELAPI
  882. VOID
  883. KeSweepCurrentIcacheRange (
  884. IN PVOID BaseAddress,
  885. IN SIZE_T Length
  886. );
  887. #define KeSweepCurrentIcache()
  888. NTKERNELAPI
  889. VOID
  890. KeSweepCacheRangeWithDrain (
  891. IN BOOLEAN AllProcessors,
  892. IN PVOID BaseAddress,
  893. IN ULONG Length
  894. );
  895. // begin_ntddk begin_ntndis begin_wdm begin_ntosp
  896. //
  897. // Cache and write buffer flush functions.
  898. //
  899. NTKERNELAPI
  900. VOID
  901. KeFlushIoBuffers (
  902. IN PMDL Mdl,
  903. IN BOOLEAN ReadOperation,
  904. IN BOOLEAN DmaOperation
  905. );
  906. // end_ntddk end_ntndis end_wdm end_ntosp
  907. //
  908. // Clock, profile, and interprocessor interrupt functions.
  909. //
  910. struct _KEXCEPTION_FRAME;
  911. struct _KTRAP_FRAME;
  912. NTKERNELAPI
  913. VOID
  914. KeIpiInterrupt (
  915. IN struct _KTRAP_FRAME *TrapFrame
  916. );
  917. #define KeYieldProcessor()
  918. NTKERNELAPI
  919. VOID
  920. KeProfileInterrupt (
  921. IN struct _KTRAP_FRAME *TrapFrame
  922. );
  923. NTKERNELAPI
  924. VOID
  925. KeProfileInterruptWithSource (
  926. IN struct _KTRAP_FRAME *TrapFrame,
  927. IN KPROFILE_SOURCE ProfileSource
  928. );
  929. NTKERNELAPI
  930. VOID
  931. KeUpdateRunTime (
  932. IN struct _KTRAP_FRAME *TrapFrame
  933. );
  934. NTKERNELAPI
  935. VOID
  936. KeUpdateSystemTime (
  937. IN struct _KTRAP_FRAME *TrapFrame,
  938. IN ULONG Increment
  939. );
  940. //
  941. // The following function prototypes are exported for use in MP HALs.
  942. //
  943. #if defined(NT_UP)
  944. #define KiAcquireSpinLock(SpinLock)
  945. #else
  946. NTKERNELAPI
  947. VOID
  948. KiAcquireSpinLock (
  949. IN PKSPIN_LOCK SpinLock
  950. );
  951. #endif
  952. #if defined(NT_UP)
  953. #define KiReleaseSpinLock(SpinLock)
  954. #else
  955. VOID
  956. KiReleaseSpinLock (
  957. IN PKSPIN_LOCK SpinLock
  958. );
  959. // #define KiReleaseSpinLock _ReleaseSpinLock
  960. #endif
  961. //
  962. // KeTestSpinLock may be used to spin at low IRQL until the lock is
  963. // available. The IRQL must then be raised and the lock acquired with
  964. // KeTryToAcquireSpinLock. If that fails, lower the IRQL and start again.
  965. //
  966. #if defined(NT_UP)
  967. #define KeTestSpinLock(SpinLock) (TRUE)
  968. #else
  969. BOOLEAN
  970. KeTestSpinLock (
  971. IN PKSPIN_LOCK SpinLock
  972. );
  973. #endif
  974. //
  975. // Define cache error routine type and prototype.
  976. //
  977. typedef
  978. VOID
  979. (*PKCACHE_ERROR_ROUTINE) (
  980. VOID
  981. );
  982. NTKERNELAPI
  983. VOID
  984. KeSetCacheErrorRoutine (
  985. IN PKCACHE_ERROR_ROUTINE Routine
  986. );
  987. // begin_ntddk begin_wdm
  988. //
  989. // Kernel breakin breakpoint
  990. //
  991. VOID
  992. KeBreakinBreakpoint (
  993. VOID
  994. );
  995. // end_ntddk end_nthal end_wdm
  996. //
  997. // Define executive macros for acquiring and releasing executive spinlocks.
  998. // These macros can ONLY be used by executive components and NOT by drivers.
  999. // Drivers MUST use the kernel interfaces since they must be MP enabled on
  1000. // all systems.
  1001. //
  1002. #if defined(NT_UP) && !defined(_NTDDK_) && !defined(_NTIFS_)
  1003. #define ExAcquireSpinLock(Lock, OldIrql) KeRaiseIrql(DISPATCH_LEVEL, (OldIrql))
  1004. #define ExReleaseSpinLock(Lock, OldIrql) KeLowerIrql((OldIrql))
  1005. #define ExAcquireSpinLockAtDpcLevel(Lock)
  1006. #define ExReleaseSpinLockFromDpcLevel(Lock)
  1007. #else
  1008. // begin_wdm begin_ntddk begin_ntosp
  1009. #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
  1010. #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
  1011. #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
  1012. #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
  1013. // end_wdm end_ntddk end_ntosp
  1014. #endif
  1015. //
  1016. // The acquire and release fast lock macros disable and enable interrupts
  1017. // on UP nondebug systems. On MP or debug systems, the spinlock routines
  1018. // are used.
  1019. //
  1020. // N.B. Extreme caution should be observed when using these routines.
  1021. //
  1022. #if defined(_M_IA64)
  1023. VOID
  1024. _disable (
  1025. VOID
  1026. );
  1027. VOID
  1028. _enable (
  1029. VOID
  1030. );
  1031. #pragma intrinsic(_disable)
  1032. #pragma intrinsic(_enable)
  1033. #endif
  1034. #if defined(NT_UP) && !DBG
  1035. #define ExAcquireFastLock(Lock, OldIrql) _disable()
  1036. #else
  1037. #define ExAcquireFastLock(Lock, OldIrql) \
  1038. ExAcquireSpinLock(Lock, OldIrql)
  1039. #endif
  1040. #if defined(NT_UP) && !DBG
  1041. #define ExReleaseFastLock(Lock, OldIrql) _enable()
  1042. #else
  1043. #define ExReleaseFastLock(Lock, OldIrql) \
  1044. ExReleaseSpinLock(Lock, OldIrql)
  1045. #endif
  1046. //
  1047. // Data and instruction bus error function prototypes.
  1048. //
  1049. BOOLEAN
  1050. KeBusError (
  1051. IN PEXCEPTION_RECORD ExceptionRecord,
  1052. IN struct _KEXCEPTION_FRAME *ExceptionFrame,
  1053. IN struct _KTRAP_FRAME *TrapFrame,
  1054. IN PVOID VirtualAddress,
  1055. IN PHYSICAL_ADDRESS PhysicalAddress
  1056. );
  1057. VOID
  1058. KiDataBusError (
  1059. IN PEXCEPTION_RECORD ExceptionRecord,
  1060. IN struct _KEXCEPTION_FRAME *ExceptionFrame,
  1061. IN struct _KTRAP_FRAME *TrapFrame
  1062. );
  1063. VOID
  1064. KiInstructionBusError (
  1065. IN PEXCEPTION_RECORD ExceptionRecord,
  1066. IN struct _KEXCEPTION_FRAME *ExceptionFrame,
  1067. IN struct _KTRAP_FRAME *TrapFrame
  1068. );
  1069. //
  1070. // Define query tick count macro.
  1071. //
  1072. // begin_ntddk begin_nthal begin_ntosp
  1073. #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
  1074. // begin_wdm
  1075. #define KeQueryTickCount(CurrentCount ) \
  1076. *(PULONGLONG)(CurrentCount) = **((volatile ULONGLONG **)(&KeTickCount));
  1077. // end_wdm
  1078. #else
  1079. // end_ntddk end_nthal end_ntosp
  1080. #define KiQueryTickCount(CurrentCount) \
  1081. *(PULONGLONG)(CurrentCount) = KeTickCount.QuadPart;
  1082. // begin_ntddk begin_nthal begin_ntosp
  1083. NTKERNELAPI
  1084. VOID
  1085. KeQueryTickCount (
  1086. OUT PLARGE_INTEGER CurrentCount
  1087. );
  1088. #endif // defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
  1089. // end_ntddk end_nthal end_ntosp
  1090. //
  1091. // The following function prototypes must be in the module since they are
  1092. // machine dependent.
  1093. //
  1094. ULONG
  1095. KiEmulateBranch (
  1096. IN struct _KEXCEPTION_FRAME *ExceptionFrame,
  1097. IN struct _KTRAP_FRAME *TrapFrame
  1098. );
  1099. BOOLEAN
  1100. KiEmulateFloating (
  1101. IN OUT PEXCEPTION_RECORD ExceptionRecord,
  1102. IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame,
  1103. IN OUT struct _KTRAP_FRAME *TrapFrame
  1104. );
  1105. BOOLEAN
  1106. KiEmulateReference (
  1107. IN OUT PEXCEPTION_RECORD ExceptionRecord,
  1108. IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame,
  1109. IN OUT struct _KTRAP_FRAME *TrapFrame
  1110. );
  1111. ULONGLONG
  1112. KiGetRegisterValue (
  1113. IN ULONG Register,
  1114. IN struct _KEXCEPTION_FRAME *ExceptionFrame,
  1115. IN struct _KTRAP_FRAME *TrapFrame
  1116. );
  1117. VOID
  1118. KiSetRegisterValue (
  1119. IN ULONG Register,
  1120. IN ULONGLONG Value,
  1121. OUT struct _KEXCEPTION_FRAME *ExceptionFrame,
  1122. OUT struct _KTRAP_FRAME *TrapFrame
  1123. );
  1124. FLOAT128
  1125. KiGetFloatRegisterValue (
  1126. IN ULONG Register,
  1127. IN struct _KEXCEPTION_FRAME *ExceptionFrame,
  1128. IN struct _KTRAP_FRAME *TrapFrame
  1129. );
  1130. VOID
  1131. KiSetFloatRegisterValue (
  1132. IN ULONG Register,
  1133. IN FLOAT128 Value,
  1134. OUT struct _KEXCEPTION_FRAME *ExceptionFrame,
  1135. OUT struct _KTRAP_FRAME *TrapFrame
  1136. );
  1137. VOID
  1138. KiAdvanceInstPointer(
  1139. IN OUT struct _KTRAP_FRAME *TrapFrame
  1140. );
  1141. VOID
  1142. KiRequestSoftwareInterrupt (
  1143. KIRQL RequestIrql
  1144. );
  1145. // begin_ntddk begin_nthal begin_ntndis begin_wdm begin_ntosp
  1146. //
  1147. // I/O space read and write macros.
  1148. //
  1149. NTHALAPI
  1150. UCHAR
  1151. READ_PORT_UCHAR (
  1152. PUCHAR RegisterAddress
  1153. );
  1154. NTHALAPI
  1155. USHORT
  1156. READ_PORT_USHORT (
  1157. PUSHORT RegisterAddress
  1158. );
  1159. NTHALAPI
  1160. ULONG
  1161. READ_PORT_ULONG (
  1162. PULONG RegisterAddress
  1163. );
  1164. NTHALAPI
  1165. VOID
  1166. READ_PORT_BUFFER_UCHAR (
  1167. PUCHAR portAddress,
  1168. PUCHAR readBuffer,
  1169. ULONG readCount
  1170. );
  1171. NTHALAPI
  1172. VOID
  1173. READ_PORT_BUFFER_USHORT (
  1174. PUSHORT portAddress,
  1175. PUSHORT readBuffer,
  1176. ULONG readCount
  1177. );
  1178. NTHALAPI
  1179. VOID
  1180. READ_PORT_BUFFER_ULONG (
  1181. PULONG portAddress,
  1182. PULONG readBuffer,
  1183. ULONG readCount
  1184. );
  1185. NTHALAPI
  1186. VOID
  1187. WRITE_PORT_UCHAR (
  1188. PUCHAR portAddress,
  1189. UCHAR Data
  1190. );
  1191. NTHALAPI
  1192. VOID
  1193. WRITE_PORT_USHORT (
  1194. PUSHORT portAddress,
  1195. USHORT Data
  1196. );
  1197. NTHALAPI
  1198. VOID
  1199. WRITE_PORT_ULONG (
  1200. PULONG portAddress,
  1201. ULONG Data
  1202. );
  1203. NTHALAPI
  1204. VOID
  1205. WRITE_PORT_BUFFER_UCHAR (
  1206. PUCHAR portAddress,
  1207. PUCHAR writeBuffer,
  1208. ULONG writeCount
  1209. );
  1210. NTHALAPI
  1211. VOID
  1212. WRITE_PORT_BUFFER_USHORT (
  1213. PUSHORT portAddress,
  1214. PUSHORT writeBuffer,
  1215. ULONG writeCount
  1216. );
  1217. NTHALAPI
  1218. VOID
  1219. WRITE_PORT_BUFFER_ULONG (
  1220. PULONG portAddress,
  1221. PULONG writeBuffer,
  1222. ULONG writeCount
  1223. );
  1224. #define READ_REGISTER_UCHAR(x) \
  1225. (__mf(), *(volatile UCHAR * const)(x))
  1226. #define READ_REGISTER_USHORT(x) \
  1227. (__mf(), *(volatile USHORT * const)(x))
  1228. #define READ_REGISTER_ULONG(x) \
  1229. (__mf(), *(volatile ULONG * const)(x))
  1230. #define READ_REGISTER_BUFFER_UCHAR(x, y, z) { \
  1231. PUCHAR registerBuffer = x; \
  1232. PUCHAR readBuffer = y; \
  1233. ULONG readCount; \
  1234. __mf(); \
  1235. for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
  1236. *readBuffer = *(volatile UCHAR * const)(registerBuffer); \
  1237. } \
  1238. }
  1239. #define READ_REGISTER_BUFFER_USHORT(x, y, z) { \
  1240. PUSHORT registerBuffer = x; \
  1241. PUSHORT readBuffer = y; \
  1242. ULONG readCount; \
  1243. __mf(); \
  1244. for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
  1245. *readBuffer = *(volatile USHORT * const)(registerBuffer); \
  1246. } \
  1247. }
  1248. #define READ_REGISTER_BUFFER_ULONG(x, y, z) { \
  1249. PULONG registerBuffer = x; \
  1250. PULONG readBuffer = y; \
  1251. ULONG readCount; \
  1252. __mf(); \
  1253. for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
  1254. *readBuffer = *(volatile ULONG * const)(registerBuffer); \
  1255. } \
  1256. }
  1257. #define WRITE_REGISTER_UCHAR(x, y) { \
  1258. *(volatile UCHAR * const)(x) = y; \
  1259. KeFlushWriteBuffer(); \
  1260. }
  1261. #define WRITE_REGISTER_USHORT(x, y) { \
  1262. *(volatile USHORT * const)(x) = y; \
  1263. KeFlushWriteBuffer(); \
  1264. }
  1265. #define WRITE_REGISTER_ULONG(x, y) { \
  1266. *(volatile ULONG * const)(x) = y; \
  1267. KeFlushWriteBuffer(); \
  1268. }
  1269. #define WRITE_REGISTER_BUFFER_UCHAR(x, y, z) { \
  1270. PUCHAR registerBuffer = x; \
  1271. PUCHAR writeBuffer = y; \
  1272. ULONG writeCount; \
  1273. for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
  1274. *(volatile UCHAR * const)(registerBuffer) = *writeBuffer; \
  1275. } \
  1276. KeFlushWriteBuffer(); \
  1277. }
  1278. #define WRITE_REGISTER_BUFFER_USHORT(x, y, z) { \
  1279. PUSHORT registerBuffer = x; \
  1280. PUSHORT writeBuffer = y; \
  1281. ULONG writeCount; \
  1282. for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
  1283. *(volatile USHORT * const)(registerBuffer) = *writeBuffer; \
  1284. } \
  1285. KeFlushWriteBuffer(); \
  1286. }
  1287. #define WRITE_REGISTER_BUFFER_ULONG(x, y, z) { \
  1288. PULONG registerBuffer = x; \
  1289. PULONG writeBuffer = y; \
  1290. ULONG writeCount; \
  1291. for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
  1292. *(volatile ULONG * const)(registerBuffer) = *writeBuffer; \
  1293. } \
  1294. KeFlushWriteBuffer(); \
  1295. }
  1296. // end_ntddk end_ntndis end_wdm end_ntosp
  1297. //
  1298. // Higher FP volatile
  1299. //
  1300. // This structure defines the higher FP volatile registers.
  1301. //
  1302. typedef struct _KHIGHER_FP_VOLATILE {
  1303. // volatile higher floating registers f32 - f127
  1304. FLOAT128 FltF32;
  1305. FLOAT128 FltF33;
  1306. FLOAT128 FltF34;
  1307. FLOAT128 FltF35;
  1308. FLOAT128 FltF36;
  1309. FLOAT128 FltF37;
  1310. FLOAT128 FltF38;
  1311. FLOAT128 FltF39;
  1312. FLOAT128 FltF40;
  1313. FLOAT128 FltF41;
  1314. FLOAT128 FltF42;
  1315. FLOAT128 FltF43;
  1316. FLOAT128 FltF44;
  1317. FLOAT128 FltF45;
  1318. FLOAT128 FltF46;
  1319. FLOAT128 FltF47;
  1320. FLOAT128 FltF48;
  1321. FLOAT128 FltF49;
  1322. FLOAT128 FltF50;
  1323. FLOAT128 FltF51;
  1324. FLOAT128 FltF52;
  1325. FLOAT128 FltF53;
  1326. FLOAT128 FltF54;
  1327. FLOAT128 FltF55;
  1328. FLOAT128 FltF56;
  1329. FLOAT128 FltF57;
  1330. FLOAT128 FltF58;
  1331. FLOAT128 FltF59;
  1332. FLOAT128 FltF60;
  1333. FLOAT128 FltF61;
  1334. FLOAT128 FltF62;
  1335. FLOAT128 FltF63;
  1336. FLOAT128 FltF64;
  1337. FLOAT128 FltF65;
  1338. FLOAT128 FltF66;
  1339. FLOAT128 FltF67;
  1340. FLOAT128 FltF68;
  1341. FLOAT128 FltF69;
  1342. FLOAT128 FltF70;
  1343. FLOAT128 FltF71;
  1344. FLOAT128 FltF72;
  1345. FLOAT128 FltF73;
  1346. FLOAT128 FltF74;
  1347. FLOAT128 FltF75;
  1348. FLOAT128 FltF76;
  1349. FLOAT128 FltF77;
  1350. FLOAT128 FltF78;
  1351. FLOAT128 FltF79;
  1352. FLOAT128 FltF80;
  1353. FLOAT128 FltF81;
  1354. FLOAT128 FltF82;
  1355. FLOAT128 FltF83;
  1356. FLOAT128 FltF84;
  1357. FLOAT128 FltF85;
  1358. FLOAT128 FltF86;
  1359. FLOAT128 FltF87;
  1360. FLOAT128 FltF88;
  1361. FLOAT128 FltF89;
  1362. FLOAT128 FltF90;
  1363. FLOAT128 FltF91;
  1364. FLOAT128 FltF92;
  1365. FLOAT128 FltF93;
  1366. FLOAT128 FltF94;
  1367. FLOAT128 FltF95;
  1368. FLOAT128 FltF96;
  1369. FLOAT128 FltF97;
  1370. FLOAT128 FltF98;
  1371. FLOAT128 FltF99;
  1372. FLOAT128 FltF100;
  1373. FLOAT128 FltF101;
  1374. FLOAT128 FltF102;
  1375. FLOAT128 FltF103;
  1376. FLOAT128 FltF104;
  1377. FLOAT128 FltF105;
  1378. FLOAT128 FltF106;
  1379. FLOAT128 FltF107;
  1380. FLOAT128 FltF108;
  1381. FLOAT128 FltF109;
  1382. FLOAT128 FltF110;
  1383. FLOAT128 FltF111;
  1384. FLOAT128 FltF112;
  1385. FLOAT128 FltF113;
  1386. FLOAT128 FltF114;
  1387. FLOAT128 FltF115;
  1388. FLOAT128 FltF116;
  1389. FLOAT128 FltF117;
  1390. FLOAT128 FltF118;
  1391. FLOAT128 FltF119;
  1392. FLOAT128 FltF120;
  1393. FLOAT128 FltF121;
  1394. FLOAT128 FltF122;
  1395. FLOAT128 FltF123;
  1396. FLOAT128 FltF124;
  1397. FLOAT128 FltF125;
  1398. FLOAT128 FltF126;
  1399. FLOAT128 FltF127;
  1400. } KHIGHER_FP_VOLATILE, *PKHIGHER_FP_VOLATILE;
  1401. //
  1402. // Debug registers
  1403. //
  1404. // This structure defines the hardware debug registers.
  1405. // We allow space for 4 pairs of instruction and 4 pairs of data debug registers
  1406. // The hardware may actually have more.
  1407. //
  1408. typedef struct _KDEBUG_REGISTERS {
  1409. ULONGLONG DbI0;
  1410. ULONGLONG DbI1;
  1411. ULONGLONG DbI2;
  1412. ULONGLONG DbI3;
  1413. ULONGLONG DbI4;
  1414. ULONGLONG DbI5;
  1415. ULONGLONG DbI6;
  1416. ULONGLONG DbI7;
  1417. ULONGLONG DbD0;
  1418. ULONGLONG DbD1;
  1419. ULONGLONG DbD2;
  1420. ULONGLONG DbD3;
  1421. ULONGLONG DbD4;
  1422. ULONGLONG DbD5;
  1423. ULONGLONG DbD6;
  1424. ULONGLONG DbD7;
  1425. } KDEBUG_REGISTERS, *PKDEBUG_REGISTERS;
  1426. //
  1427. // misc. application registers (mapped to IA-32 registers)
  1428. //
  1429. typedef struct _KAPPLICATION_REGISTERS {
  1430. ULONGLONG Ar21;
  1431. ULONGLONG Ar24;
  1432. ULONGLONG Ar25;
  1433. ULONGLONG Ar26;
  1434. ULONGLONG Ar27;
  1435. ULONGLONG Ar28;
  1436. ULONGLONG Ar29;
  1437. ULONGLONG Ar30;
  1438. } KAPPLICATION_REGISTERS, *PKAPPLICATION_REGISTERS;
  1439. //
  1440. // performance registers
  1441. //
  1442. typedef struct _KPERFORMANCE_REGISTERS {
  1443. ULONGLONG Perfr0;
  1444. ULONGLONG Perfr1;
  1445. ULONGLONG Perfr2;
  1446. ULONGLONG Perfr3;
  1447. ULONGLONG Perfr4;
  1448. ULONGLONG Perfr5;
  1449. ULONGLONG Perfr6;
  1450. ULONGLONG Perfr7;
  1451. } KPERFORMANCE_REGISTERS, *PKPERFORMANCE_REGISTERS;
  1452. //
  1453. // Thread State save area. Currently, beginning of Kernel Stack
  1454. //
  1455. // This structure defines the area for:
  1456. //
  1457. // higher fp register save/restore
  1458. // user debug register save/restore.
  1459. //
  1460. // The order of these area is significant.
  1461. //
  1462. typedef struct _KTHREAD_STATE_SAVEAREA {
  1463. KAPPLICATION_REGISTERS AppRegisters;
  1464. KPERFORMANCE_REGISTERS PerfRegisters;
  1465. KHIGHER_FP_VOLATILE HigherFPVolatile;
  1466. KDEBUG_REGISTERS DebugRegisters;
  1467. } KTHREAD_STATE_SAVEAREA, *PKTHREAD_STATE_SAVEAREA;
  1468. #define KTHREAD_STATE_SAVEAREA_LENGTH ((sizeof(KTHREAD_STATE_SAVEAREA) + 15) & ~((ULONG_PTR)15))
  1469. #define GET_HIGH_FLOATING_POINT_REGISTER_SAVEAREA(StackBase) \
  1470. (PKHIGHER_FP_VOLATILE) &(((PKTHREAD_STATE_SAVEAREA)(((ULONG_PTR)StackBase - sizeof(KTHREAD_STATE_SAVEAREA)) & ~((ULONG_PTR)15)))->HigherFPVolatile)
  1471. #define GET_DEBUG_REGISTER_SAVEAREA() \
  1472. (PKDEBUG_REGISTERS) &(((PKTHREAD_STATE_SAVEAREA)(((ULONG_PTR)KeGetCurrentThread()->StackBase - sizeof(KTHREAD_STATE_SAVEAREA)) & ~((ULONG_PTR)15)))->DebugRegisters)
  1473. #define GET_APPLICATION_REGISTER_SAVEAREA(StackBase) \
  1474. (PKAPPLICATION_REGISTERS) &(((PKTHREAD_STATE_SAVEAREA)(((ULONG_PTR)StackBase - sizeof(KTHREAD_STATE_SAVEAREA)) & ~((ULONG_PTR)15)))->AppRegisters)
  1475. //
  1476. // Exception frame
  1477. //
  1478. // This frame is established when handling an exception. It provides a place
  1479. // to save all preserved registers. The volatile registers will already
  1480. // have been saved in a trap frame. Also used as part of switch frame built
  1481. // at thread switch.
  1482. //
  1483. // The frame is 16-byte aligned to maintain 16-byte alignment for the stack,
  1484. //
  1485. typedef struct _KEXCEPTION_FRAME {
  1486. // Preserved application registers
  1487. ULONGLONG ApEC; // epilogue count
  1488. ULONGLONG ApLC; // loop count
  1489. ULONGLONG IntNats; // Nats for S0-S3; i.e. ar.UNAT after spill
  1490. // Preserved (saved) interger registers, s0-s3
  1491. ULONGLONG IntS0;
  1492. ULONGLONG IntS1;
  1493. ULONGLONG IntS2;
  1494. ULONGLONG IntS3;
  1495. // Preserved (saved) branch registers, bs0-bs4
  1496. ULONGLONG BrS0;
  1497. ULONGLONG BrS1;
  1498. ULONGLONG BrS2;
  1499. ULONGLONG BrS3;
  1500. ULONGLONG BrS4;
  1501. // Preserved (saved) floating point registers, f2 - f5, f16 - f31
  1502. FLOAT128 FltS0;
  1503. FLOAT128 FltS1;
  1504. FLOAT128 FltS2;
  1505. FLOAT128 FltS3;
  1506. FLOAT128 FltS4;
  1507. FLOAT128 FltS5;
  1508. FLOAT128 FltS6;
  1509. FLOAT128 FltS7;
  1510. FLOAT128 FltS8;
  1511. FLOAT128 FltS9;
  1512. FLOAT128 FltS10;
  1513. FLOAT128 FltS11;
  1514. FLOAT128 FltS12;
  1515. FLOAT128 FltS13;
  1516. FLOAT128 FltS14;
  1517. FLOAT128 FltS15;
  1518. FLOAT128 FltS16;
  1519. FLOAT128 FltS17;
  1520. FLOAT128 FltS18;
  1521. FLOAT128 FltS19;
  1522. } KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
  1523. //
  1524. // Switch frame
  1525. //
  1526. // This frame is established when doing a thread switch in SwapContext. It
  1527. // provides a place to save the preserved kernel state at the point of the
  1528. // switch registers.
  1529. // The volatile registers are scratch across the call to SwapContext.
  1530. //
  1531. // The frame is 16-byte aligned to maintain 16-byte alignment for the stack,
  1532. //
  1533. typedef struct _KSWITCH_FRAME {
  1534. ULONGLONG SwitchPredicates; // Predicates for Switch
  1535. ULONGLONG SwitchRp; // return pointer for Switch
  1536. ULONGLONG SwitchPFS; // PFS for Switch
  1537. ULONGLONG SwitchFPSR; // ProcessorFP status at thread switch
  1538. ULONGLONG SwitchBsp;
  1539. ULONGLONG SwitchRnat;
  1540. // ULONGLONG Pad;
  1541. KEXCEPTION_FRAME SwitchExceptionFrame;
  1542. } KSWITCH_FRAME, *PKSWITCH_FRAME;
  1543. // Trap frame
  1544. // This frame is established when handling a trap. It provides a place to
  1545. // save all volatile registers. The nonvolatile registers are saved in an
  1546. // exception frame or through the normal C calling conventions for saved
  1547. // registers. Its size must be a multiple of 16 bytes.
  1548. //
  1549. // N.B - the 16-byte alignment is required to maintain the stack alignment.
  1550. //
  1551. #define KTRAP_FRAME_ARGUMENTS (8 * 8) // up to 8 in-memory syscall args
  1552. typedef struct _KTRAP_FRAME {
  1553. //
  1554. // Reserved for additional memory arguments and stack scratch area
  1555. // The size of Reserved[] must be a multiple of 16 bytes.
  1556. //
  1557. ULONGLONG Reserved[(KTRAP_FRAME_ARGUMENTS+16)/8];
  1558. // Temporary (volatile) FP registers - f6-f15 (don't use f32+ in kernel)
  1559. FLOAT128 FltT0;
  1560. FLOAT128 FltT1;
  1561. FLOAT128 FltT2;
  1562. FLOAT128 FltT3;
  1563. FLOAT128 FltT4;
  1564. FLOAT128 FltT5;
  1565. FLOAT128 FltT6;
  1566. FLOAT128 FltT7;
  1567. FLOAT128 FltT8;
  1568. FLOAT128 FltT9;
  1569. // Temporary (volatile) interger registers
  1570. ULONGLONG IntGp; // global pointer (r1)
  1571. ULONGLONG IntT0;
  1572. ULONGLONG IntT1;
  1573. // The following 4 registers fill in space of preserved (S0-S3) to align Nats
  1574. ULONGLONG ApUNAT; // ar.UNAT on kernel entry
  1575. ULONGLONG ApCCV; // ar.CCV
  1576. ULONGLONG ApDCR; // DCR register on kernel entry
  1577. ULONGLONG Preds; // Predicates
  1578. ULONGLONG IntV0; // return value (r8)
  1579. ULONGLONG IntT2;
  1580. ULONGLONG IntT3;
  1581. ULONGLONG IntT4;
  1582. ULONGLONG IntSp; // stack pointer (r12)
  1583. ULONGLONG IntTeb; // teb (r13)
  1584. ULONGLONG IntT5;
  1585. ULONGLONG IntT6;
  1586. ULONGLONG IntT7;
  1587. ULONGLONG IntT8;
  1588. ULONGLONG IntT9;
  1589. ULONGLONG IntT10;
  1590. ULONGLONG IntT11;
  1591. ULONGLONG IntT12;
  1592. ULONGLONG IntT13;
  1593. ULONGLONG IntT14;
  1594. ULONGLONG IntT15;
  1595. ULONGLONG IntT16;
  1596. ULONGLONG IntT17;
  1597. ULONGLONG IntT18;
  1598. ULONGLONG IntT19;
  1599. ULONGLONG IntT20;
  1600. ULONGLONG IntT21;
  1601. ULONGLONG IntT22;
  1602. ULONGLONG IntNats; // Temporary (volatile) registers' Nats directly from ar.UNAT at point of spill
  1603. ULONGLONG BrRp; // Return pointer on kernel entry
  1604. ULONGLONG BrT0; // Temporary (volatile) branch registers (b6-b7)
  1605. ULONGLONG BrT1;
  1606. // Register stack info
  1607. ULONGLONG RsRSC; // RSC on kernel entry
  1608. ULONGLONG RsBSP; // BSP on kernel entry
  1609. ULONGLONG RsBSPSTORE; // User BSP Store at point of switch to kernel backing store
  1610. ULONGLONG RsRNAT; // old RNAT at point of switch to kernel backing store
  1611. ULONGLONG RsPFS; // PFS on kernel entry
  1612. // Trap Status Information
  1613. ULONGLONG StIPSR; // Interruption Processor Status Register
  1614. ULONGLONG StIIP; // Interruption IP
  1615. ULONGLONG StIFS; // Interruption Function State
  1616. ULONGLONG StFPSR; // FP status
  1617. ULONGLONG StISR; // Interruption Status Register
  1618. ULONGLONG StIFA; // Interruption Data Address
  1619. ULONGLONG StIIPA; // Last executed bundle address
  1620. ULONGLONG StIIM; // Interruption Immediate
  1621. ULONGLONG StIHA; // Interruption Hash Address
  1622. ULONG OldIrql; // Previous Irql.
  1623. ULONG PreviousMode; // Previous Mode.
  1624. ULONGLONG TrapFrame;// Previous Trap Frame
  1625. //
  1626. // Exception record
  1627. //
  1628. UCHAR ExceptionRecord[(sizeof(EXCEPTION_RECORD) + 15) & (~15)];
  1629. // End of frame marker (for debugging)
  1630. ULONGLONG Handler; // Handler for this trap
  1631. ULONGLONG EOFMarker;
  1632. } KTRAP_FRAME, *PKTRAP_FRAME;
  1633. #define KTRAP_FRAME_LENGTH ((sizeof(KTRAP_FRAME) + 15) & (~15))
  1634. #define KTRAP_FRAME_ALIGN (16)
  1635. #define KTRAP_FRAME_ROUND (KTRAP_FRAME_ALIGN - 1)
  1636. #define KTRAP_FRAME_EOF 0xe0f0e0f0e0f0e000i64
  1637. //
  1638. // Use the lowest 4 bits of EOFMarker field to encode the trap frame type
  1639. //
  1640. #define SYSCALL_FRAME 0
  1641. #define INTERRUPT_FRAME 1
  1642. #define EXCEPTION_FRAME 2
  1643. #define CONTEXT_FRAME 10
  1644. #define TRAP_FRAME_TYPE(tf) (tf->EOFMarker & 0xf)
  1645. //
  1646. // Define the kernel mode and user mode callback frame structures.
  1647. //
  1648. //
  1649. // The frame saved by KiCallUserMode is defined here to allow
  1650. // the kernel debugger to trace the entire kernel stack
  1651. // when usermode callouts are pending.
  1652. //
  1653. // N.B. The size of the following structure must be a multiple of 16 bytes
  1654. // and it must be 16-byte aligned.
  1655. //
  1656. typedef struct _KCALLOUT_FRAME {
  1657. ULONGLONG BrRp;
  1658. ULONGLONG RsPFS;
  1659. ULONGLONG Preds;
  1660. ULONGLONG ApUNAT;
  1661. ULONGLONG ApLC;
  1662. ULONGLONG RsRNAT;
  1663. ULONGLONG IntNats;
  1664. ULONGLONG IntS0;
  1665. ULONGLONG IntS1;
  1666. ULONGLONG IntS2;
  1667. ULONGLONG IntS3;
  1668. ULONGLONG BrS0;
  1669. ULONGLONG BrS1;
  1670. ULONGLONG BrS2;
  1671. ULONGLONG BrS3;
  1672. ULONGLONG BrS4;
  1673. FLOAT128 FltS0; // 16-byte aligned boundary
  1674. FLOAT128 FltS1;
  1675. FLOAT128 FltS2;
  1676. FLOAT128 FltS3;
  1677. FLOAT128 FltS4;
  1678. FLOAT128 FltS5;
  1679. FLOAT128 FltS6;
  1680. FLOAT128 FltS7;
  1681. FLOAT128 FltS8;
  1682. FLOAT128 FltS9;
  1683. FLOAT128 FltS10;
  1684. FLOAT128 FltS11;
  1685. FLOAT128 FltS12;
  1686. FLOAT128 FltS13;
  1687. FLOAT128 FltS14;
  1688. FLOAT128 FltS15;
  1689. FLOAT128 FltS16;
  1690. FLOAT128 FltS17;
  1691. FLOAT128 FltS18;
  1692. FLOAT128 FltS19;
  1693. ULONGLONG A0; // saved argument registers a0-a2
  1694. ULONGLONG A1;
  1695. ULONGLONG CbStk; // saved callback stack address
  1696. ULONGLONG InStack; // saved initial stack address
  1697. ULONGLONG CbBStore; // saved callback stack address
  1698. ULONGLONG InBStore; // saved initial stack address
  1699. ULONGLONG TrFrame; // saved callback trap frame address
  1700. ULONGLONG TrStIIP; // saved continuation address
  1701. } KCALLOUT_FRAME, *PKCALLOUT_FRAME;
  1702. typedef struct _UCALLOUT_FRAME {
  1703. PVOID Buffer;
  1704. ULONG Length;
  1705. ULONG ApiNumber;
  1706. ULONGLONG IntSp;
  1707. ULONGLONG RsPFS;
  1708. ULONGLONG BrRp;
  1709. ULONGLONG Pad;
  1710. } UCALLOUT_FRAME, *PUCALLOUT_FRAME;
  1711. // end_nthal
  1712. // begin_ntddk begin_wdm begin_ntosp
  1713. //
  1714. // Non-volatile floating point state
  1715. //
  1716. typedef struct _KFLOATING_SAVE {
  1717. ULONG Reserved;
  1718. } KFLOATING_SAVE, *PKFLOATING_SAVE;
  1719. // end_ntddk end_wdm end_ntosp
  1720. #define STATUS_IA64_INVALID_STACK STATUS_BAD_STACK
  1721. //
  1722. // iA32 control bits definition
  1723. //
  1724. //
  1725. // Define constants to access the bits in CR0.
  1726. //
  1727. #define CR0_PG 0x80000000 // paging
  1728. #define CR0_ET 0x00000010 // extension type (80387)
  1729. #define CR0_TS 0x00000008 // task switched
  1730. #define CR0_EM 0x00000004 // emulate math coprocessor
  1731. #define CR0_MP 0x00000002 // math present
  1732. #define CR0_PE 0x00000001 // protection enable
  1733. //
  1734. // More CR0 bits; these only apply to the 80486.
  1735. //
  1736. #define CR0_CD 0x40000000 // cache disable
  1737. #define CR0_NW 0x20000000 // not write-through
  1738. #define CR0_AM 0x00040000 // alignment mask
  1739. #define CR0_WP 0x00010000 // write protect
  1740. #define CR0_NE 0x00000020 // numeric error
  1741. //
  1742. // Define constants to access CFLG bits
  1743. //
  1744. #define CFLG_IO 0x00000040 // IO bit map checking on
  1745. #define CFLG_IF 0x00000080 // EFLAG.if to control external interrupt
  1746. #define CFLG_II 0x00000100 // enable EFLAG.if interception
  1747. //
  1748. // CR4 bits; These only apply to Pentium
  1749. //
  1750. #define CR4_VME 0x00000001 // V86 mode extensions
  1751. #define CR4_PVI 0x00000002 // Protected mode virtual interrupts
  1752. #define CR4_TSD 0x00000004 // Time stamp disable
  1753. #define CR4_DE 0x00000008 // Debugging Extensions
  1754. #define CR4_PSE 0x00000010 // Page size extensions
  1755. #define CR4_PAE 0x00000020 // Physical address extensions
  1756. #define CR4_MCE 0x00000040 // Machine check enable
  1757. #define CR4_PGE 0x00000080 // Page global enable
  1758. #define CR4_FXSR 0x00000200 // FXSR used by OS
  1759. #define CR4_XMMEXCPT 0x00000400 // XMMI used by OS
  1760. //
  1761. // Define constants to access ThNpxState
  1762. //
  1763. #define NPX_STATE_NOT_LOADED (CR0_TS | CR0_MP)
  1764. #define NPX_STATE_LOADED 0
  1765. //
  1766. // begin_nthal
  1767. //
  1768. // Machine type definitions
  1769. //
  1770. #define MACHINE_TYPE_ISA 0
  1771. #define MACHINE_TYPE_EISA 1
  1772. #define MACHINE_TYPE_MCA 2
  1773. //
  1774. // PAL Interface
  1775. //
  1776. // iA-64 defined PAL function IDs in decimal format as in the PAL spec
  1777. // All PAL calls done through HAL. HAL may block some calls
  1778. //
  1779. #define PAL_CACHE_FLUSH 1I64
  1780. #define PAL_CACHE_INFO 2I64
  1781. #define PAL_CACHE_INIT 3I64
  1782. #define PAL_CACHE_SUMMARY 4I64
  1783. #define PAL_PTCE_INFO 6I64
  1784. #define PAL_MEM_ATTRIB 5I64
  1785. #define PAL_VM_INFO 7I64
  1786. #define PAL_VM_SUMMARY 8I64
  1787. #define PAL_BUS_GET_FEATURES 9I64
  1788. #define PAL_BUS_SET_FEATURES 10I64
  1789. #define PAL_DEBUG_INFO 11I64
  1790. #define PAL_FIXED_ADDR 12I64
  1791. #define PAL_FREQ_BASE 13I64
  1792. #define PAL_FREQ_RATIOS 14I64
  1793. #define PAL_PERF_MON_INFO 15I64
  1794. #define PAL_PLATFORM_ADDR 16I64
  1795. #define PAL_PROC_GET_FEATURES 17I64
  1796. #define PAL_PROC_SET_FEATURES 18I64
  1797. #define PAL_RSE_INFO 19I64
  1798. #define PAL_VERSION 20I64
  1799. #define PAL_MC_CLEAR_LOG 21I64
  1800. #define PAL_MC_DRAIN 22I64
  1801. #define PAL_MC_EXPECTED 23I64
  1802. #define PAL_MC_DYNAMIC_STATE 24I64
  1803. #define PAL_MC_ERROR_INFO 25I64
  1804. #define PAL_MC_RESUME 26I64
  1805. #define PAL_MC_REGISTER_MEM 27I64
  1806. #define PAL_HALT 28I64
  1807. #define PAL_HALT_LIGHT 29I64
  1808. #define PAL_COPY_INFO 30I64
  1809. #define PAL_CACHE_LINE_INIT 31I64
  1810. #define PAL_PMI_ENTRYPOINT 32I64
  1811. #define PAL_ENTER_IA_32_ENV 33I64
  1812. #define PAL_VM_PAGE_SIZE 34I64
  1813. #define PAL_MEM_FOR_TEST 37I64
  1814. #define PAL_CACHE_PROT_INFO 38I64
  1815. #define PAL_REGISTER_INFO 39I64
  1816. #define PAL_SHUTDOWN 44I64
  1817. #define PAL_PREFETCH_VISIBILITY 41I64
  1818. #define PAL_COPY_PAL 256I64
  1819. #define PAL_HALT_INFO 257I64
  1820. #define PAL_TEST_PROC 258I64
  1821. #define PAL_CACHE_READ 259I64
  1822. #define PAL_CACHE_WRITE 260I64
  1823. #define PAL_VM_TR_READ 261I64
  1824. //
  1825. // iA-64 defined PAL return values
  1826. //
  1827. #define PAL_STATUS_INVALID_CACHELINE 1I64
  1828. #define PAL_STATUS_SUPPORT_NOT_NEEDED 1I64
  1829. #define PAL_STATUS_SUCCESS 0
  1830. #define PAL_STATUS_NOT_IMPLEMENTED -1I64
  1831. #define PAL_STATUS_INVALID_ARGUMENT -2I64
  1832. #define PAL_STATUS_ERROR -3I64
  1833. #define PAL_STATUS_UNABLE_TO_INIT_CACHE_LEVEL_AND_TYPE -4I64
  1834. #define PAL_STATUS_NOT_FOUND_IN_CACHE -5I64
  1835. #define PAL_STATUS_NO_ERROR_INFO_AVAILABLE -6I64
  1836. // end_nthal
  1837. //
  1838. // Define constants used in selector tests.
  1839. //
  1840. // RPL_MASK is the real value for extracting RPL values. IT IS THE WRONG
  1841. // CONSTANT TO USE FOR MODE TESTING.
  1842. //
  1843. // MODE_MASK is the value for deciding the current mode.
  1844. // WARNING: MODE_MASK assumes that all code runs at either ring-0
  1845. // or ring-3. Ring-1 or Ring-2 support will require changing
  1846. // this value and all of the code that refers to it.
  1847. #define MODE_MASK 1
  1848. #define RPL_MASK 3
  1849. //
  1850. // SetProcessInformation Structure for ProcessSetIoHandlers info class
  1851. //
  1852. typedef struct _PROCESS_IO_PORT_HANDLER_INFORMATION {
  1853. BOOLEAN Install; // true if handlers to be installed
  1854. ULONG NumEntries;
  1855. ULONG Context;
  1856. PEMULATOR_ACCESS_ENTRY EmulatorAccessEntries;
  1857. } PROCESS_IO_PORT_HANDLER_INFORMATION, *PPROCESS_IO_PORT_HANDLER_INFORMATION;
  1858. //
  1859. // Definitions that used by CSD and SSD
  1860. //
  1861. #define USER_CODE_DESCRIPTOR 0xCFBFFFFF00000000i64
  1862. #define USER_DATA_DESCRIPTOR 0xCF3FFFFF00000000i64
  1863. //
  1864. // Used for cleaning up ia32 contexts
  1865. // This is taken from i386.h
  1866. //
  1867. #define EFLAGS_DF_MASK 0x00000400L
  1868. #define EFLAGS_INTERRUPT_MASK 0x00000200L
  1869. #define EFLAGS_V86_MASK 0x00020000L
  1870. #define EFLAGS_ALIGN_CHECK 0x00040000L
  1871. #define EFLAGS_IOPL_MASK 0x00003000L
  1872. #define EFLAGS_VIF 0x00080000L
  1873. #define EFLAGS_VIP 0x00100000L
  1874. #define EFLAGS_USER_SANITIZE 0x003e0dd7L
  1875. // begin_windbgkd begin_nthal
  1876. #ifdef _IA64_
  1877. //
  1878. // Stack Registers for IA64
  1879. //
  1880. typedef struct _STACK_REGISTERS {
  1881. ULONGLONG IntR32;
  1882. ULONGLONG IntR33;
  1883. ULONGLONG IntR34;
  1884. ULONGLONG IntR35;
  1885. ULONGLONG IntR36;
  1886. ULONGLONG IntR37;
  1887. ULONGLONG IntR38;
  1888. ULONGLONG IntR39;
  1889. ULONGLONG IntR40;
  1890. ULONGLONG IntR41;
  1891. ULONGLONG IntR42;
  1892. ULONGLONG IntR43;
  1893. ULONGLONG IntR44;
  1894. ULONGLONG IntR45;
  1895. ULONGLONG IntR46;
  1896. ULONGLONG IntR47;
  1897. ULONGLONG IntR48;
  1898. ULONGLONG IntR49;
  1899. ULONGLONG IntR50;
  1900. ULONGLONG IntR51;
  1901. ULONGLONG IntR52;
  1902. ULONGLONG IntR53;
  1903. ULONGLONG IntR54;
  1904. ULONGLONG IntR55;
  1905. ULONGLONG IntR56;
  1906. ULONGLONG IntR57;
  1907. ULONGLONG IntR58;
  1908. ULONGLONG IntR59;
  1909. ULONGLONG IntR60;
  1910. ULONGLONG IntR61;
  1911. ULONGLONG IntR62;
  1912. ULONGLONG IntR63;
  1913. ULONGLONG IntR64;
  1914. ULONGLONG IntR65;
  1915. ULONGLONG IntR66;
  1916. ULONGLONG IntR67;
  1917. ULONGLONG IntR68;
  1918. ULONGLONG IntR69;
  1919. ULONGLONG IntR70;
  1920. ULONGLONG IntR71;
  1921. ULONGLONG IntR72;
  1922. ULONGLONG IntR73;
  1923. ULONGLONG IntR74;
  1924. ULONGLONG IntR75;
  1925. ULONGLONG IntR76;
  1926. ULONGLONG IntR77;
  1927. ULONGLONG IntR78;
  1928. ULONGLONG IntR79;
  1929. ULONGLONG IntR80;
  1930. ULONGLONG IntR81;
  1931. ULONGLONG IntR82;
  1932. ULONGLONG IntR83;
  1933. ULONGLONG IntR84;
  1934. ULONGLONG IntR85;
  1935. ULONGLONG IntR86;
  1936. ULONGLONG IntR87;
  1937. ULONGLONG IntR88;
  1938. ULONGLONG IntR89;
  1939. ULONGLONG IntR90;
  1940. ULONGLONG IntR91;
  1941. ULONGLONG IntR92;
  1942. ULONGLONG IntR93;
  1943. ULONGLONG IntR94;
  1944. ULONGLONG IntR95;
  1945. ULONGLONG IntR96;
  1946. ULONGLONG IntR97;
  1947. ULONGLONG IntR98;
  1948. ULONGLONG IntR99;
  1949. ULONGLONG IntR100;
  1950. ULONGLONG IntR101;
  1951. ULONGLONG IntR102;
  1952. ULONGLONG IntR103;
  1953. ULONGLONG IntR104;
  1954. ULONGLONG IntR105;
  1955. ULONGLONG IntR106;
  1956. ULONGLONG IntR107;
  1957. ULONGLONG IntR108;
  1958. ULONGLONG IntR109;
  1959. ULONGLONG IntR110;
  1960. ULONGLONG IntR111;
  1961. ULONGLONG IntR112;
  1962. ULONGLONG IntR113;
  1963. ULONGLONG IntR114;
  1964. ULONGLONG IntR115;
  1965. ULONGLONG IntR116;
  1966. ULONGLONG IntR117;
  1967. ULONGLONG IntR118;
  1968. ULONGLONG IntR119;
  1969. ULONGLONG IntR120;
  1970. ULONGLONG IntR121;
  1971. ULONGLONG IntR122;
  1972. ULONGLONG IntR123;
  1973. ULONGLONG IntR124;
  1974. ULONGLONG IntR125;
  1975. ULONGLONG IntR126;
  1976. ULONGLONG IntR127;
  1977. // Nat bits for stack registers
  1978. ULONGLONG IntNats2; // r32-r95 in bit positions 1 to 63
  1979. ULONGLONG IntNats3; // r96-r127 in bit position 1 to 31
  1980. } STACK_REGISTERS, *PSTACK_REGISTERS;
  1981. //
  1982. // Special Registers for IA64
  1983. //
  1984. typedef struct _KSPECIAL_REGISTERS {
  1985. // Kernel debug breakpoint registers
  1986. ULONGLONG KernelDbI0; // Instruction debug registers
  1987. ULONGLONG KernelDbI1;
  1988. ULONGLONG KernelDbI2;
  1989. ULONGLONG KernelDbI3;
  1990. ULONGLONG KernelDbI4;
  1991. ULONGLONG KernelDbI5;
  1992. ULONGLONG KernelDbI6;
  1993. ULONGLONG KernelDbI7;
  1994. ULONGLONG KernelDbD0; // Data debug registers
  1995. ULONGLONG KernelDbD1;
  1996. ULONGLONG KernelDbD2;
  1997. ULONGLONG KernelDbD3;
  1998. ULONGLONG KernelDbD4;
  1999. ULONGLONG KernelDbD5;
  2000. ULONGLONG KernelDbD6;
  2001. ULONGLONG KernelDbD7;
  2002. // Kernel performance monitor registers
  2003. ULONGLONG KernelPfC0; // Performance configuration registers
  2004. ULONGLONG KernelPfC1;
  2005. ULONGLONG KernelPfC2;
  2006. ULONGLONG KernelPfC3;
  2007. ULONGLONG KernelPfC4;
  2008. ULONGLONG KernelPfC5;
  2009. ULONGLONG KernelPfC6;
  2010. ULONGLONG KernelPfC7;
  2011. ULONGLONG KernelPfD0; // Performance data registers
  2012. ULONGLONG KernelPfD1;
  2013. ULONGLONG KernelPfD2;
  2014. ULONGLONG KernelPfD3;
  2015. ULONGLONG KernelPfD4;
  2016. ULONGLONG KernelPfD5;
  2017. ULONGLONG KernelPfD6;
  2018. ULONGLONG KernelPfD7;
  2019. // kernel bank shadow (hidden) registers
  2020. ULONGLONG IntH16;
  2021. ULONGLONG IntH17;
  2022. ULONGLONG IntH18;
  2023. ULONGLONG IntH19;
  2024. ULONGLONG IntH20;
  2025. ULONGLONG IntH21;
  2026. ULONGLONG IntH22;
  2027. ULONGLONG IntH23;
  2028. ULONGLONG IntH24;
  2029. ULONGLONG IntH25;
  2030. ULONGLONG IntH26;
  2031. ULONGLONG IntH27;
  2032. ULONGLONG IntH28;
  2033. ULONGLONG IntH29;
  2034. ULONGLONG IntH30;
  2035. ULONGLONG IntH31;
  2036. // Application Registers
  2037. // - CPUID Registers - AR
  2038. ULONGLONG ApCPUID0; // Cpuid Register 0
  2039. ULONGLONG ApCPUID1; // Cpuid Register 1
  2040. ULONGLONG ApCPUID2; // Cpuid Register 2
  2041. ULONGLONG ApCPUID3; // Cpuid Register 3
  2042. ULONGLONG ApCPUID4; // Cpuid Register 4
  2043. ULONGLONG ApCPUID5; // Cpuid Register 5
  2044. ULONGLONG ApCPUID6; // Cpuid Register 6
  2045. ULONGLONG ApCPUID7; // Cpuid Register 7
  2046. // - Kernel Registers - AR
  2047. ULONGLONG ApKR0; // Kernel Register 0 (User RO)
  2048. ULONGLONG ApKR1; // Kernel Register 1 (User RO)
  2049. ULONGLONG ApKR2; // Kernel Register 2 (User RO)
  2050. ULONGLONG ApKR3; // Kernel Register 3 (User RO)
  2051. ULONGLONG ApKR4; // Kernel Register 4
  2052. ULONGLONG ApKR5; // Kernel Register 5
  2053. ULONGLONG ApKR6; // Kernel Register 6
  2054. ULONGLONG ApKR7; // Kernel Register 7
  2055. ULONGLONG ApITC; // Interval Timer Counter
  2056. // Global control registers
  2057. ULONGLONG ApITM; // Interval Timer Match register
  2058. ULONGLONG ApIVA; // Interrupt Vector Address
  2059. ULONGLONG ApPTA; // Page Table Address
  2060. ULONGLONG ApGPTA; // ia32 Page Table Address
  2061. ULONGLONG StISR; // Interrupt status
  2062. ULONGLONG StIFA; // Interruption Faulting Address
  2063. ULONGLONG StITIR; // Interruption TLB Insertion Register
  2064. ULONGLONG StIIPA; // Interruption Instruction Previous Address (RO)
  2065. ULONGLONG StIIM; // Interruption Immediate register (RO)
  2066. ULONGLONG StIHA; // Interruption Hash Address (RO)
  2067. // - External Interrupt control registers (SAPIC)
  2068. ULONGLONG SaLID; // Local SAPIC ID
  2069. ULONGLONG SaIVR; // Interrupt Vector Register (RO)
  2070. ULONGLONG SaTPR; // Task Priority Register
  2071. ULONGLONG SaEOI; // End Of Interrupt
  2072. ULONGLONG SaIRR0; // Interrupt Request Register 0 (RO)
  2073. ULONGLONG SaIRR1; // Interrupt Request Register 1 (RO)
  2074. ULONGLONG SaIRR2; // Interrupt Request Register 2 (RO)
  2075. ULONGLONG SaIRR3; // Interrupt Request Register 3 (RO)
  2076. ULONGLONG SaITV; // Interrupt Timer Vector
  2077. ULONGLONG SaPMV; // Performance Monitor Vector
  2078. ULONGLONG SaCMCV; // Corrected Machine Check Vector
  2079. ULONGLONG SaLRR0; // Local Interrupt Redirection Vector 0
  2080. ULONGLONG SaLRR1; // Local Interrupt Redirection Vector 1
  2081. // System Registers
  2082. // - Region registers
  2083. ULONGLONG Rr0; // Region register 0
  2084. ULONGLONG Rr1; // Region register 1
  2085. ULONGLONG Rr2; // Region register 2
  2086. ULONGLONG Rr3; // Region register 3
  2087. ULONGLONG Rr4; // Region register 4
  2088. ULONGLONG Rr5; // Region register 5
  2089. ULONGLONG Rr6; // Region register 6
  2090. ULONGLONG Rr7; // Region register 7
  2091. // - Protection Key registers
  2092. ULONGLONG Pkr0; // Protection Key register 0
  2093. ULONGLONG Pkr1; // Protection Key register 1
  2094. ULONGLONG Pkr2; // Protection Key register 2
  2095. ULONGLONG Pkr3; // Protection Key register 3
  2096. ULONGLONG Pkr4; // Protection Key register 4
  2097. ULONGLONG Pkr5; // Protection Key register 5
  2098. ULONGLONG Pkr6; // Protection Key register 6
  2099. ULONGLONG Pkr7; // Protection Key register 7
  2100. ULONGLONG Pkr8; // Protection Key register 8
  2101. ULONGLONG Pkr9; // Protection Key register 9
  2102. ULONGLONG Pkr10; // Protection Key register 10
  2103. ULONGLONG Pkr11; // Protection Key register 11
  2104. ULONGLONG Pkr12; // Protection Key register 12
  2105. ULONGLONG Pkr13; // Protection Key register 13
  2106. ULONGLONG Pkr14; // Protection Key register 14
  2107. ULONGLONG Pkr15; // Protection Key register 15
  2108. // - Translation Lookaside buffers
  2109. ULONGLONG TrI0; // Instruction Translation Register 0
  2110. ULONGLONG TrI1; // Instruction Translation Register 1
  2111. ULONGLONG TrI2; // Instruction Translation Register 2
  2112. ULONGLONG TrI3; // Instruction Translation Register 3
  2113. ULONGLONG TrI4; // Instruction Translation Register 4
  2114. ULONGLONG TrI5; // Instruction Translation Register 5
  2115. ULONGLONG TrI6; // Instruction Translation Register 6
  2116. ULONGLONG TrI7; // Instruction Translation Register 7
  2117. ULONGLONG TrD0; // Data Translation Register 0
  2118. ULONGLONG TrD1; // Data Translation Register 1
  2119. ULONGLONG TrD2; // Data Translation Register 2
  2120. ULONGLONG TrD3; // Data Translation Register 3
  2121. ULONGLONG TrD4; // Data Translation Register 4
  2122. ULONGLONG TrD5; // Data Translation Register 5
  2123. ULONGLONG TrD6; // Data Translation Register 6
  2124. ULONGLONG TrD7; // Data Translation Register 7
  2125. // - Machine Specific Registers
  2126. ULONGLONG SrMSR0; // Machine Specific Register 0
  2127. ULONGLONG SrMSR1; // Machine Specific Register 1
  2128. ULONGLONG SrMSR2; // Machine Specific Register 2
  2129. ULONGLONG SrMSR3; // Machine Specific Register 3
  2130. ULONGLONG SrMSR4; // Machine Specific Register 4
  2131. ULONGLONG SrMSR5; // Machine Specific Register 5
  2132. ULONGLONG SrMSR6; // Machine Specific Register 6
  2133. ULONGLONG SrMSR7; // Machine Specific Register 7
  2134. } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
  2135. //
  2136. // Processor State structure.
  2137. //
  2138. typedef struct _KPROCESSOR_STATE {
  2139. struct _CONTEXT ContextFrame;
  2140. struct _KSPECIAL_REGISTERS SpecialRegisters;
  2141. } KPROCESSOR_STATE, *PKPROCESSOR_STATE;
  2142. #endif // _IA64_
  2143. // end_windbgkd end_nthal
  2144. // begin_nthal begin_ntddk begin_ntosp
  2145. //
  2146. // Processor Control Block (PRCB)
  2147. //
  2148. #define PRCB_MINOR_VERSION 1
  2149. #define PRCB_MAJOR_VERSION 1
  2150. #define PRCB_BUILD_DEBUG 0x0001
  2151. #define PRCB_BUILD_UNIPROCESSOR 0x0002
  2152. struct _RESTART_BLOCK;
  2153. typedef struct _KPRCB {
  2154. //
  2155. // Major and minor version numbers of the PCR.
  2156. //
  2157. USHORT MinorVersion;
  2158. USHORT MajorVersion;
  2159. //
  2160. // Start of the architecturally defined section of the PRCB. This section
  2161. // may be directly addressed by vendor/platform specific HAL code and will
  2162. // not change from version to version of NT.
  2163. //
  2164. //
  2165. struct _KTHREAD *CurrentThread;
  2166. struct _KTHREAD *RESTRICTED_POINTER NextThread;
  2167. struct _KTHREAD *IdleThread;
  2168. CCHAR Number;
  2169. CCHAR WakeIdle;
  2170. USHORT BuildType;
  2171. KAFFINITY SetMember;
  2172. struct _RESTART_BLOCK *RestartBlock;
  2173. ULONG_PTR PcrPage;
  2174. ULONG Spare0[4];
  2175. //
  2176. // Processor Idendification Registers.
  2177. //
  2178. ULONG ProcessorModel;
  2179. ULONG ProcessorRevision;
  2180. ULONG ProcessorFamily;
  2181. ULONG ProcessorArchRev;
  2182. ULONGLONG ProcessorSerialNumber;
  2183. ULONGLONG ProcessorFeatureBits;
  2184. UCHAR ProcessorVendorString[16];
  2185. //
  2186. // Space reserved for the system.
  2187. //
  2188. ULONGLONG SystemReserved[8];
  2189. //
  2190. // Space reserved for the HAL.
  2191. //
  2192. ULONGLONG HalReserved[16];
  2193. //
  2194. // End of the architecturally defined section of the PRCB.
  2195. // end_nthal end_ntddk end_ntosp
  2196. //
  2197. ULONG DpcTime;
  2198. ULONG InterruptTime;
  2199. ULONG KernelTime;
  2200. ULONG UserTime;
  2201. ULONG InterruptCount;
  2202. ULONG DispatchInterruptCount;
  2203. ULONG Spare1[5];
  2204. ULONG PageColor;
  2205. //
  2206. // MP information.
  2207. //
  2208. struct _KNODE * ParentNode; // Node this processor is a member of
  2209. PVOID Spare2;
  2210. PVOID Spare3;
  2211. volatile ULONG IpiFrozen;
  2212. struct _KPROCESSOR_STATE ProcessorState;
  2213. //
  2214. // Per-processor data for various hot code which resides in the
  2215. // kernel image. Each processor is given it's own copy of the data
  2216. // to lessen the cache impact of sharing the data between multiple
  2217. // processors.
  2218. //
  2219. //
  2220. // Spares (formerly fsrtl filelock free lists)
  2221. //
  2222. PVOID SpareHotData[2];
  2223. //
  2224. // Cache manager performance counters.
  2225. //
  2226. ULONG CcFastReadNoWait;
  2227. ULONG CcFastReadWait;
  2228. ULONG CcFastReadNotPossible;
  2229. ULONG CcCopyReadNoWait;
  2230. ULONG CcCopyReadWait;
  2231. ULONG CcCopyReadNoWaitMiss;
  2232. //
  2233. // Kernel performance counters.
  2234. //
  2235. ULONG KeAlignmentFixupCount;
  2236. ULONG KeContextSwitches;
  2237. ULONG KeDcacheFlushCount;
  2238. ULONG KeExceptionDispatchCount;
  2239. ULONG KeFirstLevelTbFills;
  2240. ULONG KeFloatingEmulationCount;
  2241. ULONG KeIcacheFlushCount;
  2242. ULONG KeSecondLevelTbFills;
  2243. ULONG KeSystemCalls;
  2244. //
  2245. // Reserved for future counters.
  2246. //
  2247. ULONG ReservedCounter[8];
  2248. //
  2249. // I/O IRP float.
  2250. //
  2251. LONG LookasideIrpFloat;
  2252. UCHAR MoreSpareHotData[52];
  2253. //
  2254. // Nonpaged per processor lookaside lists.
  2255. //
  2256. PP_LOOKASIDE_LIST PPLookasideList[16];
  2257. //
  2258. // Nonpaged per processor small pool lookaside lists.
  2259. //
  2260. PP_LOOKASIDE_LIST PPNPagedLookasideList[POOL_SMALL_LISTS];
  2261. //
  2262. // Paged per processor small pool lookaside lists.
  2263. //
  2264. PP_LOOKASIDE_LIST PPPagedLookasideList[POOL_SMALL_LISTS];
  2265. //
  2266. // Per processor lock queue entries.
  2267. //
  2268. KSPIN_LOCK_QUEUE LockQueue[16];
  2269. UCHAR ReservedPad[(3 * 8) - 4];
  2270. //
  2271. // MP interprocessor request packet barrier.
  2272. //
  2273. // N.B. This is carefully allocated in a different cache line from
  2274. // the request packet.
  2275. //
  2276. volatile ULONG PacketBarrier;
  2277. //
  2278. // MP interprocessor request packet and summary.
  2279. //
  2280. // N.B. This is carefully aligned to be on a cache line boundary.
  2281. //
  2282. volatile PVOID CurrentPacket[3];
  2283. volatile KAFFINITY TargetSet;
  2284. volatile PKIPI_WORKER WorkerRoutine;
  2285. // N.B. Place MHz here so we can keep alignment and size
  2286. // of this structure unchanged.
  2287. ULONG MHz;
  2288. ULONG CachePad0;
  2289. ULONGLONG CachePad1[10];
  2290. //
  2291. // N.B. These two longwords must be on a quadword boundary and adjacent.
  2292. //
  2293. volatile ULONG RequestSummary;
  2294. volatile struct _KPRCB *SignalDone;
  2295. //
  2296. // Spare counters.
  2297. //
  2298. ULONGLONG Spare4[14];
  2299. //
  2300. // DPC interrupt requested.
  2301. //
  2302. ULONG DpcInterruptRequested;
  2303. ULONGLONG Spare5[15];
  2304. ULONG MaximumDpcQueueDepth;
  2305. ULONG MinimumDpcRate;
  2306. ULONG AdjustDpcThreshold;
  2307. ULONG DpcRequestRate;
  2308. LARGE_INTEGER StartCount;
  2309. //
  2310. // DPC list head, spinlock, and count.
  2311. //
  2312. LIST_ENTRY DpcListHead;
  2313. KSPIN_LOCK DpcLock;
  2314. ULONG DpcCount;
  2315. ULONG DpcLastCount;
  2316. ULONG QuantumEnd;
  2317. ULONG DpcRoutineActive;
  2318. ULONG DpcQueueDepth;
  2319. //
  2320. // Debug & Processor Information
  2321. //
  2322. BOOLEAN SkipTick;
  2323. UCHAR Spare6;
  2324. //
  2325. // Processor ID from HAL (ACPI ID/EID).
  2326. //
  2327. USHORT ProcessorId;
  2328. //
  2329. // Address of MP interprocessor operation counters.
  2330. //
  2331. PKIPI_COUNTS IpiCounts;
  2332. //
  2333. // Processors power state
  2334. //
  2335. PROCESSOR_POWER_STATE PowerState;
  2336. // begin_nthal begin_ntddk begin_ntosp
  2337. } KPRCB, *PKPRCB, *RESTRICTED_POINTER PRKPRCB;
  2338. // begin_ntndis
  2339. //
  2340. // OS_MCA, OS_INIT HandOff State definitions
  2341. //
  2342. // Note: The following definitions *must* match the definiions of the
  2343. // corresponding SAL Revision Hand-Off structures.
  2344. //
  2345. typedef struct _SAL_HANDOFF_STATE {
  2346. ULONGLONG PalProcEntryPoint;
  2347. ULONGLONG SalProcEntryPoint;
  2348. ULONGLONG SalGlobalPointer;
  2349. LONGLONG RendezVousResult;
  2350. ULONGLONG SalReturnAddress;
  2351. ULONGLONG MinStateSavePtr;
  2352. } SAL_HANDOFF_STATE, *PSAL_HANDOFF_STATE;
  2353. typedef struct _OS_HANDOFF_STATE {
  2354. ULONGLONG Result;
  2355. ULONGLONG SalGlobalPointer;
  2356. ULONGLONG MinStateSavePtr;
  2357. ULONGLONG SalReturnAddress;
  2358. ULONGLONG NewContextFlag;
  2359. } OS_HANDOFF_STATE, *POS_HANDOFF_STATE;
  2360. //
  2361. // per processor OS_MCA and OS_INIT resource structure
  2362. //
  2363. #define SER_EVENT_STACK_FRAME_ENTRIES 8
  2364. typedef struct _SAL_EVENT_RESOURCES {
  2365. SAL_HANDOFF_STATE SalToOsHandOff;
  2366. OS_HANDOFF_STATE OsToSalHandOff;
  2367. PVOID StateDump;
  2368. ULONGLONG StateDumpPhysical;
  2369. PVOID BackStore;
  2370. ULONGLONG BackStoreLimit;
  2371. PVOID Stack;
  2372. ULONGLONG StackLimit;
  2373. PULONGLONG PTOM;
  2374. ULONGLONG StackFrame[SER_EVENT_STACK_FRAME_ENTRIES];
  2375. PVOID EventPool;
  2376. ULONG EventPoolSize;
  2377. } SAL_EVENT_RESOURCES, *PSAL_EVENT_RESOURCES;
  2378. //
  2379. // PAL Mini-save area, used by MCA and INIT
  2380. //
  2381. typedef struct _PAL_MINI_SAVE_AREA {
  2382. ULONGLONG IntNats; // Nat bits for r1-r31
  2383. // r1-r31 in bits 1 thru 31.
  2384. ULONGLONG IntGp; // r1, volatile
  2385. ULONGLONG IntT0; // r2-r3, volatile
  2386. ULONGLONG IntT1; //
  2387. ULONGLONG IntS0; // r4-r7, preserved
  2388. ULONGLONG IntS1;
  2389. ULONGLONG IntS2;
  2390. ULONGLONG IntS3;
  2391. ULONGLONG IntV0; // r8, volatile
  2392. ULONGLONG IntT2; // r9-r11, volatile
  2393. ULONGLONG IntT3;
  2394. ULONGLONG IntT4;
  2395. ULONGLONG IntSp; // stack pointer (r12), special
  2396. ULONGLONG IntTeb; // teb (r13), special
  2397. ULONGLONG IntT5; // r14-r31, volatile
  2398. ULONGLONG IntT6;
  2399. ULONGLONG B0R16; // Bank 0 registers 16-31
  2400. ULONGLONG B0R17;
  2401. ULONGLONG B0R18;
  2402. ULONGLONG B0R19;
  2403. ULONGLONG B0R20;
  2404. ULONGLONG B0R21;
  2405. ULONGLONG B0R22;
  2406. ULONGLONG B0R23;
  2407. ULONGLONG B0R24;
  2408. ULONGLONG B0R25;
  2409. ULONGLONG B0R26;
  2410. ULONGLONG B0R27;
  2411. ULONGLONG B0R28;
  2412. ULONGLONG B0R29;
  2413. ULONGLONG B0R30;
  2414. ULONGLONG B0R31;
  2415. ULONGLONG IntT7; // Bank 1 registers 16-31
  2416. ULONGLONG IntT8;
  2417. ULONGLONG IntT9;
  2418. ULONGLONG IntT10;
  2419. ULONGLONG IntT11;
  2420. ULONGLONG IntT12;
  2421. ULONGLONG IntT13;
  2422. ULONGLONG IntT14;
  2423. ULONGLONG IntT15;
  2424. ULONGLONG IntT16;
  2425. ULONGLONG IntT17;
  2426. ULONGLONG IntT18;
  2427. ULONGLONG IntT19;
  2428. ULONGLONG IntT20;
  2429. ULONGLONG IntT21;
  2430. ULONGLONG IntT22;
  2431. ULONGLONG Preds; // predicates, preserved
  2432. ULONGLONG BrRp; // return pointer, b0, preserved
  2433. ULONGLONG RsRSC; // RSE configuration, volatile
  2434. ULONGLONG StIIP; // Interruption IP
  2435. ULONGLONG StIPSR; // Interruption Processor Status
  2436. ULONGLONG StIFS; // Interruption Function State
  2437. ULONGLONG XIP; // Event IP
  2438. ULONGLONG XPSR; // Event Processor Status
  2439. ULONGLONG XFS; // Event Function State
  2440. } PAL_MINI_SAVE_AREA, *PPAL_MINI_SAVE_AREA;
  2441. //
  2442. // Define Processor Control Region Structure.
  2443. //
  2444. #define PCR_MINOR_VERSION 1
  2445. #define PCR_MAJOR_VERSION 1
  2446. typedef struct _KPCR {
  2447. //
  2448. // Major and minor version numbers of the PCR.
  2449. //
  2450. ULONG MinorVersion;
  2451. ULONG MajorVersion;
  2452. //
  2453. // Start of the architecturally defined section of the PCR. This section
  2454. // may be directly addressed by vendor/platform specific HAL code and will
  2455. // not change from version to version of NT.
  2456. //
  2457. //
  2458. // First and second level cache parameters.
  2459. //
  2460. ULONG FirstLevelDcacheSize;
  2461. ULONG FirstLevelDcacheFillSize;
  2462. ULONG FirstLevelIcacheSize;
  2463. ULONG FirstLevelIcacheFillSize;
  2464. ULONG SecondLevelDcacheSize;
  2465. ULONG SecondLevelDcacheFillSize;
  2466. ULONG SecondLevelIcacheSize;
  2467. ULONG SecondLevelIcacheFillSize;
  2468. //
  2469. // Data cache alignment and fill size used for cache flushing and alignment.
  2470. // These fields are set to the larger of the first and second level data
  2471. // cache fill sizes.
  2472. //
  2473. ULONG DcacheAlignment;
  2474. ULONG DcacheFillSize;
  2475. //
  2476. // Instruction cache alignment and fill size used for cache flushing and
  2477. // alignment. These fields are set to the larger of the first and second
  2478. // level data cache fill sizes.
  2479. //
  2480. ULONG IcacheAlignment;
  2481. ULONG IcacheFillSize;
  2482. //
  2483. // Processor identification from PrId register.
  2484. //
  2485. ULONG ProcessorId;
  2486. //
  2487. // Profiling data.
  2488. //
  2489. ULONG ProfileInterval;
  2490. ULONG ProfileCount;
  2491. //
  2492. // Stall execution count and scale factor.
  2493. //
  2494. ULONG StallExecutionCount;
  2495. ULONG StallScaleFactor;
  2496. ULONG InterruptionCount;
  2497. //
  2498. // Space reserved for the system.
  2499. //
  2500. ULONGLONG SystemReserved[6];
  2501. //
  2502. // Space reserved for the HAL
  2503. //
  2504. ULONGLONG HalReserved[64];
  2505. //
  2506. // IRQL mapping tables.
  2507. //
  2508. UCHAR IrqlMask[64];
  2509. UCHAR IrqlTable[64];
  2510. //
  2511. // External Interrupt vectors.
  2512. //
  2513. PKINTERRUPT_ROUTINE InterruptRoutine[MAXIMUM_VECTOR];
  2514. //
  2515. // Reserved interrupt vector mask.
  2516. //
  2517. ULONG ReservedVectors;
  2518. //
  2519. // Processor affinity mask.
  2520. //
  2521. KAFFINITY SetMember;
  2522. //
  2523. // Complement of the processor affinity mask.
  2524. //
  2525. KAFFINITY NotMember;
  2526. //
  2527. // Pointer to processor control block.
  2528. //
  2529. struct _KPRCB *Prcb;
  2530. //
  2531. // Shadow copy of Prcb->CurrentThread for fast access
  2532. //
  2533. struct _KTHREAD *CurrentThread;
  2534. //
  2535. // Processor number.
  2536. //
  2537. CCHAR Number; // Processor Number
  2538. UCHAR DebugActive; // debug register active in user flag
  2539. UCHAR KernelDebugActive; // debug register active in kernel flag
  2540. UCHAR CurrentIrql; // Current IRQL
  2541. union {
  2542. USHORT SoftwareInterruptPending; // Software Interrupt Pending Flag
  2543. struct {
  2544. UCHAR ApcInterrupt; // 0x01 if APC int pending
  2545. UCHAR DispatchInterrupt; // 0x01 if dispatch int pending
  2546. };
  2547. };
  2548. //
  2549. // Address of per processor SAPIC EOI Table
  2550. //
  2551. PVOID EOITable;
  2552. //
  2553. // IA-64 Machine Check Events trackers
  2554. //
  2555. UCHAR InOsMca;
  2556. UCHAR InOsInit;
  2557. UCHAR InOsCmc;
  2558. UCHAR InOsCpe;
  2559. ULONG InOsULONG_Spare; // Spare ULONG
  2560. PSAL_EVENT_RESOURCES OsMcaResourcePtr;
  2561. PSAL_EVENT_RESOURCES OsInitResourcePtr;
  2562. //
  2563. // End of the architecturally defined section of the PCR. This section
  2564. // may be directly addressed by vendor/platform specific HAL code and will
  2565. // not change from version to version of NT.
  2566. //
  2567. // end_nthal end_ntddk
  2568. //
  2569. // OS Part
  2570. //
  2571. //
  2572. // Address of the thread who currently owns the high fp register set
  2573. //
  2574. struct _KTHREAD *HighFpOwner;
  2575. // Per processor kernel (ntoskrnl.exe) global pointer
  2576. ULONGLONG KernelGP;
  2577. // Per processor initial kernel stack for current thread
  2578. ULONGLONG InitialStack;
  2579. // Per processor pointer to kernel BSP
  2580. ULONGLONG InitialBStore;
  2581. // Per processor kernel stack limit
  2582. ULONGLONG StackLimit;
  2583. // Per processor kernel backing store limit
  2584. ULONGLONG BStoreLimit;
  2585. // Per processor panic kernel stack
  2586. ULONGLONG PanicStack;
  2587. //
  2588. // Save area for kernel entry/exit
  2589. //
  2590. ULONGLONG SavedIIM;
  2591. ULONGLONG SavedIFA;
  2592. ULONGLONG ForwardProgressBuffer[16];
  2593. PVOID Pcb; // holds KPROCESS for MP region synchronization
  2594. //
  2595. // Nt page table base addresses
  2596. //
  2597. ULONGLONG PteUbase;
  2598. ULONGLONG PteKbase;
  2599. ULONGLONG PteSbase;
  2600. ULONGLONG PdeUbase;
  2601. ULONGLONG PdeKbase;
  2602. ULONGLONG PdeSbase;
  2603. ULONGLONG PdeUtbase;
  2604. ULONGLONG PdeKtbase;
  2605. ULONGLONG PdeStbase;
  2606. //
  2607. // The actual resources for the OS_INIT and OS_MCA handlers
  2608. // are placed at the end of the PCR structure so that auto
  2609. // can be used to get to get between the public and private
  2610. // sections of the PCR in the traps and context routines.
  2611. //
  2612. SAL_EVENT_RESOURCES OsMcaResource;
  2613. SAL_EVENT_RESOURCES OsInitResource;
  2614. // begin_nthal begin_ntddk
  2615. } KPCR, *PKPCR;
  2616. // end_nthal end_ntddk end_ntosp
  2617. // begin_nthal
  2618. //
  2619. // Define the number of bits to shift to right justify the Page Table Index
  2620. // field of a PTE.
  2621. //
  2622. #define PTI_SHIFT PAGE_SHIFT
  2623. //
  2624. // Define the number of bits to shift to right justify the Page Directory Index
  2625. // field of a PTE.
  2626. //
  2627. #define PDI_SHIFT (PTI_SHIFT + PAGE_SHIFT - PTE_SHIFT)
  2628. #define PDI1_SHIFT (PDI_SHIFT + PAGE_SHIFT - PTE_SHIFT)
  2629. #define PDI_MASK ((1 << (PAGE_SHIFT - PTE_SHIFT)) - 1)
  2630. //
  2631. // Define the number of bits to shift to left to produce page table offset
  2632. // from page table index.
  2633. //
  2634. #define PTE_SHIFT 3
  2635. //
  2636. // Define the number of bits to shift to the right justify the Page Directory
  2637. // Table Entry field.
  2638. //
  2639. #define VHPT_PDE_BITS 40
  2640. //
  2641. // Define the RID for IO Port Space.
  2642. //
  2643. #define RR_IO_PORT 6
  2644. //
  2645. // The following definitions are required for the debugger data block.
  2646. //
  2647. // begin_ntddk begin_ntosp
  2648. //
  2649. // The highest user address reserves 64K bytes for a guard page. This
  2650. // the probing of address from kernel mode to only have to check the
  2651. // starting address for structures of 64k bytes or less.
  2652. //
  2653. extern NTKERNELAPI PVOID MmHighestUserAddress;
  2654. extern NTKERNELAPI PVOID MmSystemRangeStart;
  2655. extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
  2656. #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
  2657. #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
  2658. #define MM_SYSTEM_RANGE_START MmSystemRangeStart
  2659. //
  2660. // The lowest user address reserves the low 64k.
  2661. //
  2662. #define MM_LOWEST_USER_ADDRESS (PVOID)((ULONG_PTR)(UADDRESS_BASE+0x00010000))
  2663. // begin_wdm
  2664. #define MmGetProcedureAddress(Address) (Address)
  2665. #define MmLockPagableCodeSection(PLabelAddress) \
  2666. MmLockPagableDataSection((PVOID)(*((PULONGLONG)PLabelAddress)))
  2667. #define VRN_MASK 0xE000000000000000UI64 // Virtual Region Number mask
  2668. // end_ntddk end_wdm end_ntosp
  2669. //
  2670. // Limit the IA32 subsystem to a 2GB virtual address space.
  2671. // This means "Large Address Aware" apps are not supported in emulation mode.
  2672. //
  2673. #define MM_MAX_WOW64_ADDRESS (0x00000000080000000UI64)
  2674. #define MI_HIGHEST_USER_ADDRESS (PVOID) (ULONG_PTR)((UADDRESS_BASE + 0x6FC00000000 - 0x10000 - 1)) // highest user address
  2675. #define MI_USER_PROBE_ADDRESS ((ULONG_PTR)(UADDRESS_BASE + 0x6FC00000000UI64 - 0x10000)) // starting address of guard page
  2676. #define MI_SYSTEM_RANGE_START (PVOID) (UADDRESS_BASE + 0x6FC00000000) // start of system space
  2677. //
  2678. // Define the page table base and the page directory base for
  2679. // the TB miss routines and memory management.
  2680. //
  2681. //
  2682. // user/kernel page table base and top addresses
  2683. //
  2684. extern ULONG_PTR KiIA64VaSignedFill;
  2685. extern ULONG_PTR KiIA64PtaSign;
  2686. #define PTA_SIGN KiIA64PtaSign
  2687. #define VA_FILL KiIA64VaSignedFill
  2688. #define SADDRESS_BASE 0x2000000000000000UI64 // session base address
  2689. #define PTE_UBASE PCR->PteUbase
  2690. #define PTE_KBASE PCR->PteKbase
  2691. #define PTE_SBASE PCR->PteSbase
  2692. #define PTE_UTOP (PTE_UBASE|(((ULONG_PTR)1 << PDI1_SHIFT) - 1)) // top level PDR address (user)
  2693. #define PTE_KTOP (PTE_KBASE|(((ULONG_PTR)1 << PDI1_SHIFT) - 1)) // top level PDR address (kernel)
  2694. #define PTE_STOP (PTE_SBASE|(((ULONG_PTR)1 << PDI1_SHIFT) - 1)) // top level PDR address (session)
  2695. //
  2696. // Second level user and kernel PDR address
  2697. //
  2698. #define PDE_UBASE PCR->PdeUbase
  2699. #define PDE_KBASE PCR->PdeKbase
  2700. #define PDE_SBASE PCR->PdeSbase
  2701. #define PDE_UTOP (PDE_UBASE|(((ULONG_PTR)1 << PDI_SHIFT) - 1)) // second level PDR address (user)
  2702. #define PDE_KTOP (PDE_KBASE|(((ULONG_PTR)1 << PDI_SHIFT) - 1)) // second level PDR address (kernel)
  2703. #define PDE_STOP (PDE_SBASE|(((ULONG_PTR)1 << PDI_SHIFT) - 1)) // second level PDR address (session)
  2704. //
  2705. // 8KB first level user and kernel PDR address
  2706. //
  2707. #define PDE_UTBASE PCR->PdeUtbase
  2708. #define PDE_KTBASE PCR->PdeKtbase
  2709. #define PDE_STBASE PCR->PdeStbase
  2710. #define PDE_USELFMAP (PDE_UTBASE|(PAGE_SIZE - (1<<PTE_SHIFT))) // self mapped PPE address (user)
  2711. #define PDE_KSELFMAP (PDE_KTBASE|(PAGE_SIZE - (1<<PTE_SHIFT))) // self mapped PPE address (kernel)
  2712. #define PDE_SSELFMAP (PDE_STBASE|(PAGE_SIZE - (1<<PTE_SHIFT))) // self mapped PPE address (kernel)
  2713. #define PTE_BASE PTE_UBASE
  2714. #define PDE_BASE PDE_UBASE
  2715. #define PDE_TBASE PDE_UTBASE
  2716. #define PDE_SELFMAP PDE_USELFMAP
  2717. #define KSEG0_BASE (KADDRESS_BASE + 0x80000000) // base of kernel
  2718. #define KSEG2_BASE (KADDRESS_BASE + 0xA0000000) // end of kernel
  2719. #define KSEG3_BASE 0x8000000000000000UI64
  2720. #define KSEG3_LIMIT 0x8000100000000000UI64
  2721. #define KSEG4_BASE 0xA000000000000000UI64
  2722. #define KSEG4_LIMIT 0xA000100000000000UI64
  2723. //
  2724. //++
  2725. //PVOID
  2726. //KSEG_ADDRESS (
  2727. // IN ULONG PAGE
  2728. // );
  2729. //
  2730. // Routine Description:
  2731. //
  2732. // This macro returns a KSEG virtual address which maps the page.
  2733. //
  2734. // Arguments:
  2735. //
  2736. // PAGE - Supplies the physical page frame number
  2737. //
  2738. // Return Value:
  2739. //
  2740. // The address of the KSEG address
  2741. //
  2742. //--
  2743. #define KSEG_ADDRESS(PAGE) ((PVOID)(KSEG3_BASE | ((ULONG_PTR)(PAGE) << PAGE_SHIFT)))
  2744. #define KSEG4_ADDRESS(PAGE) ((PVOID)(KSEG4_BASE | ((ULONG_PTR)(PAGE) << PAGE_SHIFT)))
  2745. #define MAXIMUM_FWP_BUFFER_ENTRY 8
  2746. typedef struct _REGION_MAP_INFO {
  2747. ULONG RegionId;
  2748. ULONG PageSize;
  2749. ULONGLONG SequenceNumber;
  2750. } REGION_MAP_INFO, *PREGION_MAP_INFO;
  2751. // begin_ntddk begin_wdm
  2752. //
  2753. // The lowest address for system space.
  2754. //
  2755. #define MM_LOWEST_SYSTEM_ADDRESS ((PVOID)((ULONG_PTR)(KADDRESS_BASE + 0xC0C00000)))
  2756. // end_nthal end_ntddk end_wdm
  2757. #define SYSTEM_BASE (KADDRESS_BASE + 0xC3000000) // start of system space (no typecast)
  2758. //
  2759. // Define macro to initialize directory table base.
  2760. //
  2761. #define INITIALIZE_DIRECTORY_TABLE_BASE(dirbase, pfn) \
  2762. *((PULONGLONG)(dirbase)) = 0; \
  2763. ((PHARDWARE_PTE)(dirbase))->PageFrameNumber = pfn; \
  2764. ((PHARDWARE_PTE)(dirbase))->Accessed = 1; \
  2765. ((PHARDWARE_PTE)(dirbase))->Dirty = 1; \
  2766. ((PHARDWARE_PTE)(dirbase))->Cache = 0; \
  2767. ((PHARDWARE_PTE)(dirbase))->Write = 1; \
  2768. ((PHARDWARE_PTE)(dirbase))->Valid = 1;
  2769. //
  2770. // IA64 function definitions
  2771. //
  2772. //++
  2773. //
  2774. // BOOLEAN
  2775. // KiIsThreadNumericStateSaved(
  2776. // IN PKTHREAD Address
  2777. // )
  2778. //
  2779. // This call is used on a not running thread to see if it's numeric
  2780. // state has been saved in it's context information. On IA64 the
  2781. // numeric state is always saved.
  2782. //
  2783. //--
  2784. #define KiIsThreadNumericStateSaved(a) TRUE
  2785. //++
  2786. //
  2787. // VOID
  2788. // KiRundownThread(
  2789. // IN PKTHREAD Address
  2790. // )
  2791. //
  2792. //--
  2793. #define KiRundownThread(a)
  2794. //
  2795. // ia64 Feature bit definitions
  2796. //
  2797. #define KF_BRL 0x00000001 // processor supports long branch instruction.
  2798. //
  2799. // Define macro to test if x86 feature is present.
  2800. //
  2801. // N.B. All x86 features test TRUE on IA64 systems.
  2802. //
  2803. #define Isx86FeaturePresent(_f_) TRUE
  2804. // begin_nthal begin_ntddk begin_ntndis begin_wdm begin_ntosp
  2805. #endif // defined(_IA64_)
  2806. // end_nthal end_ntddk end_ntndis end_wdm end_ntosp
  2807. #endif // _IA64H_