From patchwork Wed Jan 24 23:25:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 125725 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp734772ljf; Wed, 24 Jan 2018 15:35:25 -0800 (PST) X-Google-Smtp-Source: AH8x227nBmObwM5qsa/NV7+lB4UGObkNvHI2idtoebKjBdZ6SYohiImwE4vazxVbdxoEq6u+CaRB X-Received: by 10.129.122.73 with SMTP id v70mr6702385ywc.156.1516836925292; Wed, 24 Jan 2018 15:35:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516836925; cv=none; d=google.com; s=arc-20160816; b=bo5Cb7HG0ik7u3FLP7Q0P5VzJaCbTxTACen5GEuByjwx8iOsN/DwKHFVAjDWw11MFb jBIp4kI8YMm17gRJOM+GbmqEqJkmlGI3sbTqXSXLrz4MnXJscbOWoC8i3dHcPd3bzHXP 7ybgYhJQ4GGiuon62z1HwLvwarAifwOXFmS7kevBIqqpTLOvoEZCYkY96jLr31yZNHsw 7SYRfOyFVT3mBRkdVxuen8sceOzlmbUgWyqvWLHlmgrBnsdn50JNBtHgDHhJ7WpHCax+ LSt9dzzrA8flC4mQgWZO3kFdo6N0ixVQfN8ntSUb0r4aeIrC1biQb9MEQag2qW4VYVTC 9crQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=CUfgcA2foVF68I+6bbQG+I5P6I+RV/GKq3qFtasSazM=; b=wpOfugul3Fg4h+jJA337icFQ15G0M04rId9fhlHPDDDxDHrAm6JZi0i/Y9cnZa0+qi lYHiFjiKMTNlwNsRuEhg4U8qY7JlZ+ezAYQcdL4WuyafU9h+WuYC7eTyzWageIQT1Elw 6cVGIld9XZUuDtU4pBYC6SKyftpJNQTZfUre6hc+kFSLIjhG6vIolCxGRLEl3mND0fzv hcHfimUMU2TlVHGO5qGxwX5Qd7mtQCd7eKUK8Qje9BdqD15deHAZcEF/JlzxA7eTFY4q O+TV9BJTssASNVNLLFYxxm+U653ZTpmAEUxkomaNKzR1E8O9sm5XJBwp/BXWRzdT1Hei fmEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XxCZ1mVu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z14si1705893ybm.30.2018.01.24.15.35.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Jan 2018 15:35:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XxCZ1mVu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeUZg-0001k6-KA for patch@linaro.org; Wed, 24 Jan 2018 18:35:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeURV-0004f0-K5 for qemu-devel@nongnu.org; Wed, 24 Jan 2018 18:26:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeURU-0001qe-Dj for qemu-devel@nongnu.org; Wed, 24 Jan 2018 18:26:57 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:34036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eeURU-0001on-72 for qemu-devel@nongnu.org; Wed, 24 Jan 2018 18:26:56 -0500 Received: by mail-pg0-x243.google.com with SMTP id r19so3821098pgn.1 for ; Wed, 24 Jan 2018 15:26:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=CUfgcA2foVF68I+6bbQG+I5P6I+RV/GKq3qFtasSazM=; b=XxCZ1mVu25SzEYStB70W5mr5o0yVDnjWNkYB/qJwQxO6THwwzQ/wWS72pmk4CzaHCK YJxZuuknCmhsGUH09IpZkBzqh7ubV3yodep0l5SWE8im1Ij2ocbO85mFs4uGelc8cO5l SUl3tIRkmblxlbN/yayLYUm0r1hCc7GRqw9GY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=CUfgcA2foVF68I+6bbQG+I5P6I+RV/GKq3qFtasSazM=; b=fHWhIkXL8wA4OB6u+vBefaS1Lt2y7gmDTYdhdzBqLNWfGrN9bgYSIfNyTHTMeTbjKH HNXiRFEt07ZcajvnnqckCY+G+8QKE5lNXs/dxr+M8FlK6LeN/XlwCbq2Zd7cT9Fc7bQG CAIFLK3earLGhiWAY1cuMGhUhYTwEMWBd8zn4I4i96zTddbLAx56Tw0E3xOCdLNplsZ7 9QMPWASVf+52fZJTviwEvUPQrYDiddNEYYm335CXynXfKDOcW5X0LwbsN5NQc6bXIXj0 lya6lfMJD6WCMpggVe5X05sphOy4S62gjb+gMCHwE1OBPKADysHdQ792dQRG56Un8C8f NhaA== X-Gm-Message-State: AKwxyteIngiG0wvniNKS5EsTBnrsBa4gsrHEoIbWKvu4qWfblwdbYGLh FvrYIJPO8D5wz2doJnizfqIYhFUD2og= X-Received: by 2002:a17:902:9306:: with SMTP id bc6-v6mr9383899plb.29.1516836414951; Wed, 24 Jan 2018 15:26:54 -0800 (PST) Received: from cloudburst.twiddle.net (174-21-6-47.tukw.qwest.net. [174.21.6.47]) by smtp.gmail.com with ESMTPSA id z19sm9760028pfh.185.2018.01.24.15.26.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jan 2018 15:26:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 24 Jan 2018 15:25:58 -0800 Message-Id: <20180124232625.30105-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180124232625.30105-1-richard.henderson@linaro.org> References: <20180124232625.30105-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v3 18/45] target/hppa: Implement external interrupts 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 1 + target/hppa/helper.h | 2 ++ target/hppa/cpu.c | 6 +++++ target/hppa/int_helper.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ target/hppa/translate.c | 16 ++++++++++++- 5 files changed, 83 insertions(+), 1 deletion(-) -- 2.14.3 diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index c7a2fb5b20..fc3e62c0af 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -340,6 +340,7 @@ int hppa_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw, int midx); #else int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, MMUAccessType type, hwaddr *pphys, int *pprot); +extern const MemoryRegionOps hppa_io_eir_ops; #endif #endif /* HPPA_CPU_H */ diff --git a/target/hppa/helper.h b/target/hppa/helper.h index 79d22ae486..535f086ab4 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -80,5 +80,7 @@ DEF_HELPER_FLAGS_4(fmpynfadd_d, TCG_CALL_NO_RWG, i64, env, i64, i64, i64) #ifndef CONFIG_USER_ONLY DEF_HELPER_1(rfi, void, env) DEF_HELPER_1(rfi_r, void, env) +DEF_HELPER_FLAGS_2(write_eirr, TCG_CALL_NO_RWG, void, env, tr) +DEF_HELPER_FLAGS_2(write_eiem, TCG_CALL_NO_RWG, void, env, tr) DEF_HELPER_FLAGS_2(swap_system_mask, TCG_CALL_NO_RWG, tr, env, tr) #endif diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 2970afd58d..888a48f16d 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -57,6 +57,11 @@ static void hppa_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) cpu->env.psw_n = (tb->flags & PSW_N) != 0; } +static bool hppa_cpu_has_work(CPUState *cs) +{ + return cs->interrupt_request & CPU_INTERRUPT_HARD; +} + static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info) { info->mach = bfd_mach_hppa20; @@ -159,6 +164,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) dc->realize = hppa_cpu_realizefn; cc->class_by_name = hppa_cpu_class_by_name; + cc->has_work = hppa_cpu_has_work; cc->do_interrupt = hppa_cpu_do_interrupt; cc->cpu_exec_interrupt = hppa_cpu_exec_interrupt; cc->dump_state = hppa_cpu_dump_state; diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index 5ae5233a96..249e14a2a1 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -24,6 +24,65 @@ #include "exec/helper-proto.h" #include "qom/cpu.h" +#ifndef CONFIG_USER_ONLY +static void eval_interrupt(HPPACPU *cpu) +{ + CPUState *cs = CPU(cpu); + if (cpu->env.cr[CR_EIRR] & cpu->env.cr[CR_EIEM]) { + cpu_interrupt(cs, CPU_INTERRUPT_HARD); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); + } +} + +/* Each CPU has a word mapped into the GSC bus. Anything on the GSC bus + * can write to this word to raise an external interrupt on the target CPU. + * This includes the system controler (DINO) for regular devices, or + * another CPU for SMP interprocessor interrupts. + */ +static uint64_t io_eir_read(void *opaque, hwaddr addr, unsigned size) +{ + HPPACPU *cpu = opaque; + + /* ??? What does a read of this register over the GSC bus do? */ + return cpu->env.cr[CR_EIRR]; +} + +static void io_eir_write(void *opaque, hwaddr addr, + uint64_t data, unsigned size) +{ + HPPACPU *cpu = opaque; + int le_bit = ~data & (TARGET_REGISTER_BITS - 1); + + cpu->env.cr[CR_EIRR] |= (target_ureg)1 << le_bit; + eval_interrupt(cpu); +} + +const MemoryRegionOps hppa_io_eir_ops = { + .read = io_eir_read, + .write = io_eir_write, + .valid.min_access_size = 4, + .valid.max_access_size = 4, + .impl.min_access_size = 4, + .impl.max_access_size = 4, +}; + +void HELPER(write_eirr)(CPUHPPAState *env, target_ureg val) +{ + env->cr[CR_EIRR] &= ~val; + qemu_mutex_lock_iothread(); + eval_interrupt(hppa_env_get_cpu(env)); + qemu_mutex_unlock_iothread(); +} + +void HELPER(write_eiem)(CPUHPPAState *env, target_ureg val) +{ + env->cr[CR_EIEM] = val; + qemu_mutex_lock_iothread(); + eval_interrupt(hppa_env_get_cpu(env)); + qemu_mutex_unlock_iothread(); +} +#endif /* !CONFIG_USER_ONLY */ void hppa_cpu_do_interrupt(CPUState *cs) { diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 44abc9006b..d6c65f314b 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2124,12 +2124,25 @@ static DisasJumpType trans_mtctl(DisasContext *ctx, uint32_t insn, /* All other control registers are privileged or read-only. */ CHECK_MOST_PRIVILEGED(EXCP_PRIV_REG); +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else + DisasJumpType ret = DISAS_NEXT; + nullify_over(ctx); switch (ctl) { case CR_IT: /* ??? modify interval timer offset */ break; + case CR_EIRR: + gen_helper_write_eirr(cpu_env, reg); + break; + case CR_EIEM: + gen_helper_write_eiem(cpu_env, reg); + ret = DISAS_IAQ_N_STALE_EXIT; + break; + case CR_IIASQ: case CR_IIAOQ: /* FIXME: Respect PSW_Q bit */ @@ -2146,7 +2159,8 @@ static DisasJumpType trans_mtctl(DisasContext *ctx, uint32_t insn, tcg_gen_st_reg(reg, cpu_env, offsetof(CPUHPPAState, cr[ctl])); break; } - return nullify_end(ctx, DISAS_NEXT); + return nullify_end(ctx, ret); +#endif } static DisasJumpType trans_mtsarcm(DisasContext *ctx, uint32_t insn,