qemu中的translationblock的成员

Kvm、VMware、Virtualbox、Xen、Qemu 等
回复
millenary
帖子: 2
注册时间: 2012-02-12 22:30

qemu中的translationblock的成员

#1

帖子 millenary » 2012-02-12 23:01

大家好。最近在研究qemu的源码,里面最关键的translationblock这个结构体一直不是很懂。

代码: 全选

struct TranslationBlock {
    target_ulong pc;   /* simulated PC corresponding to this block (EIP + CS base) */
    target_ulong cs_base; /* CS base for this block */
    uint64_t flags; /* flags defining in which context the code was generated */
    uint16_t size;      /* size of target code for this block (1 <=
                           size <= TARGET_PAGE_SIZE) */
    uint16_t cflags;    /* compile flags */
#define CF_COUNT_MASK  0x7fff
#define CF_LAST_IO     0x8000 /* Last insn may be an IO access.  */

    uint8_t *tc_ptr;    /* pointer to the translated code */
    /* next matching tb for physical address. */
    struct TranslationBlock *phys_hash_next;
    /* first and second physical page containing code. The lower bit
       of the pointer tells the index in page_next[] */
    struct TranslationBlock *page_next[2];
    target_ulong page_addr[2];

    /* the following data are used to directly call another TB from
       the code of this one. */
    uint16_t tb_next_offset[2]; /* offset of original jump target */
#ifdef USE_DIRECT_JUMP
    uint16_t tb_jmp_offset[4]; /* offset of jump instruction */
#else
    uintptr_t tb_next[2]; /* address of jump generated code */
#endif
uintptr_t tb_next[2]; /* address of jump generated code */
#endif
    /* list of TBs jumping to this one. This is a circular list using
       the two least significant bits of the pointers to tell what is
       the next pointer: 0 = jmp_next[0], 1 = jmp_next[1], 2 =
       jmp_first */
    struct TranslationBlock *jmp_next[2];
    struct TranslationBlock *jmp_first;
    uint32_t icount;
};


其中几个成员变量倒是理解了,但是其他的比如jmp_next[2]中的两个next的跳转,使用TB指针的后两位来选择方向,两个DEFINE的数字代表的意思等等问题还不是很理解。希望论坛中的各位大大能够解释一下这个结构体中的成员变量都代表什么,谢谢大家。
回复