Leaked source code of windows server 2003
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.

1614 lines
22 KiB

  1. /*++ BUILD Version: 0000 // Increment this if a change has global effects
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. emulate.h
  5. Abstract:
  6. This module contains the private header file for the x86 bios
  7. emulation.
  8. Author:
  9. David N. Cutler (davec) 2-Sep-1994
  10. Revision History:
  11. --*/
  12. #ifndef _EMULATE_
  13. #define _EMULATE_
  14. #include "setjmp.h"
  15. #include "xm86.h"
  16. #include "x86new.h"
  17. //
  18. // Define debug tracing flags.
  19. //
  20. //#define XM_DEBUG 1 // ****** temp ******
  21. #define TRACE_INSTRUCTIONS 0x1
  22. #define TRACE_OPERANDS 0x2
  23. #define TRACE_GENERAL_REGISTERS 0x4
  24. #define TRACE_OVERRIDE 0x8
  25. #define TRACE_JUMPS 0x10
  26. #define TRACE_SPECIFIERS 0x20
  27. #define TRACE_SINGLE_STEP 0x40
  28. //
  29. // Define opcode function table indexes.
  30. //
  31. // N.B. This values must correspond exactly one for one with the function
  32. // table entries. If the C language had indexed initializers this
  33. // type would not be necessary.
  34. //
  35. typedef enum _XM_FUNCTION_TABLE_INDEX {
  36. //
  37. // ASCII operators.
  38. //
  39. X86_AAA_OP,
  40. X86_AAD_OP,
  41. X86_AAM_OP,
  42. X86_AAS_OP,
  43. X86_DAA_OP,
  44. X86_DAS_OP,
  45. //
  46. // Group 1 operators.
  47. //
  48. X86_ADD_OP,
  49. X86_OR_OP,
  50. X86_ADC_OP,
  51. X86_SBB_OP,
  52. X86_AND_OP,
  53. X86_SUB_OP,
  54. X86_XOR_OP,
  55. X86_CMP_OP,
  56. //
  57. // Group 2 operators.
  58. //
  59. X86_ROL_OP,
  60. X86_ROR_OP,
  61. X86_RCL_OP,
  62. X86_RCR_OP,
  63. X86_SHL_OP,
  64. X86_SHR_OP,
  65. X86_FILL0_OP,
  66. X86_SAR_OP,
  67. //
  68. // Group 3 operators.
  69. //
  70. X86_TEST_OP,
  71. X86_FILL1_OP,
  72. X86_NOT_OP,
  73. X86_NEG_OP,
  74. X86_MUL_OP,
  75. X86_IMULX_OP,
  76. X86_DIV_OP,
  77. X86_IDIV_OP,
  78. //
  79. // Group 4 and 5 operators.
  80. //
  81. X86_INC_OP,
  82. X86_DEC_OP,
  83. X86_CALL_OP,
  84. X86_FILL2_OP,
  85. X86_JMP_OP,
  86. X86_FILL3_OP,
  87. X86_PUSH_OP,
  88. X86_FILL4_OP,
  89. //
  90. // Group 8 operators.
  91. //
  92. X86_BT_OP,
  93. X86_BTS_OP,
  94. X86_BTR_OP,
  95. X86_BTC_OP,
  96. //
  97. // Stack push and pop operators.
  98. //
  99. X86_POP_OP,
  100. X86_PUSHA_OP,
  101. X86_POPA_OP,
  102. //
  103. // Jump operators.
  104. //
  105. X86_JXX_OP,
  106. X86_LOOP_OP,
  107. X86_JCXZ_OP,
  108. //
  109. // Control operators.
  110. //
  111. X86_ENTER_OP,
  112. X86_HLT_OP,
  113. X86_INT_OP,
  114. X86_IRET_OP,
  115. X86_LEAVE_OP,
  116. X86_RET_OP,
  117. //
  118. // Set boolean byte value based on condition.
  119. //
  120. X86_SXX_OP,
  121. //
  122. // Condition code operators.
  123. //
  124. X86_CMC_OP,
  125. X86_CLC_OP,
  126. X86_STC_OP,
  127. X86_CLI_OP,
  128. X86_STI_OP,
  129. X86_CLD_OP,
  130. X86_STD_OP,
  131. X86_LAHF_OP,
  132. X86_SAHF_OP,
  133. //
  134. // General move operators.
  135. //
  136. X86_MOV_OP,
  137. X86_XCHG_OP,
  138. //
  139. // Convert operations.
  140. //
  141. X86_CBW_OP,
  142. X86_CWD_OP,
  143. //
  144. // Single multiply operator.
  145. //
  146. X86_IMUL_OP,
  147. //
  148. // String operators.
  149. //
  150. X86_CMPS_OP,
  151. X86_INS_OP,
  152. X86_LODS_OP,
  153. X86_MOVS_OP,
  154. X86_OUTS_OP,
  155. X86_SCAS_OP,
  156. X86_STOS_OP,
  157. //
  158. // Effective address operators.
  159. //
  160. X86_BOUND_OP,
  161. X86_LEA_OP,
  162. //
  163. // Double shift operators.
  164. //
  165. X86_SHLD_OP,
  166. X86_SHRD_OP,
  167. //
  168. // I/O operators.
  169. //
  170. X86_IN_OP,
  171. X86_OUT_OP,
  172. //
  173. // Bit scan operators.
  174. //
  175. X86_BSF_OP,
  176. X86_BSR_OP,
  177. //
  178. // Byte swap operators.
  179. //
  180. X86_BSWAP_OP,
  181. //
  182. // Add/compare and exchange operators.
  183. //
  184. X86_XADD_OP,
  185. X86_CMPXCHG_OP,
  186. //
  187. // No operation.
  188. //
  189. X86_NOP_OP,
  190. //
  191. // Illegal opcode.
  192. //
  193. X86_ILL_OP,
  194. X86_MAXIMUM_INDEX
  195. } XM_FUNCTION_TABLE_INDEX;
  196. //
  197. // Define 8-bit register numbers.
  198. //
  199. typedef enum _X86_8BIT_REGISTER {
  200. AL,
  201. CL,
  202. DL,
  203. BL,
  204. AH,
  205. CH,
  206. DH,
  207. BH
  208. } X86_8BIT_REGISTER;
  209. //
  210. // Define 16-bit register numbers.
  211. //
  212. typedef enum _X86_16BIT_REGISTER {
  213. AX,
  214. CX,
  215. DX,
  216. BX,
  217. SP,
  218. BP,
  219. SI,
  220. DI
  221. } X86_16BIT_REGISTER;
  222. //
  223. // Define 32-bit register numbers.
  224. //
  225. typedef enum _X86_32BIT_REGISTER {
  226. EAX,
  227. ECX,
  228. EDX,
  229. EBX,
  230. ESP,
  231. EBP,
  232. ESI,
  233. EDI
  234. } X86_32BIT_REGISTER;
  235. //
  236. // Define general register structure.
  237. //
  238. typedef union _X86_GENERAL_REGISTER {
  239. ULONG Exx;
  240. union {
  241. USHORT Xx;
  242. struct {
  243. UCHAR Xl;
  244. UCHAR Xh;
  245. };
  246. };
  247. } X86_GENERAL_REGISTER, *PX86_GENERAL_REGISTER;
  248. //
  249. // Define segment register numbers.
  250. //
  251. typedef enum _X86_SEGMENT_REGISTER {
  252. ES,
  253. CS,
  254. SS,
  255. DS,
  256. FS,
  257. GS
  258. } X86_SEGMENT_REGISTER;
  259. //
  260. // Define instruction format types.
  261. //
  262. typedef enum _XM_FORMAT_TYPE {
  263. //
  264. // N.B. These format codes MUST be the first codes and MUST be
  265. // exactly in this order since the ordering corresponds to
  266. // segment numbers.
  267. //
  268. FormatSegmentES,
  269. FormatSegmentCS,
  270. FormatSegmentSS,
  271. FormatSegmentDS,
  272. FormatSegmentFS,
  273. FormatSegmentGS,
  274. //
  275. // N.B. These format codes MUST be the second codes and MUST be
  276. // exactly in this order since the ordering corresponds to
  277. // biased segment number. The entry for the code segment is
  278. // a dummy entry to make the indexing work right.
  279. //
  280. FormatLoadSegmentES,
  281. FormatLoadSegmentCS,
  282. FormatLoadSegmentSS,
  283. FormatLoadSegmentDS,
  284. FormatLoadSegmentFS,
  285. FormatLoadSegmentGS,
  286. //
  287. // The following codes can be in any order.
  288. //
  289. FormatGroup1General,
  290. FormatGroup1Immediate,
  291. FormatGroup2By1,
  292. FormatGroup2ByCL,
  293. FormatGroup2ByByte,
  294. FormatGroup3General,
  295. FormatGroup4General,
  296. FormatGroup5General,
  297. FormatGroup8BitOffset,
  298. FormatOpcodeRegister,
  299. FormatLongJump,
  300. FormatShortJump,
  301. FormatSetccByte,
  302. FormatAccumImmediate,
  303. FormatAccumRegister,
  304. FormatMoveGeneral,
  305. FormatMoveImmediate,
  306. FormatMoveRegImmediate,
  307. FormatSegmentOffset,
  308. FormatMoveSegment,
  309. FormatMoveXxGeneral,
  310. FormatFlagsRegister,
  311. FormatPushImmediate,
  312. FormatPopGeneral,
  313. FormatImulImmediate,
  314. FormatStringOperands,
  315. FormatEffectiveOffset,
  316. FormatImmediateJump,
  317. FormatImmediateEnter,
  318. FormatGeneralBitOffset,
  319. FormatShiftDouble,
  320. FormatPortImmediate,
  321. FormatPortDX,
  322. FormatBitScanGeneral,
  323. FormatByteImmediate,
  324. FormatXlatOpcode,
  325. FormatGeneralRegister,
  326. FormatNoOperands,
  327. FormatOpcodeEscape,
  328. FormatPrefixOpcode
  329. } XM_FORMAT_TYPE;
  330. //
  331. // Defined opcode modifier bit masks.
  332. //
  333. #define WIDTH_BIT 0x1 // operand size control
  334. #define DIRECTION_BIT 0x2 // direction of operation
  335. #define SIGN_BIT 0x2 // sign extended byte
  336. //
  337. // Define prefix opcode function index values.
  338. //
  339. typedef enum _XM_PREFIX_FUNCTION_INDEX {
  340. X86_ES_OP = ES,
  341. X86_CS_OP = CS,
  342. X86_SS_OP = SS,
  343. X86_DS_OP = DS,
  344. X86_FS_OP = FS,
  345. X86_GS_OP = GS,
  346. X86_LOCK_OP,
  347. X86_ADSZ_OP,
  348. X86_OPSZ_OP,
  349. X86_REPZ_OP,
  350. X86_REPNZ_OP
  351. } XM_PREFIX_FUNCTION_INDEX;
  352. //
  353. // Define two byte opcode escape.
  354. //
  355. #define TWO_BYTE_ESCAPE 0x0f
  356. //
  357. // Define opcode control table structure.
  358. //
  359. // This table controls the decoding of instructions and there operands.
  360. //
  361. typedef struct _OPCODE_CONTROL {
  362. UCHAR FunctionIndex;
  363. UCHAR FormatType;
  364. } OPCODE_CONTROL, *POPCODE_CONTROL;
  365. //
  366. // Define emulator context structure.
  367. //
  368. // This structure holds the global emulator state.
  369. //
  370. typedef struct _XM_CONTEXT {
  371. //
  372. // Pointers to the opcode control table and the opcode name table.
  373. //
  374. const OPCODE_CONTROL *OpcodeControlTable;
  375. const CHAR **OpcodeNameTable;
  376. //
  377. // x86 extended flags register.
  378. //
  379. union {
  380. UCHAR AhFlags;
  381. USHORT Flags;
  382. ULONG AllFlags;
  383. struct {
  384. ULONG EFLAG_CF : 1;
  385. ULONG EFLAG_MBO : 1;
  386. ULONG EFLAG_PF : 1;
  387. ULONG EFLAG_SBZ0 : 1;
  388. ULONG EFLAG_AF : 1;
  389. ULONG EFLAG_SBZ1 : 1;
  390. ULONG EFLAG_ZF : 1;
  391. ULONG EFLAG_SF : 1;
  392. ULONG EFLAG_TF : 1;
  393. ULONG EFLAG_IF : 1;
  394. ULONG EFLAG_DF : 1;
  395. ULONG EFLAG_OF : 1;
  396. ULONG EFLAG_IOPL : 2;
  397. ULONG EFLAG_NT : 1;
  398. ULONG EFLAG_SBZ2 : 1;
  399. ULONG EFLAG_RF : 1;
  400. ULONG EFLAG_VM : 1;
  401. ULONG EFLAG_AC : 1;
  402. ULONG EFLAG_SBZ3 : 13;
  403. } Eflags;
  404. };
  405. //
  406. // x86 instruction pointer.
  407. //
  408. union {
  409. USHORT Ip;
  410. ULONG Eip;
  411. };
  412. //
  413. // x86 general registers.
  414. //
  415. X86_GENERAL_REGISTER Gpr[8];
  416. //
  417. // x86 segment registers.
  418. //
  419. USHORT SegmentRegister[6];
  420. //
  421. // Emulator segment descriptors.
  422. //
  423. USHORT SegmentLimit[6];
  424. //
  425. // Instruction opcode control information read from the opcode
  426. // control table.
  427. //
  428. OPCODE_CONTROL OpcodeControl;
  429. //
  430. // Call or jmp destination segment segment.
  431. //
  432. USHORT DstSegment;
  433. //
  434. // Source and destination address and value.
  435. //
  436. union {
  437. UCHAR UNALIGNED *DstByte;
  438. USHORT UNALIGNED *DstWord;
  439. ULONG UNALIGNED *DstLong;
  440. };
  441. union {
  442. UCHAR UNALIGNED *SrcByte;
  443. USHORT UNALIGNED *SrcWord;
  444. ULONG UNALIGNED *SrcLong;
  445. };
  446. union {
  447. UCHAR Byte;
  448. ULONG Long;
  449. USHORT Word;
  450. } DstValue;
  451. union {
  452. UCHAR Byte;
  453. ULONG Long;
  454. USHORT Word;
  455. } SrcValue;
  456. //
  457. // Current opcode, data segment register to be used to access
  458. // data operands, function index, and operand data type, and
  459. // effective address offset.
  460. //
  461. ULONG CurrentOpcode;
  462. ULONG DataSegment;
  463. ULONG DataType;
  464. ULONG FunctionIndex;
  465. ULONG Offset;
  466. //
  467. // Prefix control information.
  468. //
  469. BOOLEAN LockPrefixActive;
  470. BOOLEAN OpaddrPrefixActive;
  471. BOOLEAN OpsizePrefixActive;
  472. BOOLEAN RepeatPrefixActive;
  473. BOOLEAN SegmentPrefixActive;
  474. UCHAR RepeatZflag;
  475. //
  476. // Effective address computation control.
  477. //
  478. BOOLEAN RegisterOffsetAddress;
  479. BOOLEAN ComputeOffsetAddress;
  480. //
  481. // Shift count.
  482. //
  483. UCHAR Shift;
  484. //
  485. // Jump buffer.
  486. //
  487. _JBTYPE JumpBuffer[_JBLEN];
  488. //
  489. // Address of read I/O space, write I/O space, and translation address
  490. // routines.
  491. //
  492. PXM_READ_IO_SPACE ReadIoSpace;
  493. PXM_WRITE_IO_SPACE WriteIoSpace;
  494. PXM_TRANSLATE_ADDRESS TranslateAddress;
  495. } XM_CONTEXT, *PXM_CONTEXT, *RESTRICTED_POINTER PRXM_CONTEXT;
  496. //
  497. // Define opcode function and decode operand types.
  498. //
  499. typedef
  500. ULONG
  501. (*POPERAND_DECODE) (
  502. IN PRXM_CONTEXT P
  503. );
  504. typedef
  505. VOID
  506. (*POPCODE_FUNCTION) (
  507. IN PRXM_CONTEXT P
  508. );
  509. //
  510. // Operand decode prototypes.
  511. //
  512. ULONG
  513. XmPushPopSegment (
  514. IN PRXM_CONTEXT P
  515. );
  516. ULONG
  517. XmLoadSegment (
  518. IN PRXM_CONTEXT P
  519. );
  520. ULONG
  521. XmGroup1General (
  522. IN PRXM_CONTEXT P
  523. );
  524. ULONG
  525. XmGroup1Immediate (
  526. IN PRXM_CONTEXT P
  527. );
  528. ULONG
  529. XmGroup2By1 (
  530. IN PRXM_CONTEXT P
  531. );
  532. ULONG
  533. XmGroup2ByCL (
  534. IN PRXM_CONTEXT P
  535. );
  536. ULONG
  537. XmGroup2ByByte (
  538. IN PRXM_CONTEXT P
  539. );
  540. ULONG
  541. XmGroup3General (
  542. IN PRXM_CONTEXT P
  543. );
  544. ULONG
  545. XmGroup45General (
  546. IN PRXM_CONTEXT P
  547. );
  548. ULONG
  549. XmGroup8BitOffset (
  550. IN PRXM_CONTEXT P
  551. );
  552. ULONG
  553. XmOpcodeRegister (
  554. IN PRXM_CONTEXT P
  555. );
  556. ULONG
  557. XmLongJump (
  558. IN PRXM_CONTEXT P
  559. );
  560. ULONG
  561. XmShortJump (
  562. IN PRXM_CONTEXT P
  563. );
  564. ULONG
  565. XmSetccByte (
  566. IN PRXM_CONTEXT P
  567. );
  568. ULONG
  569. XmAccumImmediate (
  570. IN PRXM_CONTEXT P
  571. );
  572. ULONG
  573. XmAccumRegister (
  574. IN PRXM_CONTEXT P
  575. );
  576. ULONG
  577. XmMoveGeneral (
  578. IN PRXM_CONTEXT P
  579. );
  580. ULONG
  581. XmMoveImmediate (
  582. IN PRXM_CONTEXT P
  583. );
  584. ULONG
  585. XmMoveRegImmediate (
  586. IN PRXM_CONTEXT P
  587. );
  588. ULONG
  589. XmSegmentOffset (
  590. IN PRXM_CONTEXT P
  591. );
  592. ULONG
  593. XmMoveSegment (
  594. IN PRXM_CONTEXT P
  595. );
  596. ULONG
  597. XmMoveXxGeneral (
  598. IN PRXM_CONTEXT P
  599. );
  600. ULONG
  601. XmFlagsRegister (
  602. IN PRXM_CONTEXT P
  603. );
  604. ULONG
  605. XmPushImmediate (
  606. IN PRXM_CONTEXT P
  607. );
  608. ULONG
  609. XmPopGeneral (
  610. IN PRXM_CONTEXT P
  611. );
  612. ULONG
  613. XmImulImmediate (
  614. IN PRXM_CONTEXT P
  615. );
  616. ULONG
  617. XmStringOperands (
  618. IN PRXM_CONTEXT P
  619. );
  620. ULONG
  621. XmEffectiveOffset (
  622. IN PRXM_CONTEXT P
  623. );
  624. ULONG
  625. XmImmediateJump (
  626. IN PRXM_CONTEXT P
  627. );
  628. ULONG
  629. XmImmediateEnter (
  630. IN PRXM_CONTEXT P
  631. );
  632. ULONG
  633. XmGeneralBitOffset (
  634. IN PRXM_CONTEXT P
  635. );
  636. ULONG
  637. XmShiftDouble (
  638. IN PRXM_CONTEXT P
  639. );
  640. ULONG
  641. XmPortImmediate (
  642. IN PRXM_CONTEXT P
  643. );
  644. ULONG
  645. XmPortDX (
  646. IN PRXM_CONTEXT P
  647. );
  648. ULONG
  649. XmBitScanGeneral (
  650. IN PRXM_CONTEXT P
  651. );
  652. ULONG
  653. XmByteImmediate (
  654. IN PRXM_CONTEXT P
  655. );
  656. ULONG
  657. XmXlatOpcode (
  658. IN PRXM_CONTEXT P
  659. );
  660. ULONG
  661. XmGeneralRegister (
  662. IN PRXM_CONTEXT P
  663. );
  664. ULONG
  665. XmOpcodeEscape (
  666. IN PRXM_CONTEXT P
  667. );
  668. ULONG
  669. XmPrefixOpcode (
  670. IN PRXM_CONTEXT P
  671. );
  672. ULONG
  673. XmNoOperands (
  674. IN PRXM_CONTEXT P
  675. );
  676. //
  677. // Define miscellaneous prototypes.
  678. //
  679. ULONG
  680. XmComputeParity (
  681. IN ULONG Result
  682. );
  683. XM_STATUS
  684. XmEmulateStream (
  685. IN PRXM_CONTEXT P,
  686. USHORT Segment,
  687. USHORT Offset,
  688. PXM86_CONTEXT Context
  689. );
  690. UCHAR
  691. XmGetCodeByte (
  692. IN PRXM_CONTEXT P
  693. );
  694. UCHAR
  695. XmGetByteImmediate (
  696. IN PRXM_CONTEXT P
  697. );
  698. USHORT
  699. XmGetByteImmediateToWord (
  700. IN PRXM_CONTEXT P
  701. );
  702. ULONG
  703. XmGetByteImmediateToLong (
  704. IN PRXM_CONTEXT P
  705. );
  706. USHORT
  707. XmGetSignedByteImmediateToWord (
  708. IN PRXM_CONTEXT P
  709. );
  710. ULONG
  711. XmGetSignedByteImmediateToLong (
  712. IN PRXM_CONTEXT P
  713. );
  714. USHORT
  715. XmGetWordImmediate (
  716. IN PRXM_CONTEXT P
  717. );
  718. ULONG
  719. XmGetLongImmediate (
  720. IN PRXM_CONTEXT P
  721. );
  722. ULONG
  723. XmPopStack (
  724. IN PRXM_CONTEXT P
  725. );
  726. VOID
  727. XmPushStack (
  728. IN PRXM_CONTEXT P,
  729. IN ULONG Value
  730. );
  731. VOID
  732. XmSetDataType (
  733. IN PRXM_CONTEXT P
  734. );
  735. VOID
  736. XmStoreResult (
  737. IN PRXM_CONTEXT P,
  738. IN ULONG Result
  739. );
  740. //
  741. // Define operand specifier prototypes.
  742. //
  743. PVOID
  744. XmEvaluateAddressSpecifier (
  745. IN PRXM_CONTEXT P,
  746. OUT PLONG Register
  747. );
  748. PVOID
  749. XmGetOffsetAddress (
  750. IN PRXM_CONTEXT P,
  751. IN ULONG Offset
  752. );
  753. PVOID
  754. XmGetRegisterAddress (
  755. IN PRXM_CONTEXT P,
  756. IN ULONG Number
  757. );
  758. PVOID
  759. XmGetStringAddress (
  760. IN PRXM_CONTEXT P,
  761. IN ULONG Segment,
  762. IN ULONG Register
  763. );
  764. VOID
  765. XmSetDestinationValue (
  766. IN PRXM_CONTEXT P,
  767. IN PVOID Destination
  768. );
  769. VOID
  770. XmSetSourceValue (
  771. IN PRXM_CONTEXT P,
  772. IN PVOID Source
  773. );
  774. ULONG
  775. XmGetImmediateSourceValue (
  776. IN PRXM_CONTEXT P,
  777. IN ULONG ByteFlag
  778. );
  779. VOID
  780. XmSetImmediateSourceValue (
  781. IN PRXM_CONTEXT P,
  782. IN ULONG Source
  783. );
  784. //
  785. // ASCII operators.
  786. //
  787. VOID
  788. XmAaaOp (
  789. IN PRXM_CONTEXT P
  790. );
  791. VOID
  792. XmAadOp (
  793. IN PRXM_CONTEXT P
  794. );
  795. VOID
  796. XmAamOp (
  797. IN PRXM_CONTEXT P
  798. );
  799. VOID
  800. XmAasOp (
  801. IN PRXM_CONTEXT P
  802. );
  803. VOID
  804. XmDaaOp (
  805. IN PRXM_CONTEXT P
  806. );
  807. VOID
  808. XmDasOp (
  809. IN PRXM_CONTEXT P
  810. );
  811. //
  812. // Group 1 operations.
  813. //
  814. VOID
  815. XmAddOp (
  816. IN PRXM_CONTEXT P
  817. );
  818. VOID
  819. XmOrOp (
  820. IN PRXM_CONTEXT P
  821. );
  822. VOID
  823. XmAdcOp (
  824. IN PRXM_CONTEXT P
  825. );
  826. VOID
  827. XmSbbOp (
  828. IN PRXM_CONTEXT P
  829. );
  830. VOID
  831. XmAndOp (
  832. IN PRXM_CONTEXT P
  833. );
  834. VOID
  835. XmSubOp (
  836. IN PRXM_CONTEXT P
  837. );
  838. VOID
  839. XmXorOp (
  840. IN PRXM_CONTEXT P
  841. );
  842. VOID
  843. XmCmpOp (
  844. IN PRXM_CONTEXT P
  845. );
  846. //
  847. // Group 2 operations.
  848. //
  849. VOID
  850. XmRolOp (
  851. IN PRXM_CONTEXT P
  852. );
  853. VOID
  854. XmRorOp (
  855. IN PRXM_CONTEXT P
  856. );
  857. VOID
  858. XmRclOp (
  859. IN PRXM_CONTEXT P
  860. );
  861. VOID
  862. XmRcrOp (
  863. IN PRXM_CONTEXT P
  864. );
  865. VOID
  866. XmShlOp (
  867. IN PRXM_CONTEXT P
  868. );
  869. VOID
  870. XmShrOp (
  871. IN PRXM_CONTEXT P
  872. );
  873. VOID
  874. XmSarOp (
  875. IN PRXM_CONTEXT P
  876. );
  877. //
  878. // Group 3 operations.
  879. //
  880. VOID
  881. XmTestOp (
  882. IN PRXM_CONTEXT P
  883. );
  884. VOID
  885. XmNotOp (
  886. IN PRXM_CONTEXT P
  887. );
  888. VOID
  889. XmNegOp (
  890. IN PRXM_CONTEXT P
  891. );
  892. VOID
  893. XmDivOp (
  894. IN PRXM_CONTEXT P
  895. );
  896. VOID
  897. XmIdivOp (
  898. IN PRXM_CONTEXT P
  899. );
  900. VOID
  901. XmImulOp (
  902. IN PRXM_CONTEXT P
  903. );
  904. VOID
  905. XmImulxOp (
  906. IN PRXM_CONTEXT P
  907. );
  908. VOID
  909. XmMulOp (
  910. IN PRXM_CONTEXT P
  911. );
  912. //
  913. // Group 4 and 5 operators.
  914. //
  915. VOID
  916. XmIncOp (
  917. IN PRXM_CONTEXT P
  918. );
  919. VOID
  920. XmDecOp (
  921. IN PRXM_CONTEXT P
  922. );
  923. VOID
  924. XmCallOp (
  925. PRXM_CONTEXT P
  926. );
  927. VOID
  928. XmJmpOp (
  929. IN PRXM_CONTEXT P
  930. );
  931. VOID
  932. XmPushOp (
  933. IN PRXM_CONTEXT P
  934. );
  935. //
  936. // Group 8 operators.
  937. //
  938. VOID
  939. XmBtOp (
  940. IN PRXM_CONTEXT P
  941. );
  942. VOID
  943. XmBtsOp (
  944. IN PRXM_CONTEXT P
  945. );
  946. VOID
  947. XmBtrOp (
  948. IN PRXM_CONTEXT P
  949. );
  950. VOID
  951. XmBtcOp (
  952. IN PRXM_CONTEXT P
  953. );
  954. //
  955. // Stack operations.
  956. //
  957. VOID
  958. XmPopOp (
  959. IN PRXM_CONTEXT P
  960. );
  961. VOID
  962. XmPushaOp (
  963. IN PRXM_CONTEXT P
  964. );
  965. VOID
  966. XmPopaOp (
  967. IN PRXM_CONTEXT P
  968. );
  969. //
  970. // Conditional jump and set conditional operations.
  971. //
  972. VOID
  973. XmJxxOp (
  974. IN PRXM_CONTEXT P
  975. );
  976. VOID
  977. XmLoopOp (
  978. IN PRXM_CONTEXT P
  979. );
  980. VOID
  981. XmJcxzOp (
  982. IN PRXM_CONTEXT P
  983. );
  984. VOID
  985. XmSxxOp (
  986. IN PRXM_CONTEXT P
  987. );
  988. //
  989. // Condition code operations.
  990. //
  991. VOID
  992. XmClcOp (
  993. PRXM_CONTEXT P
  994. );
  995. VOID
  996. XmCldOp (
  997. PRXM_CONTEXT P
  998. );
  999. VOID
  1000. XmCliOp (
  1001. PRXM_CONTEXT P
  1002. );
  1003. VOID
  1004. XmCmcOp (
  1005. PRXM_CONTEXT P
  1006. );
  1007. VOID
  1008. XmStcOp (
  1009. PRXM_CONTEXT P
  1010. );
  1011. VOID
  1012. XmStdOp (
  1013. PRXM_CONTEXT P
  1014. );
  1015. VOID
  1016. XmStiOp (
  1017. PRXM_CONTEXT P
  1018. );
  1019. VOID
  1020. XmLahfOp (
  1021. PRXM_CONTEXT P
  1022. );
  1023. VOID
  1024. XmSahfOp (
  1025. PRXM_CONTEXT P
  1026. );
  1027. //
  1028. // Move operations.
  1029. //
  1030. VOID
  1031. XmMovOp (
  1032. PRXM_CONTEXT P
  1033. );
  1034. VOID
  1035. XmXchgOp (
  1036. PRXM_CONTEXT P
  1037. );
  1038. //
  1039. // Convert operations.
  1040. //
  1041. VOID
  1042. XmCbwOp (
  1043. PRXM_CONTEXT P
  1044. );
  1045. VOID
  1046. XmCwdOp (
  1047. PRXM_CONTEXT P
  1048. );
  1049. //
  1050. // Control operations.
  1051. //
  1052. VOID
  1053. XmEnterOp (
  1054. PRXM_CONTEXT P
  1055. );
  1056. VOID
  1057. XmHltOp (
  1058. PRXM_CONTEXT P
  1059. );
  1060. VOID
  1061. XmIntOp (
  1062. PRXM_CONTEXT P
  1063. );
  1064. VOID
  1065. XmIretOp (
  1066. PRXM_CONTEXT P
  1067. );
  1068. VOID
  1069. XmLeaveOp (
  1070. PRXM_CONTEXT P
  1071. );
  1072. VOID
  1073. XmRetOp (
  1074. PRXM_CONTEXT P
  1075. );
  1076. //
  1077. // String operations.
  1078. //
  1079. VOID
  1080. XmCmpsOp (
  1081. PRXM_CONTEXT P
  1082. );
  1083. VOID
  1084. XmInsOp (
  1085. PRXM_CONTEXT P
  1086. );
  1087. VOID
  1088. XmLodsOp (
  1089. PRXM_CONTEXT P
  1090. );
  1091. VOID
  1092. XmMovsOp (
  1093. PRXM_CONTEXT P
  1094. );
  1095. VOID
  1096. XmOutsOp (
  1097. PRXM_CONTEXT P
  1098. );
  1099. VOID
  1100. XmScasOp (
  1101. PRXM_CONTEXT P
  1102. );
  1103. VOID
  1104. XmStosOp (
  1105. PRXM_CONTEXT P
  1106. );
  1107. //
  1108. // Shift double operators.
  1109. //
  1110. VOID
  1111. XmShldOp (
  1112. PRXM_CONTEXT P
  1113. );
  1114. VOID
  1115. XmShrdOp (
  1116. PRXM_CONTEXT P
  1117. );
  1118. //
  1119. // I/O operators.
  1120. //
  1121. VOID
  1122. XmInOp (
  1123. PRXM_CONTEXT P
  1124. );
  1125. VOID
  1126. XmOutOp (
  1127. PRXM_CONTEXT P
  1128. );
  1129. //
  1130. // Bit scan operators.
  1131. //
  1132. VOID
  1133. XmBsfOp (
  1134. PRXM_CONTEXT P
  1135. );
  1136. VOID
  1137. XmBsrOp (
  1138. PRXM_CONTEXT P
  1139. );
  1140. //
  1141. // MIscellaneous operations.
  1142. //
  1143. VOID
  1144. XmXaddOp (
  1145. PRXM_CONTEXT P
  1146. );
  1147. VOID
  1148. XmBoundOp (
  1149. PRXM_CONTEXT P
  1150. );
  1151. VOID
  1152. XmBswapOp (
  1153. PRXM_CONTEXT P
  1154. );
  1155. VOID
  1156. XmCmpxchgOp (
  1157. PRXM_CONTEXT P
  1158. );
  1159. VOID
  1160. XmIllOp (
  1161. PRXM_CONTEXT P
  1162. );
  1163. VOID
  1164. XmNopOp (
  1165. PRXM_CONTEXT P
  1166. );
  1167. //
  1168. // PCI Bios emulation routines.
  1169. //
  1170. #if !defined(_PURE_EMULATION_)
  1171. BOOLEAN
  1172. XmExecuteInt1a (
  1173. IN OUT PRXM_CONTEXT Context
  1174. );
  1175. VOID
  1176. XmInt1aPciBiosPresent(
  1177. IN OUT PRXM_CONTEXT Context
  1178. );
  1179. VOID
  1180. XmInt1aFindPciClassCode(
  1181. IN OUT PRXM_CONTEXT Context
  1182. );
  1183. VOID
  1184. XmInt1aFindPciDevice(
  1185. IN OUT PRXM_CONTEXT Context
  1186. );
  1187. VOID
  1188. XmInt1aGenerateSpecialCycle(
  1189. IN OUT PRXM_CONTEXT Context
  1190. );
  1191. VOID
  1192. XmInt1aGetRoutingOptions(
  1193. IN OUT PRXM_CONTEXT Context
  1194. );
  1195. VOID
  1196. XmInt1aSetPciIrq(
  1197. IN OUT PRXM_CONTEXT Context
  1198. );
  1199. VOID
  1200. XmInt1aReadConfigRegister(
  1201. IN OUT PRXM_CONTEXT Context
  1202. );
  1203. VOID
  1204. XmInt1aWriteConfigRegister(
  1205. IN OUT PRXM_CONTEXT Context
  1206. );
  1207. #endif
  1208. //
  1209. // Debug routines.
  1210. //
  1211. #if XM_DEBUG
  1212. #include "stdio.h"
  1213. //#define DEBUG_PRINT(_X_) DbgPrint _X_
  1214. #define DEBUG_PRINT(_X_) printf _X_
  1215. VOID
  1216. XmTraceDestination (
  1217. IN PRXM_CONTEXT P,
  1218. IN ULONG Destination
  1219. );
  1220. VOID
  1221. XmTraceFlags (
  1222. IN PRXM_CONTEXT P
  1223. );
  1224. VOID
  1225. XmTraceInstruction (
  1226. IN XM_OPERATION_DATATYPE DataType,
  1227. IN ULONG Instruction
  1228. );
  1229. VOID
  1230. XmTraceJumps (
  1231. IN PRXM_CONTEXT P
  1232. );
  1233. VOID
  1234. XmTraceOverride (
  1235. IN PRXM_CONTEXT P
  1236. );
  1237. VOID
  1238. XmTraceRegisters (
  1239. IN PRXM_CONTEXT P
  1240. );
  1241. VOID
  1242. XmTraceResult (
  1243. IN PRXM_CONTEXT P,
  1244. IN ULONG Result
  1245. );
  1246. VOID
  1247. XmTraceSpecifier (
  1248. IN UCHAR Specifier
  1249. );
  1250. VOID
  1251. XmTraceSource (
  1252. IN PRXM_CONTEXT P,
  1253. IN ULONG Source
  1254. );
  1255. #else
  1256. #define XmTraceDestination(P, Destination)
  1257. #define XmTraceInstruction(DataType, Instruction)
  1258. #define XmTraceFlags(P)
  1259. #define XmTraceJumps(P)
  1260. #define XmTraceOverride(P)
  1261. #define XmTraceRegisters(P)
  1262. #define XmTraceResult(P, Result)
  1263. #define XmTraceSpecifier(Specifier)
  1264. #define XmTraceSource(P, Source)
  1265. #endif
  1266. //
  1267. // Define global data.
  1268. //
  1269. extern XM_CONTEXT XmContext;
  1270. extern BOOLEAN XmEmulatorInitialized;
  1271. extern const OPCODE_CONTROL XmOpcodeControlTable1[];
  1272. extern const OPCODE_CONTROL XmOpcodeControlTable2[];
  1273. extern const POPCODE_FUNCTION XmOpcodeFunctionTable[];
  1274. extern const POPERAND_DECODE XmOperandDecodeTable[];
  1275. #if !defined(_PURE_EMULATION)
  1276. extern UCHAR XmNumberPciBusses;
  1277. extern BOOLEAN XmPciBiosPresent;
  1278. extern PGETSETPCIBUSDATA XmGetPciData;
  1279. extern PGETSETPCIBUSDATA XmSetPciData;
  1280. #endif
  1281. #if XM_DEBUG
  1282. extern ULONG XmDebugFlags;
  1283. extern const PCHAR XmOpcodeNameTable1[];
  1284. extern const PCHAR XmOpcodeNameTable2[];
  1285. #endif
  1286. #endif // _EMULATE_