winCPUInfo.cc 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platform/platform.h"
  23. #include "platformWin32/platformWin32.h"
  24. #include "console/console.h"
  25. #include "string/stringTable.h"
  26. #include <math.h>
  27. extern void PlatformBlitInit();
  28. extern void SetProcessorInfo(TorqueSystemInfo::Processor& pInfo,
  29. char* vendor, U32 processor, U32 properties); // platform/platformCPU.cc
  30. void Processor::init()
  31. {
  32. Con::printSeparator();
  33. Con::printf("Processor Initialization:");
  34. // Reference:
  35. // www.cyrix.com
  36. // www.amd.com
  37. // www.intel.com
  38. // http://developer.intel.com/design/PentiumII/manuals/24512701.pdf
  39. PlatformSystemInfo.processor.type = CPU_X86Compatible;
  40. PlatformSystemInfo.processor.name = StringTable->insert("Unknown x86 Compatible");
  41. PlatformSystemInfo.processor.mhz = 0;
  42. PlatformSystemInfo.processor.properties = CPU_PROP_C;
  43. char vendor[13] = {0,};
  44. U32 properties = 0;
  45. U32 processor = 0;
  46. SetProcessorInfo(PlatformSystemInfo.processor, vendor, processor, properties);
  47. // now calculate speed of processor...
  48. U16 nearmhz = 0; // nearest rounded mhz
  49. U16 mhz = 0; // calculated value.
  50. if (mhz==0)
  51. {
  52. Con::printf(" %s, (Unknown) Mhz", PlatformSystemInfo.processor.name);
  53. // stick SOMETHING in so it isn't ZERO.
  54. PlatformSystemInfo.processor.mhz = 200; // seems a decent value.
  55. }
  56. else
  57. {
  58. if (nearmhz >= 1000)
  59. Con::printf(" %s, ~%.2f Ghz", PlatformSystemInfo.processor.name, ((float)nearmhz)/1000.0f);
  60. else
  61. Con::printf(" %s, ~%d Mhz", PlatformSystemInfo.processor.name, nearmhz);
  62. if (nearmhz != mhz)
  63. {
  64. if (mhz >= 1000)
  65. Con::printf(" (timed at roughly %.2f Ghz)", ((float)mhz)/1000.0f);
  66. else
  67. Con::printf(" (timed at roughly %d Mhz)", mhz);
  68. }
  69. }
  70. if (PlatformSystemInfo.processor.properties & CPU_PROP_FPU)
  71. Con::printf(" FPU detected");
  72. if (PlatformSystemInfo.processor.properties & CPU_PROP_MMX)
  73. Con::printf(" MMX detected");
  74. if (PlatformSystemInfo.processor.properties & CPU_PROP_3DNOW)
  75. Con::printf(" 3DNow detected");
  76. if (PlatformSystemInfo.processor.properties & CPU_PROP_SSE)
  77. Con::printf(" SSE detected");
  78. Con::printf(" ");
  79. PlatformBlitInit();
  80. }