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.

1172 lines
26 KiB

  1. /*++ BUILD Version: 0015 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntmips.h
  5. Abstract:
  6. User-mode visible Mips specific structures and constants
  7. Author:
  8. David N. Cutler (davec) 31-Mar-1990
  9. Revision History:
  10. --*/
  11. #ifndef _NTMIPS_
  12. #define _NTMIPS_
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16. #include "mipsinst.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. // begin_ntddk begin_wdm begin_nthal
  21. #if defined(_MIPS_)
  22. //
  23. // Define system time structure.
  24. //
  25. typedef union _KSYSTEM_TIME {
  26. struct {
  27. ULONG LowPart;
  28. LONG High1Time;
  29. LONG High2Time;
  30. };
  31. ULONGLONG Alignment;
  32. } KSYSTEM_TIME, *PKSYSTEM_TIME;
  33. //
  34. // Define unsupported "keywords".
  35. //
  36. #define _cdecl
  37. #if defined(_MIPS_)
  38. // end_ntddk end_wdm end_nthal
  39. //
  40. // Define breakpoint codes.
  41. //
  42. #define USER_BREAKPOINT 0 // user breakpoint
  43. #define KERNEL_BREAKPOINT 1 // kernel breakpoint
  44. #define BREAKIN_BREAKPOINT 2 // break into kernel debugger
  45. #define BRANCH_TAKEN_BREAKPOINT 3 // branch taken breakpoint
  46. #define BRANCH_NOT_TAKEN_BREAKPOINT 4 // branch not taken breakpoint
  47. #define SINGLE_STEP_BREAKPOINT 5 // single step breakpoint
  48. #define DIVIDE_OVERFLOW_BREAKPOINT 6 // divide overflow breakpoint
  49. #define DIVIDE_BY_ZERO_BREAKPOINT 7 // divide by zero breakpoint
  50. #define RANGE_CHECK_BREAKPOINT 8 // range check breakpoint
  51. #define STACK_OVERFLOW_BREAKPOINT 9 // MIPS code
  52. #define MULTIPLY_OVERFLOW_BREAKPOINT 10 // multiply overflow breakpoint
  53. #define DEBUG_PRINT_BREAKPOINT 20 // debug print breakpoint
  54. #define DEBUG_PROMPT_BREAKPOINT 21 // debug prompt breakpoint
  55. #define DEBUG_STOP_BREAKPOINT 22 // debug stop breakpoint
  56. #define DEBUG_LOAD_SYMBOLS_BREAKPOINT 23 // load symbols breakpoint
  57. #define DEBUG_UNLOAD_SYMBOLS_BREAKPOINT 24 // unload symbols breakpoint
  58. #define DEBUG_COMMAND_STRING_BREAKPOINT 25 // command string breakpoint
  59. // begin_ntddk begin_nthal
  60. //
  61. // Define size of kernel mode stack.
  62. //
  63. #define KERNEL_STACK_SIZE 12288
  64. //
  65. // Define size of large kernel mode stack for callbacks.
  66. //
  67. #define KERNEL_LARGE_STACK_SIZE 61440
  68. //
  69. // Define number of pages to initialize in a large kernel stack.
  70. //
  71. #define KERNEL_LARGE_STACK_COMMIT 12288
  72. // begin_wdm
  73. //
  74. // Define length of exception code dispatch vector.
  75. //
  76. #define XCODE_VECTOR_LENGTH 32
  77. //
  78. // Define length of interrupt vector table.
  79. //
  80. #define MAXIMUM_VECTOR 256
  81. //
  82. // Define bus error routine type.
  83. //
  84. struct _EXCEPTION_RECORD;
  85. struct _KEXCEPTION_FRAME;
  86. struct _KTRAP_FRAME;
  87. typedef
  88. BOOLEAN
  89. (*PKBUS_ERROR_ROUTINE) (
  90. IN struct _EXCEPTION_RECORD *ExceptionRecord,
  91. IN struct _KEXCEPTION_FRAME *ExceptionFrame,
  92. IN struct _KTRAP_FRAME *TrapFrame,
  93. IN PVOID VirtualAddress,
  94. IN PHYSICAL_ADDRESS PhysicalAddress
  95. );
  96. //
  97. // Define Processor Control Region Structure.
  98. //
  99. #define PCR_MINOR_VERSION 1
  100. #define PCR_MAJOR_VERSION 1
  101. typedef struct _KPCR {
  102. //
  103. // Major and minor version numbers of the PCR.
  104. //
  105. USHORT MinorVersion;
  106. USHORT MajorVersion;
  107. //
  108. // Start of the architecturally defined section of the PCR. This section
  109. // may be directly addressed by vendor/platform specific HAL code and will
  110. // not change from version to version of NT.
  111. //
  112. // Interrupt and error exception vectors.
  113. //
  114. PKINTERRUPT_ROUTINE InterruptRoutine[MAXIMUM_VECTOR];
  115. PVOID XcodeDispatch[XCODE_VECTOR_LENGTH];
  116. //
  117. // First and second level cache parameters.
  118. //
  119. ULONG FirstLevelDcacheSize;
  120. ULONG FirstLevelDcacheFillSize;
  121. ULONG FirstLevelIcacheSize;
  122. ULONG FirstLevelIcacheFillSize;
  123. ULONG SecondLevelDcacheSize;
  124. ULONG SecondLevelDcacheFillSize;
  125. ULONG SecondLevelIcacheSize;
  126. ULONG SecondLevelIcacheFillSize;
  127. //
  128. // Pointer to processor control block.
  129. //
  130. struct _KPRCB *Prcb;
  131. //
  132. // Pointer to the thread environment block and the address of the TLS array.
  133. //
  134. PVOID Teb;
  135. PVOID TlsArray;
  136. //
  137. // Data fill size used for cache flushing and alignment. This field is set
  138. // to the larger of the first and second level data cache fill sizes.
  139. //
  140. ULONG DcacheFillSize;
  141. //
  142. // Instruction cache alignment and fill size used for cache flushing and
  143. // alignment. These fields are set to the larger of the first and second
  144. // level data cache fill sizes.
  145. //
  146. ULONG IcacheAlignment;
  147. ULONG IcacheFillSize;
  148. //
  149. // Processor identification from PrId register.
  150. //
  151. ULONG ProcessorId;
  152. //
  153. // Profiling data.
  154. //
  155. ULONG ProfileInterval;
  156. ULONG ProfileCount;
  157. //
  158. // Stall execution count and scale factor.
  159. //
  160. ULONG StallExecutionCount;
  161. ULONG StallScaleFactor;
  162. //
  163. // Processor number.
  164. //
  165. CCHAR Number;
  166. //
  167. // Spare cells.
  168. //
  169. CCHAR Spareb1;
  170. CCHAR Spareb2;
  171. CCHAR Spareb3;
  172. //
  173. // Pointers to bus error and parity error routines.
  174. //
  175. PKBUS_ERROR_ROUTINE DataBusError;
  176. PKBUS_ERROR_ROUTINE InstructionBusError;
  177. //
  178. // Cache policy, right justified, as read from the processor configuration
  179. // register at startup.
  180. //
  181. ULONG CachePolicy;
  182. //
  183. // IRQL mapping tables.
  184. //
  185. UCHAR IrqlMask[32];
  186. UCHAR IrqlTable[9];
  187. //
  188. // Current IRQL.
  189. //
  190. UCHAR CurrentIrql;
  191. //
  192. // Processor affinity mask.
  193. //
  194. KAFFINITY SetMember;
  195. //
  196. // Reserved interrupt vector mask.
  197. //
  198. ULONG ReservedVectors;
  199. //
  200. // Current state parameters.
  201. //
  202. struct _KTHREAD *CurrentThread;
  203. //
  204. // Cache policy, PTE field aligned, as read from the processor configuration
  205. // register at startup.
  206. //
  207. ULONG AlignedCachePolicy;
  208. //
  209. // Complement of processor affinity mask.
  210. //
  211. KAFFINITY NotMember;
  212. //
  213. // Space reserved for the system.
  214. //
  215. ULONG SystemReserved[15];
  216. //
  217. // Data cache alignment used for cache flushing and alignment. This field is
  218. // set to the larger of the first and second level data cache fill sizes.
  219. //
  220. ULONG DcacheAlignment;
  221. //
  222. // Space reserved for the HAL
  223. //
  224. ULONG HalReserved[16];
  225. //
  226. // End of the architecturally defined section of the PCR. This section
  227. // may be directly addressed by vendor/platform specific HAL code and will
  228. // not change from version to version of NT.
  229. //
  230. // end_ntddk end_wdm end_nthal
  231. //
  232. // Start of the operating system release dependent section of the PCR.
  233. // This section may change from release to release and should not be
  234. // addressed by vendor/platform specific HAL code.
  235. //
  236. // Function active flags.
  237. //
  238. ULONG FirstLevelActive;
  239. ULONG DpcRoutineActive;
  240. //
  241. // Current process id.
  242. //
  243. ULONG CurrentPid;
  244. //
  245. // On interrupt stack indicator, saved initial stack, and saved stack limit.
  246. //
  247. ULONG OnInterruptStack;
  248. PVOID SavedInitialStack;
  249. PVOID SavedStackLimit;
  250. //
  251. // System service dispatch start and end address used by get/set context.
  252. //
  253. ULONG SystemServiceDispatchStart;
  254. ULONG SystemServiceDispatchEnd;
  255. //
  256. // Interrupt stack.
  257. //
  258. PVOID InterruptStack;
  259. //
  260. // Panic stack.
  261. //
  262. PVOID PanicStack;
  263. //
  264. // Exception handler values.
  265. //
  266. ULONG Sparel1;
  267. PVOID InitialStack;
  268. PVOID StackLimit;
  269. ULONG SavedEpc;
  270. ULONGLONG SavedT7;
  271. ULONGLONG SavedT8;
  272. ULONGLONG SavedT9;
  273. PVOID SystemGp;
  274. //
  275. // Quantum end flag.
  276. //
  277. ULONG QuantumEnd;
  278. //
  279. // Bad virtual address and fault bad virtual address.
  280. //
  281. ULONGLONG BadVaddr;
  282. ULONGLONG TmpVaddr;
  283. } KPCR, *PKPCR; // ntddk wdm nthal
  284. //
  285. // Define Address of Processor Control Registers.
  286. //
  287. #define USPCR 0x7ffff000 // user address of first PCR
  288. #define USPCR2 0x7fffe000 // user address of second PCR
  289. //
  290. // Define Pointer to Processor Control Registers.
  291. //
  292. #define USER_PCR ((KPCR * const)USPCR)
  293. #if defined(NTOS_KERNEL_RUNTIME)
  294. #define NtCurrentTeb() ((PTEB)(PCR->Teb))
  295. #define USER_SHARED_DATA ((KUSER_SHARED_DATA * const)0xffffe000)
  296. #else
  297. #define NtCurrentTeb() ((PTEB)(USER_PCR->Teb))
  298. #define USER_SHARED_DATA ((KUSER_SHARED_DATA * const)0x7fffe000)
  299. #endif
  300. //
  301. // Define get system time macro.
  302. //
  303. // N.B. This macro can be changed when the compiler generates real double
  304. // integer instructions.
  305. //
  306. #define QUERY_SYSTEM_TIME(CurrentTime) \
  307. *((DOUBLE *)(CurrentTime)) = *((DOUBLE *)(&USER_SHARED_DATA->SystemTime))
  308. // begin_winnt
  309. #if defined(_MIPS_)
  310. //
  311. // Define functions to get the address of the current fiber and the
  312. // current fiber data.
  313. //
  314. #define GetCurrentFiber() ((*(PNT_TIB *)0x7ffff4a8)->FiberData)
  315. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  316. // begin_ntddk begin_nthal
  317. //
  318. // The following flags control the contents of the CONTEXT structure.
  319. //
  320. #if !defined(RC_INVOKED)
  321. #define CONTEXT_R4000 0x00010000 // r4000 context
  322. #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
  323. #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
  324. #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
  325. #define CONTEXT_EXTENDED_FLOAT (CONTEXT_FLOATING_POINT | 0x00000008)
  326. #define CONTEXT_EXTENDED_INTEGER (CONTEXT_INTEGER | 0x00000010)
  327. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | \
  328. CONTEXT_INTEGER | CONTEXT_EXTENDED_INTEGER)
  329. #endif
  330. //
  331. // Context Frame
  332. //
  333. // N.B. This frame must be exactly a multiple of 16 bytes in length.
  334. //
  335. // This frame has a several purposes: 1) it is used as an argument to
  336. // NtContinue, 2) it is used to constuct a call frame for APC delivery,
  337. // 3) it is used to construct a call frame for exception dispatching
  338. // in user mode, and 4) it is used in the user level thread creation
  339. // routines.
  340. //
  341. // The layout of the record conforms to a standard call frame.
  342. //
  343. typedef struct _CONTEXT {
  344. //
  345. // This section is always present and is used as an argument build
  346. // area.
  347. //
  348. // N.B. Context records are 0 mod 8 aligned starting with NT 4.0.
  349. //
  350. union {
  351. ULONG Argument[4];
  352. ULONGLONG Alignment;
  353. };
  354. //
  355. // The following union defines the 32-bit and 64-bit register context.
  356. //
  357. union {
  358. //
  359. // 32-bit context.
  360. //
  361. struct {
  362. //
  363. // This section is specified/returned if the ContextFlags contains
  364. // the flag CONTEXT_FLOATING_POINT.
  365. //
  366. // N.B. This section contains the 16 double floating registers f0,
  367. // f2, ..., f30.
  368. //
  369. ULONG FltF0;
  370. ULONG FltF1;
  371. ULONG FltF2;
  372. ULONG FltF3;
  373. ULONG FltF4;
  374. ULONG FltF5;
  375. ULONG FltF6;
  376. ULONG FltF7;
  377. ULONG FltF8;
  378. ULONG FltF9;
  379. ULONG FltF10;
  380. ULONG FltF11;
  381. ULONG FltF12;
  382. ULONG FltF13;
  383. ULONG FltF14;
  384. ULONG FltF15;
  385. ULONG FltF16;
  386. ULONG FltF17;
  387. ULONG FltF18;
  388. ULONG FltF19;
  389. ULONG FltF20;
  390. ULONG FltF21;
  391. ULONG FltF22;
  392. ULONG FltF23;
  393. ULONG FltF24;
  394. ULONG FltF25;
  395. ULONG FltF26;
  396. ULONG FltF27;
  397. ULONG FltF28;
  398. ULONG FltF29;
  399. ULONG FltF30;
  400. ULONG FltF31;
  401. //
  402. // This section is specified/returned if the ContextFlags contains
  403. // the flag CONTEXT_INTEGER.
  404. //
  405. // N.B. The registers gp, sp, and ra are defined in this section,
  406. // but are considered part of the control context rather than
  407. // part of the integer context.
  408. //
  409. // N.B. Register zero is not stored in the frame.
  410. //
  411. ULONG IntZero;
  412. ULONG IntAt;
  413. ULONG IntV0;
  414. ULONG IntV1;
  415. ULONG IntA0;
  416. ULONG IntA1;
  417. ULONG IntA2;
  418. ULONG IntA3;
  419. ULONG IntT0;
  420. ULONG IntT1;
  421. ULONG IntT2;
  422. ULONG IntT3;
  423. ULONG IntT4;
  424. ULONG IntT5;
  425. ULONG IntT6;
  426. ULONG IntT7;
  427. ULONG IntS0;
  428. ULONG IntS1;
  429. ULONG IntS2;
  430. ULONG IntS3;
  431. ULONG IntS4;
  432. ULONG IntS5;
  433. ULONG IntS6;
  434. ULONG IntS7;
  435. ULONG IntT8;
  436. ULONG IntT9;
  437. ULONG IntK0;
  438. ULONG IntK1;
  439. ULONG IntGp;
  440. ULONG IntSp;
  441. ULONG IntS8;
  442. ULONG IntRa;
  443. ULONG IntLo;
  444. ULONG IntHi;
  445. //
  446. // This section is specified/returned if the ContextFlags word contains
  447. // the flag CONTEXT_FLOATING_POINT.
  448. //
  449. ULONG Fsr;
  450. //
  451. // This section is specified/returned if the ContextFlags word contains
  452. // the flag CONTEXT_CONTROL.
  453. //
  454. // N.B. The registers gp, sp, and ra are defined in the integer section,
  455. // but are considered part of the control context rather than part of
  456. // the integer context.
  457. //
  458. ULONG Fir;
  459. ULONG Psr;
  460. //
  461. // The flags values within this flag control the contents of
  462. // a CONTEXT record.
  463. //
  464. // If the context record is used as an input parameter, then
  465. // for each portion of the context record controlled by a flag
  466. // whose value is set, it is assumed that that portion of the
  467. // context record contains valid context. If the context record
  468. // is being used to modify a thread's context, then only that
  469. // portion of the threads context will be modified.
  470. //
  471. // If the context record is used as an IN OUT parameter to capture
  472. // the context of a thread, then only those portions of the thread's
  473. // context corresponding to set flags will be returned.
  474. //
  475. // The context record is never used as an OUT only parameter.
  476. //
  477. ULONG ContextFlags;
  478. };
  479. //
  480. // 64-bit context.
  481. //
  482. struct {
  483. //
  484. // This section is specified/returned if the ContextFlags contains
  485. // the flag CONTEXT_EXTENDED_FLOAT.
  486. //
  487. // N.B. This section contains the 32 double floating registers f0,
  488. // f1, ..., f31.
  489. //
  490. ULONGLONG XFltF0;
  491. ULONGLONG XFltF1;
  492. ULONGLONG XFltF2;
  493. ULONGLONG XFltF3;
  494. ULONGLONG XFltF4;
  495. ULONGLONG XFltF5;
  496. ULONGLONG XFltF6;
  497. ULONGLONG XFltF7;
  498. ULONGLONG XFltF8;
  499. ULONGLONG XFltF9;
  500. ULONGLONG XFltF10;
  501. ULONGLONG XFltF11;
  502. ULONGLONG XFltF12;
  503. ULONGLONG XFltF13;
  504. ULONGLONG XFltF14;
  505. ULONGLONG XFltF15;
  506. ULONGLONG XFltF16;
  507. ULONGLONG XFltF17;
  508. ULONGLONG XFltF18;
  509. ULONGLONG XFltF19;
  510. ULONGLONG XFltF20;
  511. ULONGLONG XFltF21;
  512. ULONGLONG XFltF22;
  513. ULONGLONG XFltF23;
  514. ULONGLONG XFltF24;
  515. ULONGLONG XFltF25;
  516. ULONGLONG XFltF26;
  517. ULONGLONG XFltF27;
  518. ULONGLONG XFltF28;
  519. ULONGLONG XFltF29;
  520. ULONGLONG XFltF30;
  521. ULONGLONG XFltF31;
  522. //
  523. // The following sections must exactly overlay the 32-bit context.
  524. //
  525. ULONG Fill1;
  526. ULONG Fill2;
  527. //
  528. // This section is specified/returned if the ContextFlags contains
  529. // the flag CONTEXT_FLOATING_POINT.
  530. //
  531. ULONG XFsr;
  532. //
  533. // This section is specified/returned if the ContextFlags contains
  534. // the flag CONTEXT_CONTROL.
  535. //
  536. // N.B. The registers gp, sp, and ra are defined in the integer
  537. // section, but are considered part of the control context
  538. // rather than part of the integer context.
  539. //
  540. ULONG XFir;
  541. ULONG XPsr;
  542. //
  543. // The flags values within this flag control the contents of
  544. // a CONTEXT record.
  545. //
  546. // If the context record is used as an input parameter, then
  547. // for each portion of the context record controlled by a flag
  548. // whose value is set, it is assumed that that portion of the
  549. // context record contains valid context. If the context record
  550. // is being used to modify a thread's context, then only that
  551. // portion of the threads context will be modified.
  552. //
  553. // If the context record is used as an IN OUT parameter to capture
  554. // the context of a thread, then only those portions of the thread's
  555. // context corresponding to set flags will be returned.
  556. //
  557. // The context record is never used as an OUT only parameter.
  558. //
  559. ULONG XContextFlags;
  560. //
  561. // This section is specified/returned if the ContextFlags contains
  562. // the flag CONTEXT_EXTENDED_INTEGER.
  563. //
  564. // N.B. The registers gp, sp, and ra are defined in this section,
  565. // but are considered part of the control context rather than
  566. // part of the integer context.
  567. //
  568. // N.B. Register zero is not stored in the frame.
  569. //
  570. ULONGLONG XIntZero;
  571. ULONGLONG XIntAt;
  572. ULONGLONG XIntV0;
  573. ULONGLONG XIntV1;
  574. ULONGLONG XIntA0;
  575. ULONGLONG XIntA1;
  576. ULONGLONG XIntA2;
  577. ULONGLONG XIntA3;
  578. ULONGLONG XIntT0;
  579. ULONGLONG XIntT1;
  580. ULONGLONG XIntT2;
  581. ULONGLONG XIntT3;
  582. ULONGLONG XIntT4;
  583. ULONGLONG XIntT5;
  584. ULONGLONG XIntT6;
  585. ULONGLONG XIntT7;
  586. ULONGLONG XIntS0;
  587. ULONGLONG XIntS1;
  588. ULONGLONG XIntS2;
  589. ULONGLONG XIntS3;
  590. ULONGLONG XIntS4;
  591. ULONGLONG XIntS5;
  592. ULONGLONG XIntS6;
  593. ULONGLONG XIntS7;
  594. ULONGLONG XIntT8;
  595. ULONGLONG XIntT9;
  596. ULONGLONG XIntK0;
  597. ULONGLONG XIntK1;
  598. ULONGLONG XIntGp;
  599. ULONGLONG XIntSp;
  600. ULONGLONG XIntS8;
  601. ULONGLONG XIntRa;
  602. ULONGLONG XIntLo;
  603. ULONGLONG XIntHi;
  604. };
  605. };
  606. } CONTEXT, *PCONTEXT;
  607. // end_ntddk end_nthal
  608. #define CONTEXT32_LENGTH 0x130 // The original 32-bit Context length (pre NT 4.0)
  609. #endif // MIPS
  610. // end_winnt
  611. #define CONTEXT_TO_PROGRAM_COUNTER(Context) ((Context)->Fir)
  612. #define CONTEXT_LENGTH (sizeof(CONTEXT))
  613. #define CONTEXT_ALIGN (sizeof(double))
  614. #define CONTEXT_ROUND (CONTEXT_ALIGN - 1)
  615. //
  616. // Nonvolatile context pointer record.
  617. //
  618. typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
  619. PULONG FloatingContext[20];
  620. PULONG FltF20;
  621. PULONG FltF21;
  622. PULONG FltF22;
  623. PULONG FltF23;
  624. PULONG FltF24;
  625. PULONG FltF25;
  626. PULONG FltF26;
  627. PULONG FltF27;
  628. PULONG FltF28;
  629. PULONG FltF29;
  630. PULONG FltF30;
  631. PULONG FltF31;
  632. PULONGLONG XIntegerContext[16];
  633. PULONGLONG XIntS0;
  634. PULONGLONG XIntS1;
  635. PULONGLONG XIntS2;
  636. PULONGLONG XIntS3;
  637. PULONGLONG XIntS4;
  638. PULONGLONG XIntS5;
  639. PULONGLONG XIntS6;
  640. PULONGLONG XIntS7;
  641. PULONGLONG XIntT8;
  642. PULONGLONG XIntT9;
  643. PULONGLONG XIntK0;
  644. PULONGLONG XIntK1;
  645. PULONGLONG XIntGp;
  646. PULONGLONG XIntSp;
  647. PULONGLONG XIntS8;
  648. PULONGLONG XIntRa;
  649. } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
  650. // begin_nthal
  651. //
  652. // Define R4000 system coprocessor registers.
  653. //
  654. // Define index register fields.
  655. //
  656. typedef struct _INDEX {
  657. ULONG INDEX : 6;
  658. ULONG X1 : 25;
  659. ULONG P : 1;
  660. } INDEX;
  661. //
  662. // Define random register fields.
  663. //
  664. typedef struct _RANDOM {
  665. ULONG INDEX : 6;
  666. ULONG X1 : 26;
  667. } RANDOM;
  668. //
  669. // Define TB entry low register fields.
  670. //
  671. typedef struct _ENTRYLO {
  672. ULONG G : 1;
  673. ULONG V : 1;
  674. ULONG D : 1;
  675. ULONG C : 3;
  676. ULONG PFN : 24;
  677. ULONG X1 : 2;
  678. } ENTRYLO, *PENTRYLO;
  679. //
  680. // Define R4000 PTE format for memory management.
  681. //
  682. // N.B. This must map exactly over the entrylo register.
  683. //
  684. typedef struct _HARDWARE_PTE {
  685. ULONG Global : 1;
  686. ULONG Valid : 1;
  687. ULONG Dirty : 1;
  688. ULONG CachePolicy : 3;
  689. ULONG PageFrameNumber : 24;
  690. ULONG Write : 1;
  691. ULONG CopyOnWrite : 1;
  692. } HARDWARE_PTE, *PHARDWARE_PTE;
  693. #define HARDWARE_PTE_DIRTY_MASK 0x4
  694. //
  695. // Define R4000 macro to initialize page directory table base.
  696. //
  697. #define INITIALIZE_DIRECTORY_TABLE_BASE(dirbase, pfn) \
  698. ((HARDWARE_PTE *)(dirbase))->PageFrameNumber = pfn; \
  699. ((HARDWARE_PTE *)(dirbase))->Global = 0; \
  700. ((HARDWARE_PTE *)(dirbase))->Valid = 1; \
  701. ((HARDWARE_PTE *)(dirbase))->Dirty = 1; \
  702. ((HARDWARE_PTE *)(dirbase))->CachePolicy = PCR->CachePolicy
  703. //
  704. // Define page mask register fields.
  705. //
  706. typedef struct _PAGEMASK {
  707. ULONG X1 : 13;
  708. ULONG PAGEMASK : 12;
  709. ULONG X2 : 7;
  710. } PAGEMASK, *PPAGEMASK;
  711. //
  712. // Define wired register fields.
  713. //
  714. typedef struct _WIRED {
  715. ULONG NUMBER : 6;
  716. ULONG X1 : 26;
  717. } WIRED;
  718. //
  719. // Define TB entry high register fields.
  720. //
  721. typedef struct _ENTRYHI {
  722. ULONG PID : 8;
  723. ULONG X1 : 5;
  724. ULONG VPN2 : 19;
  725. } ENTRYHI, *PENTRYHI;
  726. //
  727. // Define processor status register fields.
  728. //
  729. typedef struct _PSR {
  730. ULONG IE : 1;
  731. ULONG EXL : 1;
  732. ULONG ERL : 1;
  733. ULONG KSU : 2;
  734. ULONG UX : 1;
  735. ULONG SX : 1;
  736. ULONG KX : 1;
  737. ULONG INTMASK : 8;
  738. ULONG DE : 1;
  739. ULONG CE : 1;
  740. ULONG CH : 1;
  741. ULONG X1 : 1;
  742. ULONG SR : 1;
  743. ULONG TS : 1;
  744. ULONG BEV : 1;
  745. ULONG X2 : 2;
  746. ULONG RE : 1;
  747. ULONG FR : 1;
  748. ULONG RP : 1;
  749. ULONG CU0 : 1;
  750. ULONG CU1 : 1;
  751. ULONG CU2 : 1;
  752. ULONG CU3 : 1;
  753. } PSR, *PPSR;
  754. //
  755. // Define configuration register fields.
  756. //
  757. typedef struct _CONFIGR {
  758. ULONG K0 : 3;
  759. ULONG CU : 1;
  760. ULONG DB : 1;
  761. ULONG IB : 1;
  762. ULONG DC : 3;
  763. ULONG IC : 3;
  764. ULONG X1 : 1;
  765. ULONG EB : 1;
  766. ULONG EM : 1;
  767. ULONG BE : 1;
  768. ULONG SM : 1;
  769. ULONG SC : 1;
  770. ULONG EW : 2;
  771. ULONG SW : 1;
  772. ULONG SS : 1;
  773. ULONG SB : 2;
  774. ULONG EP : 4;
  775. ULONG EC : 3;
  776. ULONG CM : 1;
  777. } CONFIGR;
  778. //
  779. // Define ECC register fields.
  780. //
  781. typedef struct _ECC {
  782. ULONG ECC : 8;
  783. ULONG X1 : 24;
  784. } ECC;
  785. //
  786. // Define cache error register fields.
  787. //
  788. typedef struct _CACHEERR {
  789. ULONG PIDX : 3;
  790. ULONG SIDX : 19;
  791. ULONG X1 : 2;
  792. ULONG EI : 1;
  793. ULONG EB : 1;
  794. ULONG EE : 1;
  795. ULONG ES : 1;
  796. ULONG ET : 1;
  797. ULONG ED : 1;
  798. ULONG EC : 1;
  799. ULONG ER : 1;
  800. } CACHEERR;
  801. //
  802. // Define R4000 cause register fields.
  803. //
  804. typedef struct _CAUSE {
  805. ULONG X1 : 2;
  806. ULONG XCODE : 5;
  807. ULONG X2 : 1;
  808. ULONG INTPEND : 8;
  809. ULONG X3 : 12;
  810. ULONG CE : 2;
  811. ULONG X4 : 1;
  812. ULONG BD : 1;
  813. } CAUSE;
  814. //
  815. // Define R4000 processor id register fields.
  816. //
  817. typedef struct _PRID {
  818. ULONG REV : 8;
  819. ULONG IMP : 8;
  820. ULONG X1 : 16;
  821. } PRID;
  822. // end_nthal
  823. // begin_nthal
  824. //
  825. // Define R4000 floating status register field definitions.
  826. //
  827. typedef struct _FSR {
  828. ULONG RM : 2;
  829. ULONG SI : 1;
  830. ULONG SU : 1;
  831. ULONG SO : 1;
  832. ULONG SZ : 1;
  833. ULONG SV : 1;
  834. ULONG EI : 1;
  835. ULONG EU : 1;
  836. ULONG EO : 1;
  837. ULONG EZ : 1;
  838. ULONG EV : 1;
  839. ULONG XI : 1;
  840. ULONG XU : 1;
  841. ULONG XO : 1;
  842. ULONG XZ : 1;
  843. ULONG XV : 1;
  844. ULONG XE : 1;
  845. ULONG X1 : 5;
  846. ULONG CC : 1;
  847. ULONG FS : 1;
  848. ULONG X2 : 7;
  849. } FSR, *PFSR;
  850. // end_nthal
  851. // begin_nthal
  852. //
  853. // Define address space layout as defined by MIPS memory management.
  854. //
  855. #define KUSEG_BASE 0x0 // base of user segment
  856. #define KSEG0_BASE 0x80000000 // 32-bit base of cached kernel physical
  857. #define KSEG0_BASE64 0xffffffff80000000 // 64-bit base of cached kernel physical
  858. #define KSEG1_BASE 0xa0000000 // 32-bit base of uncached kernel physical
  859. #define KSEG1_BASE64 0xffffffffa0000000 // 64-bit base of uncached kernel physical
  860. #define KSEG2_BASE 0xc0000000 // 32-bit base of cached kernel virtual
  861. #define KSEG2_BASE64 0xffffffffc0000000 // 64-bit base of cached kernel virtual
  862. // end_nthal
  863. //
  864. // Define MIPS exception handling structures and function prototypes.
  865. //
  866. // Function table entry structure definition.
  867. //
  868. typedef struct _RUNTIME_FUNCTION {
  869. ULONG BeginAddress;
  870. ULONG EndAddress;
  871. PEXCEPTION_ROUTINE ExceptionHandler;
  872. PVOID HandlerData;
  873. ULONG PrologEndAddress;
  874. } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
  875. //
  876. // Scope table structure definition.
  877. //
  878. typedef struct _SCOPE_TABLE {
  879. ULONG Count;
  880. struct {
  881. ULONG BeginAddress;
  882. ULONG EndAddress;
  883. ULONG HandlerAddress;
  884. ULONG JumpTarget;
  885. } ScopeRecord[1];
  886. } SCOPE_TABLE, *PSCOPE_TABLE;
  887. //
  888. // Runtime Library function prototypes.
  889. //
  890. VOID
  891. RtlCaptureContext (
  892. OUT PCONTEXT ContextRecord
  893. );
  894. PRUNTIME_FUNCTION
  895. RtlLookupFunctionEntry (
  896. IN ULONG ControlPc
  897. );
  898. ULONG
  899. RtlVirtualUnwind (
  900. IN ULONG ControlPc,
  901. IN PRUNTIME_FUNCTION FunctionEntry,
  902. IN OUT PCONTEXT ContextRecord,
  903. OUT PBOOLEAN InFunction,
  904. OUT PULONG EstablisherFrame,
  905. IN OUT PKNONVOLATILE_CONTEXT_POINTERS ContextPointers OPTIONAL
  906. );
  907. //
  908. // Define C structured exception handing function prototypes.
  909. //
  910. typedef struct _DISPATCHER_CONTEXT {
  911. ULONG ControlPc;
  912. PRUNTIME_FUNCTION FunctionEntry;
  913. ULONG EstablisherFrame;
  914. PCONTEXT ContextRecord;
  915. } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
  916. struct _EXCEPTION_POINTERS;
  917. typedef
  918. LONG
  919. (*EXCEPTION_FILTER) (
  920. struct _EXCEPTION_POINTERS *ExceptionPointers
  921. );
  922. typedef
  923. VOID
  924. (*TERMINATION_HANDLER) (
  925. BOOLEAN is_abnormal
  926. );
  927. // begin_winnt
  928. #if defined(_MIPS_)
  929. VOID
  930. __jump_unwind (
  931. PVOID Fp,
  932. PVOID TargetPc
  933. );
  934. #endif // MIPS
  935. // end_winnt
  936. // begin_ntddk begin_wdm begin_nthal
  937. #endif // defined(_MIPS_)
  938. // end_ntddk end_wdm end_nthal
  939. #ifdef __cplusplus
  940. }
  941. #endif
  942. #endif // _NTMIPS_