OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Ideally, we would call | 68 // Ideally, we would call |
69 // syscall(__ARM_NR_cacheflush, start, | 69 // syscall(__ARM_NR_cacheflush, start, |
70 // reinterpret_cast<intptr_t>(start) + size, 0); | 70 // reinterpret_cast<intptr_t>(start) + size, 0); |
71 // however, syscall(int, ...) is not supported on all platforms, especially | 71 // however, syscall(int, ...) is not supported on all platforms, especially |
72 // not when using EABI, so we call the __ARM_NR_cacheflush syscall directly. | 72 // not when using EABI, so we call the __ARM_NR_cacheflush syscall directly. |
73 | 73 |
74 register uint32_t beg asm("a1") = reinterpret_cast<uint32_t>(start); | 74 register uint32_t beg asm("a1") = reinterpret_cast<uint32_t>(start); |
75 register uint32_t end asm("a2") = | 75 register uint32_t end asm("a2") = |
76 reinterpret_cast<uint32_t>(start) + size; | 76 reinterpret_cast<uint32_t>(start) + size; |
77 register uint32_t flg asm("a3") = 0; | 77 register uint32_t flg asm("a3") = 0; |
78 #ifdef __ARM_EABI__ | 78 #if defined (__arm__) && !defined(__thumb__) |
79 #if defined (__arm__) && !defined(__thumb__) | 79 // __arm__ may be defined in thumb mode. |
80 // __arm__ may be defined in thumb mode. | 80 register uint32_t scno asm("r7") = __ARM_NR_cacheflush; |
81 register uint32_t scno asm("r7") = __ARM_NR_cacheflush; | 81 asm volatile( |
82 asm volatile( | 82 "svc 0x0" |
83 "svc 0x0" | 83 : "=r" (beg) |
84 : "=r" (beg) | 84 : "0" (beg), "r" (end), "r" (flg), "r" (scno)); |
85 : "0" (beg), "r" (end), "r" (flg), "r" (scno)); | |
86 #else | |
87 // r7 is reserved by the EABI in thumb mode. | |
88 asm volatile( | |
89 "@ Enter ARM Mode \n\t" | |
90 "adr r3, 1f \n\t" | |
91 "bx r3 \n\t" | |
92 ".ALIGN 4 \n\t" | |
93 ".ARM \n" | |
94 "1: push {r7} \n\t" | |
95 "mov r7, %4 \n\t" | |
96 "svc 0x0 \n\t" | |
97 "pop {r7} \n\t" | |
98 "@ Enter THUMB Mode\n\t" | |
99 "adr r3, 2f+1 \n\t" | |
100 "bx r3 \n\t" | |
101 ".THUMB \n" | |
102 "2: \n\t" | |
103 : "=r" (beg) | |
104 : "0" (beg), "r" (end), "r" (flg), "r" (__ARM_NR_cacheflush) | |
105 : "r3"); | |
106 #endif | |
107 #else | 85 #else |
108 #if defined (__arm__) && !defined(__thumb__) | 86 // r7 is reserved by the EABI in thumb mode. |
109 // __arm__ may be defined in thumb mode. | 87 asm volatile( |
110 asm volatile( | 88 "@ Enter ARM Mode \n\t" |
111 "svc %1" | 89 "adr r3, 1f \n\t" |
112 : "=r" (beg) | 90 "bx r3 \n\t" |
113 : "i" (__ARM_NR_cacheflush), "0" (beg), "r" (end), "r" (flg)); | 91 ".ALIGN 4 \n\t" |
114 #else | 92 ".ARM \n" |
115 // Do not use the value of __ARM_NR_cacheflush in the inline assembly | 93 "1: push {r7} \n\t" |
116 // below, because the thumb mode value would be used, which would be | 94 "mov r7, %4 \n\t" |
117 // wrong, since we switch to ARM mode before executing the svc instruction | 95 "svc 0x0 \n\t" |
118 asm volatile( | 96 "pop {r7} \n\t" |
119 "@ Enter ARM Mode \n\t" | 97 "@ Enter THUMB Mode\n\t" |
120 "adr r3, 1f \n\t" | 98 "adr r3, 2f+1 \n\t" |
121 "bx r3 \n\t" | 99 "bx r3 \n\t" |
122 ".ALIGN 4 \n\t" | 100 ".THUMB \n" |
123 ".ARM \n" | 101 "2: \n\t" |
124 "1: svc 0x9f0002 \n" | 102 : "=r" (beg) |
125 "@ Enter THUMB Mode\n\t" | 103 : "0" (beg), "r" (end), "r" (flg), "r" (__ARM_NR_cacheflush) |
126 "adr r3, 2f+1 \n\t" | 104 : "r3"); |
127 "bx r3 \n\t" | |
128 ".THUMB \n" | |
129 "2: \n\t" | |
130 : "=r" (beg) | |
131 : "0" (beg), "r" (end), "r" (flg) | |
132 : "r3"); | |
133 #endif | |
134 #endif | 105 #endif |
135 #endif | 106 #endif |
136 } | 107 } |
137 | 108 |
138 | 109 |
139 void CPU::DebugBreak() { | 110 void CPU::DebugBreak() { |
140 #if !defined (__arm__) || !defined(CAN_USE_ARMV5_INSTRUCTIONS) | 111 #if !defined (__arm__) || !defined(CAN_USE_ARMV5_INSTRUCTIONS) |
141 UNIMPLEMENTED(); // when building ARM emulator target | 112 UNIMPLEMENTED(); // when building ARM emulator target |
142 #else | 113 #else |
143 asm volatile("bkpt 0"); | 114 asm volatile("bkpt 0"); |
144 #endif | 115 #endif |
145 } | 116 } |
146 | 117 |
147 } } // namespace v8::internal | 118 } } // namespace v8::internal |
148 | 119 |
149 #endif // V8_TARGET_ARCH_ARM | 120 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |