From patchwork Tue May 17 14:24:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 9112631 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 381E19F1C3 for ; Tue, 17 May 2016 14:26:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50EF52022D for ; Tue, 17 May 2016 14:26:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E4512021B for ; Tue, 17 May 2016 14:26:32 +0000 (UTC) Received: from localhost ([::1]:50537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2fx9-0004j8-BM for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 May 2016 10:26:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2fve-0001WP-Iw for qemu-devel@nongnu.org; Tue, 17 May 2016 10:25:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2fvZ-0000d5-CY for qemu-devel@nongnu.org; Tue, 17 May 2016 10:24:58 -0400 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:33294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2fvY-0000cl-WB for qemu-devel@nongnu.org; Tue, 17 May 2016 10:24:53 -0400 Received: by mail-lf0-x244.google.com with SMTP id j8so1280075lfd.0 for ; Tue, 17 May 2016 07:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=a9tHnslMD19Qlkhx1pFWxenr9H7IwkXfTwmFFenCKew=; b=G27USvwd+FStMXBjjK7OEF9MQsU8fM/4o8Y1s8AD2FZnzNjNFyhKvLSSjzkCVxPVt1 N40flzsk7ZHsht1w4lLt8kllBz4t0tD7BKFDV0+wZZbNv4PurZQscO3RvuK9XXQ5LPCx LNEeLy7C7XZizvxRsp8Aq6zB9sp7D2pVzTS0hu+KUllsYp/W+17Kf66f03F6hddrBIUu elz96FH1FrZ3gmx/OOiMhI9nmqu6ACfUaIMNmaYqZVso6aZhKFS0VrCWTTbJTDw6w2YO mxATqKqr05k1zLz2G3iCPH1AuBPl7lL1AqO6Ny3blkeRzjlpFbN5M4DUNfhPaesXRyho nolQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=a9tHnslMD19Qlkhx1pFWxenr9H7IwkXfTwmFFenCKew=; b=ieX/cp4nFpolbniKm1zDVEI+Jq/NK7SrgUNHf/3X2IEPuOrVdxGgZ5v6OrR/2XRQ9f 8mjgIZYO0zwbAFxpNeLsdl8Z1uBpIsodht9yA4Yb+/MexWUcHWZI+/PWpNcHjlGmzHSO jrgWtQ3M1qnRzVrj2gRTVD9q8HD25gpw0FUI9TwNFEfE02dcsDhp92Q7J4kvxpR0vtgw tOJKgV/FqbPUOe7NeJdaOY/Lzx4BUQDFf7ZXpL+rZeLsofjI5yEc71MEIizRT/Wv4beN goHnjrf/Bf4MFT6TaVFU1G+ftGEbaP/J7tYAaBrjjAZ63ENtD3Gi6Ni/wBIMdFp0h01p LPYA== X-Gm-Message-State: AOPr4FXWnUUGaT+akyF2hXwMvFWfCeZzuRvlT8rV3p284+ThvAc1KWvYRRq7HhFwWCgkyw== X-Received: by 10.25.24.170 with SMTP id 42mr649350lfy.47.1463495091941; Tue, 17 May 2016 07:24:51 -0700 (PDT) Received: from octofox.metropolis ([5.19.183.212]) by smtp.gmail.com with ESMTPSA id xx7sm528770lbb.19.2016.05.17.07.24.50 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 May 2016 07:24:50 -0700 (PDT) Date: Tue, 17 May 2016 17:24:44 +0300 From: Max Filippov To: Paolo Bonzini Message-ID: <20160517142444.GA4915@octofox.metropolis> References: <1463412982-6681-1-git-send-email-pbonzini@redhat.com> <1463412982-6681-21-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1463412982-6681-21-git-send-email-pbonzini@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::244 Subject: Re: [Qemu-devel] [PATCH 20/50] target-xtensa: make cpu-qom.h not target specific X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_FROM, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Paolo, On Mon, May 16, 2016 at 05:35:52PM +0200, Paolo Bonzini wrote: > Make XtensaCPU an opaque type within cpu-qom.h, and move all definitions > of private methods, as well as all type definitions that require knowledge > of the layout to cpu.h. Conversely, move all definitions needed to > define a class to cpu-qom.h. This helps making files independent of > NEED_CPU_H if they only need to pass around CPU pointers. XtensaCPUClass doesn't need definition of XtensaConfig that pulled a lot of related structures, macros and enums from cpu.h. Mere typedef struct XtensaConfig XtensaConfig; above the XtensaCPUClass could be enough. How about the following? diff --git a/target-xtensa/cpu-qom.h b/target-xtensa/cpu-qom.h index f5d9b9f..403bd95 100644 --- a/target-xtensa/cpu-qom.h +++ b/target-xtensa/cpu-qom.h @@ -40,6 +40,8 @@ #define XTENSA_CPU_GET_CLASS(obj) \ OBJECT_GET_CLASS(XtensaCPUClass, (obj), TYPE_XTENSA_CPU) +typedef struct XtensaConfig XtensaConfig; + /** * XtensaCPUClass: * @parent_realize: The parent class' realize handler. @@ -59,40 +61,6 @@ typedef struct XtensaCPUClass { const XtensaConfig *config; } XtensaCPUClass; -/** - * XtensaCPU: - * @env: #CPUXtensaState - * - * An Xtensa CPU. - */ -typedef struct XtensaCPU { - /*< private >*/ - CPUState parent_obj; - /*< public >*/ - - CPUXtensaState env; -} XtensaCPU; - -static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env) -{ - return container_of(env, XtensaCPU, env); -} - -#define ENV_GET_CPU(e) CPU(xtensa_env_get_cpu(e)) - -#define ENV_OFFSET offsetof(XtensaCPU, env) - -void xtensa_cpu_do_interrupt(CPUState *cpu); -bool xtensa_cpu_exec_interrupt(CPUState *cpu, int interrupt_request); -void xtensa_cpu_do_unassigned_access(CPUState *cpu, hwaddr addr, - bool is_write, bool is_exec, int opaque, - unsigned size); -void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); -hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int xtensa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); -int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, - int is_write, int is_user, uintptr_t retaddr); +typedef struct XtensaCPU XtensaCPU; #endif diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h index d0bd9da..f6bbe29 100644 --- a/target-xtensa/cpu.h +++ b/target-xtensa/cpu.h @@ -34,6 +34,7 @@ #define CPUArchState struct CPUXtensaState #include "qemu-common.h" +#include "cpu-qom.h" #include "exec/cpu-defs.h" #include "fpu/softfloat.h" @@ -379,7 +380,41 @@ typedef struct CPUXtensaState { CPU_COMMON } CPUXtensaState; -#include "cpu-qom.h" +/** + * XtensaCPU: + * @env: #CPUXtensaState + * + * An Xtensa CPU. + */ +struct XtensaCPU { + /*< private >*/ + CPUState parent_obj; + /*< public >*/ + + CPUXtensaState env; +}; + +static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env) +{ + return container_of(env, XtensaCPU, env); +} + +#define ENV_GET_CPU(e) CPU(xtensa_env_get_cpu(e)) + +#define ENV_OFFSET offsetof(XtensaCPU, env) + +void xtensa_cpu_do_interrupt(CPUState *cpu); +bool xtensa_cpu_exec_interrupt(CPUState *cpu, int interrupt_request); +void xtensa_cpu_do_unassigned_access(CPUState *cpu, hwaddr addr, + bool is_write, bool is_exec, int opaque, + unsigned size); +void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, + fprintf_function cpu_fprintf, int flags); +hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); +int xtensa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, + int is_write, int is_user, uintptr_t retaddr); #define cpu_exec cpu_xtensa_exec #define cpu_signal_handler cpu_xtensa_signal_handler