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.

138 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1999-2002 Microsoft Corporation
  3. Module Name:
  4. platform.h
  5. Abstract:
  6. Platform specific macros and functions.
  7. Author:
  8. Matthew D Hendel (math) 28-Aug-1999
  9. Revision History:
  10. --*/
  11. // Some processors use both a stack and a backing store.
  12. // If a particular processor supports backing store add
  13. // DUMP_BACKING_STORE.
  14. #if defined (i386)
  15. #define PROGRAM_COUNTER(_context) ((LONG)(_context)->Eip)
  16. #define STACK_POINTER(_context) ((LONG)(_context)->Esp)
  17. #define PAGE_SIZE 4096
  18. #define CPU_TYPE_NAME L"x86"
  19. //
  20. // The CONTEXT_FULL definition on x86 doesn't really get all
  21. // the registers. Use ALL_REGISTERS to get the compelte
  22. // context.
  23. //
  24. #define ALL_REGISTERS (CONTEXT_CONTROL |\
  25. CONTEXT_INTEGER |\
  26. CONTEXT_SEGMENTS |\
  27. CONTEXT_FLOATING_POINT |\
  28. CONTEXT_DEBUG_REGISTERS |\
  29. CONTEXT_EXTENDED_REGISTERS)
  30. //
  31. // The following are flags specific to the CPUID instruction on x86 only.
  32. //
  33. #define CPUID_VENDOR_ID (0)
  34. #define CPUID_VERSION_FEATURES (1)
  35. #define CPUID_AMD_EXTENDED_FEATURES (0x80000001)
  36. #elif defined(_AMD64_)
  37. #define PROGRAM_COUNTER(_context) ((_context)->Rip)
  38. #define STACK_POINTER(_context) ((_context)->Rsp)
  39. #define PAGE_SIZE 4096
  40. #define CPU_TYPE_NAME L"AMD64"
  41. #define ALL_REGISTERS (CONTEXT_FULL | CONTEXT_SEGMENTS | CONTEXT_DEBUG_REGISTERS)
  42. #elif defined (_IA64_)
  43. #define PROGRAM_COUNTER(_context) ((_context)->StIIP)
  44. #define STACK_POINTER(_context) ((_context)->IntSp)
  45. #define PAGE_SIZE 8192
  46. #define ALL_REGISTERS (CONTEXT_FULL | CONTEXT_DEBUG)
  47. #define CPU_TYPE_NAME L"IA64"
  48. #define DUMP_BACKING_STORE
  49. #if 1
  50. // XXX drewb - The TEB bstore values don't seem to point to
  51. // the actual base of the backing store. Just
  52. // assume it's contiguous with the stack.
  53. #define BSTORE_BASE(_teb) ((ULONG64)(_teb)->NtTib.StackBase)
  54. #else
  55. #define BSTORE_BASE(_teb) ((ULONG64)(_teb)->DeallocationBStore)
  56. #endif
  57. #define BSTORE_LIMIT(_teb) ((ULONG64)(_teb)->BStoreLimit)
  58. // The BSP points to the bottom of the current frame's
  59. // storage area. We need to add on the size of the
  60. // current frame to get the amount of memory that
  61. // really needs to be stored. When computing the
  62. // size of the current frame space for NAT bits
  63. // must be figured in properly based on the number
  64. // of entries in the frame. The NAT collection
  65. // is spilled on every 63'rd spilled register to
  66. // make each block an every 64 ULONG64s long.
  67. // On NT the backing store base is always 9-bit aligned
  68. // so we can tell when exactly the next NAT spill
  69. // will occur by looking for when the 9-bit spill
  70. // region will overflow.
  71. __inline ULONG64
  72. BSTORE_POINTER(CONTEXT* Context)
  73. {
  74. ULONG64 Limit = Context->RsBSP;
  75. ULONG Count = (ULONG)(Context->StIFS & 0x7f);
  76. // Add in a ULONG64 for every register in the
  77. // current frame. While doing so, check for
  78. // spill entries.
  79. while (Count-- > 0)
  80. {
  81. Limit += sizeof(ULONG64);
  82. if ((Limit & 0x1f8) == 0x1f8)
  83. {
  84. // Spill will be placed at this address so
  85. // account for it.
  86. Limit += sizeof(ULONG64);
  87. }
  88. }
  89. return Limit;
  90. }
  91. #elif defined (ARM)
  92. #define PROGRAM_COUNTER(_context) ((LONG)(_context)->Pc)
  93. #define STACK_POINTER(_context) ((LONG)(_context)->Sp)
  94. #define PAGE_SIZE 4096
  95. #define CPU_TYPE_NAME L"ARM"
  96. #define ALL_REGISTERS (CONTEXT_CONTROL | CONTEXT_INTEGER)
  97. #else
  98. #error ("unknown processor type")
  99. #endif
  100. #define AMD_VENDOR_ID_0 ('htuA')
  101. #define AMD_VENDOR_ID_1 ('itne')
  102. #define AMD_VENDOR_ID_2 ('DMAc')
  103. #define INTEL_VENDOR_ID_0 ('uneG')
  104. #define INTEL_VENDOR_ID_1 ('Ieni')
  105. #define INTEL_VENDOR_ID_2 ('letn')