cid.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. #include <windows.h>
  12. #include <stdarg.h>
  13. #include "cpuidlib.h"
  14. #include "cidasm.h"
  15. #include <process.h>
  16. #include <stdio.h>
  17. extern int WillametteNewInstructionOSSupport();
  18. extern int WillametteNewInstructionHWSupport();
  19. /*
  20. * **-DoesOSSupportXMM
  21. *
  22. * This function will check to see if the operating supports the XMM (Pentium III) instructions
  23. * The XMM functionality adds 8 128-bit registers to the pentium II register set. With the addition
  24. * of the new registers the OS needs to preserve and restore the registers on task switches.
  25. *
  26. * Inputs:
  27. * None
  28. *
  29. * Outputs:
  30. * True returned if the OS supports the XMM instructions.
  31. * False returned if the OS does not suppor the XMM instructions.
  32. */
  33. int DoesOSSupportXMM( void )
  34. {
  35. OSVERSIONINFO OSInformation; // Data structure where OS version will be filled in
  36. int ReturnValue = FALSE; // Preload to fail
  37. // need to initilize size of OS info structure before calling GetVersionEx
  38. OSInformation.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  39. if( !GetVersionEx( &OSInformation ) ) // Get OS information
  40. {
  41. /*
  42. * having trouble getting OS information
  43. * to be safe will return that we do not support XMM
  44. * instructions
  45. */
  46. // ReturnValue = FALSE;
  47. }
  48. if( OSInformation.dwPlatformId == VER_PLATFORM_WIN32_NT )
  49. // if( 1 )
  50. {
  51. /*
  52. * If we are on a windows NT system we cannot directly
  53. * read the control registers to see if the OS supports
  54. * the XMM instructions. We will just check to see if
  55. * service pack 4 is installed.
  56. */
  57. int ServicePackNumber;
  58. if( strcmp(OSInformation.szCSDVersion, "" ) != 0 ) // is there a service pack installed?
  59. {
  60. // Yes, get service pack revision
  61. char Junk[132], Junk2[132];
  62. sscanf( OSInformation.szCSDVersion, "%s %s %d", Junk, Junk2, &ServicePackNumber );
  63. }
  64. else
  65. {
  66. ServicePackNumber = 0;
  67. }
  68. if( OSInformation.dwMajorVersion == 4 && // must be versio 4 or greater
  69. ServicePackNumber >= 4 || // must have service pack 4 or greater
  70. OSInformation.dwMajorVersion >=5)
  71. {
  72. ReturnValue = TRUE;
  73. }
  74. else
  75. {
  76. // ReturnValue = FALSE;
  77. }
  78. #if 0
  79. // some handy debugging info if you are desperate
  80. printf("OS Major Revision %d\n", OSInformation.dwMajorVersion );
  81. printf("OS Minor REvision %d\n", OSInformation.dwMinorVersion );
  82. printf("Service Pack Number %d\n", ServicePackNumber );
  83. #endif
  84. }
  85. else
  86. {
  87. /*
  88. * we are on a Windows 9x system.
  89. */
  90. //if( Does9xOSSupportXMM()) // does the Windows 9x support the XMM instructions?
  91. {
  92. ReturnValue = TRUE; // yup
  93. }
  94. //else
  95. //{
  96. //ReturnValue = FALSE; // Nope, don't support XMM instructions
  97. //}
  98. }
  99. return( ReturnValue );
  100. }
  101. /*
  102. * **-findCPUId
  103. *
  104. * See cpuidlib.h for a detailed description of this function
  105. */
  106. PROCTYPE findCPUId( void )
  107. {
  108. PROCTYPE CpuType;
  109. // return 0;
  110. // return (PII); // drop to next lowest type of CPU which should be the Pentium II processor
  111. CpuType = getCPUType(); // Get version of processor
  112. // The code to check whether willammete instructions are called attempts to run
  113. // an illegal instruction. Under 98 mplayer crashes the os as soon as the illegal
  114. // instruction is called, so I've disabled it.
  115. if( CpuType == XMM ) // If the CPU supports XMM (Pentium III) instructions
  116. {
  117. // if( DoesOSSupportXMM()) // need to check to see if the OS supports the XMM instructions
  118. {
  119. if( WillametteNewInstructionHWSupport()&&
  120. WillametteNewInstructionOSSupport())
  121. {
  122. CpuType = WMT;
  123. }
  124. }
  125. // else
  126. // {
  127. // os does not support the XMM instructions
  128. // CpuType = PII; // drop to next lowest type of CPU which should be the Pentium II processor
  129. // }
  130. }
  131. return( CpuType );
  132. }