OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_OS_WINDOWS) |
| 7 |
| 8 // __cpuid() |
| 9 #include <intrin.h> // NOLINT |
| 10 |
| 11 #include "vm/cpuinfo.h" |
| 12 |
| 13 #include "platform/assert.h" |
| 14 |
| 15 namespace dart { |
| 16 |
| 17 char* CpuInfo::data_ = NULL; |
| 18 intptr_t CpuInfo::datalen_ = 0; |
| 19 |
| 20 void CpuInfo::Read() {} |
| 21 |
| 22 |
| 23 bool CpuInfo::FieldContains(const char* field, const char* search_string) { |
| 24 UNIMPLEMENTED(); |
| 25 return false; |
| 26 } |
| 27 |
| 28 |
| 29 intptr_t CpuInfo::ExtractField( |
| 30 const char* field, char* dest, const intptr_t dest_len) { |
| 31 UNIMPLEMENTED(); |
| 32 return 0; |
| 33 } |
| 34 |
| 35 |
| 36 bool CpuInfo::HasField(const char* field) { |
| 37 UNIMPLEMENTED(); |
| 38 return 0; |
| 39 } |
| 40 |
| 41 |
| 42 intptr_t CpuInfo::GetCpuModel(char* dest, const intptr_t dest_len) { |
| 43 ASSERT(dest != NULL); |
| 44 ASSERT(dest_len >= 3 * 4 * sizeof(int32_t)); |
| 45 int32_t info[4] = {-1}; |
| 46 intptr_t i, num_ids = 0; |
| 47 |
| 48 // The documentation for __cpuid is at: |
| 49 // http://msdn.microsoft.com/en-us/library/hskdteyh(v=vs.90).aspx |
| 50 // TODO(zra): In Read() above, read and cache more entries using __cpuid, |
| 51 // then extract as in the implementations for other OS's. |
| 52 dest[0] = '\0'; |
| 53 __cpuid(info, 0x80000000); |
| 54 num_ids = info[0]; |
| 55 for (i = 0x80000000; i <= num_ids; i++) { |
| 56 __cpuid(info, i); |
| 57 if ((i == 0x80000002) || (i == 0x80000003) || (i == 0x80000004)) { |
| 58 intptr_t off = (i - 0x80000002) * 4 * sizeof(int32_t); |
| 59 char* chunk = reinterpret_cast<char*>(info); |
| 60 for (int j = 0; j < 4 * sizeof(int32_t); j++) { |
| 61 dest[off + j] = chunk[j]; |
| 62 } |
| 63 } |
| 64 if (i >= 0x80000004) { |
| 65 break; |
| 66 } |
| 67 } |
| 68 |
| 69 return strlen(dest); |
| 70 } |
| 71 |
| 72 } // namespace dart |
| 73 |
| 74 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |