| 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 /* | 7 /* |
| 8 * ncdecode.h - table driven decoder for Native Client. | 8 * ncdecode.h - table driven decoder for Native Client. |
| 9 * | 9 * |
| 10 * This header file contains type declarations and constants | 10 * This header file contains type declarations and constants |
| 11 * used by the decoder input table | 11 * used by the decoder input table |
| 12 */ | 12 */ |
| 13 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_SEG_SFI_NCDECODE_H_ | 13 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_SEG_SFI_NCDECODE_H_ |
| 14 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_SEG_SFI_NCDECODE_H_ | 14 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_SEG_SFI_NCDECODE_H_ |
| 15 | 15 |
| 16 #include "native_client/src/shared/utils/types.h" | 16 #include "native_client/src/shared/utils/types.h" |
| 17 #include "native_client/src/trusted/validator/ncvalidate.h" |
| 17 #include "native_client/src/trusted/validator/x86/error_reporter.h" | 18 #include "native_client/src/trusted/validator/x86/error_reporter.h" |
| 18 #include "native_client/src/trusted/validator/x86/ncinstbuffer.h" | 19 #include "native_client/src/trusted/validator/x86/ncinstbuffer.h" |
| 19 #include "native_client/src/trusted/validator/x86/x86_insts.h" | 20 #include "native_client/src/trusted/validator/x86/x86_insts.h" |
| 20 | 21 |
| 21 EXTERN_C_BEGIN | 22 EXTERN_C_BEGIN |
| 22 | 23 |
| 23 struct NCDecoderInst; | 24 struct NCDecoderInst; |
| 24 struct NCDecoderState; | 25 struct NCDecoderState; |
| 25 | 26 |
| 26 /* Function type for a decoder action. Returns TRUE if action | 27 /* Function type for a decoder action. Returns TRUE if action |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 /* PROTECTED: */ | 379 /* PROTECTED: */ |
| 379 | 380 |
| 380 /* The old decoder state. */ | 381 /* The old decoder state. */ |
| 381 NCDecoderState* old_dstate; | 382 NCDecoderState* old_dstate; |
| 382 | 383 |
| 383 /* The new decoder state. */ | 384 /* The new decoder state. */ |
| 384 NCDecoderState* new_dstate; | 385 NCDecoderState* new_dstate; |
| 385 | 386 |
| 386 /* The (virtual method) action to apply to each instruction. */ | 387 /* The (virtual method) action to apply to each instruction. */ |
| 387 NCDecoderStatePairAction action_fn; | 388 NCDecoderStatePairAction action_fn; |
| 389 |
| 390 /* Utility function that copies a single instruction in memory, can be used in |
| 391 * actions. |
| 392 */ |
| 393 NaClCopyInstructionFunc copy_func; |
| 388 } NCDecoderStatePair; | 394 } NCDecoderStatePair; |
| 389 | 395 |
| 390 /* | 396 /* |
| 391 * Construct a decoder state pair. | 397 * Construct a decoder state pair. |
| 392 * | 398 * |
| 393 * Parameters are: | 399 * Parameters are: |
| 394 * tthis - The decoder state pair to construct. | 400 * tthis - The decoder state pair to construct. |
| 395 * old_dstate - A constructed old decoder state to use. | 401 * old_dstate - A constructed old decoder state to use. |
| 396 * new_dstate - A constructed new decoder state to use. | 402 * new_dstate - A constructed new decoder state to use. |
| 397 * | 403 * |
| 398 * Note: Constructors of subclasses of NCDecoderStatePair should | 404 * Note: Constructors of subclasses of NCDecoderStatePair should |
| 399 * call this constructor first, to initialize the decoder pair fields. | 405 * call this constructor first, to initialize the decoder pair fields. |
| 400 */ | 406 */ |
| 401 extern void NCDecoderStatePairConstruct(NCDecoderStatePair* tthis, | 407 extern void NCDecoderStatePairConstruct( |
| 402 NCDecoderState* old_dstate, | 408 NCDecoderStatePair* tthis, |
| 403 NCDecoderState* new_dstate); | 409 NCDecoderState* old_dstate, |
| 410 NCDecoderState* new_dstate, |
| 411 NaClCopyInstructionFunc copy_func); |
| 404 | 412 |
| 405 /* | 413 /* |
| 406 * Decode the memory segments in each instruction state, applying | 414 * Decode the memory segments in each instruction state, applying |
| 407 * the appropriate action on each instruction till either: | 415 * the appropriate action on each instruction till either: |
| 408 * (1) The instruction lengths differ. | 416 * (1) The instruction lengths differ. |
| 409 * (2) The action returns false. | 417 * (2) The action returns false. |
| 410 * Returns true if no instruction lengths differ, and the action | 418 * Returns true if no instruction lengths differ, and the action |
| 411 * returns true for all found instructions. | 419 * returns true for all found instructions. |
| 412 */ | 420 */ |
| 413 extern Bool NCDecoderStatePairDecode(NCDecoderStatePair* tthis); | 421 extern Bool NCDecoderStatePairDecode(NCDecoderStatePair* tthis); |
| 414 | 422 |
| 415 /* | 423 /* |
| 416 * Destruct a decoder state pair. | 424 * Destruct a decoder state pair. |
| 417 * | 425 * |
| 418 * Note: Destructors of subclasses of NCDecoderStatePair should | 426 * Note: Destructors of subclasses of NCDecoderStatePair should |
| 419 * call this distructor last, after the subinstance has been destructed. | 427 * call this distructor last, after the subinstance has been destructed. |
| 420 */ | 428 */ |
| 421 extern void NCDecoderStatePairDestruct(NCDecoderStatePair* tthis); | 429 extern void NCDecoderStatePairDestruct(NCDecoderStatePair* tthis); |
| 422 | 430 |
| 423 EXTERN_C_END | 431 EXTERN_C_END |
| 424 | 432 |
| 425 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_SEG_SFI_NCDECODE_H_ */ | 433 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_SEG_SFI_NCDECODE_H_ */ |
| OLD | NEW |