qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] How does env_to_regs and regs_to_env works?
@ 2010-05-31  8:41 曹莹
  2010-06-02 21:25 ` Stuart Brady
  0 siblings, 1 reply; 2+ messages in thread
From: 曹莹 @ 2010-05-31  8:41 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1588 bytes --]

Now, I’m working with Qemu source study, but I have some difficulties. Could someday give me some help or advice.

 

At the beginning of cpu_exec, there is a function call env_to_regs, but I cannot understand the behavior of env_to_regs. In my understanding, env_to_regs stores environment context pointer(pointer that points to X86CPUState)  and other critical Qemu defined variable to real host register, that is to say function env_to_regs accomplishes the task register mapping for translating optimization. That is my understanding, but I really understand the codes in env_to_regs and regs_to_env. Codes in env_to_regs are like this:

#ifdef reg_EAX

EAX = env->regs[R_EAX];

…………

I cannot find where the micro reg_EAX is defined, actually, I insert one line: printf(“reg_EAX is defined!\n”) after #ifdef reg_EAX into Qemu source, compile it and run Qemu, there is no output information, so I think, env_to_regs is actually a void function (For other micro define, situations are the same). But if this is true, how did Qemu’s register mapping accomplished? 

 

If I suppose that reg_EAX has already defined somewhere in Qemu source, but how does EAX = env->regs[R_EAX] works? EAX is also a micro definition like this #define EAX (env->regs[R_EAX]). Then the code becomes like this: env->regs[R_EAX]= env->regs[R_EAX]. Left side and right side of “=” is the same . So how does regs_to_env and regs_to_env work? How to understand the functionality of the two functions, Could anyone give me some advice. I will own my thankfulness for all of you. Thank you very much.

 

[-- Attachment #2: Type: text/html, Size: 5759 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-02 21:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-31  8:41 [Qemu-devel] How does env_to_regs and regs_to_env works? 曹莹
2010-06-02 21:25 ` Stuart Brady

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).