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.

150 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. trapc.c
  5. Abstract:
  6. This module contains utility functions used by IA-64 Boot Debugger.
  7. Author:
  8. Allen Kay 11-Nov-99 allen.m.kay@intel.com
  9. Environment:
  10. Revision History:
  11. --*/
  12. #include "bd.h"
  13. extern ULONGLONG BdPcr;
  14. extern VOID BdInstallVectors();
  15. typedef struct _MOVL_INST {
  16. union {
  17. struct {
  18. ULONGLONG qp: 6;
  19. ULONGLONG r1: 7;
  20. ULONGLONG Imm7b: 7;
  21. ULONGLONG Vc: 1;
  22. ULONGLONG Ic: 1;
  23. ULONGLONG Imm5c: 5;
  24. ULONGLONG Imm9d: 9;
  25. ULONGLONG I: 1;
  26. ULONGLONG OpCode: 4;
  27. ULONGLONG Rsv: 23;
  28. } i_field;
  29. ULONGLONG Ulong64;
  30. } u;
  31. } MOVL_INST, *PMOVL_INST;
  32. ULONGLONG
  33. BdSetMovlImmediate (
  34. IN OUT PULONGLONG Ip,
  35. IN ULONGLONG VectorAddr
  36. )
  37. /*++
  38. Routine Description:
  39. Extract immediate operand from break instruction.
  40. Arguments:
  41. Ip - Bundle address of instruction
  42. Return Value:
  43. Value of immediate operand.
  44. --*/
  45. {
  46. PULONGLONG BundleAddress;
  47. ULONGLONG BundleLow;
  48. ULONGLONG BundleHigh;
  49. IN MOVL_INST MovlInst, Slot0, Slot1, Slot2;
  50. IN ULONGLONG Imm64;
  51. BundleAddress = (PULONGLONG)Ip;
  52. BundleLow = *BundleAddress;
  53. BundleHigh = *(BundleAddress+1);
  54. //
  55. // Extract Slot0
  56. //
  57. Slot0.u.Ulong64 = BundleLow & 0x3FFFFFFFFFFF;
  58. //
  59. // Now set immediate address from slot1
  60. //
  61. Slot1.u.Ulong64 = (BundleLow >> 46) | (BundleHigh << 18);
  62. Slot1.u.Ulong64 = (VectorAddr >> 22) & 0x1FFFFFFFFFF;
  63. //
  64. // First set immediate address from slot2
  65. //
  66. Slot2.u.Ulong64 = (BundleHigh >> 23);
  67. Slot2.u.i_field.I = (VectorAddr >> 63) & 0x1;
  68. Slot2.u.i_field.Ic = (VectorAddr >> 21) & 0x1;
  69. Slot2.u.i_field.Imm5c = (VectorAddr >> 16) & 0x1F;
  70. Slot2.u.i_field.Imm9d = (VectorAddr >> 7) & 0x1FF;
  71. Slot2.u.i_field.Imm7b = VectorAddr & 0x7F;
  72. //
  73. // Change the bundle
  74. //
  75. *BundleAddress = (BundleLow & 0x3FFFFFFFFFFF) |
  76. Slot1.u.Ulong64 << 46;
  77. *(BundleAddress+1) = Slot2.u.Ulong64 << 23 |
  78. (Slot1.u.Ulong64 & 0x1FFFFFC0000) >> 18;
  79. //
  80. // Now get the address.
  81. //
  82. BundleAddress = (PULONGLONG)Ip;
  83. BundleLow = *BundleAddress;
  84. BundleHigh = *(BundleAddress+1);
  85. //
  86. // First get immediate address from slot2
  87. //
  88. MovlInst.u.Ulong64 = (BundleHigh >> 23);
  89. Imm64 = MovlInst.u.i_field.I << 63 |
  90. MovlInst.u.i_field.Ic << 21 |
  91. MovlInst.u.i_field.Imm5c << 16 |
  92. MovlInst.u.i_field.Imm9d << 7 |
  93. MovlInst.u.i_field.Imm7b;
  94. //
  95. // Now get immediate address from slot1
  96. //
  97. MovlInst.u.Ulong64 = (BundleLow >> 46) | (BundleHigh << 18);
  98. Imm64 = Imm64 | ( (MovlInst.u.Ulong64 & 0x1FFFFFFFFFF) << 22);
  99. return Imm64;
  100. }
  101. VOID
  102. BdIa64Init()
  103. {
  104. BdInstallVectors();
  105. BdPrcb.PcrPage = BdPcr >> PAGE_SIZE;
  106. }