From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTKui-0004wU-3r for qemu-devel@nongnu.org; Sun, 14 Sep 2014 21:17:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTKuV-0001kB-Dy for qemu-devel@nongnu.org; Sun, 14 Sep 2014 21:17:08 -0400 Received: from mail-la0-f46.google.com ([209.85.215.46]:52416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTKuV-0001jx-6b for qemu-devel@nongnu.org; Sun, 14 Sep 2014 21:16:55 -0400 Received: by mail-la0-f46.google.com with SMTP id el20so3723668lab.19 for ; Sun, 14 Sep 2014 18:16:54 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <878ulmoumw.fsf@linaro.org> References: <1410626734-3804-1-git-send-email-rth@twiddle.net> <1410626734-3804-6-git-send-email-rth@twiddle.net> <878ulmoumw.fsf@linaro.org> From: Peter Maydell Date: Sun, 14 Sep 2014 18:16:33 -0700 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 05/23] target-ppc: Use cpu_exec_enter qom hook List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QWxleCBCZW5uw6ll?= Cc: Anthony Liguori , "qemu-ppc@nongnu.org" , QEMU Developers , =?UTF-8?Q?Andreas_F=C3=A4rber?= , Richard Henderson On 14 September 2014 12:43, Alex Benn=C3=A9e wrote= : > > Richard Henderson writes: > >> Cc: qemu-ppc@nongnu.org >> Signed-off-by: Richard Henderson > >> +static void ppc_cpu_exec_enter(CPUState *cs) >> +{ >> + PowerPCCPU *cpu =3D POWERPC_CPU(cs); >> + CPUPPCState *env =3D &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