Wmt_CpuID.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //==========================================================================
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------
  11. /****************************************************************************
  12. *
  13. * Module Title : Wmt_CpuID.cpp
  14. *
  15. * Description : willamette processor detection functions
  16. *
  17. *
  18. *****************************************************************************
  19. */
  20. /****************************************************************************
  21. * Header Files
  22. *****************************************************************************
  23. */
  24. #include <excpt.h>
  25. #include <string.h>
  26. extern "C" {
  27. /****************************************************************************
  28. *
  29. * ROUTINE : WillametteNewInstructionSupport()
  30. *
  31. * INPUTS :
  32. *
  33. * OUTPUTS :
  34. *
  35. * RETURNS : retrun true if the processor support willamette new
  36. * instructions, return false otherwise
  37. *
  38. *
  39. * FUNCTION : detect willamette processor
  40. *
  41. * SPECIAL NOTES : None.
  42. *
  43. * ERRORS : None.
  44. *
  45. ****************************************************************************/
  46. int WillametteNewInstructionHWSupport()
  47. {
  48. int HWSupport = 0;
  49. char brand[12];
  50. __try
  51. {
  52. __asm
  53. {
  54. lea esi, brand
  55. mov eax, 0
  56. cpuid
  57. mov [esi], ebx
  58. mov [esi+4], edx
  59. mov [esi+8], ecx
  60. }
  61. }
  62. __except(EXCEPTION_EXECUTE_HANDLER)
  63. {
  64. if(_exception_code())
  65. {
  66. //cout<<endl<<"*******CPUID is not supported**********"<<endl;
  67. return 0;
  68. }
  69. return 0;
  70. }
  71. if(strncmp(brand, "GenuineIntel", 12)!=0)
  72. {
  73. //cout<<endl<<"this is not an intel processor1"<<endl;
  74. return 0;
  75. }
  76. __asm
  77. {
  78. mov eax, 1
  79. cpuid
  80. test edx, 04000000h
  81. jz NotFound
  82. mov [HWSupport], 1
  83. NotFound:
  84. nop
  85. }
  86. return (HWSupport);
  87. }
  88. /****************************************************************************
  89. *
  90. * ROUTINE : WillametteNewInstructionOSSupport()
  91. *
  92. * INPUTS :
  93. *
  94. * OUTPUTS :
  95. *
  96. * RETURNS : retrun true if the OS support willamette new
  97. * instructions, return false otherwise
  98. *
  99. *
  100. * FUNCTION : detect willamette processor
  101. *
  102. * SPECIAL NOTES : None.
  103. *
  104. * ERRORS : None.
  105. *
  106. ****************************************************************************/
  107. int WillametteNewInstructionOSSupport()
  108. {
  109. __try
  110. {
  111. __asm xorpd xmm0, xmm0
  112. }
  113. __except(EXCEPTION_EXECUTE_HANDLER)
  114. {
  115. if(_exception_code())
  116. {
  117. return 0;
  118. }
  119. return 0;
  120. }
  121. return 1;
  122. }
  123. }