From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvPZ5-0005Gi-OD for qemu-devel@nongnu.org; Fri, 13 Jun 2014 07:22:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WvPYv-0004Fq-Mk for qemu-devel@nongnu.org; Fri, 13 Jun 2014 07:22:35 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:55467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvPYv-0004Fd-Ef for qemu-devel@nongnu.org; Fri, 13 Jun 2014 07:22:25 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Jun 2014 12:22:24 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 449C81B08061 for ; Fri, 13 Jun 2014 12:22:49 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5DBMMhm33423512 for ; Fri, 13 Jun 2014 11:22:22 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5DCMM5m009727 for ; Fri, 13 Jun 2014 06:22:22 -0600 From: Greg Kurz Date: Fri, 13 Jun 2014 13:22:19 +0200 Message-ID: <20140613112201.22108.52075.stgit@bahia.local> In-Reply-To: <20140613111703.22108.14322.stgit@bahia.local> References: <20140613111703.22108.14322.stgit@bahia.local> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH v8 10/20] cpu: introduce CPUClass::virtio_is_big_endian() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Stefan Hajnoczi , Juan Quintela , Rusty Russell , Alexander Graf , "Michael S. Tsirkin" , aneesh.kumar@linux.vnet.ibm.com, Anthony Liguori , Amit Shah , Paolo Bonzini , Andreas =?utf-8?q?F=C3=A4rber?= If we want to support targets that can change endianness (modern PPC and ARM for the moment), we need to add a per-CPU class method to be called from the virtio code. The virtio_ prefix in the name is a hint for people to avoid misusage (aka. anywhere but from the virtio code). The default behaviour is to return the compile-time default target endianness. Suggested-by: Peter Maydell Signed-off-by: Greg Kurz --- include/qom/cpu.h | 10 ++++++++++ qom/cpu.c | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 4b352a2..30e8fe3 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -116,6 +116,7 @@ typedef struct CPUClass { CPUUnassignedAccess do_unassigned_access; void (*do_unaligned_access)(CPUState *cpu, vaddr addr, int is_write, int is_user, uintptr_t retaddr); + bool (*virtio_is_big_endian)(CPUState *cpu); int (*memory_rw_debug)(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, @@ -548,6 +549,15 @@ void cpu_interrupt(CPUState *cpu, int mask); #endif /* USER_ONLY */ +#ifndef CONFIG_USER_ONLY +static inline bool cpu_virtio_is_big_endian(CPUState *cpu) +{ + CPUClass *cc = CPU_GET_CLASS(cpu); + + return cc->virtio_is_big_endian(cpu); +} +#endif + #ifdef CONFIG_SOFTMMU static inline void cpu_unassigned_access(CPUState *cpu, hwaddr addr, bool is_write, bool is_exec, diff --git a/qom/cpu.c b/qom/cpu.c index fada2d4..d9bf151 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -25,6 +25,7 @@ #include "qemu/log.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" +#include "exec/cpu-common.h" bool cpu_exists(int64_t id) { @@ -196,6 +197,10 @@ static int cpu_common_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg) return 0; } +static bool cpu_common_virtio_is_big_endian(CPUState *cpu) +{ + return target_words_bigendian(); +} void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags) @@ -334,6 +339,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->write_elf64_note = cpu_common_write_elf64_note; k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register; + k->virtio_is_big_endian = cpu_common_virtio_is_big_endian; dc->realize = cpu_common_realizefn; /* * Reason: CPUs still need special care by board code: wiring up