OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
7 | 7 |
8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
9 #include "vm/cpu_mips.h" | 9 #include "vm/cpu_mips.h" |
10 | 10 |
11 #include "vm/cpuinfo.h" | 11 #include "vm/cpuinfo.h" |
12 #include "vm/simulator.h" | 12 #include "vm/simulator.h" |
13 | 13 |
14 #if !defined(USING_SIMULATOR) | 14 #if !defined(USING_SIMULATOR) |
15 #include <asm/cachectl.h> /* NOLINT */ | 15 #include <asm/cachectl.h> /* NOLINT */ |
16 #include <sys/syscall.h> /* NOLINT */ | 16 #include <sys/syscall.h> /* NOLINT */ |
17 #include <unistd.h> /* NOLINT */ | 17 #include <unistd.h> /* NOLINT */ |
18 #endif | 18 #endif |
19 | 19 |
20 namespace dart { | 20 namespace dart { |
21 | 21 |
22 void CPU::FlushICache(uword start, uword size) { | 22 void CPU::FlushICache(uword start, uword size) { |
23 #if !defined(USING_SIMULATOR) | 23 #if !defined(USING_SIMULATOR) |
24 int res; | 24 int res; |
25 // See http://www.linux-mips.org/wiki/Cacheflush_Syscall. | 25 // See http://www.linux-mips.org/wiki/Cacheflush_Syscall. |
26 res = syscall(__NR_cacheflush, start, size, ICACHE); | 26 res = syscall(__NR_cacheflush, start, size, ICACHE); |
27 ASSERT(res == 0); | 27 ASSERT(res == 0); |
28 #else // defined(HOST_ARCH_MIPS) | 28 #else // defined(HOST_ARCH_MIPS) |
29 // When running in simulated mode we do not need to flush the ICache because | 29 // When running in simulated mode we do not need to flush the ICache because |
30 // we are not running on the actual hardware. | 30 // we are not running on the actual hardware. |
31 #endif // defined(HOST_ARCH_MIPS) | 31 #endif // defined(HOST_ARCH_MIPS) |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 const char* CPU::Id() { | 35 const char* CPU::Id() { |
36 return | 36 return |
37 #if defined(USING_SIMULATOR) | 37 #if defined(USING_SIMULATOR) |
38 "sim" | 38 "sim" |
39 #endif // !defined(HOST_ARCH_MIPS) | 39 #endif // !defined(HOST_ARCH_MIPS) |
40 "mips"; | 40 "mips"; |
41 } | 41 } |
42 | 42 |
43 | 43 |
44 const char* HostCPUFeatures::hardware_ = NULL; | 44 const char* HostCPUFeatures::hardware_ = NULL; |
45 MIPSVersion HostCPUFeatures::mips_version_ = MIPSvUnknown; | 45 MIPSVersion HostCPUFeatures::mips_version_ = MIPSvUnknown; |
46 #if defined(DEBUG) | 46 #if defined(DEBUG) |
47 bool HostCPUFeatures::initialized_ = false; | 47 bool HostCPUFeatures::initialized_ = false; |
48 #endif | 48 #endif |
49 | 49 |
50 | 50 |
51 #if !defined(USING_SIMULATOR) | 51 #if !defined(USING_SIMULATOR) |
52 void HostCPUFeatures::InitOnce() { | 52 void HostCPUFeatures::InitOnce() { |
53 CpuInfo::InitOnce(); | 53 CpuInfo::InitOnce(); |
54 hardware_ = CpuInfo::GetCpuModel(); | 54 hardware_ = CpuInfo::GetCpuModel(); |
55 // Has a floating point unit. | 55 // Has a floating point unit. |
56 ASSERT(CpuInfo::FieldContains(kCpuInfoModel, "FPU")); | 56 ASSERT(CpuInfo::FieldContains(kCpuInfoModel, "FPU")); |
57 | 57 |
58 // We want to know the ISA version, but on MIPS, CpuInfo can't tell us, so | 58 // We want to know the ISA version, but on MIPS, CpuInfo can't tell us, so |
59 // we use the same ISA version that Dart's C++ compiler targeted. | 59 // we use the same ISA version that Dart's C++ compiler targeted. |
60 #if defined(_MIPS_ARCH_MIPS32R2) | 60 #if defined(_MIPS_ARCH_MIPS32R2) |
61 mips_version_ = MIPS32r2; | 61 mips_version_ = MIPS32r2; |
62 #elif defined(_MIPS_ARCH_MIPS32) | 62 #elif defined(_MIPS_ARCH_MIPS32) |
63 mips_version_ = MIPS32; | 63 mips_version_ = MIPS32; |
64 #endif | 64 #endif |
65 | 65 |
66 #if defined(DEBUG) | 66 #if defined(DEBUG) |
67 initialized_ = true; | 67 initialized_ = true; |
68 #endif | 68 #endif |
69 } | 69 } |
(...skipping 30 matching lines...) Expand all Loading... |
100 ASSERT(hardware_ != NULL); | 100 ASSERT(hardware_ != NULL); |
101 free(const_cast<char*>(hardware_)); | 101 free(const_cast<char*>(hardware_)); |
102 hardware_ = NULL; | 102 hardware_ = NULL; |
103 CpuInfo::Cleanup(); | 103 CpuInfo::Cleanup(); |
104 } | 104 } |
105 #endif // defined(HOST_ARCH_MIPS) | 105 #endif // defined(HOST_ARCH_MIPS) |
106 | 106 |
107 } // namespace dart | 107 } // namespace dart |
108 | 108 |
109 #endif // defined TARGET_ARCH_MIPS | 109 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |