On 14 September 2014 12:43, Alex Bennée <alex.ben...@linaro.org> wrote:
>
> Richard Henderson writes:
>
>> Cc: qemu-...@nongnu.org
>> Signed-off-by: Richard Henderson <r...@twiddle.net>
> <snip>
>> +static void ppc_cpu_exec_enter(CPUState *cs)
>> +{
>> +    PowerPCCPU *cpu = POWERPC_CPU(cs);
>> +    CPUPPCState *env = &cpu->env;
>> +
>
> Ok the naming of those structures and the order to traverse them gets
> confusing - is it really CPUState -> ${ARCH}CPU -> ${ARCH}CPUState?

CPUState is the QOM base class name. The
subclass names are ${ARCH}CPU. CPU${ARCH}State
is the name of the "env struct" which is embedded
within the ${ARCH}CPU struct (but not at the start of it).

The available conversions are:
 ${ARCH}CPU to CPUState : CPU(x)
 CPUState to ${ARCH}CPU : ${ARCH}_CPU(cs)
(these are just the stock QOM casting macros)

 ${ARCH}CPU to env: &cpu->env
 env to ${ARCH}CPU: ${arch}_env_get_cpu(env)
(the latter is just a container_of operation)

 env to CPUState: ENV_GET_CPU(env)
 CPUState to env: convert via ${ARCH}_CPU
(and actually ENV_GET_CPU is just sugar for
a conversion via ${ARCH}_CPU)

As a method on the base QOM CPU class, this
family of functions is correctly taking CPUState*
as the argument.

-- PMM

Reply via email to