OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_V2_MODEL_H | 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_V2_MODEL_H |
8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_V2_MODEL_H | 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_V2_MODEL_H |
9 | 9 |
10 /* | 10 /* |
(...skipping 17 matching lines...) Expand all Loading... |
28 * but anything nontrivial should go in model-inl.h. | 28 * but anything nontrivial should go in model-inl.h. |
29 * - Do not declare destructors. A destructor causes an object to be passed | 29 * - Do not declare destructors. A destructor causes an object to be passed |
30 * on the stack, even when passed by value. (This may be a GCC bug.) | 30 * on the stack, even when passed by value. (This may be a GCC bug.) |
31 * Adding a destructor to Instruction slowed the decoder down by 10% on | 31 * Adding a destructor to Instruction slowed the decoder down by 10% on |
32 * gcc 4.3.3. | 32 * gcc 4.3.3. |
33 */ | 33 */ |
34 | 34 |
35 #include <stdint.h> | 35 #include <stdint.h> |
36 #include <cstddef> | 36 #include <cstddef> |
37 #include <string> | 37 #include <string> |
| 38 #include "native_client/src/include/arm_sandbox.h" |
38 #include "native_client/src/include/portability_bits.h" | 39 #include "native_client/src/include/portability_bits.h" |
39 | 40 |
40 namespace nacl_arm_dec { | 41 namespace nacl_arm_dec { |
41 | 42 |
42 class RegisterList; | 43 class RegisterList; |
43 | 44 |
44 // Defines the architecture version of the ARM processor. Currently assumes | 45 // Defines the architecture version of the ARM processor. Currently assumes |
45 // always 7. | 46 // always 7. |
46 // TODO(karl): Generalize this to handle multiple versions, once we know how | 47 // TODO(karl): Generalize this to handle multiple versions, once we know how |
47 // to do this. | 48 // to do this. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 RegisterList& operator=(const RegisterList& r); // Disallow assignment. | 250 RegisterList& operator=(const RegisterList& r); // Disallow assignment. |
250 }; | 251 }; |
251 | 252 |
252 | 253 |
253 // The number of bits in an ARM instruction. | 254 // The number of bits in an ARM instruction. |
254 static const int kArm32InstSize = 32; | 255 static const int kArm32InstSize = 32; |
255 | 256 |
256 // The number of bits in a word of a THUMB instruction. | 257 // The number of bits in a word of a THUMB instruction. |
257 static const int kThumbWordSize = 16; | 258 static const int kThumbWordSize = 16; |
258 | 259 |
259 // BKPT #0x7777 is used as literal pool head. | 260 // Special ARM instructions for sandboxing. |
260 static const uint32_t kLiteralPoolHeadInstruction = 0xE1277777; | 261 static const uint32_t kLiteralPoolHead = NACL_INSTR_LITERAL_POOL_HEAD; |
| 262 static const uint32_t kBreakpoint = NACL_INSTR_BREAKPOINT; |
| 263 static const uint32_t kHaltFill = NACL_INSTR_HALT_FILL; |
| 264 static const uint32_t kAbortNow = NACL_INSTR_ABORT_NOW; |
| 265 static const uint32_t kFailValidation = NACL_INSTR_FAIL_VALIDATION; |
261 | 266 |
262 // Models an instruction, either a 32-bit ARM instruction of unspecified type, | 267 // Models an instruction, either a 32-bit ARM instruction of unspecified type, |
263 // or one word (16-bit) and two word (32-bit) THUMB instructions. | 268 // or one word (16-bit) and two word (32-bit) THUMB instructions. |
264 // | 269 // |
265 // This class is designed for efficiency: | 270 // This class is designed for efficiency: |
266 // - Its public methods for bitfield extraction are short and inline. | 271 // - Its public methods for bitfield extraction are short and inline. |
267 // - It has no vtable, so on 32-bit platforms it's exactly the size of the | 272 // - It has no vtable, so on 32-bit platforms it's exactly the size of the |
268 // instruction it models. | 273 // instruction it models. |
269 // - API's exist for accessing both ARM (32-bit) instructions and | 274 // - API's exist for accessing both ARM (32-bit) instructions and |
270 // THUMB instructions (which are 1 or two (16-bit) words). | 275 // THUMB instructions (which are 1 or two (16-bit) words). |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 } | 495 } |
491 | 496 |
492 private: | 497 private: |
493 uint32_t bits_; | 498 uint32_t bits_; |
494 Instruction& operator=(const Instruction& insn); // Disallow assignment. | 499 Instruction& operator=(const Instruction& insn); // Disallow assignment. |
495 }; | 500 }; |
496 | 501 |
497 } // namespace nacl_arm_dec | 502 } // namespace nacl_arm_dec |
498 | 503 |
499 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_V2_MODEL_H | 504 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_V2_MODEL_H |
OLD | NEW |