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.

156 lines
5.3 KiB

  1. #include "mcegen.h"
  2. #if 0
  3. ULONG DumpMCE(
  4. void
  5. )
  6. {
  7. HANDLE Handle;
  8. GUID Guid = { 0x23602a8a,0xdadd,0x462f, { 0x9a,0xe5,0x30,0xfa,0x2c,0x37,0xdd,0x5b } };
  9. ULONG Status;
  10. ULONG SizeNeeded;
  11. Status = WmiOpenBlock(&Guid,
  12. 0,
  13. &Handle);
  14. if (Status == ERROR_SUCCESS)
  15. {
  16. SizeNeeded = 0;
  17. Status = WmiQueryAllData(Handle,
  18. &SizeNeeded,
  19. NULL);
  20. if (Status == ERROR_BUFFER_TOO_SMALL)
  21. {
  22. Buffer = malloc(SizeNeeded);
  23. if (Buffer != NULL)
  24. {
  25. Status = WmiQueryAllData(Handle,
  26. &SizeNeeded,
  27. Buffer);
  28. if (Status == ERROR_SUCCESS)
  29. {
  30. Wnode = (PWNODE_ALL_DATA)Buffer;
  31. MCAData = (PMSMCAInfo_RawMCAData)OffsetToPtr(Wnode,
  32. Wnode->
  33. }
  34. }
  35. }
  36. }
  37. }
  38. #endif
  39. void Usage()
  40. {
  41. printf("MCEGen <code> [<count> <threads>]\n\n");
  42. printf(" Generates a MCE exception. <code> specifies the type\n");
  43. printf(" of exception to generate\n\n");
  44. printf(" Note that the MCAHCT driver must be installed and started\n\n");
  45. printf(" 101 - Generates a single bit memory error. Note memerr.efi must have already seeded an error (460GX platform only)\n");
  46. printf(" 102 - Generates a multi bit memory error. Note memerr.efi must have already seeded an error (460GX platform only)\n");
  47. printf(" 103 - Generates a CMC via FSB (460GX platform only)\n");
  48. printf(" 104 - Generates fatal MCA TLB error (460GX platform only)\n");
  49. printf(" 105 - Generates fatal MCA PCI bus error (SoftSur only)\n");
  50. printf(" 106 - Generates fatal MCA PCI bus error (Lion only)\n");
  51. printf(" 456 - Generates a fatal MCA (Itanium only)\n");
  52. printf(" 490 - Generates a L1 1-bit ECC CMC (Itanium only)\n");
  53. printf(" 900 - Generate single bit ECC error in user mode. Memerr.efi must have been run (460GX only)\n");
  54. printf(" 901 - Generate double bit ECC error in user mode. Memerr.efi must have been run (460GX only)\n");
  55. printf(" 1001/2001/3001 - Fatal/Corrected CMC/CPE SMBIOS MCE\n");
  56. printf(" 1002/2002/3002 - Fatal/Corrected CMC/CPE Cache Level 1 MCE\n");
  57. printf(" 1003/2003/3003 - Fatal/Corrected CMC/CPE TLB level 2 MCE\n");
  58. printf(" 1004/2004/3004 - Fatal/Corrected CMC/CPE Unknown PCI Bus\n");
  59. printf(" 1005/2005/3005 - Fatal/Corrected CMC/CPE Unknown PCI Bus\n");
  60. printf(" 1006/2006/3006 - Fatal/Corrected CMC/CPE PCI Bus Parity Error\n");
  61. printf(" 1007/2007/3007 - Fatal/Corrected CMC/CPE System Eventlog\n");
  62. printf(" 1008/2008/3008 - Fatal/Corrected CMC/CPE Memory\n");
  63. printf(" 1009/2009/3009 - Fatal/Corrected CMC/CPE Memory\n");
  64. printf(" 1010/2010/3010 - Fatal/Corrected CMC/CPE Memory\n");
  65. printf(" 1011/2011/3011 - Fatal/Corrected CMC/CPE Memory\n");
  66. printf(" 1012/2012/3012 - Fatal/Corrected CMC/CPE SMBIOS and Platform Specific\n");
  67. printf(" 1013/2013/3013 - Fatal/Corrected CMC/CPE PCI Component\n");
  68. printf(" 1014/2014/3014 - Fatal/Corrected CMC/CPE SMBIOS (100KB in size)\n");
  69. printf(" 1015/2015/3015 - Fatal/Corrected Invalid\n");
  70. printf(" 1016/2016/3016 - Fatal/Corrected CMC/CPE CPU 1 MS check\n");
  71. printf(" 1017/2017/3017 - Fatal/Corrected CMC/CPE CPU 1 Bus check, 1 RegFile check\n");
  72. printf(" 1018/2018/3018 - Fatal/Corrected CMC/CPE CPU 1 reg check, 2 MS check\n");
  73. printf(" 1019/2019/3019 - Fatal/Corrected CMC/CPE CPU nothing valid\n");
  74. printf(" 1020/2020/3020 - Fatal/Corrected CMC/CPE Memory Error nothing valid\n");
  75. printf(" 1021/2021/3021 - Fatal/Corrected CMC/CPE PCI Bus Error nothing valid\n");
  76. printf(" 1116/2116/3116 - Fatal/Corrected Over temp\n");
  77. printf(" 1117/2117/3117 - Fatal/Corrected Normal temp\n");
  78. printf(" 1118/2118/3118 - Generate simulated single bit ECC error\n");
  79. printf(" 1019/2019/3019 - Fatal/Corrected CMC/CPE SMBIOS and informational Platform Specific\n");
  80. }
  81. int _cdecl main(int argc, char *argv[])
  82. {
  83. ULONG Status;
  84. ULONG Code, Threads, Count;
  85. HANDLE h;
  86. ULONG i;
  87. DWORD Id;
  88. if (argc < 2)
  89. {
  90. Usage();
  91. } else {
  92. Code = atoi(argv[1]);
  93. if (argc == 2) {
  94. THREADCONTROL ThreadControl;
  95. //
  96. // parameter is code number to generate MCE
  97. //
  98. ThreadControl.Count = 1;
  99. ThreadControl.Code = Code;
  100. GenerateMCE(&ThreadControl);
  101. } else {
  102. PHANDLE Events;
  103. if (argc >= 4)
  104. {
  105. //
  106. // specified multiple generation threads
  107. //
  108. Threads = atoi(argv[3]);
  109. } else {
  110. Threads = 1;
  111. }
  112. //
  113. // Get number of MCE to generate
  114. //
  115. Count = atoi(argv[2]);
  116. Events = malloc(Threads * sizeof(HANDLE));
  117. for (i = 0; i < Threads; i++)
  118. {
  119. PTHREADCONTROL ThreadControl;
  120. ThreadControl = malloc(sizeof(THREADCONTROL));
  121. ThreadControl->Count = Count;
  122. ThreadControl->Code = Code;
  123. Events[i] = CreateThread(NULL,
  124. 0,
  125. GenerateMCE,
  126. ThreadControl,
  127. 0,
  128. &Id);
  129. if (Events[i] == NULL)
  130. {
  131. printf("CreateThread failed %d\n", GetLastError());
  132. }
  133. }
  134. printf("Waiting for threads to complete\n");
  135. WaitForMultipleObjects(Threads, Events, TRUE, INFINITE);
  136. }
  137. }
  138. return(0);
  139. }