[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [PATCH 05/23] target-ppc: Use cpu_exec_enter
From: |
Peter Maydell |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [PATCH 05/23] target-ppc: Use cpu_exec_enter qom hook |
Date: |
Sun, 14 Sep 2014 18:16:33 -0700 |
On 14 September 2014 12:43, Alex Bennée <address@hidden> wrote:
>
> Richard Henderson writes:
>
>> Cc: address@hidden
>> Signed-off-by: Richard Henderson <address@hidden>
> <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