Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / validator_x86 / ncdis_segments.h
1 /*
2  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /*
8  * ncdis_segments.h - Common routine for disassembling a block of code.
9  */
10
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCDIS_SEGMENTS_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCDIS_SEGMENTS_H_
13
14 #ifndef NACL_TRUSTED_BUT_NOT_TCB
15 #error("This file is not meant for use in the TCB")
16 #endif
17
18 #include "native_client/src/shared/utils/types.h"
19 #include "native_client/src/trusted/validator/types_memory_model.h"
20
21 /* Flags that can be passed to the disassembler */
22 typedef enum NaClDisassembleFlag {
23   /* Use the full decoder to disassemble the instruction. */
24   NaClDisassembleFull,
25   /* Use the dissassembler associated with the corresponding decoder. */
26   NaClDisassembleValidatorDecoder,
27   /* If additional internal information is available about the disassembled
28    * instruction, print it also.
29    */
30   NaClDisassembleAddInternals,
31 } NaClDisassembleFlag;
32
33 /* Defines an integer to represent sets of possible disassembler flags. */
34 typedef uint8_t NaClDisassembleFlags;
35
36 /* Converts a NaClDisssembleFlag to the corresponding bit in
37  * NaClDisassembleFlags.
38  */
39 #define NACL_DISASSEMBLE_FLAG(x) (((NaClDisassembleFlags) 1) << (x))
40
41 /* Returns Bool flag defining if given flag is in the set of
42  * disassemble flags.
43  */
44 Bool NaClContainsDisassembleFlag(NaClDisassembleFlags flags,
45                                  NaClDisassembleFlag flag);
46
47 /* Disassemble the code segment, following the rules specified by
48  * the given set of flags.
49  *
50  * Parameters:
51  *    mbase - Memory region containing code segment.
52  *    vbase - PC address associated with first byte of memory region.
53  *    size - Number of bytes in memory region.
54  *    flags - Flags to use when decoding.
55  */
56 void NaClDisassembleSegment(uint8_t* mbase, NaClPcAddress vbase,
57                             NaClMemorySize size, NaClDisassembleFlags flags);
58
59 #endif   /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCDIS_SEGMENTS_H_ */