From nobody Fri May 3 07:16:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502944393153844.1991458795186; Wed, 16 Aug 2017 21:33:13 -0700 (PDT) Received: from localhost ([::1]:56536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCUZ-0001nn-Sh for importer@patchew.org; Thu, 17 Aug 2017 00:33:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCSl-0000KH-OZ for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diCSk-0004rp-RM for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:19 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:37988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diCSk-0004rO-MT for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:18 -0400 Received: by mail-qt0-x242.google.com with SMTP id p3so5286826qtg.5 for ; Wed, 16 Aug 2017 21:31:18 -0700 (PDT) Received: from yoga.offpageads.com (host21.190-139-16.telecom.net.ar. [190.139.16.21]) by smtp.gmail.com with ESMTPSA id l11sm1748738qtl.24.2017.08.16.21.31.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 21:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RxC0vxxKITW5Zpevpx/giZ850aN0cy/13wdGO3lBY30=; b=TWhfEMTi672beLzeV50zX9A6Ijf42Zv0+tvntInUVOe91Pq+8r15xSzpuNRsNvhoy6 DqKAq9PX5NbooY7+gz9FlXQpuypULu6Be56Ag8ApOcFBd4q7xB/Q6YRhSgKngRZ2/lek HoUbDCSpi9HrgBdPmp59S+PP/S7RtoAM4v2gsr9B7sIq0qPAh4D/3rWjKOMg1oXLKiLH mItDleAuj8fafceU3osKYPnPp8O5Wh1unGum5/KcNB9RDtfijkJQBN4e61wlEZOw4UcP rXh+FE8nIJMNywj7QLfD82v0Z+ODv3QOeb+NBthYAIUt0P2YBsrSHfk7fEBICSQmNaKw JJfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=RxC0vxxKITW5Zpevpx/giZ850aN0cy/13wdGO3lBY30=; b=Ez0a1b0/4R1qL3xp5I2V7hz9Yjhcnl5uld/Y4DNexPYD77KaiPnNmcy1wTXJh68DVO tC6lLKMKCb1+mQ1phEAWvbPcRrbjNFu0iZ13z7xSojyes0cT0Lv/ZcxEl5ESJMJMUJ3m /XakQn+gqnEuLXiRIjg7BTl4qrx+LZWRGd8SmIkE807MkjtM0PZFUET5G/zPbN6dQz1M D/7/r/TtI1R1qWBtGuZjurH5xH4Be4cj2TKdgVz/ZL0we+Z9gWYfta7QOQC9pM9D7Rjv +G9bTV/Ug4tZ7j3b3bsyi6XdOa1z9sbmFbQ1BxOAhUjnOqThh96Pg323Urw2KKQOUv59 r+VA== X-Gm-Message-State: AHYfb5hJACtKglnPmEYZqSCv7yPW/469Tq1iHNgLf1RDqs1rZRTgHm6B pR/JHjLY6k8mjQ== X-Received: by 10.200.36.121 with SMTP id d54mr5859259qtd.171.1502944278191; Wed, 16 Aug 2017 21:31:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Igor Mammedov , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Yongbok Kim Date: Thu, 17 Aug 2017 01:30:55 -0300 Message-Id: <20170817043102.6322-2-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817043102.6322-1-f4bug@amsat.org> References: <20170817043102.6322-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH 1/8] mips: move hw/mips/cputimer.c to target/mips/ 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: Peter Maydell , Thomas Huth , James Hogan , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 This timer is a required part of the MIPS32/MIPS64 System Control coprocess= or (CP0). Moving it with the other architecture related files will allow an op= aque use of CPUMIPSState* in the next commit (introduce "internal.h"). also remove it from 'user' targets, remove an unnecessary include. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Igor Mammedov --- hw/mips/cputimer.c =3D> target/mips/cp0_timer.c | 1 - hw/mips/Makefile.objs | 2 +- target/mips/Makefile.objs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) rename hw/mips/cputimer.c =3D> target/mips/cp0_timer.c (99%) diff --git a/hw/mips/cputimer.c b/target/mips/cp0_timer.c similarity index 99% rename from hw/mips/cputimer.c rename to target/mips/cp0_timer.c index 8a166b3ea7..a9a58c5604 100644 --- a/hw/mips/cputimer.c +++ b/target/mips/cp0_timer.c @@ -21,7 +21,6 @@ */ =20 #include "qemu/osdep.h" -#include "hw/hw.h" #include "hw/mips/cpudevs.h" #include "qemu/timer.h" #include "sysemu/kvm.h" diff --git a/hw/mips/Makefile.objs b/hw/mips/Makefile.objs index 48cd2ef50e..17a311aaba 100644 --- a/hw/mips/Makefile.objs +++ b/hw/mips/Makefile.objs @@ -1,5 +1,5 @@ obj-y +=3D mips_r4k.o mips_malta.o mips_mipssim.o -obj-y +=3D addr.o cputimer.o mips_int.o +obj-y +=3D addr.o mips_int.o obj-$(CONFIG_JAZZ) +=3D mips_jazz.o obj-$(CONFIG_FULONG) +=3D mips_fulong2e.o obj-y +=3D gt64xxx_pci.o diff --git a/target/mips/Makefile.objs b/target/mips/Makefile.objs index bc5ed8511f..651f36f517 100644 --- a/target/mips/Makefile.objs +++ b/target/mips/Makefile.objs @@ -1,4 +1,4 @@ obj-y +=3D translate.o dsp_helper.o op_helper.o lmi_helper.o helper.o cpu.o obj-y +=3D gdbstub.o msa_helper.o mips-semi.o -obj-$(CONFIG_SOFTMMU) +=3D machine.o +obj-$(CONFIG_SOFTMMU) +=3D machine.o cp0_timer.o obj-$(CONFIG_KVM) +=3D kvm.o --=20 2.14.1 From nobody Fri May 3 07:16:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150294440917175.55619834533218; Wed, 16 Aug 2017 21:33:29 -0700 (PDT) Received: from localhost ([::1]:56538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCUp-00024d-Rf for importer@patchew.org; Thu, 17 Aug 2017 00:33:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCSt-0000Sq-3b for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diCSp-0004w1-T6 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:27 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:38340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diCSp-0004vl-N8 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:23 -0400 Received: by mail-qk0-x242.google.com with SMTP id m84so5143469qki.5 for ; Wed, 16 Aug 2017 21:31:23 -0700 (PDT) Received: from yoga.offpageads.com (host21.190-139-16.telecom.net.ar. [190.139.16.21]) by smtp.gmail.com with ESMTPSA id l11sm1748738qtl.24.2017.08.16.21.31.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 21:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=higQbEeKTDP7G1p0/7qFhdTXV0favRoW73+wHUX7oVc=; b=Ru4xnM3ie90Thv/M8jgBxZaJ6w8dLcF5OiFWMO7br0OojCYnKrLgx5dL9pfBhnSgWe rYdPoTux/NONdgN2sLvRILKTQI6Pc8mMsxJSP0gu06XEeX1QeDXT19C3rKCTmrRi52wC Sh71kh0UKuXK9WwxgLaeeLoWBIubwP7Safiaxoq7A839H7bWLQOALFEFoygQstOvig57 xyLL/RkCWKzobNUCvoEskHgXYCiXvJngfizzhsZLXJA1sTLodK69y/LkczRcjJN5zHKS M7SP/53JGmD2uqjjoJ1Rtt2Vb7GFSjlCDo67hT8daEidK7wfwaPsls0s1ivrbaZXAmYE r7uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=higQbEeKTDP7G1p0/7qFhdTXV0favRoW73+wHUX7oVc=; b=o2YRM0E99cq/+h3+x5UEFO7kvHtp9wcMosCOVfsq4qhN0NLShIr6RpHvBkOqINY8uh vcIu7M3JqPHGZcSFgY+kAxggvJ0FU1UUoEDyemH1hYr4RDGW5miGmJLzqNRdKfAAyWbf mgxVeC4QJqumiwiPZSRTuVcOWc3+QeMqmFtohYJQJRtsJ+9PVTuolU/Ur6fKWuwxJBo1 cflKawpy+s8vxnQn9FW1kE3+0MAolSNce+A1CMFfipeJ4cbHK1lgRYPCiUkKLRWh+i6i boqnTR5nX32Q+OHxyHlXxO9L5NKrP7cuiJDM6iwd7Ch7ViHWGT9CRCpQahIxAVpaY5cs LqBA== X-Gm-Message-State: AHYfb5hWzCmNIZ0yUZ8MIwCzwpyXE4Pv5DOTaZ4on1gazOCsZKN65Bwf 0L0JNCrXCoMC6g== X-Received: by 10.55.148.70 with SMTP id w67mr4934024qkd.160.1502944282661; Wed, 16 Aug 2017 21:31:22 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Igor Mammedov , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Yongbok Kim Date: Thu, 17 Aug 2017 01:30:56 -0300 Message-Id: <20170817043102.6322-3-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817043102.6322-1-f4bug@amsat.org> References: <20170817043102.6322-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH 2/8] mips: introduce internal.h and cleanup cpu.h 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: Peter Maydell , Thomas Huth , James Hogan , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 no logical change, only code movement (and fix a comment typo). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Igor Mammedov --- target/mips/cpu.h | 354 +------------------------------------------= -- target/mips/internal.h | 362 +++++++++++++++++++++++++++++++++++++++++++= ++++ target/mips/cp0_timer.c | 1 + target/mips/cpu.c | 1 + target/mips/gdbstub.c | 1 + target/mips/helper.c | 1 + target/mips/kvm.c | 1 + target/mips/machine.c | 1 + target/mips/msa_helper.c | 1 + target/mips/op_helper.c | 1 + target/mips/translate.c | 1 + 11 files changed, 372 insertions(+), 353 deletions(-) create mode 100644 target/mips/internal.h diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 74f6a5b098..2f81e0f950 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1,8 +1,6 @@ #ifndef MIPS_CPU_H #define MIPS_CPU_H =20 -//#define DEBUG_OP - #define ALIGNED_ONLY =20 #define CPUArchState struct CPUMIPSState @@ -15,56 +13,11 @@ =20 struct CPUMIPSState; =20 -typedef struct r4k_tlb_t r4k_tlb_t; -struct r4k_tlb_t { - target_ulong VPN; - uint32_t PageMask; - uint16_t ASID; - unsigned int G:1; - unsigned int C0:3; - unsigned int C1:3; - unsigned int V0:1; - unsigned int V1:1; - unsigned int D0:1; - unsigned int D1:1; - unsigned int XI0:1; - unsigned int XI1:1; - unsigned int RI0:1; - unsigned int RI1:1; - unsigned int EHINV:1; - uint64_t PFN[2]; -}; - -#if !defined(CONFIG_USER_ONLY) typedef struct CPUMIPSTLBContext CPUMIPSTLBContext; -struct CPUMIPSTLBContext { - uint32_t nb_tlb; - uint32_t tlb_in_use; - int (*map_address) (struct CPUMIPSState *env, hwaddr *physical, int *p= rot, target_ulong address, int rw, int access_type); - void (*helper_tlbwi)(struct CPUMIPSState *env); - void (*helper_tlbwr)(struct CPUMIPSState *env); - void (*helper_tlbp)(struct CPUMIPSState *env); - void (*helper_tlbr)(struct CPUMIPSState *env); - void (*helper_tlbinv)(struct CPUMIPSState *env); - void (*helper_tlbinvf)(struct CPUMIPSState *env); - union { - struct { - r4k_tlb_t tlb[MIPS_TLB_MAX]; - } r4k; - } mmu; -}; -#endif =20 /* MSA Context */ #define MSA_WRLEN (128) =20 -enum CPUMIPSMSADataFormat { - DF_BYTE =3D 0, - DF_HALF, - DF_WORD, - DF_DOUBLE -}; - typedef union wr_t wr_t; union wr_t { int8_t b[MSA_WRLEN/8]; @@ -682,40 +635,6 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *= env) =20 #define ENV_OFFSET offsetof(MIPSCPU, env) =20 -#ifndef CONFIG_USER_ONLY -extern const struct VMStateDescription vmstate_mips_cpu; -#endif - -void mips_cpu_do_interrupt(CPUState *cpu); -bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req); -void mips_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fpri= ntf, - int flags); -hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int mips_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); -int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, - MMUAccessType access_type, - int mmu_idx, uintptr_t retaddr); - -#if !defined(CONFIG_USER_ONLY) -int no_mmu_map_address (CPUMIPSState *env, hwaddr *physical, int *prot, - target_ulong address, int rw, int access_type); -int fixed_mmu_map_address (CPUMIPSState *env, hwaddr *physical, int *prot, - target_ulong address, int rw, int access_type); -int r4k_map_address (CPUMIPSState *env, hwaddr *physical, int *prot, - target_ulong address, int rw, int access_type); -void r4k_helper_tlbwi(CPUMIPSState *env); -void r4k_helper_tlbwr(CPUMIPSState *env); -void r4k_helper_tlbp(CPUMIPSState *env); -void r4k_helper_tlbr(CPUMIPSState *env); -void r4k_helper_tlbinv(CPUMIPSState *env); -void r4k_helper_tlbinvf(CPUMIPSState *env); - -void mips_cpu_unassigned_access(CPUState *cpu, hwaddr addr, - bool is_write, bool is_exec, int unused, - unsigned size); -#endif - void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf); =20 #define cpu_signal_handler cpu_mips_signal_handler @@ -746,42 +665,6 @@ static inline int cpu_mmu_index (CPUMIPSState *env, bo= ol ifetch) return hflags_mmu_index(env->hflags); } =20 -static inline bool cpu_mips_hw_interrupts_enabled(CPUMIPSState *env) -{ - return (env->CP0_Status & (1 << CP0St_IE)) && - !(env->CP0_Status & (1 << CP0St_EXL)) && - !(env->CP0_Status & (1 << CP0St_ERL)) && - !(env->hflags & MIPS_HFLAG_DM) && - /* Note that the TCStatus IXMT field is initialized to zero, - and only MT capable cores can set it to one. So we don't - need to check for MT capabilities here. */ - !(env->active_tc.CP0_TCStatus & (1 << CP0TCSt_IXMT)); -} - -/* Check if there is pending and not masked out interrupt */ -static inline bool cpu_mips_hw_interrupts_pending(CPUMIPSState *env) -{ - int32_t pending; - int32_t status; - bool r; - - pending =3D env->CP0_Cause & CP0Ca_IP_mask; - status =3D env->CP0_Status & CP0Ca_IP_mask; - - if (env->CP0_Config3 & (1 << CP0C3_VEIC)) { - /* A MIPS configured with a vectorizing external interrupt control= ler - will feed a vector into the Cause pending lines. The core treats - the status lines as a vector level, not as indiviual masks. */ - r =3D pending > status; - } else { - /* A MIPS configured with compatibility or VInt (Vectored Interrup= ts) - treats the pending lines as individual interrupt lines, the sta= tus - lines are individual masks. */ - r =3D (pending & status) !=3D 0; - } - return r; -} - #include "exec/cpu-all.h" =20 /* Memory access type : @@ -847,14 +730,13 @@ enum { #define EXCP_SC 0x100 =20 /* - * This is an interrnally generated WAKE request line. + * This is an internally generated WAKE request line. * It is driven by the CPU itself. Raised when the MT * block wants to wake a VPE from an inactive state and * cleared when VPE goes from active to inactive. */ #define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0 =20 -void mips_tcg_init(void); MIPSCPU *cpu_mips_init(const char *cpu_model); int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc); =20 @@ -863,84 +745,18 @@ bool cpu_supports_cps_smp(const char *cpu_model); bool cpu_supports_isa(const char *cpu_model, unsigned int isa); void cpu_set_exception_base(int vp_index, target_ulong address); =20 -/* TODO QOM'ify CPU reset and remove */ -void cpu_state_reset(CPUMIPSState *s); - -/* mips_timer.c */ -uint32_t cpu_mips_get_random (CPUMIPSState *env); -uint32_t cpu_mips_get_count (CPUMIPSState *env); -void cpu_mips_store_count (CPUMIPSState *env, uint32_t value); -void cpu_mips_store_compare (CPUMIPSState *env, uint32_t value); -void cpu_mips_start_count(CPUMIPSState *env); -void cpu_mips_stop_count(CPUMIPSState *env); - /* mips_int.c */ void cpu_mips_soft_irq(CPUMIPSState *env, int irq, int level); =20 /* helper.c */ -int mips_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw, - int mmu_idx); - -/* op_helper.c */ -uint32_t float_class_s(uint32_t arg, float_status *fst); -uint64_t float_class_d(uint64_t arg, float_status *fst); - -#if !defined(CONFIG_USER_ONLY) -void r4k_invalidate_tlb (CPUMIPSState *env, int idx, int use_extra); -hwaddr cpu_mips_translate_address (CPUMIPSState *env, target_ulong address, - int rw); -#endif target_ulong exception_resume_pc (CPUMIPSState *env); =20 -/* op_helper.c */ -extern unsigned int ieee_rm[]; -int ieee_ex_to_mips(int xcpt); - -static inline void restore_rounding_mode(CPUMIPSState *env) -{ - set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3], - &env->active_fpu.fp_status); -} - -static inline void restore_flush_mode(CPUMIPSState *env) -{ - set_flush_to_zero((env->active_fpu.fcr31 & (1 << FCR31_FS)) !=3D 0, - &env->active_fpu.fp_status); -} - static inline void restore_snan_bit_mode(CPUMIPSState *env) { set_snan_bit_is_one((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) =3D= =3D 0, &env->active_fpu.fp_status); } =20 -static inline void restore_fp_status(CPUMIPSState *env) -{ - restore_rounding_mode(env); - restore_flush_mode(env); - restore_snan_bit_mode(env); -} - -static inline void restore_msa_fp_status(CPUMIPSState *env) -{ - float_status *status =3D &env->active_tc.msa_fp_status; - int rounding_mode =3D (env->active_tc.msacsr & MSACSR_RM_MASK) >> MSAC= SR_RM; - bool flush_to_zero =3D (env->active_tc.msacsr & MSACSR_FS_MASK) !=3D 0; - - set_float_rounding_mode(ieee_rm[rounding_mode], status); - set_flush_to_zero(flush_to_zero, status); - set_flush_inputs_to_zero(flush_to_zero, status); -} - -static inline void restore_pamask(CPUMIPSState *env) -{ - if (env->hflags & MIPS_HFLAG_ELPA) { - env->PAMask =3D (1ULL << env->PABITS) - 1; - } else { - env->PAMask =3D PAMASK_BASE; - } -} - static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong *p= c, target_ulong *cs_base, uint32_t *f= lags) { @@ -950,172 +766,4 @@ static inline void cpu_get_tb_cpu_state(CPUMIPSState = *env, target_ulong *pc, MIPS_HFLAG_HWRENA_ULR); } =20 -static inline int mips_vpe_active(CPUMIPSState *env) -{ - int active =3D 1; - - /* Check that the VPE is enabled. */ - if (!(env->mvp->CP0_MVPControl & (1 << CP0MVPCo_EVP))) { - active =3D 0; - } - /* Check that the VPE is activated. */ - if (!(env->CP0_VPEConf0 & (1 << CP0VPEC0_VPA))) { - active =3D 0; - } - - /* Now verify that there are active thread contexts in the VPE. - - This assumes the CPU model will internally reschedule threads - if the active one goes to sleep. If there are no threads available - the active one will be in a sleeping state, and we can turn off - the entire VPE. */ - if (!(env->active_tc.CP0_TCStatus & (1 << CP0TCSt_A))) { - /* TC is not activated. */ - active =3D 0; - } - if (env->active_tc.CP0_TCHalt & 1) { - /* TC is in halt state. */ - active =3D 0; - } - - return active; -} - -static inline int mips_vp_active(CPUMIPSState *env) -{ - CPUState *other_cs =3D first_cpu; - - /* Check if the VP disabled other VPs (which means the VP is enabled) = */ - if ((env->CP0_VPControl >> CP0VPCtl_DIS) & 1) { - return 1; - } - - /* Check if the virtual processor is disabled due to a DVP */ - CPU_FOREACH(other_cs) { - MIPSCPU *other_cpu =3D MIPS_CPU(other_cs); - if ((&other_cpu->env !=3D env) && - ((other_cpu->env.CP0_VPControl >> CP0VPCtl_DIS) & 1)) { - return 0; - } - } - return 1; -} - -static inline void compute_hflags(CPUMIPSState *env) -{ - env->hflags &=3D ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 | - MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU | - MIPS_HFLAG_AWRAP | MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2 | - MIPS_HFLAG_SBRI | MIPS_HFLAG_MSA | MIPS_HFLAG_FRE | - MIPS_HFLAG_ELPA | MIPS_HFLAG_ERL); - if (env->CP0_Status & (1 << CP0St_ERL)) { - env->hflags |=3D MIPS_HFLAG_ERL; - } - if (!(env->CP0_Status & (1 << CP0St_EXL)) && - !(env->CP0_Status & (1 << CP0St_ERL)) && - !(env->hflags & MIPS_HFLAG_DM)) { - env->hflags |=3D (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU; - } -#if defined(TARGET_MIPS64) - if ((env->insn_flags & ISA_MIPS3) && - (((env->hflags & MIPS_HFLAG_KSU) !=3D MIPS_HFLAG_UM) || - (env->CP0_Status & (1 << CP0St_PX)) || - (env->CP0_Status & (1 << CP0St_UX)))) { - env->hflags |=3D MIPS_HFLAG_64; - } - - if (!(env->insn_flags & ISA_MIPS3)) { - env->hflags |=3D MIPS_HFLAG_AWRAP; - } else if (((env->hflags & MIPS_HFLAG_KSU) =3D=3D MIPS_HFLAG_UM) && - !(env->CP0_Status & (1 << CP0St_UX))) { - env->hflags |=3D MIPS_HFLAG_AWRAP; - } else if (env->insn_flags & ISA_MIPS64R6) { - /* Address wrapping for Supervisor and Kernel is specified in R6 */ - if ((((env->hflags & MIPS_HFLAG_KSU) =3D=3D MIPS_HFLAG_SM) && - !(env->CP0_Status & (1 << CP0St_SX))) || - (((env->hflags & MIPS_HFLAG_KSU) =3D=3D MIPS_HFLAG_KM) && - !(env->CP0_Status & (1 << CP0St_KX)))) { - env->hflags |=3D MIPS_HFLAG_AWRAP; - } - } -#endif - if (((env->CP0_Status & (1 << CP0St_CU0)) && - !(env->insn_flags & ISA_MIPS32R6)) || - !(env->hflags & MIPS_HFLAG_KSU)) { - env->hflags |=3D MIPS_HFLAG_CP0; - } - if (env->CP0_Status & (1 << CP0St_CU1)) { - env->hflags |=3D MIPS_HFLAG_FPU; - } - if (env->CP0_Status & (1 << CP0St_FR)) { - env->hflags |=3D MIPS_HFLAG_F64; - } - if (((env->hflags & MIPS_HFLAG_KSU) !=3D MIPS_HFLAG_KM) && - (env->CP0_Config5 & (1 << CP0C5_SBRI))) { - env->hflags |=3D MIPS_HFLAG_SBRI; - } - if (env->insn_flags & ASE_DSPR2) { - /* Enables access MIPS DSP resources, now our cpu is DSP ASER2, - so enable to access DSPR2 resources. */ - if (env->CP0_Status & (1 << CP0St_MX)) { - env->hflags |=3D MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2; - } - - } else if (env->insn_flags & ASE_DSP) { - /* Enables access MIPS DSP resources, now our cpu is DSP ASE, - so enable to access DSP resources. */ - if (env->CP0_Status & (1 << CP0St_MX)) { - env->hflags |=3D MIPS_HFLAG_DSP; - } - - } - if (env->insn_flags & ISA_MIPS32R2) { - if (env->active_fpu.fcr0 & (1 << FCR0_F64)) { - env->hflags |=3D MIPS_HFLAG_COP1X; - } - } else if (env->insn_flags & ISA_MIPS32) { - if (env->hflags & MIPS_HFLAG_64) { - env->hflags |=3D MIPS_HFLAG_COP1X; - } - } else if (env->insn_flags & ISA_MIPS4) { - /* All supported MIPS IV CPUs use the XX (CU3) to enable - and disable the MIPS IV extensions to the MIPS III ISA. - Some other MIPS IV CPUs ignore the bit, so the check here - would be too restrictive for them. */ - if (env->CP0_Status & (1U << CP0St_CU3)) { - env->hflags |=3D MIPS_HFLAG_COP1X; - } - } - if (env->insn_flags & ASE_MSA) { - if (env->CP0_Config5 & (1 << CP0C5_MSAEn)) { - env->hflags |=3D MIPS_HFLAG_MSA; - } - } - if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) { - if (env->CP0_Config5 & (1 << CP0C5_FRE)) { - env->hflags |=3D MIPS_HFLAG_FRE; - } - } - if (env->CP0_Config3 & (1 << CP0C3_LPA)) { - if (env->CP0_PageGrain & (1 << CP0PG_ELPA)) { - env->hflags |=3D MIPS_HFLAG_ELPA; - } - } -} - -void cpu_mips_tlb_flush(CPUMIPSState *env); -void sync_c0_status(CPUMIPSState *env, CPUMIPSState *cpu, int tc); -void cpu_mips_store_status(CPUMIPSState *env, target_ulong val); -void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val); - -void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, uint32_t exce= ption, - int error_code, uintptr_t pc); - -static inline void QEMU_NORETURN do_raise_exception(CPUMIPSState *env, - uint32_t exception, - uintptr_t pc) -{ - do_raise_exception_err(env, exception, 0, pc); -} - #endif /* MIPS_CPU_H */ diff --git a/target/mips/internal.h b/target/mips/internal.h new file mode 100644 index 0000000000..91c2df4537 --- /dev/null +++ b/target/mips/internal.h @@ -0,0 +1,362 @@ +/* mips internal definitions and helpers + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef MIPS_INTERNAL_H +#define MIPS_INTERNAL_H + +enum CPUMIPSMSADataFormat { + DF_BYTE =3D 0, + DF_HALF, + DF_WORD, + DF_DOUBLE +}; + +void mips_cpu_do_interrupt(CPUState *cpu); +bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req); +void mips_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fpri= ntf, + int flags); +hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); +int mips_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr); + +#if !defined(CONFIG_USER_ONLY) + +typedef struct r4k_tlb_t r4k_tlb_t; +struct r4k_tlb_t { + target_ulong VPN; + uint32_t PageMask; + uint16_t ASID; + unsigned int G:1; + unsigned int C0:3; + unsigned int C1:3; + unsigned int V0:1; + unsigned int V1:1; + unsigned int D0:1; + unsigned int D1:1; + unsigned int XI0:1; + unsigned int XI1:1; + unsigned int RI0:1; + unsigned int RI1:1; + unsigned int EHINV:1; + uint64_t PFN[2]; +}; + +struct CPUMIPSTLBContext { + uint32_t nb_tlb; + uint32_t tlb_in_use; + int (*map_address)(struct CPUMIPSState *env, hwaddr *physical, int *pr= ot, + target_ulong address, int rw, int access_type); + void (*helper_tlbwi)(struct CPUMIPSState *env); + void (*helper_tlbwr)(struct CPUMIPSState *env); + void (*helper_tlbp)(struct CPUMIPSState *env); + void (*helper_tlbr)(struct CPUMIPSState *env); + void (*helper_tlbinv)(struct CPUMIPSState *env); + void (*helper_tlbinvf)(struct CPUMIPSState *env); + union { + struct { + r4k_tlb_t tlb[MIPS_TLB_MAX]; + } r4k; + } mmu; +}; + +int no_mmu_map_address(CPUMIPSState *env, hwaddr *physical, int *prot, + target_ulong address, int rw, int access_type); +int fixed_mmu_map_address(CPUMIPSState *env, hwaddr *physical, int *prot, + target_ulong address, int rw, int access_type); +int r4k_map_address(CPUMIPSState *env, hwaddr *physical, int *prot, + target_ulong address, int rw, int access_type); +void r4k_helper_tlbwi(CPUMIPSState *env); +void r4k_helper_tlbwr(CPUMIPSState *env); +void r4k_helper_tlbp(CPUMIPSState *env); +void r4k_helper_tlbr(CPUMIPSState *env); +void r4k_helper_tlbinv(CPUMIPSState *env); +void r4k_helper_tlbinvf(CPUMIPSState *env); +void r4k_invalidate_tlb(CPUMIPSState *env, int idx, int use_extra); + +void mips_cpu_unassigned_access(CPUState *cpu, hwaddr addr, + bool is_write, bool is_exec, int unused, + unsigned size); +hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address, + int rw); +#endif + +#define cpu_signal_handler cpu_mips_signal_handler + +#ifndef CONFIG_USER_ONLY +extern const struct VMStateDescription vmstate_mips_cpu; +#endif + +static inline bool cpu_mips_hw_interrupts_enabled(CPUMIPSState *env) +{ + return (env->CP0_Status & (1 << CP0St_IE)) && + !(env->CP0_Status & (1 << CP0St_EXL)) && + !(env->CP0_Status & (1 << CP0St_ERL)) && + !(env->hflags & MIPS_HFLAG_DM) && + /* Note that the TCStatus IXMT field is initialized to zero, + and only MT capable cores can set it to one. So we don't + need to check for MT capabilities here. */ + !(env->active_tc.CP0_TCStatus & (1 << CP0TCSt_IXMT)); +} + +/* Check if there is pending and not masked out interrupt */ +static inline bool cpu_mips_hw_interrupts_pending(CPUMIPSState *env) +{ + int32_t pending; + int32_t status; + bool r; + + pending =3D env->CP0_Cause & CP0Ca_IP_mask; + status =3D env->CP0_Status & CP0Ca_IP_mask; + + if (env->CP0_Config3 & (1 << CP0C3_VEIC)) { + /* A MIPS configured with a vectorizing external interrupt control= ler + will feed a vector into the Cause pending lines. The core treats + the status lines as a vector level, not as indiviual masks. */ + r =3D pending > status; + } else { + /* A MIPS configured with compatibility or VInt (Vectored Interrup= ts) + treats the pending lines as individual interrupt lines, the sta= tus + lines are individual masks. */ + r =3D (pending & status) !=3D 0; + } + return r; +} + +void mips_tcg_init(void); + +/* TODO QOM'ify CPU reset and remove */ +void cpu_state_reset(CPUMIPSState *s); + +/* cp0_timer.c */ +uint32_t cpu_mips_get_random(CPUMIPSState *env); +uint32_t cpu_mips_get_count(CPUMIPSState *env); +void cpu_mips_store_count(CPUMIPSState *env, uint32_t value); +void cpu_mips_store_compare(CPUMIPSState *env, uint32_t value); +void cpu_mips_start_count(CPUMIPSState *env); +void cpu_mips_stop_count(CPUMIPSState *env); + +/* helper.c */ +int mips_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw, + int mmu_idx); + +/* op_helper.c */ +uint32_t float_class_s(uint32_t arg, float_status *fst); +uint64_t float_class_d(uint64_t arg, float_status *fst); + +extern unsigned int ieee_rm[]; +int ieee_ex_to_mips(int xcpt); + +static inline void restore_rounding_mode(CPUMIPSState *env) +{ + set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3], + &env->active_fpu.fp_status); +} + +static inline void restore_flush_mode(CPUMIPSState *env) +{ + set_flush_to_zero((env->active_fpu.fcr31 & (1 << FCR31_FS)) !=3D 0, + &env->active_fpu.fp_status); +} + +static inline void restore_fp_status(CPUMIPSState *env) +{ + restore_rounding_mode(env); + restore_flush_mode(env); + restore_snan_bit_mode(env); +} + +static inline void restore_msa_fp_status(CPUMIPSState *env) +{ + float_status *status =3D &env->active_tc.msa_fp_status; + int rounding_mode =3D (env->active_tc.msacsr & MSACSR_RM_MASK) >> MSAC= SR_RM; + bool flush_to_zero =3D (env->active_tc.msacsr & MSACSR_FS_MASK) !=3D 0; + + set_float_rounding_mode(ieee_rm[rounding_mode], status); + set_flush_to_zero(flush_to_zero, status); + set_flush_inputs_to_zero(flush_to_zero, status); +} + +static inline void restore_pamask(CPUMIPSState *env) +{ + if (env->hflags & MIPS_HFLAG_ELPA) { + env->PAMask =3D (1ULL << env->PABITS) - 1; + } else { + env->PAMask =3D PAMASK_BASE; + } +} + +static inline int mips_vpe_active(CPUMIPSState *env) +{ + int active =3D 1; + + /* Check that the VPE is enabled. */ + if (!(env->mvp->CP0_MVPControl & (1 << CP0MVPCo_EVP))) { + active =3D 0; + } + /* Check that the VPE is activated. */ + if (!(env->CP0_VPEConf0 & (1 << CP0VPEC0_VPA))) { + active =3D 0; + } + + /* Now verify that there are active thread contexts in the VPE. + + This assumes the CPU model will internally reschedule threads + if the active one goes to sleep. If there are no threads available + the active one will be in a sleeping state, and we can turn off + the entire VPE. */ + if (!(env->active_tc.CP0_TCStatus & (1 << CP0TCSt_A))) { + /* TC is not activated. */ + active =3D 0; + } + if (env->active_tc.CP0_TCHalt & 1) { + /* TC is in halt state. */ + active =3D 0; + } + + return active; +} + +static inline int mips_vp_active(CPUMIPSState *env) +{ + CPUState *other_cs =3D first_cpu; + + /* Check if the VP disabled other VPs (which means the VP is enabled) = */ + if ((env->CP0_VPControl >> CP0VPCtl_DIS) & 1) { + return 1; + } + + /* Check if the virtual processor is disabled due to a DVP */ + CPU_FOREACH(other_cs) { + MIPSCPU *other_cpu =3D MIPS_CPU(other_cs); + if ((&other_cpu->env !=3D env) && + ((other_cpu->env.CP0_VPControl >> CP0VPCtl_DIS) & 1)) { + return 0; + } + } + return 1; +} + +static inline void compute_hflags(CPUMIPSState *env) +{ + env->hflags &=3D ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 | + MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU | + MIPS_HFLAG_AWRAP | MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2 | + MIPS_HFLAG_SBRI | MIPS_HFLAG_MSA | MIPS_HFLAG_FRE | + MIPS_HFLAG_ELPA | MIPS_HFLAG_ERL); + if (env->CP0_Status & (1 << CP0St_ERL)) { + env->hflags |=3D MIPS_HFLAG_ERL; + } + if (!(env->CP0_Status & (1 << CP0St_EXL)) && + !(env->CP0_Status & (1 << CP0St_ERL)) && + !(env->hflags & MIPS_HFLAG_DM)) { + env->hflags |=3D (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU; + } +#if defined(TARGET_MIPS64) + if ((env->insn_flags & ISA_MIPS3) && + (((env->hflags & MIPS_HFLAG_KSU) !=3D MIPS_HFLAG_UM) || + (env->CP0_Status & (1 << CP0St_PX)) || + (env->CP0_Status & (1 << CP0St_UX)))) { + env->hflags |=3D MIPS_HFLAG_64; + } + + if (!(env->insn_flags & ISA_MIPS3)) { + env->hflags |=3D MIPS_HFLAG_AWRAP; + } else if (((env->hflags & MIPS_HFLAG_KSU) =3D=3D MIPS_HFLAG_UM) && + !(env->CP0_Status & (1 << CP0St_UX))) { + env->hflags |=3D MIPS_HFLAG_AWRAP; + } else if (env->insn_flags & ISA_MIPS64R6) { + /* Address wrapping for Supervisor and Kernel is specified in R6 */ + if ((((env->hflags & MIPS_HFLAG_KSU) =3D=3D MIPS_HFLAG_SM) && + !(env->CP0_Status & (1 << CP0St_SX))) || + (((env->hflags & MIPS_HFLAG_KSU) =3D=3D MIPS_HFLAG_KM) && + !(env->CP0_Status & (1 << CP0St_KX)))) { + env->hflags |=3D MIPS_HFLAG_AWRAP; + } + } +#endif + if (((env->CP0_Status & (1 << CP0St_CU0)) && + !(env->insn_flags & ISA_MIPS32R6)) || + !(env->hflags & MIPS_HFLAG_KSU)) { + env->hflags |=3D MIPS_HFLAG_CP0; + } + if (env->CP0_Status & (1 << CP0St_CU1)) { + env->hflags |=3D MIPS_HFLAG_FPU; + } + if (env->CP0_Status & (1 << CP0St_FR)) { + env->hflags |=3D MIPS_HFLAG_F64; + } + if (((env->hflags & MIPS_HFLAG_KSU) !=3D MIPS_HFLAG_KM) && + (env->CP0_Config5 & (1 << CP0C5_SBRI))) { + env->hflags |=3D MIPS_HFLAG_SBRI; + } + if (env->insn_flags & ASE_DSPR2) { + /* Enables access MIPS DSP resources, now our cpu is DSP ASER2, + so enable to access DSPR2 resources. */ + if (env->CP0_Status & (1 << CP0St_MX)) { + env->hflags |=3D MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2; + } + + } else if (env->insn_flags & ASE_DSP) { + /* Enables access MIPS DSP resources, now our cpu is DSP ASE, + so enable to access DSP resources. */ + if (env->CP0_Status & (1 << CP0St_MX)) { + env->hflags |=3D MIPS_HFLAG_DSP; + } + + } + if (env->insn_flags & ISA_MIPS32R2) { + if (env->active_fpu.fcr0 & (1 << FCR0_F64)) { + env->hflags |=3D MIPS_HFLAG_COP1X; + } + } else if (env->insn_flags & ISA_MIPS32) { + if (env->hflags & MIPS_HFLAG_64) { + env->hflags |=3D MIPS_HFLAG_COP1X; + } + } else if (env->insn_flags & ISA_MIPS4) { + /* All supported MIPS IV CPUs use the XX (CU3) to enable + and disable the MIPS IV extensions to the MIPS III ISA. + Some other MIPS IV CPUs ignore the bit, so the check here + would be too restrictive for them. */ + if (env->CP0_Status & (1U << CP0St_CU3)) { + env->hflags |=3D MIPS_HFLAG_COP1X; + } + } + if (env->insn_flags & ASE_MSA) { + if (env->CP0_Config5 & (1 << CP0C5_MSAEn)) { + env->hflags |=3D MIPS_HFLAG_MSA; + } + } + if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) { + if (env->CP0_Config5 & (1 << CP0C5_FRE)) { + env->hflags |=3D MIPS_HFLAG_FRE; + } + } + if (env->CP0_Config3 & (1 << CP0C3_LPA)) { + if (env->CP0_PageGrain & (1 << CP0PG_ELPA)) { + env->hflags |=3D MIPS_HFLAG_ELPA; + } + } +} + +void cpu_mips_tlb_flush(CPUMIPSState *env); +void sync_c0_status(CPUMIPSState *env, CPUMIPSState *cpu, int tc); +void cpu_mips_store_status(CPUMIPSState *env, target_ulong val); +void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val); + +void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, uint32_t exce= ption, + int error_code, uintptr_t pc); + +static inline void QEMU_NORETURN do_raise_exception(CPUMIPSState *env, + uint32_t exception, + uintptr_t pc) +{ + do_raise_exception_err(env, exception, 0, pc); +} + +#endif diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c index a9a58c5604..f4716395df 100644 --- a/target/mips/cp0_timer.c +++ b/target/mips/cp0_timer.c @@ -24,6 +24,7 @@ #include "hw/mips/cpudevs.h" #include "qemu/timer.h" #include "sysemu/kvm.h" +#include "internal.h" =20 #define TIMER_PERIOD 10 /* 10 ns period for 100 Mhz frequency */ =20 diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 1bb66b7a5a..68bf423e9d 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -21,6 +21,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "cpu.h" +#include "internal.h" #include "kvm_mips.h" #include "qemu-common.h" #include "sysemu/kvm.h" diff --git a/target/mips/gdbstub.c b/target/mips/gdbstub.c index 7c682289c2..6d1fb70f2c 100644 --- a/target/mips/gdbstub.c +++ b/target/mips/gdbstub.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "cpu.h" +#include "internal.h" #include "exec/gdbstub.h" =20 int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) diff --git a/target/mips/helper.c b/target/mips/helper.c index ca39aca08a..ea076261af 100644 --- a/target/mips/helper.c +++ b/target/mips/helper.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" =20 #include "cpu.h" +#include "internal.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "exec/log.h" diff --git a/target/mips/kvm.c b/target/mips/kvm.c index 3317905e71..e604aa8b12 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -16,6 +16,7 @@ =20 #include "qemu-common.h" #include "cpu.h" +#include "internal.h" #include "qemu/error-report.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" diff --git a/target/mips/machine.c b/target/mips/machine.c index 898825de3b..20100d5adb 100644 --- a/target/mips/machine.c +++ b/target/mips/machine.c @@ -1,6 +1,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "cpu.h" +#include "internal.h" #include "hw/hw.h" #include "migration/cpu.h" =20 diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index 1fdb0d9792..f167a42655 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -19,6 +19,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" +#include "internal.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" =20 diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index 320f2b0dc4..e537a8bfd8 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include "qemu/main-loop.h" #include "cpu.h" +#include "internal.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" diff --git a/target/mips/translate.c b/target/mips/translate.c index c78d27294c..f0febaf1b2 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -23,6 +23,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" +#include "internal.h" #include "disas/disas.h" #include "exec/exec-all.h" #include "tcg-op.h" --=20 2.14.1 From nobody Fri May 3 07:16:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502944404579128.71112832073243; Wed, 16 Aug 2017 21:33:24 -0700 (PDT) Received: from localhost ([::1]:56537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCUl-00020h-9X for importer@patchew.org; Thu, 17 Aug 2017 00:33:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCSu-0000Ui-2V for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diCSt-0004yy-4L for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:28 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:36643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diCSs-0004yf-Vs for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:27 -0400 Received: by mail-qk0-x242.google.com with SMTP id d21so3741553qke.3 for ; Wed, 16 Aug 2017 21:31:26 -0700 (PDT) Received: from yoga.offpageads.com (host21.190-139-16.telecom.net.ar. [190.139.16.21]) by smtp.gmail.com with ESMTPSA id l11sm1748738qtl.24.2017.08.16.21.31.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 21:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ufgy7imhu89KSAhK96N1A+30LzFHlgYENFQ1ftcpK5o=; b=rFWt18OBvI6bi66U5HdeBBq0b3q7to9/1Wl80Fpo7whibmDV+mfc/U410hqTq21s3q SFyAzWYZGcvumkxtZ1zG0eSllatKB7ZVZ+DnIeF+UhJTLaRcR7H2n0pXacFaSPY2yHTH PAVWERV4bC1bS2atxB4oxANFgsZE/NGNNJvXumI+Pg07MbfhlWhcwWYdX8ry4ZaHupx5 PoGTdF14cSq2pA1y8qBxDcrwLqOej9sCA4gx2yAEZlsDM5F9uSom1WsUSHraW2f2CLHl SrP7Dat89PRen0Swz2A2Qgh/mrV3nf6hBk3Y+yVaYP8UwGDSHnFAK0iXm70pY1AH7C+6 wUtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Ufgy7imhu89KSAhK96N1A+30LzFHlgYENFQ1ftcpK5o=; b=fJERk18gzUfj7ZF+MJZ9NOmYtxipgIoBmQt6lym6VmdoMU4vtx0fqlFvC5WMqe2Yg2 nL6YfVRalQrASfi90l/xzcfb07sb82cVg0NukP7diInFEUIovXdssLGjulCfR3csb8Iu pbBms1Cofy9pvlpbNt1R9OJTOzCCJ0LvcVtwV6JptGjiuz8BFMJkbvqtSqlkSedKsnhM NKIiuqstqAz940aePuVZAbO4E3YHm7OsMPaMq0C64TxqgDa6SK5JrU6mnEvfqyr7bgDy HbWhC582d3GeHkToa/pzoTF/zsGBwi8999XV+Gu6Zy4TdDcr+r6nlPDFdNFPssw1Je+q 0Kbw== X-Gm-Message-State: AHYfb5h1kA8kuJICemAo75nBy6CDvpIR6D3iphf8T+9EiNg22dOGCB5D ZXKDHL+nyo6pSQ== X-Received: by 10.55.109.5 with SMTP id i5mr5222975qkc.69.1502944286535; Wed, 16 Aug 2017 21:31:26 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Igor Mammedov , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Yongbok Kim Date: Thu, 17 Aug 2017 01:30:57 -0300 Message-Id: <20170817043102.6322-4-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817043102.6322-1-f4bug@amsat.org> References: <20170817043102.6322-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH 3/8] mips: split cpu_mips_realize_env() out of cpu_mips_init() 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: Peter Maydell , Thomas Huth , James Hogan , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 so it can be used in mips_cpu_realizefn() in the next commit Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Igor Mammedov --- target/mips/internal.h | 1 + target/mips/translate.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/target/mips/internal.h b/target/mips/internal.h index 91c2df4537..cf4c9db427 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -132,6 +132,7 @@ void mips_tcg_init(void); =20 /* TODO QOM'ify CPU reset and remove */ void cpu_state_reset(CPUMIPSState *s); +void cpu_mips_realize_env(CPUMIPSState *env); =20 /* cp0_timer.c */ uint32_t cpu_mips_get_random(CPUMIPSState *env); diff --git a/target/mips/translate.c b/target/mips/translate.c index f0febaf1b2..5fc7979ac5 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20512,6 +20512,17 @@ void mips_tcg_init(void) =20 #include "translate_init.c" =20 +void cpu_mips_realize_env(CPUMIPSState *env) +{ + env->exception_base =3D (int32_t)0xBFC00000; + +#ifndef CONFIG_USER_ONLY + mmu_init(env, env->cpu_model); +#endif + fpu_init(env, env->cpu_model); + mvp_init(env, env->cpu_model); +} + MIPSCPU *cpu_mips_init(const char *cpu_model) { MIPSCPU *cpu; @@ -20524,13 +20535,7 @@ MIPSCPU *cpu_mips_init(const char *cpu_model) cpu =3D MIPS_CPU(object_new(TYPE_MIPS_CPU)); env =3D &cpu->env; env->cpu_model =3D def; - env->exception_base =3D (int32_t)0xBFC00000; - -#ifndef CONFIG_USER_ONLY - mmu_init(env, def); -#endif - fpu_init(env, def); - mvp_init(env, def); + cpu_mips_realize_env(env); =20 object_property_set_bool(OBJECT(cpu), true, "realized", NULL); =20 --=20 2.14.1 From nobody Fri May 3 07:16:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502944560196185.1387655656663; Wed, 16 Aug 2017 21:36:00 -0700 (PDT) Received: from localhost ([::1]:56636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCXG-0004RW-Vu for importer@patchew.org; Thu, 17 Aug 2017 00:35:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCSx-0000Xh-Ga for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diCSw-00051x-LD for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:31 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:37993) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diCSw-00051Z-GW for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:30 -0400 Received: by mail-qt0-x244.google.com with SMTP id p3so5286990qtg.5 for ; Wed, 16 Aug 2017 21:31:30 -0700 (PDT) Received: from yoga.offpageads.com (host21.190-139-16.telecom.net.ar. [190.139.16.21]) by smtp.gmail.com with ESMTPSA id l11sm1748738qtl.24.2017.08.16.21.31.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 21:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7O3Qhux9KB2tUeb+D/wqb7+htksROKQfNe4Mv5KosmA=; b=tc2LJcVAfBlD6OaDOWH07P0knX8j9VEr51/guny/DEyk9bG5aqaD4qm6x3Pg5XMcPt 7Vc6pZaYA55ecNX7jS3uHphuORd8eGum/ObuhmaMDH+TCRUz2EoA0txzEhvVyMJjT9ag UOTlIyPSDQ2YBVwICLxXwstwDH6fVikZtLIBoWjy937BTisKDVtssGmykeddfQBYghpv cJgJb4yPSKG1FVFMicVwL/GSou2CO6H7zygMSuyXZB506tefiZyx9ZGobn2orf9k3wY/ b7J9XySKl53GUqhUZMzgixKy/8hpOfQQgWtdWIWHNtjR71vO31+05D7uidLufYUGSpgY T75A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7O3Qhux9KB2tUeb+D/wqb7+htksROKQfNe4Mv5KosmA=; b=s+noZ8FNt++2O/wUZeqiHlQjcsclJm6eJ0/P3rp8T32suaIzWO6Thd+0PyY5exNJlz 7kCmBDyOnf2Lsvq+CEShWHMkURve1lr8xvSPfwVtOMSbKMGnO6hMMbDI+OJbwRBn9hBQ BhpHdeCcLzL2aMisukWQjB8Wu/n1pHfzASjbzt2X6X2nh/VqLasJEAJZxr3QyMMwOAhx B1lDv8qpZsQsP0S7JSXxzqfdNefmwt8wdiGF5R2U4/Zn4vlborvAyIDhWMRgj2/2Gnzj f+JsIEHrHIMSlWTjcLRcxnBz4M8dgmS2UYTiEuZX6Q48fWwdSxnn0mHv735ln1MoTe88 G/tw== X-Gm-Message-State: AHYfb5gla1r0pVSEYELzFJxyVwrb/4yEtsC843uPoAoMVHjjpN2Uidvx tNBAhHynV/4ftA== X-Received: by 10.237.49.132 with SMTP id 4mr5941775qth.105.1502944290018; Wed, 16 Aug 2017 21:31:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Igor Mammedov , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Yongbok Kim Date: Thu, 17 Aug 2017 01:30:58 -0300 Message-Id: <20170817043102.6322-5-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817043102.6322-1-f4bug@amsat.org> References: <20170817043102.6322-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH 4/8] mips: call cpu_mips_realize_env() from mips_cpu_realizefn() 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: Peter Maydell , Thomas Huth , James Hogan , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Igor Mammedov --- target/mips/cpu.c | 3 +++ target/mips/translate.c | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 68bf423e9d..e3ef835599 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -123,6 +123,7 @@ static void mips_cpu_disas_set_info(CPUState *s, disass= emble_info *info) { static void mips_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); + MIPSCPU *cpu =3D MIPS_CPU(dev); MIPSCPUClass *mcc =3D MIPS_CPU_GET_CLASS(dev); Error *local_err =3D NULL; =20 @@ -132,6 +133,8 @@ static void mips_cpu_realizefn(DeviceState *dev, Error = **errp) return; } =20 + cpu_mips_realize_env(&cpu->env); + cpu_reset(cs); qemu_init_vcpu(cs); =20 diff --git a/target/mips/translate.c b/target/mips/translate.c index 5fc7979ac5..94c38e8755 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20535,7 +20535,6 @@ MIPSCPU *cpu_mips_init(const char *cpu_model) cpu =3D MIPS_CPU(object_new(TYPE_MIPS_CPU)); env =3D &cpu->env; env->cpu_model =3D def; - cpu_mips_realize_env(env); =20 object_property_set_bool(OBJECT(cpu), true, "realized", NULL); =20 --=20 2.14.1 From nobody Fri May 3 07:16:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502944541364451.8911987180246; Wed, 16 Aug 2017 21:35:41 -0700 (PDT) Received: from localhost ([::1]:56626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCWx-00049w-I8 for importer@patchew.org; Thu, 17 Aug 2017 00:35:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCT3-0000gR-V4 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diCT0-00055N-PX for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:37 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:35899) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diCT0-000553-Jx for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:34 -0400 Received: by mail-qt0-x243.google.com with SMTP id c15so5325861qta.3 for ; Wed, 16 Aug 2017 21:31:34 -0700 (PDT) Received: from yoga.offpageads.com (host21.190-139-16.telecom.net.ar. [190.139.16.21]) by smtp.gmail.com with ESMTPSA id l11sm1748738qtl.24.2017.08.16.21.31.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 21:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IwJl+BX/44tDmTaBfTSkocUzZaMFjChxyHCt32Llac0=; b=c8eqmLbVbupcg53T1H7VzGk6PwR1Hgt5JCmAmr3wEg8zIczITjreEVnO6Nyw/QaF8P xW9rLDvKTiuaYYvTQpqfHLbeqnZ38b+lgHoZ0vQMfO3bnSU1R6wzn033lPJW4idosbI5 nrIWsMyIXVi63wmPyGyvHowwyVJCtdw0Py6IFaiMPkHVg0Ng5hFV5rMo/UAyQjfKLP9l cyFQoeRDjyLvzmcRsmBhOv7iCka7hHWwBoozRYjvl0B6eynp6KS7Y8qIyCHNN43XkyLY gd34FOjk9oPhD84iREwn8x5nU49fisVBBYW54jyvz6P7ZfzYBD1EYuq9ZKF0EbAuJr/n PGoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=IwJl+BX/44tDmTaBfTSkocUzZaMFjChxyHCt32Llac0=; b=lRyB23NlgILJ7GLtIIRCh8p4z2fUR/bc0QK3dSKZEwU4nYe2q1HhfY0KjQi6KN1rIg Z4JN6RyvudHmClZbN/FoqUi/qYyEhghwJ/R+49iFvc4YQy/kuYoq4NKQYNrIjvzvbhsR Qcv24JpjLCr/2N3MnkgLykIxsHSYTEMQipIjeUHSk5ciz/qr5Z077PZW2isM6/vBetDE XY225EmhWSz2CqynqFM+ICq2bSEPTqtB6noXLW+fjq/UltoF6+AEP4903j0DPI0kD/8v /x6yWcfFeyabD1BsIwmg/2cbY6XtctkdArvhhoHbjE9vXKjm7QfTua0Fp/xZJMLZCmJr ToBA== X-Gm-Message-State: AHYfb5hjOzB6VG7R7INUkEOjyEvYmO8PMZMnZTR0ZxxzNCpPvmfAYSuq jm9yDz3XnjkCnw== X-Received: by 10.200.34.195 with SMTP id g3mr5456769qta.4.1502944294071; Wed, 16 Aug 2017 21:31:34 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Igor Mammedov , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Yongbok Kim Date: Thu, 17 Aug 2017 01:30:59 -0300 Message-Id: <20170817043102.6322-6-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817043102.6322-1-f4bug@amsat.org> References: <20170817043102.6322-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH 5/8] mips: MIPSCPU model subclasses 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: Peter Maydell , Thomas Huth , James Hogan , Eduardo Habkost , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Igor Mammedov Register separate QOM types for each mips cpu model, so it would be possible to reuse generic CPU creation routines. Signed-off-by: Igor Mammedov Signed-off-by: Philippe Mathieu-Daud=C3=A9 [PMD: use internal.h, use void* to hold cpu_def in MIPSCPUClass] Tested-by: Igor Mammedov --- target/mips/cpu-qom.h | 1 + target/mips/internal.h | 59 ++++++++++++++++++++++++++++++++++++++++= ++++ target/mips/cpu.c | 51 ++++++++++++++++++++++++++++++++++++++ target/mips/translate.c | 13 +++++----- target/mips/translate_init.c | 58 ++--------------------------------------= --- 5 files changed, 119 insertions(+), 63 deletions(-) diff --git a/target/mips/cpu-qom.h b/target/mips/cpu-qom.h index 3f5bf23823..085711d8f9 100644 --- a/target/mips/cpu-qom.h +++ b/target/mips/cpu-qom.h @@ -49,6 +49,7 @@ typedef struct MIPSCPUClass { =20 DeviceRealize parent_realize; void (*parent_reset)(CPUState *cpu); + const void *cpu_def; } MIPSCPUClass; =20 typedef struct MIPSCPU MIPSCPU; diff --git a/target/mips/internal.h b/target/mips/internal.h index cf4c9db427..45ded3484c 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -7,6 +7,65 @@ #ifndef MIPS_INTERNAL_H #define MIPS_INTERNAL_H =20 + +/* MMU types, the first four entries have the same layout as the + CP0C0_MT field. */ +enum mips_mmu_types { + MMU_TYPE_NONE, + MMU_TYPE_R4000, + MMU_TYPE_RESERVED, + MMU_TYPE_FMT, + MMU_TYPE_R3000, + MMU_TYPE_R6000, + MMU_TYPE_R8000 +}; + +struct mips_def_t { + const char *name; + int32_t CP0_PRid; + int32_t CP0_Config0; + int32_t CP0_Config1; + int32_t CP0_Config2; + int32_t CP0_Config3; + int32_t CP0_Config4; + int32_t CP0_Config4_rw_bitmask; + int32_t CP0_Config5; + int32_t CP0_Config5_rw_bitmask; + int32_t CP0_Config6; + int32_t CP0_Config7; + target_ulong CP0_LLAddr_rw_bitmask; + int CP0_LLAddr_shift; + int32_t SYNCI_Step; + int32_t CCRes; + int32_t CP0_Status_rw_bitmask; + int32_t CP0_TCStatus_rw_bitmask; + int32_t CP0_SRSCtl; + int32_t CP1_fcr0; + int32_t CP1_fcr31_rw_bitmask; + int32_t CP1_fcr31; + int32_t MSAIR; + int32_t SEGBITS; + int32_t PABITS; + int32_t CP0_SRSConf0_rw_bitmask; + int32_t CP0_SRSConf0; + int32_t CP0_SRSConf1_rw_bitmask; + int32_t CP0_SRSConf1; + int32_t CP0_SRSConf2_rw_bitmask; + int32_t CP0_SRSConf2; + int32_t CP0_SRSConf3_rw_bitmask; + int32_t CP0_SRSConf3; + int32_t CP0_SRSConf4_rw_bitmask; + int32_t CP0_SRSConf4; + int32_t CP0_PageGrain_rw_bitmask; + int32_t CP0_PageGrain; + target_ulong CP0_EBaseWG_rw_bitmask; + int insn_flags; + enum mips_mmu_types mmu_type; +}; + +extern const struct mips_def_t mips_defs[]; +extern const int mips_defs_number; + enum CPUMIPSMSADataFormat { DF_BYTE =3D 0, DF_HALF, diff --git a/target/mips/cpu.c b/target/mips/cpu.c index e3ef835599..f99cfbde7e 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -146,12 +146,37 @@ static void mips_cpu_initfn(Object *obj) CPUState *cs =3D CPU(obj); MIPSCPU *cpu =3D MIPS_CPU(obj); CPUMIPSState *env =3D &cpu->env; + MIPSCPUClass *mcc =3D MIPS_CPU_GET_CLASS(obj); =20 cs->env_ptr =3D env; =20 if (tcg_enabled()) { mips_tcg_init(); } + + if (mcc->cpu_def) { + env->cpu_model =3D mcc->cpu_def; + } +} + +static char *mips_cpu_type_name(const char *cpu_model) +{ + return g_strdup_printf("%s-" TYPE_MIPS_CPU, cpu_model); +} + +static ObjectClass *mips_cpu_class_by_name(const char *cpu_model) +{ + ObjectClass *oc; + char *typename; + + if (cpu_model =3D=3D NULL) { + return NULL; + } + + typename =3D mips_cpu_type_name(cpu_model); + oc =3D object_class_by_name(typename); + g_free(typename); + return oc; } =20 static void mips_cpu_class_init(ObjectClass *c, void *data) @@ -166,6 +191,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) mcc->parent_reset =3D cc->reset; cc->reset =3D mips_cpu_reset; =20 + cc->class_by_name =3D mips_cpu_class_by_name; cc->has_work =3D mips_cpu_has_work; cc->do_interrupt =3D mips_cpu_do_interrupt; cc->cpu_exec_interrupt =3D mips_cpu_exec_interrupt; @@ -198,9 +224,34 @@ static const TypeInfo mips_cpu_type_info =3D { .class_init =3D mips_cpu_class_init, }; =20 +static void mips_cpu_cpudef_class_init(ObjectClass *oc, void *data) +{ + MIPSCPUClass *mcc =3D MIPS_CPU_CLASS(oc); + mcc->cpu_def =3D data; +} + +static void mips_register_cpudef_type(const struct mips_def_t *def) +{ + char *typename =3D mips_cpu_type_name(def->name); + TypeInfo ti =3D { + .name =3D typename, + .parent =3D TYPE_MIPS_CPU, + .class_init =3D mips_cpu_cpudef_class_init, + .class_data =3D (void *)def, + }; + + type_register(&ti); + g_free(typename); +} + static void mips_cpu_register_types(void) { + int i; + type_register_static(&mips_cpu_type_info); + for (i =3D 0; i < mips_defs_number; i++) { + mips_register_cpudef_type(&mips_defs[i]); + } } =20 type_init(mips_cpu_register_types) diff --git a/target/mips/translate.c b/target/mips/translate.c index 94c38e8755..f7128bc91d 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20525,16 +20525,15 @@ void cpu_mips_realize_env(CPUMIPSState *env) =20 MIPSCPU *cpu_mips_init(const char *cpu_model) { + ObjectClass *oc; MIPSCPU *cpu; - CPUMIPSState *env; - const mips_def_t *def; =20 - def =3D cpu_mips_find_by_name(cpu_model); - if (!def) + oc =3D cpu_class_by_name(TYPE_MIPS_CPU, cpu_model); + if (oc =3D=3D NULL) { return NULL; - cpu =3D MIPS_CPU(object_new(TYPE_MIPS_CPU)); - env =3D &cpu->env; - env->cpu_model =3D def; + } + + cpu =3D MIPS_CPU(object_new(object_class_get_name(oc))); =20 object_property_set_bool(OBJECT(cpu), true, "realized", NULL); =20 diff --git a/target/mips/translate_init.c b/target/mips/translate_init.c index 255d25bacd..8bbded46c4 100644 --- a/target/mips/translate_init.c +++ b/target/mips/translate_init.c @@ -51,64 +51,9 @@ #define MIPS_CONFIG5 \ ((0 << CP0C5_M)) =20 -/* MMU types, the first four entries have the same layout as the - CP0C0_MT field. */ -enum mips_mmu_types { - MMU_TYPE_NONE, - MMU_TYPE_R4000, - MMU_TYPE_RESERVED, - MMU_TYPE_FMT, - MMU_TYPE_R3000, - MMU_TYPE_R6000, - MMU_TYPE_R8000 -}; - -struct mips_def_t { - const char *name; - int32_t CP0_PRid; - int32_t CP0_Config0; - int32_t CP0_Config1; - int32_t CP0_Config2; - int32_t CP0_Config3; - int32_t CP0_Config4; - int32_t CP0_Config4_rw_bitmask; - int32_t CP0_Config5; - int32_t CP0_Config5_rw_bitmask; - int32_t CP0_Config6; - int32_t CP0_Config7; - target_ulong CP0_LLAddr_rw_bitmask; - int CP0_LLAddr_shift; - int32_t SYNCI_Step; - int32_t CCRes; - int32_t CP0_Status_rw_bitmask; - int32_t CP0_TCStatus_rw_bitmask; - int32_t CP0_SRSCtl; - int32_t CP1_fcr0; - int32_t CP1_fcr31_rw_bitmask; - int32_t CP1_fcr31; - int32_t MSAIR; - int32_t SEGBITS; - int32_t PABITS; - int32_t CP0_SRSConf0_rw_bitmask; - int32_t CP0_SRSConf0; - int32_t CP0_SRSConf1_rw_bitmask; - int32_t CP0_SRSConf1; - int32_t CP0_SRSConf2_rw_bitmask; - int32_t CP0_SRSConf2; - int32_t CP0_SRSConf3_rw_bitmask; - int32_t CP0_SRSConf3; - int32_t CP0_SRSConf4_rw_bitmask; - int32_t CP0_SRSConf4; - int32_t CP0_PageGrain_rw_bitmask; - int32_t CP0_PageGrain; - target_ulong CP0_EBaseWG_rw_bitmask; - int insn_flags; - enum mips_mmu_types mmu_type; -}; - /*************************************************************************= ****/ /* MIPS CPU definitions */ -static const mips_def_t mips_defs[] =3D +const mips_def_t mips_defs[] =3D { { .name =3D "4Kc", @@ -808,6 +753,7 @@ static const mips_def_t mips_defs[] =3D =20 #endif }; +const int mips_defs_number =3D ARRAY_SIZE(mips_defs); =20 static const mips_def_t *cpu_mips_find_by_name (const char *name) { --=20 2.14.1 From nobody Fri May 3 07:16:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502944542596421.74614453954496; Wed, 16 Aug 2017 21:35:42 -0700 (PDT) Received: from localhost ([::1]:56628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCWz-0004Cb-Ff for importer@patchew.org; Thu, 17 Aug 2017 00:35:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCT5-0000i2-KE for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diCT4-00058V-S8 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:39 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:35902) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diCT4-00058D-OL for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:38 -0400 Received: by mail-qt0-x243.google.com with SMTP id c15so5325930qta.3 for ; Wed, 16 Aug 2017 21:31:38 -0700 (PDT) Received: from yoga.offpageads.com (host21.190-139-16.telecom.net.ar. [190.139.16.21]) by smtp.gmail.com with ESMTPSA id l11sm1748738qtl.24.2017.08.16.21.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 21:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9MgN8rqfPuaW6DpHyqBTbSHZGdvobPV8DFqmfBoCvpA=; b=pMYmdt3VMLbRf9bzLqifs83ANIuJV0ylHacbYTgTLohvaozEAqpO4AXl09rUiKhD4s xQnaGTHQpHxa1NyaZdH8h+kyjxcR1UY2hECc9VAGQDbkSM9vnwJr6E2nOnC1MvWD1fj2 rkuKSzSEKNhWu0wc1ye51ojckknBfZbQBRq+4lkwBxnDJmW4IC7TF8AZxZTC/vg1wfhX /B6JZNCR1G9gMaXFp3zjSISnZaH9M19AhyeQq9E9j6l06uyIrp+eMhqWqP6vWltmGnrI bPsDVh72jJOqXf0p8wcfAzwTsY52KRXrClDPuGoEr0xZk9uMREXvM3mZmUBulxQeo+oD DlxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=9MgN8rqfPuaW6DpHyqBTbSHZGdvobPV8DFqmfBoCvpA=; b=Z+FM66BHkZYYQk6UYlHSInrajBxWdfWsZKTWHj4Udl2JfkWR+RNwIuGrNV1e1eGud4 f9o4Avv4BxS1aomjGZy378LvKy8x0VtacOJh1tSKfNbm4t6Mzo1rurYNGidYrlz3kWPq sPvPpnrGrbllFDafIHuXYlRJc4uZVPwcb2niaVeBCkWzJ098QHdb+vCoQX3L6tutXvoT 3vbZCU7mPhzw4PPS3FxiUguox0GD45kCl48QpKekXFJmksNQAgno2RlSlv8y8D0tduP0 utJ4TSqSGJVJA8LEXkDq3aHH496zfLlb9d6yP2o6ygyARvPD5BVlsmGTeuQw6k2YvkIc RPtQ== X-Gm-Message-State: AHYfb5i22GOCnCxRxN/zvVrmY3z4JdoJ+In0B+1uxzX2ofl3H8rOXXgl +LnRoRDQ3PSULQ== X-Received: by 10.200.26.68 with SMTP id q4mr5734177qtk.295.1502944298191; Wed, 16 Aug 2017 21:31:38 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Igor Mammedov , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Yongbok Kim Date: Thu, 17 Aug 2017 01:31:00 -0300 Message-Id: <20170817043102.6322-7-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817043102.6322-1-f4bug@amsat.org> References: <20170817043102.6322-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [RFC PATCH 6/8] !fixup mips: now than MIPSCPU is QOMified, mark it abstract 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: Peter Maydell , Thomas Huth , James Hogan , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Igor Mammedov --- target/mips/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index f99cfbde7e..84b6f8bf68 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -219,7 +219,7 @@ static const TypeInfo mips_cpu_type_info =3D { .parent =3D TYPE_CPU, .instance_size =3D sizeof(MIPSCPU), .instance_init =3D mips_cpu_initfn, - .abstract =3D false, + .abstract =3D true, .class_size =3D sizeof(MIPSCPUClass), .class_init =3D mips_cpu_class_init, }; --=20 2.14.1 From nobody Fri May 3 07:16:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502944681005768.663114931176; Wed, 16 Aug 2017 21:38:01 -0700 (PDT) Received: from localhost ([::1]:56801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCZD-0006Gq-Ta for importer@patchew.org; Thu, 17 Aug 2017 00:37:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCTA-0000lA-1k for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diCT8-0005BW-Os for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:44 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:37038) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diCT8-0005BF-JD for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:42 -0400 Received: by mail-qt0-x243.google.com with SMTP id d10so5317145qtb.4 for ; Wed, 16 Aug 2017 21:31:42 -0700 (PDT) Received: from yoga.offpageads.com (host21.190-139-16.telecom.net.ar. [190.139.16.21]) by smtp.gmail.com with ESMTPSA id l11sm1748738qtl.24.2017.08.16.21.31.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 21:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SGtmCyGoCzLDtpKZKyVkalySiseIERuUat3sbEYm7Ew=; b=vcQagzeIy3vBV1ZZ2CeZwlEQIjlBBjBWI4OLNQcxVi1LWGtcc7K3xesut2t2zk1hvh LTxX/33hY2FJbZBl4mD2FH8riGp/hFXbEL501E3zU/Du3R5vWs30w1zynSc9MyZoqdqk DyEYTDdQjZJw+4CjinOU9/UGOszaFjup9/4TkNZeGGLRFFQF1iwkELnCFi28iiDKVa+I vF7ox61/KyrkrNSF/HjEKuReUm2dMdtbEKKHk3x6t4zUvbTgjYZdXva0wZhUU0IvT0sB tplptQJFodTfqYLYWhrZvyThO4fQsZPc3c9OlsjQ1F9tpL1AXhAmlbYYpADzPB3CMT1p yVcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=SGtmCyGoCzLDtpKZKyVkalySiseIERuUat3sbEYm7Ew=; b=lb2bh7LaoQvZ0tcxz3CM2Do373F6N53gtwAB6KYC2FBTTFxbD1NUdmLG0WWxHbyKMo XQry8qBgrdiwuEGWOfLcVo1SwiNEokVvd1gtQo3MXdSP01M5BGsPodTC+PrC/2PfQC5Q x0MGa2FxBW8f45BaX78W1mqoA9L1GiheLo7WH+94iVjY7Lor7a+/YRGIxnsNLk8xSSTK j/S10L0/j6bGiA6Ya+vhGHieR1Ph3Fhlo9wWORufg70n78zm5u2IPdDbJpO7swd6pBy/ U3CQnaxvObOhZnaC9fyfpVSciGI+DkPfi18hOrInH4i7dEQHaRYqu7yLLJC+Ai65C8M8 xfJA== X-Gm-Message-State: AHYfb5hGnJdwOgdOpJKggwHp1+jOAyZNBbNFLg+CFAHvAzgjiArK4vNZ dUz1uYcaSbGkeA== X-Received: by 10.200.46.80 with SMTP id s16mr5423991qta.38.1502944302128; Wed, 16 Aug 2017 21:31:42 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Igor Mammedov , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Yongbok Kim Date: Thu, 17 Aug 2017 01:31:01 -0300 Message-Id: <20170817043102.6322-8-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817043102.6322-1-f4bug@amsat.org> References: <20170817043102.6322-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH 7/8] mips: replace cpu_mips_init() with cpu_generic_init() 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: Peter Maydell , Thomas Huth , James Hogan , Eduardo Habkost , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Igor Mammedov now cpu_mips_init() reimplements subset of cpu_generic_init() tasks, so just drop it and use cpu_generic_init() directly. Signed-off-by: Igor Mammedov Reviewed-by: Herv=C3=A9 Poussineau Signed-off-by: Philippe Mathieu-Daud=C3=A9 [PMD: use internal.h instead of cpu.h] Tested-by: Igor Mammedov --- target/mips/cpu.h | 3 +-- hw/mips/cps.c | 2 +- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_jazz.c | 2 +- hw/mips/mips_malta.c | 2 +- hw/mips/mips_mipssim.c | 2 +- hw/mips/mips_r4k.c | 2 +- target/mips/translate.c | 17 ----------------- 8 files changed, 7 insertions(+), 25 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 2f81e0f950..66265e4eb6 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -737,10 +737,9 @@ enum { */ #define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0 =20 -MIPSCPU *cpu_mips_init(const char *cpu_model); int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc); =20 -#define cpu_init(cpu_model) CPU(cpu_mips_init(cpu_model)) +#define cpu_init(cpu_model) cpu_generic_init(TYPE_MIPS_CPU, cpu_model) bool cpu_supports_cps_smp(const char *cpu_model); bool cpu_supports_isa(const char *cpu_model, unsigned int isa); void cpu_set_exception_base(int vp_index, target_ulong address); diff --git a/hw/mips/cps.c b/hw/mips/cps.c index 4ef337d5c4..708899cf92 100644 --- a/hw/mips/cps.c +++ b/hw/mips/cps.c @@ -71,7 +71,7 @@ static void mips_cps_realize(DeviceState *dev, Error **er= rp) bool itu_present =3D false; =20 for (i =3D 0; i < s->num_vp; i++) { - cpu =3D cpu_mips_init(s->cpu_model); + cpu =3D MIPS_CPU(cpu_generic_init(TYPE_MIPS_CPU, s->cpu_model)); if (cpu =3D=3D NULL) { error_setg(errp, "%s: CPU initialization failed", __func__); return; diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 3532399a13..5d9462ec35 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -280,7 +280,7 @@ static void mips_fulong2e_init(MachineState *machine) if (cpu_model =3D=3D NULL) { cpu_model =3D "Loongson-2E"; } - cpu =3D cpu_mips_init(cpu_model); + cpu =3D MIPS_CPU(cpu_generic_init(TYPE_MIPS_CPU, cpu_model)); if (cpu =3D=3D NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c index df2262a2a8..c1402de1ce 100644 --- a/hw/mips/mips_jazz.c +++ b/hw/mips/mips_jazz.c @@ -151,7 +151,7 @@ static void mips_jazz_init(MachineState *machine, if (cpu_model =3D=3D NULL) { cpu_model =3D "R4000"; } - cpu =3D cpu_mips_init(cpu_model); + cpu =3D MIPS_CPU(cpu_generic_init(TYPE_MIPS_CPU, cpu_model)); if (cpu =3D=3D NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index af678f5784..9ecdc818b1 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -931,7 +931,7 @@ static void create_cpu_without_cps(const char *cpu_mode= l, int i; =20 for (i =3D 0; i < smp_cpus; i++) { - cpu =3D cpu_mips_init(cpu_model); + cpu =3D MIPS_CPU(cpu_generic_init(TYPE_MIPS_CPU, cpu_model)); if (cpu =3D=3D NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); diff --git a/hw/mips/mips_mipssim.c b/hw/mips/mips_mipssim.c index 07fc4c2300..1166834f54 100644 --- a/hw/mips/mips_mipssim.c +++ b/hw/mips/mips_mipssim.c @@ -163,7 +163,7 @@ mips_mipssim_init(MachineState *machine) cpu_model =3D "24Kf"; #endif } - cpu =3D cpu_mips_init(cpu_model); + cpu =3D MIPS_CPU(cpu_generic_init(TYPE_MIPS_CPU, cpu_model)); if (cpu =3D=3D NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c index 2f5ced7409..de212f5c13 100644 --- a/hw/mips/mips_r4k.c +++ b/hw/mips/mips_r4k.c @@ -193,7 +193,7 @@ void mips_r4k_init(MachineState *machine) cpu_model =3D "24Kf"; #endif } - cpu =3D cpu_mips_init(cpu_model); + cpu =3D MIPS_CPU(cpu_generic_init(TYPE_MIPS_CPU, cpu_model)); if (cpu =3D=3D NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); diff --git a/target/mips/translate.c b/target/mips/translate.c index f7128bc91d..d16d879df7 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20523,23 +20523,6 @@ void cpu_mips_realize_env(CPUMIPSState *env) mvp_init(env, env->cpu_model); } =20 -MIPSCPU *cpu_mips_init(const char *cpu_model) -{ - ObjectClass *oc; - MIPSCPU *cpu; - - oc =3D cpu_class_by_name(TYPE_MIPS_CPU, cpu_model); - if (oc =3D=3D NULL) { - return NULL; - } - - cpu =3D MIPS_CPU(object_new(object_class_get_name(oc))); - - object_property_set_bool(OBJECT(cpu), true, "realized", NULL); - - return cpu; -} - bool cpu_supports_cps_smp(const char *cpu_model) { const mips_def_t *def =3D cpu_mips_find_by_name(cpu_model); --=20 2.14.1 From nobody Fri May 3 07:16:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502944662593673.81193349023; Wed, 16 Aug 2017 21:37:42 -0700 (PDT) Received: from localhost ([::1]:56795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCYv-00064J-I5 for importer@patchew.org; Thu, 17 Aug 2017 00:37:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diCTJ-0000ws-So for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diCTI-0005Jb-SY for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:53 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:33944) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diCTI-0005JK-NP for qemu-devel@nongnu.org; Thu, 17 Aug 2017 00:31:52 -0400 Received: by mail-qt0-x242.google.com with SMTP id i19so5325285qte.1 for ; Wed, 16 Aug 2017 21:31:52 -0700 (PDT) Received: from yoga.offpageads.com (host21.190-139-16.telecom.net.ar. [190.139.16.21]) by smtp.gmail.com with ESMTPSA id l11sm1748738qtl.24.2017.08.16.21.31.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 21:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aPXCK4yDIgK86wQzowvIMPpKHcDnmH/v1B9MwUxwMcc=; b=b9fLmcn8Ydc2TUufv/EbTFZlzZZeEYIbAW3IRO2KjrNgjfcIR9esR1BZJveoifpNzb 2n8IoG1WkAdmWmdUa2pleK2t+jIykxNtiwFAtpYvi2l5LMgr4cFHhdUiNY38jL9XIgkH BrCbUGN5irBKPtzUTMj9hczB6hvTABkKn4i5AGtpPo6EkyF+i0sWXUgrSDpgtbNEr+D4 cFjPyJPdrnx30ExSaxDoeFA+PE5VqqXUOqCPxao7krqMnjbmFlVGRZ+kVt5Ybf3CCkiu 0RDVpmDEehfVMCkimRer3oLarYt/J3soTehNWySrRz3GCLgdRATFvo9YLGaCYLfX28H2 rTnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=aPXCK4yDIgK86wQzowvIMPpKHcDnmH/v1B9MwUxwMcc=; b=gix9C/nEeUZ5w6RjJFkBNDMB3nJiANash4xkTOtjayPZ8XGFQuV1M0yCdKv7rp+YOh lbpWMb5vx3cZ/yUcFGfETLWLbURpCK2ARC2meoBHeLXzuyJrBViYWpwVL+7FgNEqzT3w Ec9u8Kc9Oj9yKd8RHEGOaKCe5xR9BsrFucZZl7iU6ElPnNweHdsPO6nHlaTIzsKt66xt nu6kcZJD1GjElQVQ8YN64XMsQu5O36iBzANcAmKBhqSiJUhRtEWqj91rICSB1y0gx6xc tbFS9MK44cn3cN7zcsJt819AdCKQDf7LNtkP3IQVE3gGtflC2VJRd7rzs2BkpuNq6raV G+5Q== X-Gm-Message-State: AHYfb5inSgnX9d3FS/Pv9fluommdlWgDHzBeWSKsw6FheRS17q2M/XG0 1KGsny9pWUGyxw== X-Received: by 10.200.40.135 with SMTP id i7mr6066503qti.55.1502944312289; Wed, 16 Aug 2017 21:31:52 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Igor Mammedov , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Yongbok Kim Date: Thu, 17 Aug 2017 01:31:02 -0300 Message-Id: <20170817043102.6322-9-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817043102.6322-1-f4bug@amsat.org> References: <20170817043102.6322-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH 8/8] mips: update mips_cpu_list() to use object_class_get_list() 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: Peter Maydell , Thomas Huth , James Hogan , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 while here, move it from translate_init.c to helper.c Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Igor Mammedov --- target/mips/helper.c | 46 ++++++++++++++++++++++++++++++++++++++++= ++++ target/mips/translate_init.c | 10 ---------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/target/mips/helper.c b/target/mips/helper.c index ea076261af..8d12b0088a 100644 --- a/target/mips/helper.c +++ b/target/mips/helper.c @@ -1093,3 +1093,49 @@ void QEMU_NORETURN do_raise_exception_err(CPUMIPSSta= te *env, =20 cpu_loop_exit_restore(cs, pc); } + +/* Sort alphabetically by type name, except for "any". */ +static gint mips_cpu_list_compare(gconstpointer a, gconstpointer b) +{ + ObjectClass *class_a =3D (ObjectClass *)a; + ObjectClass *class_b =3D (ObjectClass *)b; + const char *name_a, *name_b; + + name_a =3D object_class_get_name(class_a); + name_b =3D object_class_get_name(class_b); + if (strcmp(name_a, "any-" TYPE_MIPS_CPU) =3D=3D 0) { + return 1; + } else if (strcmp(name_b, "any-" TYPE_MIPS_CPU) =3D=3D 0) { + return -1; + } else { + return strcmp(name_a, name_b); + } +} + +static void mips_cpu_list_entry(gpointer data, gpointer user_data) +{ + ObjectClass *oc =3D data; + CPUListState *s =3D user_data; + const char *typename; + char *name; + + typename =3D object_class_get_name(oc); + name =3D g_strndup(typename, strlen(typename) - strlen("-" TYPE_MIPS_C= PU)); + (*s->cpu_fprintf)(s->file, " %s\n", name); + g_free(name); +} + +void mips_cpu_list(FILE *f, fprintf_function cpu_fprintf) +{ + CPUListState s =3D { + .file =3D f, + .cpu_fprintf =3D cpu_fprintf, + }; + GSList *list; + + list =3D object_class_get_list(TYPE_MIPS_CPU, false); + list =3D g_slist_sort(list, mips_cpu_list_compare); + (*cpu_fprintf)(f, "Available CPUs:\n"); + g_slist_foreach(list, mips_cpu_list_entry, &s); + g_slist_free(list); +} diff --git a/target/mips/translate_init.c b/target/mips/translate_init.c index 8bbded46c4..b75f4c9065 100644 --- a/target/mips/translate_init.c +++ b/target/mips/translate_init.c @@ -767,16 +767,6 @@ static const mips_def_t *cpu_mips_find_by_name (const = char *name) return NULL; } =20 -void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf) -{ - int i; - - for (i =3D 0; i < ARRAY_SIZE(mips_defs); i++) { - (*cpu_fprintf)(f, "MIPS '%s'\n", - mips_defs[i].name); - } -} - #ifndef CONFIG_USER_ONLY static void no_mmu_init (CPUMIPSState *env, const mips_def_t *def) { --=20 2.14.1