get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/807965/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 807965,
    "url": "http://patchwork.ozlabs.org/api/patches/807965/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170830225225.27925-3-f4bug@amsat.org/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20170830225225.27925-3-f4bug@amsat.org>",
    "list_archive_url": null,
    "date": "2017-08-30T22:52:20",
    "name": "[v2,2/7] mips: introduce internal.h and cleanup cpu.h",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "724ad46dab6eb98c1f0207e9e6eca29990f74bdf",
    "submitter": {
        "id": 70924,
        "url": "http://patchwork.ozlabs.org/api/people/70924/?format=api",
        "name": "Philippe Mathieu-Daudé",
        "email": "f4bug@amsat.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170830225225.27925-3-f4bug@amsat.org/mbox/",
    "series": [
        {
            "id": 718,
            "url": "http://patchwork.ozlabs.org/api/series/718/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=718",
            "date": "2017-08-30T22:52:19",
            "name": "[v2,1/7] mips: move hw/mips/cputimer.c to target/mips/",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/718/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/807965/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/807965/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"IMXb9dL8\"; dkim-atps=neutral"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjLTG4CHjz9s83\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 08:56:02 +1000 (AEST)",
            "from localhost ([::1]:53117 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnBtw-0005a9-9O\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 18:56:00 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:34691)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dnBqr-0003PB-3O\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 18:52:53 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dnBqo-0002Ed-2Z\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 18:52:49 -0400",
            "from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:35873)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1dnBqn-0002EU-Rr\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 18:52:46 -0400",
            "by mail-qk0-x241.google.com with SMTP id l65so6493151qkc.3\n\tfor <qemu-devel@nongnu.org>; Wed, 30 Aug 2017 15:52:45 -0700 (PDT)",
            "from yoga.offpageads.com ([181.93.89.178])\n\tby smtp.gmail.com with ESMTPSA id\n\t54sm4449874qts.31.2017.08.30.15.52.40\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 30 Aug 2017 15:52:44 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=GBWk/aK2LY6vNZGjegygfbSqeWS4LG7m1OT5FmBmW4U=;\n\tb=IMXb9dL8uDPa5s8mSLzzr0yEyxMxYuiyDPUhLApw9KUVHGx+W/dD5JyPaVrHbjtCBH\n\tDHgy8s7OTgvXIjlkNJdLa73+14y9COZ4hisV0UjTzRFXcFeTm8uXudCeaP+Ok+aSmvPU\n\tp6E7rhZ0poDi7Ken8UBlQcjrjMcTigELXCxku2ldioVCkhlSRFBrzFs21q3JK8wKzFV8\n\tbO081LUORqFi5MjKNNN7OPhhF8MH4gKZ18xwaObYn2DRLMSyFr26JVmIrb2gGCT3l5Yr\n\tZ4/vXsXISZW+a6hsTOR2eBT8Y4syZD1ZMOqlFBg4TMapOLeJj96fokTAHW11FX7Zrbjr\n\tQl4A==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references:mime-version:content-transfer-encoding;\n\tbh=GBWk/aK2LY6vNZGjegygfbSqeWS4LG7m1OT5FmBmW4U=;\n\tb=EbvNckhCBmPnM9+qyn3JGl1GCicN/HIumXxRDlyfjjdqqWFnh6m8umfuufSGHsXnoV\n\tjpZQvetZh3DFjL7Gj//1BmeyJyn/+NjAfmDU3dL6lLWOc0KuD4VtwXFyu6zZepfVz5kC\n\t3RhPN9IUO3yAEKewSH7fIylFQ2ZUJ0Es7dBLFyd6P/bzEEGgpIcmUD7AwfGwzFcsb6jk\n\t1vcSS6RSbmjlNKmBU4Um4sUjek3owEExjhhGEfZwMLbQEkAK/wffssVhVPChTlt+5NXD\n\tJRrAZu7H9qscI2t55712Bo7vSv+B0wp35AMs6AJcdhAh+WHSWcE6XOLn3OochrH9Yrlo\n\tFVfg==",
        "X-Gm-Message-State": "AHYfb5g70n52HKqCKotcyMpAYZCzvd29WJ5g/Dy/OjCh+U1L8/3x1O9/\n\tGHwNwHo+h6+9YUuBqgSBAw==",
        "X-Received": "by 10.55.98.15 with SMTP id w15mr1264692qkb.161.1504133564754;\n\tWed, 30 Aug 2017 15:52:44 -0700 (PDT)",
        "From": "=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>",
        "To": "Igor Mammedov <imammedo@redhat.com>, =?utf-8?q?Herv=C3=A9_Poussineau?=\n\t<hpoussin@reactos.org>, \tAurelien Jarno <aurelien@aurel32.net>,\n\tEduardo Habkost <ehabkost@redhat.com>, \n\tMarcel Apfelbaum <marcel@redhat.com>,\n\tJames Hogan <james.hogan@imgtec.com>, Yongbok Kim\n\t<yongbok.kim@imgtec.com>",
        "Date": "Wed, 30 Aug 2017 19:52:20 -0300",
        "Message-Id": "<20170830225225.27925-3-f4bug@amsat.org>",
        "X-Mailer": "git-send-email 2.14.1",
        "In-Reply-To": "<20170830225225.27925-1-f4bug@amsat.org>",
        "References": "<20170830225225.27925-1-f4bug@amsat.org>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "X-detected-operating-system": "by eggs.gnu.org: Genre and OS details not\n\trecognized.",
        "X-Received-From": "2607:f8b0:400d:c09::241",
        "Subject": "[Qemu-devel] [PATCH v2 2/7] mips: introduce internal.h and cleanup\n\tcpu.h",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "Thomas Huth <thuth@redhat.com>, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?=\n\t<f4bug@amsat.org>, \tqemu-devel@nongnu.org",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "no logical change, only code movement (and fix a comment typo).\n\nSigned-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\nTested-by: Igor Mammedov <imammedo@redhat.com>\nTested-by: James Hogan <james.hogan@imgtec.com>\n---\n\nThis patch triggers 3 positive falses from checkpatch:\n\nERROR: space prohibited after that '&' (ctx:WxW)\n#664: FILE: target/mips/internal.h:230:\n+    if ((env->CP0_VPControl >> CP0VPCtl_DIS) & 1) {\n                                              ^\n#672: FILE: target/mips/internal.h:238:\n+            ((other_cpu->env.CP0_VPControl >> CP0VPCtl_DIS) & 1)) {\n                                                             ^\n#692: FILE: target/mips/internal.h:258:\n+        env->hflags |= (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU;\n                                                       ^\ntotal: 3 errors, 0 warnings, 842 lines checked\n\nThis is a \"binary vs unary operators\" confusion.\n\n target/mips/cpu.h        | 354 +--------------------------------------------\n target/mips/internal.h   | 362 +++++++++++++++++++++++++++++++++++++++++++++++\n target/mips/cp0_timer.c  |   1 +\n target/mips/cpu.c        |   1 +\n target/mips/gdbstub.c    |   1 +\n target/mips/helper.c     |   1 +\n target/mips/kvm.c        |   1 +\n target/mips/machine.c    |   1 +\n target/mips/msa_helper.c |   1 +\n target/mips/op_helper.c  |   1 +\n target/mips/translate.c  |   1 +\n 11 files changed, 372 insertions(+), 353 deletions(-)\n create mode 100644 target/mips/internal.h",
    "diff": "diff --git a/target/mips/cpu.h b/target/mips/cpu.h\nindex 74f6a5b098..2f81e0f950 100644\n--- a/target/mips/cpu.h\n+++ b/target/mips/cpu.h\n@@ -1,8 +1,6 @@\n #ifndef MIPS_CPU_H\n #define MIPS_CPU_H\n \n-//#define DEBUG_OP\n-\n #define ALIGNED_ONLY\n \n #define CPUArchState struct CPUMIPSState\n@@ -15,56 +13,11 @@\n \n struct CPUMIPSState;\n \n-typedef struct r4k_tlb_t r4k_tlb_t;\n-struct r4k_tlb_t {\n-    target_ulong VPN;\n-    uint32_t PageMask;\n-    uint16_t ASID;\n-    unsigned int G:1;\n-    unsigned int C0:3;\n-    unsigned int C1:3;\n-    unsigned int V0:1;\n-    unsigned int V1:1;\n-    unsigned int D0:1;\n-    unsigned int D1:1;\n-    unsigned int XI0:1;\n-    unsigned int XI1:1;\n-    unsigned int RI0:1;\n-    unsigned int RI1:1;\n-    unsigned int EHINV:1;\n-    uint64_t PFN[2];\n-};\n-\n-#if !defined(CONFIG_USER_ONLY)\n typedef struct CPUMIPSTLBContext CPUMIPSTLBContext;\n-struct CPUMIPSTLBContext {\n-    uint32_t nb_tlb;\n-    uint32_t tlb_in_use;\n-    int (*map_address) (struct CPUMIPSState *env, hwaddr *physical, int *prot, target_ulong address, int rw, int access_type);\n-    void (*helper_tlbwi)(struct CPUMIPSState *env);\n-    void (*helper_tlbwr)(struct CPUMIPSState *env);\n-    void (*helper_tlbp)(struct CPUMIPSState *env);\n-    void (*helper_tlbr)(struct CPUMIPSState *env);\n-    void (*helper_tlbinv)(struct CPUMIPSState *env);\n-    void (*helper_tlbinvf)(struct CPUMIPSState *env);\n-    union {\n-        struct {\n-            r4k_tlb_t tlb[MIPS_TLB_MAX];\n-        } r4k;\n-    } mmu;\n-};\n-#endif\n \n /* MSA Context */\n #define MSA_WRLEN (128)\n \n-enum CPUMIPSMSADataFormat {\n-    DF_BYTE = 0,\n-    DF_HALF,\n-    DF_WORD,\n-    DF_DOUBLE\n-};\n-\n typedef union wr_t wr_t;\n union wr_t {\n     int8_t  b[MSA_WRLEN/8];\n@@ -682,40 +635,6 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env)\n \n #define ENV_OFFSET offsetof(MIPSCPU, env)\n \n-#ifndef CONFIG_USER_ONLY\n-extern const struct VMStateDescription vmstate_mips_cpu;\n-#endif\n-\n-void mips_cpu_do_interrupt(CPUState *cpu);\n-bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req);\n-void mips_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,\n-                         int flags);\n-hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);\n-int mips_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);\n-int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);\n-void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,\n-                                  MMUAccessType access_type,\n-                                  int mmu_idx, uintptr_t retaddr);\n-\n-#if !defined(CONFIG_USER_ONLY)\n-int no_mmu_map_address (CPUMIPSState *env, hwaddr *physical, int *prot,\n-                        target_ulong address, int rw, int access_type);\n-int fixed_mmu_map_address (CPUMIPSState *env, hwaddr *physical, int *prot,\n-                           target_ulong address, int rw, int access_type);\n-int r4k_map_address (CPUMIPSState *env, hwaddr *physical, int *prot,\n-                     target_ulong address, int rw, int access_type);\n-void r4k_helper_tlbwi(CPUMIPSState *env);\n-void r4k_helper_tlbwr(CPUMIPSState *env);\n-void r4k_helper_tlbp(CPUMIPSState *env);\n-void r4k_helper_tlbr(CPUMIPSState *env);\n-void r4k_helper_tlbinv(CPUMIPSState *env);\n-void r4k_helper_tlbinvf(CPUMIPSState *env);\n-\n-void mips_cpu_unassigned_access(CPUState *cpu, hwaddr addr,\n-                                bool is_write, bool is_exec, int unused,\n-                                unsigned size);\n-#endif\n-\n void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf);\n \n #define cpu_signal_handler cpu_mips_signal_handler\n@@ -746,42 +665,6 @@ static inline int cpu_mmu_index (CPUMIPSState *env, bool ifetch)\n     return hflags_mmu_index(env->hflags);\n }\n \n-static inline bool cpu_mips_hw_interrupts_enabled(CPUMIPSState *env)\n-{\n-    return (env->CP0_Status & (1 << CP0St_IE)) &&\n-        !(env->CP0_Status & (1 << CP0St_EXL)) &&\n-        !(env->CP0_Status & (1 << CP0St_ERL)) &&\n-        !(env->hflags & MIPS_HFLAG_DM) &&\n-        /* Note that the TCStatus IXMT field is initialized to zero,\n-           and only MT capable cores can set it to one. So we don't\n-           need to check for MT capabilities here.  */\n-        !(env->active_tc.CP0_TCStatus & (1 << CP0TCSt_IXMT));\n-}\n-\n-/* Check if there is pending and not masked out interrupt */\n-static inline bool cpu_mips_hw_interrupts_pending(CPUMIPSState *env)\n-{\n-    int32_t pending;\n-    int32_t status;\n-    bool r;\n-\n-    pending = env->CP0_Cause & CP0Ca_IP_mask;\n-    status = env->CP0_Status & CP0Ca_IP_mask;\n-\n-    if (env->CP0_Config3 & (1 << CP0C3_VEIC)) {\n-        /* A MIPS configured with a vectorizing external interrupt controller\n-           will feed a vector into the Cause pending lines. The core treats\n-           the status lines as a vector level, not as indiviual masks.  */\n-        r = pending > status;\n-    } else {\n-        /* A MIPS configured with compatibility or VInt (Vectored Interrupts)\n-           treats the pending lines as individual interrupt lines, the status\n-           lines are individual masks.  */\n-        r = (pending & status) != 0;\n-    }\n-    return r;\n-}\n-\n #include \"exec/cpu-all.h\"\n \n /* Memory access type :\n@@ -847,14 +730,13 @@ enum {\n #define EXCP_SC 0x100\n \n /*\n- * This is an interrnally generated WAKE request line.\n+ * This is an internally generated WAKE request line.\n  * It is driven by the CPU itself. Raised when the MT\n  * block wants to wake a VPE from an inactive state and\n  * cleared when VPE goes from active to inactive.\n  */\n #define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0\n \n-void mips_tcg_init(void);\n MIPSCPU *cpu_mips_init(const char *cpu_model);\n int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);\n \n@@ -863,84 +745,18 @@ bool cpu_supports_cps_smp(const char *cpu_model);\n bool cpu_supports_isa(const char *cpu_model, unsigned int isa);\n void cpu_set_exception_base(int vp_index, target_ulong address);\n \n-/* TODO QOM'ify CPU reset and remove */\n-void cpu_state_reset(CPUMIPSState *s);\n-\n-/* mips_timer.c */\n-uint32_t cpu_mips_get_random (CPUMIPSState *env);\n-uint32_t cpu_mips_get_count (CPUMIPSState *env);\n-void cpu_mips_store_count (CPUMIPSState *env, uint32_t value);\n-void cpu_mips_store_compare (CPUMIPSState *env, uint32_t value);\n-void cpu_mips_start_count(CPUMIPSState *env);\n-void cpu_mips_stop_count(CPUMIPSState *env);\n-\n /* mips_int.c */\n void cpu_mips_soft_irq(CPUMIPSState *env, int irq, int level);\n \n /* helper.c */\n-int mips_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,\n-                              int mmu_idx);\n-\n-/* op_helper.c */\n-uint32_t float_class_s(uint32_t arg, float_status *fst);\n-uint64_t float_class_d(uint64_t arg, float_status *fst);\n-\n-#if !defined(CONFIG_USER_ONLY)\n-void r4k_invalidate_tlb (CPUMIPSState *env, int idx, int use_extra);\n-hwaddr cpu_mips_translate_address (CPUMIPSState *env, target_ulong address,\n-\t\t                               int rw);\n-#endif\n target_ulong exception_resume_pc (CPUMIPSState *env);\n \n-/* op_helper.c */\n-extern unsigned int ieee_rm[];\n-int ieee_ex_to_mips(int xcpt);\n-\n-static inline void restore_rounding_mode(CPUMIPSState *env)\n-{\n-    set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3],\n-                            &env->active_fpu.fp_status);\n-}\n-\n-static inline void restore_flush_mode(CPUMIPSState *env)\n-{\n-    set_flush_to_zero((env->active_fpu.fcr31 & (1 << FCR31_FS)) != 0,\n-                      &env->active_fpu.fp_status);\n-}\n-\n static inline void restore_snan_bit_mode(CPUMIPSState *env)\n {\n     set_snan_bit_is_one((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) == 0,\n                         &env->active_fpu.fp_status);\n }\n \n-static inline void restore_fp_status(CPUMIPSState *env)\n-{\n-    restore_rounding_mode(env);\n-    restore_flush_mode(env);\n-    restore_snan_bit_mode(env);\n-}\n-\n-static inline void restore_msa_fp_status(CPUMIPSState *env)\n-{\n-    float_status *status = &env->active_tc.msa_fp_status;\n-    int rounding_mode = (env->active_tc.msacsr & MSACSR_RM_MASK) >> MSACSR_RM;\n-    bool flush_to_zero = (env->active_tc.msacsr & MSACSR_FS_MASK) != 0;\n-\n-    set_float_rounding_mode(ieee_rm[rounding_mode], status);\n-    set_flush_to_zero(flush_to_zero, status);\n-    set_flush_inputs_to_zero(flush_to_zero, status);\n-}\n-\n-static inline void restore_pamask(CPUMIPSState *env)\n-{\n-    if (env->hflags & MIPS_HFLAG_ELPA) {\n-        env->PAMask = (1ULL << env->PABITS) - 1;\n-    } else {\n-        env->PAMask = PAMASK_BASE;\n-    }\n-}\n-\n static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong *pc,\n                                         target_ulong *cs_base, uint32_t *flags)\n {\n@@ -950,172 +766,4 @@ static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong *pc,\n                             MIPS_HFLAG_HWRENA_ULR);\n }\n \n-static inline int mips_vpe_active(CPUMIPSState *env)\n-{\n-    int active = 1;\n-\n-    /* Check that the VPE is enabled.  */\n-    if (!(env->mvp->CP0_MVPControl & (1 << CP0MVPCo_EVP))) {\n-        active = 0;\n-    }\n-    /* Check that the VPE is activated.  */\n-    if (!(env->CP0_VPEConf0 & (1 << CP0VPEC0_VPA))) {\n-        active = 0;\n-    }\n-\n-    /* Now verify that there are active thread contexts in the VPE.\n-\n-       This assumes the CPU model will internally reschedule threads\n-       if the active one goes to sleep. If there are no threads available\n-       the active one will be in a sleeping state, and we can turn off\n-       the entire VPE.  */\n-    if (!(env->active_tc.CP0_TCStatus & (1 << CP0TCSt_A))) {\n-        /* TC is not activated.  */\n-        active = 0;\n-    }\n-    if (env->active_tc.CP0_TCHalt & 1) {\n-        /* TC is in halt state.  */\n-        active = 0;\n-    }\n-\n-    return active;\n-}\n-\n-static inline int mips_vp_active(CPUMIPSState *env)\n-{\n-    CPUState *other_cs = first_cpu;\n-\n-    /* Check if the VP disabled other VPs (which means the VP is enabled) */\n-    if ((env->CP0_VPControl >> CP0VPCtl_DIS) & 1) {\n-        return 1;\n-    }\n-\n-    /* Check if the virtual processor is disabled due to a DVP */\n-    CPU_FOREACH(other_cs) {\n-        MIPSCPU *other_cpu = MIPS_CPU(other_cs);\n-        if ((&other_cpu->env != env) &&\n-            ((other_cpu->env.CP0_VPControl >> CP0VPCtl_DIS) & 1)) {\n-            return 0;\n-        }\n-    }\n-    return 1;\n-}\n-\n-static inline void compute_hflags(CPUMIPSState *env)\n-{\n-    env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |\n-                     MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU |\n-                     MIPS_HFLAG_AWRAP | MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2 |\n-                     MIPS_HFLAG_SBRI | MIPS_HFLAG_MSA | MIPS_HFLAG_FRE |\n-                     MIPS_HFLAG_ELPA | MIPS_HFLAG_ERL);\n-    if (env->CP0_Status & (1 << CP0St_ERL)) {\n-        env->hflags |= MIPS_HFLAG_ERL;\n-    }\n-    if (!(env->CP0_Status & (1 << CP0St_EXL)) &&\n-        !(env->CP0_Status & (1 << CP0St_ERL)) &&\n-        !(env->hflags & MIPS_HFLAG_DM)) {\n-        env->hflags |= (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU;\n-    }\n-#if defined(TARGET_MIPS64)\n-    if ((env->insn_flags & ISA_MIPS3) &&\n-        (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_UM) ||\n-         (env->CP0_Status & (1 << CP0St_PX)) ||\n-         (env->CP0_Status & (1 << CP0St_UX)))) {\n-        env->hflags |= MIPS_HFLAG_64;\n-    }\n-\n-    if (!(env->insn_flags & ISA_MIPS3)) {\n-        env->hflags |= MIPS_HFLAG_AWRAP;\n-    } else if (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&\n-               !(env->CP0_Status & (1 << CP0St_UX))) {\n-        env->hflags |= MIPS_HFLAG_AWRAP;\n-    } else if (env->insn_flags & ISA_MIPS64R6) {\n-        /* Address wrapping for Supervisor and Kernel is specified in R6 */\n-        if ((((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_SM) &&\n-             !(env->CP0_Status & (1 << CP0St_SX))) ||\n-            (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_KM) &&\n-             !(env->CP0_Status & (1 << CP0St_KX)))) {\n-            env->hflags |= MIPS_HFLAG_AWRAP;\n-        }\n-    }\n-#endif\n-    if (((env->CP0_Status & (1 << CP0St_CU0)) &&\n-         !(env->insn_flags & ISA_MIPS32R6)) ||\n-        !(env->hflags & MIPS_HFLAG_KSU)) {\n-        env->hflags |= MIPS_HFLAG_CP0;\n-    }\n-    if (env->CP0_Status & (1 << CP0St_CU1)) {\n-        env->hflags |= MIPS_HFLAG_FPU;\n-    }\n-    if (env->CP0_Status & (1 << CP0St_FR)) {\n-        env->hflags |= MIPS_HFLAG_F64;\n-    }\n-    if (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_KM) &&\n-        (env->CP0_Config5 & (1 << CP0C5_SBRI))) {\n-        env->hflags |= MIPS_HFLAG_SBRI;\n-    }\n-    if (env->insn_flags & ASE_DSPR2) {\n-        /* Enables access MIPS DSP resources, now our cpu is DSP ASER2,\n-           so enable to access DSPR2 resources. */\n-        if (env->CP0_Status & (1 << CP0St_MX)) {\n-            env->hflags |= MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2;\n-        }\n-\n-    } else if (env->insn_flags & ASE_DSP) {\n-        /* Enables access MIPS DSP resources, now our cpu is DSP ASE,\n-           so enable to access DSP resources. */\n-        if (env->CP0_Status & (1 << CP0St_MX)) {\n-            env->hflags |= MIPS_HFLAG_DSP;\n-        }\n-\n-    }\n-    if (env->insn_flags & ISA_MIPS32R2) {\n-        if (env->active_fpu.fcr0 & (1 << FCR0_F64)) {\n-            env->hflags |= MIPS_HFLAG_COP1X;\n-        }\n-    } else if (env->insn_flags & ISA_MIPS32) {\n-        if (env->hflags & MIPS_HFLAG_64) {\n-            env->hflags |= MIPS_HFLAG_COP1X;\n-        }\n-    } else if (env->insn_flags & ISA_MIPS4) {\n-        /* All supported MIPS IV CPUs use the XX (CU3) to enable\n-           and disable the MIPS IV extensions to the MIPS III ISA.\n-           Some other MIPS IV CPUs ignore the bit, so the check here\n-           would be too restrictive for them.  */\n-        if (env->CP0_Status & (1U << CP0St_CU3)) {\n-            env->hflags |= MIPS_HFLAG_COP1X;\n-        }\n-    }\n-    if (env->insn_flags & ASE_MSA) {\n-        if (env->CP0_Config5 & (1 << CP0C5_MSAEn)) {\n-            env->hflags |= MIPS_HFLAG_MSA;\n-        }\n-    }\n-    if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) {\n-        if (env->CP0_Config5 & (1 << CP0C5_FRE)) {\n-            env->hflags |= MIPS_HFLAG_FRE;\n-        }\n-    }\n-    if (env->CP0_Config3 & (1 << CP0C3_LPA)) {\n-        if (env->CP0_PageGrain & (1 << CP0PG_ELPA)) {\n-            env->hflags |= MIPS_HFLAG_ELPA;\n-        }\n-    }\n-}\n-\n-void cpu_mips_tlb_flush(CPUMIPSState *env);\n-void sync_c0_status(CPUMIPSState *env, CPUMIPSState *cpu, int tc);\n-void cpu_mips_store_status(CPUMIPSState *env, target_ulong val);\n-void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val);\n-\n-void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, uint32_t exception,\n-                                          int error_code, uintptr_t pc);\n-\n-static inline void QEMU_NORETURN do_raise_exception(CPUMIPSState *env,\n-                                                    uint32_t exception,\n-                                                    uintptr_t pc)\n-{\n-    do_raise_exception_err(env, exception, 0, pc);\n-}\n-\n #endif /* MIPS_CPU_H */\ndiff --git a/target/mips/internal.h b/target/mips/internal.h\nnew file mode 100644\nindex 0000000000..91c2df4537\n--- /dev/null\n+++ b/target/mips/internal.h\n@@ -0,0 +1,362 @@\n+/* mips internal definitions and helpers\n+ *\n+ * This work is licensed under the terms of the GNU GPL, version 2 or later.\n+ * See the COPYING file in the top-level directory.\n+ */\n+\n+#ifndef MIPS_INTERNAL_H\n+#define MIPS_INTERNAL_H\n+\n+enum CPUMIPSMSADataFormat {\n+    DF_BYTE = 0,\n+    DF_HALF,\n+    DF_WORD,\n+    DF_DOUBLE\n+};\n+\n+void mips_cpu_do_interrupt(CPUState *cpu);\n+bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req);\n+void mips_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,\n+                         int flags);\n+hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);\n+int mips_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);\n+int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);\n+void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,\n+                                  MMUAccessType access_type,\n+                                  int mmu_idx, uintptr_t retaddr);\n+\n+#if !defined(CONFIG_USER_ONLY)\n+\n+typedef struct r4k_tlb_t r4k_tlb_t;\n+struct r4k_tlb_t {\n+    target_ulong VPN;\n+    uint32_t PageMask;\n+    uint16_t ASID;\n+    unsigned int G:1;\n+    unsigned int C0:3;\n+    unsigned int C1:3;\n+    unsigned int V0:1;\n+    unsigned int V1:1;\n+    unsigned int D0:1;\n+    unsigned int D1:1;\n+    unsigned int XI0:1;\n+    unsigned int XI1:1;\n+    unsigned int RI0:1;\n+    unsigned int RI1:1;\n+    unsigned int EHINV:1;\n+    uint64_t PFN[2];\n+};\n+\n+struct CPUMIPSTLBContext {\n+    uint32_t nb_tlb;\n+    uint32_t tlb_in_use;\n+    int (*map_address)(struct CPUMIPSState *env, hwaddr *physical, int *prot,\n+                       target_ulong address, int rw, int access_type);\n+    void (*helper_tlbwi)(struct CPUMIPSState *env);\n+    void (*helper_tlbwr)(struct CPUMIPSState *env);\n+    void (*helper_tlbp)(struct CPUMIPSState *env);\n+    void (*helper_tlbr)(struct CPUMIPSState *env);\n+    void (*helper_tlbinv)(struct CPUMIPSState *env);\n+    void (*helper_tlbinvf)(struct CPUMIPSState *env);\n+    union {\n+        struct {\n+            r4k_tlb_t tlb[MIPS_TLB_MAX];\n+        } r4k;\n+    } mmu;\n+};\n+\n+int no_mmu_map_address(CPUMIPSState *env, hwaddr *physical, int *prot,\n+                       target_ulong address, int rw, int access_type);\n+int fixed_mmu_map_address(CPUMIPSState *env, hwaddr *physical, int *prot,\n+                          target_ulong address, int rw, int access_type);\n+int r4k_map_address(CPUMIPSState *env, hwaddr *physical, int *prot,\n+                    target_ulong address, int rw, int access_type);\n+void r4k_helper_tlbwi(CPUMIPSState *env);\n+void r4k_helper_tlbwr(CPUMIPSState *env);\n+void r4k_helper_tlbp(CPUMIPSState *env);\n+void r4k_helper_tlbr(CPUMIPSState *env);\n+void r4k_helper_tlbinv(CPUMIPSState *env);\n+void r4k_helper_tlbinvf(CPUMIPSState *env);\n+void r4k_invalidate_tlb(CPUMIPSState *env, int idx, int use_extra);\n+\n+void mips_cpu_unassigned_access(CPUState *cpu, hwaddr addr,\n+                                bool is_write, bool is_exec, int unused,\n+                                unsigned size);\n+hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address,\n+                                  int rw);\n+#endif\n+\n+#define cpu_signal_handler cpu_mips_signal_handler\n+\n+#ifndef CONFIG_USER_ONLY\n+extern const struct VMStateDescription vmstate_mips_cpu;\n+#endif\n+\n+static inline bool cpu_mips_hw_interrupts_enabled(CPUMIPSState *env)\n+{\n+    return (env->CP0_Status & (1 << CP0St_IE)) &&\n+        !(env->CP0_Status & (1 << CP0St_EXL)) &&\n+        !(env->CP0_Status & (1 << CP0St_ERL)) &&\n+        !(env->hflags & MIPS_HFLAG_DM) &&\n+        /* Note that the TCStatus IXMT field is initialized to zero,\n+           and only MT capable cores can set it to one. So we don't\n+           need to check for MT capabilities here.  */\n+        !(env->active_tc.CP0_TCStatus & (1 << CP0TCSt_IXMT));\n+}\n+\n+/* Check if there is pending and not masked out interrupt */\n+static inline bool cpu_mips_hw_interrupts_pending(CPUMIPSState *env)\n+{\n+    int32_t pending;\n+    int32_t status;\n+    bool r;\n+\n+    pending = env->CP0_Cause & CP0Ca_IP_mask;\n+    status = env->CP0_Status & CP0Ca_IP_mask;\n+\n+    if (env->CP0_Config3 & (1 << CP0C3_VEIC)) {\n+        /* A MIPS configured with a vectorizing external interrupt controller\n+           will feed a vector into the Cause pending lines. The core treats\n+           the status lines as a vector level, not as indiviual masks.  */\n+        r = pending > status;\n+    } else {\n+        /* A MIPS configured with compatibility or VInt (Vectored Interrupts)\n+           treats the pending lines as individual interrupt lines, the status\n+           lines are individual masks.  */\n+        r = (pending & status) != 0;\n+    }\n+    return r;\n+}\n+\n+void mips_tcg_init(void);\n+\n+/* TODO QOM'ify CPU reset and remove */\n+void cpu_state_reset(CPUMIPSState *s);\n+\n+/* cp0_timer.c */\n+uint32_t cpu_mips_get_random(CPUMIPSState *env);\n+uint32_t cpu_mips_get_count(CPUMIPSState *env);\n+void cpu_mips_store_count(CPUMIPSState *env, uint32_t value);\n+void cpu_mips_store_compare(CPUMIPSState *env, uint32_t value);\n+void cpu_mips_start_count(CPUMIPSState *env);\n+void cpu_mips_stop_count(CPUMIPSState *env);\n+\n+/* helper.c */\n+int mips_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,\n+                              int mmu_idx);\n+\n+/* op_helper.c */\n+uint32_t float_class_s(uint32_t arg, float_status *fst);\n+uint64_t float_class_d(uint64_t arg, float_status *fst);\n+\n+extern unsigned int ieee_rm[];\n+int ieee_ex_to_mips(int xcpt);\n+\n+static inline void restore_rounding_mode(CPUMIPSState *env)\n+{\n+    set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3],\n+                            &env->active_fpu.fp_status);\n+}\n+\n+static inline void restore_flush_mode(CPUMIPSState *env)\n+{\n+    set_flush_to_zero((env->active_fpu.fcr31 & (1 << FCR31_FS)) != 0,\n+                      &env->active_fpu.fp_status);\n+}\n+\n+static inline void restore_fp_status(CPUMIPSState *env)\n+{\n+    restore_rounding_mode(env);\n+    restore_flush_mode(env);\n+    restore_snan_bit_mode(env);\n+}\n+\n+static inline void restore_msa_fp_status(CPUMIPSState *env)\n+{\n+    float_status *status = &env->active_tc.msa_fp_status;\n+    int rounding_mode = (env->active_tc.msacsr & MSACSR_RM_MASK) >> MSACSR_RM;\n+    bool flush_to_zero = (env->active_tc.msacsr & MSACSR_FS_MASK) != 0;\n+\n+    set_float_rounding_mode(ieee_rm[rounding_mode], status);\n+    set_flush_to_zero(flush_to_zero, status);\n+    set_flush_inputs_to_zero(flush_to_zero, status);\n+}\n+\n+static inline void restore_pamask(CPUMIPSState *env)\n+{\n+    if (env->hflags & MIPS_HFLAG_ELPA) {\n+        env->PAMask = (1ULL << env->PABITS) - 1;\n+    } else {\n+        env->PAMask = PAMASK_BASE;\n+    }\n+}\n+\n+static inline int mips_vpe_active(CPUMIPSState *env)\n+{\n+    int active = 1;\n+\n+    /* Check that the VPE is enabled.  */\n+    if (!(env->mvp->CP0_MVPControl & (1 << CP0MVPCo_EVP))) {\n+        active = 0;\n+    }\n+    /* Check that the VPE is activated.  */\n+    if (!(env->CP0_VPEConf0 & (1 << CP0VPEC0_VPA))) {\n+        active = 0;\n+    }\n+\n+    /* Now verify that there are active thread contexts in the VPE.\n+\n+       This assumes the CPU model will internally reschedule threads\n+       if the active one goes to sleep. If there are no threads available\n+       the active one will be in a sleeping state, and we can turn off\n+       the entire VPE.  */\n+    if (!(env->active_tc.CP0_TCStatus & (1 << CP0TCSt_A))) {\n+        /* TC is not activated.  */\n+        active = 0;\n+    }\n+    if (env->active_tc.CP0_TCHalt & 1) {\n+        /* TC is in halt state.  */\n+        active = 0;\n+    }\n+\n+    return active;\n+}\n+\n+static inline int mips_vp_active(CPUMIPSState *env)\n+{\n+    CPUState *other_cs = first_cpu;\n+\n+    /* Check if the VP disabled other VPs (which means the VP is enabled) */\n+    if ((env->CP0_VPControl >> CP0VPCtl_DIS) & 1) {\n+        return 1;\n+    }\n+\n+    /* Check if the virtual processor is disabled due to a DVP */\n+    CPU_FOREACH(other_cs) {\n+        MIPSCPU *other_cpu = MIPS_CPU(other_cs);\n+        if ((&other_cpu->env != env) &&\n+            ((other_cpu->env.CP0_VPControl >> CP0VPCtl_DIS) & 1)) {\n+            return 0;\n+        }\n+    }\n+    return 1;\n+}\n+\n+static inline void compute_hflags(CPUMIPSState *env)\n+{\n+    env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |\n+                     MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU |\n+                     MIPS_HFLAG_AWRAP | MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2 |\n+                     MIPS_HFLAG_SBRI | MIPS_HFLAG_MSA | MIPS_HFLAG_FRE |\n+                     MIPS_HFLAG_ELPA | MIPS_HFLAG_ERL);\n+    if (env->CP0_Status & (1 << CP0St_ERL)) {\n+        env->hflags |= MIPS_HFLAG_ERL;\n+    }\n+    if (!(env->CP0_Status & (1 << CP0St_EXL)) &&\n+        !(env->CP0_Status & (1 << CP0St_ERL)) &&\n+        !(env->hflags & MIPS_HFLAG_DM)) {\n+        env->hflags |= (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU;\n+    }\n+#if defined(TARGET_MIPS64)\n+    if ((env->insn_flags & ISA_MIPS3) &&\n+        (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_UM) ||\n+         (env->CP0_Status & (1 << CP0St_PX)) ||\n+         (env->CP0_Status & (1 << CP0St_UX)))) {\n+        env->hflags |= MIPS_HFLAG_64;\n+    }\n+\n+    if (!(env->insn_flags & ISA_MIPS3)) {\n+        env->hflags |= MIPS_HFLAG_AWRAP;\n+    } else if (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&\n+               !(env->CP0_Status & (1 << CP0St_UX))) {\n+        env->hflags |= MIPS_HFLAG_AWRAP;\n+    } else if (env->insn_flags & ISA_MIPS64R6) {\n+        /* Address wrapping for Supervisor and Kernel is specified in R6 */\n+        if ((((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_SM) &&\n+             !(env->CP0_Status & (1 << CP0St_SX))) ||\n+            (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_KM) &&\n+             !(env->CP0_Status & (1 << CP0St_KX)))) {\n+            env->hflags |= MIPS_HFLAG_AWRAP;\n+        }\n+    }\n+#endif\n+    if (((env->CP0_Status & (1 << CP0St_CU0)) &&\n+         !(env->insn_flags & ISA_MIPS32R6)) ||\n+        !(env->hflags & MIPS_HFLAG_KSU)) {\n+        env->hflags |= MIPS_HFLAG_CP0;\n+    }\n+    if (env->CP0_Status & (1 << CP0St_CU1)) {\n+        env->hflags |= MIPS_HFLAG_FPU;\n+    }\n+    if (env->CP0_Status & (1 << CP0St_FR)) {\n+        env->hflags |= MIPS_HFLAG_F64;\n+    }\n+    if (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_KM) &&\n+        (env->CP0_Config5 & (1 << CP0C5_SBRI))) {\n+        env->hflags |= MIPS_HFLAG_SBRI;\n+    }\n+    if (env->insn_flags & ASE_DSPR2) {\n+        /* Enables access MIPS DSP resources, now our cpu is DSP ASER2,\n+           so enable to access DSPR2 resources. */\n+        if (env->CP0_Status & (1 << CP0St_MX)) {\n+            env->hflags |= MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2;\n+        }\n+\n+    } else if (env->insn_flags & ASE_DSP) {\n+        /* Enables access MIPS DSP resources, now our cpu is DSP ASE,\n+           so enable to access DSP resources. */\n+        if (env->CP0_Status & (1 << CP0St_MX)) {\n+            env->hflags |= MIPS_HFLAG_DSP;\n+        }\n+\n+    }\n+    if (env->insn_flags & ISA_MIPS32R2) {\n+        if (env->active_fpu.fcr0 & (1 << FCR0_F64)) {\n+            env->hflags |= MIPS_HFLAG_COP1X;\n+        }\n+    } else if (env->insn_flags & ISA_MIPS32) {\n+        if (env->hflags & MIPS_HFLAG_64) {\n+            env->hflags |= MIPS_HFLAG_COP1X;\n+        }\n+    } else if (env->insn_flags & ISA_MIPS4) {\n+        /* All supported MIPS IV CPUs use the XX (CU3) to enable\n+           and disable the MIPS IV extensions to the MIPS III ISA.\n+           Some other MIPS IV CPUs ignore the bit, so the check here\n+           would be too restrictive for them.  */\n+        if (env->CP0_Status & (1U << CP0St_CU3)) {\n+            env->hflags |= MIPS_HFLAG_COP1X;\n+        }\n+    }\n+    if (env->insn_flags & ASE_MSA) {\n+        if (env->CP0_Config5 & (1 << CP0C5_MSAEn)) {\n+            env->hflags |= MIPS_HFLAG_MSA;\n+        }\n+    }\n+    if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) {\n+        if (env->CP0_Config5 & (1 << CP0C5_FRE)) {\n+            env->hflags |= MIPS_HFLAG_FRE;\n+        }\n+    }\n+    if (env->CP0_Config3 & (1 << CP0C3_LPA)) {\n+        if (env->CP0_PageGrain & (1 << CP0PG_ELPA)) {\n+            env->hflags |= MIPS_HFLAG_ELPA;\n+        }\n+    }\n+}\n+\n+void cpu_mips_tlb_flush(CPUMIPSState *env);\n+void sync_c0_status(CPUMIPSState *env, CPUMIPSState *cpu, int tc);\n+void cpu_mips_store_status(CPUMIPSState *env, target_ulong val);\n+void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val);\n+\n+void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, uint32_t exception,\n+                                          int error_code, uintptr_t pc);\n+\n+static inline void QEMU_NORETURN do_raise_exception(CPUMIPSState *env,\n+                                                    uint32_t exception,\n+                                                    uintptr_t pc)\n+{\n+    do_raise_exception_err(env, exception, 0, pc);\n+}\n+\n+#endif\ndiff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c\nindex a9a58c5604..f4716395df 100644\n--- a/target/mips/cp0_timer.c\n+++ b/target/mips/cp0_timer.c\n@@ -24,6 +24,7 @@\n #include \"hw/mips/cpudevs.h\"\n #include \"qemu/timer.h\"\n #include \"sysemu/kvm.h\"\n+#include \"internal.h\"\n \n #define TIMER_PERIOD 10 /* 10 ns period for 100 Mhz frequency */\n \ndiff --git a/target/mips/cpu.c b/target/mips/cpu.c\nindex 1bb66b7a5a..68bf423e9d 100644\n--- a/target/mips/cpu.c\n+++ b/target/mips/cpu.c\n@@ -21,6 +21,7 @@\n #include \"qemu/osdep.h\"\n #include \"qapi/error.h\"\n #include \"cpu.h\"\n+#include \"internal.h\"\n #include \"kvm_mips.h\"\n #include \"qemu-common.h\"\n #include \"sysemu/kvm.h\"\ndiff --git a/target/mips/gdbstub.c b/target/mips/gdbstub.c\nindex 7c682289c2..6d1fb70f2c 100644\n--- a/target/mips/gdbstub.c\n+++ b/target/mips/gdbstub.c\n@@ -20,6 +20,7 @@\n #include \"qemu/osdep.h\"\n #include \"qemu-common.h\"\n #include \"cpu.h\"\n+#include \"internal.h\"\n #include \"exec/gdbstub.h\"\n \n int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)\ndiff --git a/target/mips/helper.c b/target/mips/helper.c\nindex ca39aca08a..ea076261af 100644\n--- a/target/mips/helper.c\n+++ b/target/mips/helper.c\n@@ -19,6 +19,7 @@\n #include \"qemu/osdep.h\"\n \n #include \"cpu.h\"\n+#include \"internal.h\"\n #include \"exec/exec-all.h\"\n #include \"exec/cpu_ldst.h\"\n #include \"exec/log.h\"\ndiff --git a/target/mips/kvm.c b/target/mips/kvm.c\nindex 3317905e71..e604aa8b12 100644\n--- a/target/mips/kvm.c\n+++ b/target/mips/kvm.c\n@@ -16,6 +16,7 @@\n \n #include \"qemu-common.h\"\n #include \"cpu.h\"\n+#include \"internal.h\"\n #include \"qemu/error-report.h\"\n #include \"qemu/timer.h\"\n #include \"sysemu/sysemu.h\"\ndiff --git a/target/mips/machine.c b/target/mips/machine.c\nindex 898825de3b..20100d5adb 100644\n--- a/target/mips/machine.c\n+++ b/target/mips/machine.c\n@@ -1,6 +1,7 @@\n #include \"qemu/osdep.h\"\n #include \"qemu-common.h\"\n #include \"cpu.h\"\n+#include \"internal.h\"\n #include \"hw/hw.h\"\n #include \"migration/cpu.h\"\n \ndiff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c\nindex 1fdb0d9792..f167a42655 100644\n--- a/target/mips/msa_helper.c\n+++ b/target/mips/msa_helper.c\n@@ -19,6 +19,7 @@\n \n #include \"qemu/osdep.h\"\n #include \"cpu.h\"\n+#include \"internal.h\"\n #include \"exec/exec-all.h\"\n #include \"exec/helper-proto.h\"\n \ndiff --git a/target/mips/op_helper.c b/target/mips/op_helper.c\nindex 320f2b0dc4..e537a8bfd8 100644\n--- a/target/mips/op_helper.c\n+++ b/target/mips/op_helper.c\n@@ -19,6 +19,7 @@\n #include \"qemu/osdep.h\"\n #include \"qemu/main-loop.h\"\n #include \"cpu.h\"\n+#include \"internal.h\"\n #include \"qemu/host-utils.h\"\n #include \"exec/helper-proto.h\"\n #include \"exec/exec-all.h\"\ndiff --git a/target/mips/translate.c b/target/mips/translate.c\nindex c78d27294c..f0febaf1b2 100644\n--- a/target/mips/translate.c\n+++ b/target/mips/translate.c\n@@ -23,6 +23,7 @@\n \n #include \"qemu/osdep.h\"\n #include \"cpu.h\"\n+#include \"internal.h\"\n #include \"disas/disas.h\"\n #include \"exec/exec-all.h\"\n #include \"tcg-op.h\"\n",
    "prefixes": [
        "v2",
        "2/7"
    ]
}