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.

166 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. frag.h
  5. Abstract:
  6. This module contains public structures and interfaces for the fragment
  7. library.
  8. Author:
  9. Dave Hastings (daveh) creation-date 24-Jun-1995
  10. Revision History:
  11. --*/
  12. #ifndef _FRAG_H_
  13. #define _FRAG_H_
  14. //
  15. // function declaration for the function to patch Operand fragments
  16. // CodeLocation specifies the location of the beginning of the copy
  17. // of the fragment in memory. Reference indicates if it is a value
  18. // or reference operand. Argument number refers to which argument it
  19. // is for the c call to the operation fragment (zero based)
  20. //
  21. typedef INT (*PPLACEOPERANDFN)(
  22. IN PULONG CodeLocation,
  23. IN POPERAND Operand,
  24. IN ULONG OperandNumber
  25. );
  26. //
  27. // function declaration for the function to patch operation fragments
  28. // CodeLocation specifies the location of the beginning of the copy
  29. // of the fragment in memory
  30. //
  31. typedef ULONG (*PPLACEOPERATIONFN)(PULONG CodeLocation,
  32. #if _ALPHA_
  33. ULONG CurrentECU,
  34. #endif
  35. PINSTRUCTION Instruction);
  36. //
  37. // Structure to describe and locate the code for a fragment
  38. //
  39. typedef struct _FragDescr {
  40. BYTE FastPlaceFn; // index into PlaceFn[] when in fast mode
  41. BYTE SlowPlaceFn; // index into PlaceFn[] when in slow mode
  42. USHORT Flags; // OPFL_ flags
  43. DWORD RegsSet; // registers set by this instr
  44. USHORT FlagsNeeded; // bits from flags register required for this instr
  45. USHORT FlagsSet; // bits from flags register modified by this instr
  46. } FRAGDESC;
  47. typedef CONST FRAGDESC *PFRAGDESCR;
  48. //
  49. // Bit definitions for FRAGDESC.Flags field
  50. //
  51. #define OPFL_ALIGN 1
  52. #define OPFL_HASNOFLAGS 2
  53. #define OPFL_STOP_COMPILE 4
  54. #define OPFL_END_NEXT_EP 8
  55. #define OPFL_CTRLTRNS 16
  56. #define OPFL_ADDR16 32
  57. #define OPFL_INLINEARITH 64
  58. // Bit values for FRAGDESC.RegsSet field
  59. #define REGAL 1
  60. #define REGAH 2
  61. #define REGAX 3
  62. #define REGEAX 7
  63. #define REGCL (1<<3)
  64. #define REGCH (2<<3)
  65. #define REGCX (3<<3)
  66. #define REGECX (7<<3)
  67. #define REGDL (1<<6)
  68. #define REGDH (2<<6)
  69. #define REGDX (3<<6)
  70. #define REGEDX (7<<6)
  71. #define REGBL (1<<9)
  72. #define REGBH (2<<9)
  73. #define REGBX (3<<9)
  74. #define REGEBX (7<<9)
  75. #define REGSP (3<<12)
  76. #define REGESP (7<<12)
  77. #define REGBP (3<<15)
  78. #define REGEBP (7<<15)
  79. #define REGSI (3<<18)
  80. #define REGESI (7<<18)
  81. #define REGDI (3<<21)
  82. #define REGEDI (7<<21)
  83. #define ALLREGS (REGEAX|REGEBX|REGECX|REGEDX|REGESP|REGEBP|REGESI|REGEDI)
  84. //
  85. // Constants to help break apart bitfields of REG... constants. Register
  86. // caching code uses a single DWORD to hold caching information for the 8
  87. // x86 general-purpose registers (REGEAX through REGEDI), using 3 bits of
  88. // data for each.
  89. //
  90. #define REGMASK 7
  91. #define REGCOUNT 8
  92. #define REGSHIFT 3
  93. //
  94. // Declare fragment description array
  95. //
  96. extern CONST FRAGDESC Fragments[OP_MAX];
  97. extern CONST PPLACEOPERATIONFN PlaceFn[FN_MAX];
  98. VOID
  99. FlushCallstack(
  100. PTHREADSTATE cpu
  101. );
  102. //
  103. // The following three functions are used by the indirect control transfer code
  104. //
  105. ULONG
  106. getUniqueIndex(
  107. VOID
  108. );
  109. VOID
  110. FlushIndirControlTransferTable(
  111. VOID
  112. );
  113. ULONG
  114. IndirectControlTransfer(
  115. IN ULONG tableEntry,
  116. IN ULONG intelAddr,
  117. IN PTHREADSTATE cpu
  118. );
  119. ULONG
  120. IndirectControlTransferFar(
  121. IN PTHREADSTATE cpu,
  122. IN PUSHORT pintelAddr,
  123. IN ULONG tableEntry
  124. );
  125. ULONG PlaceInstructions(
  126. PCHAR CodeLocation,
  127. DWORD cEntryPoints
  128. );
  129. //
  130. // Function for initializing the fragment library
  131. //
  132. BOOL
  133. FragLibInit(
  134. PCPUCONTEXT cpu,
  135. DWORD StackBase
  136. );
  137. #endif