From patchwork Sun Jan 28 23:15:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 126111 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp1984082ljd; Sun, 28 Jan 2018 15:37:04 -0800 (PST) X-Google-Smtp-Source: AH8x226+YuExXBZpUd947f/csPIVi0orMcfaJRzkqgeEs7IfHKrUmdWWaKlxvz9DvnKGKyQzQMez X-Received: by 10.37.180.10 with SMTP id n10mr15546955ybj.117.1517182624773; Sun, 28 Jan 2018 15:37:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517182624; cv=none; d=google.com; s=arc-20160816; b=YXovilTfbAJiK2p5Uj4vRnjKGJLeznnJxQ0OLl5sYHuSOQcEuPz4ot5GT333aiW/yR AQCbCiGyAxtRuFuxEecaYLwJ+VrT7e46ETDduY0AGsCTkvRSUoLuR3yYwB7uDlsiFQst 5yRQbtmao0UeHqz/S8DvwK+2il5yHIntQxIkJcxkOtimRRD/oGnLepdi0mutjwGuvrDW 3AlKltUBLmZwMfQlLPO3t8zsFajLavY5xQMkWFUm1353NoYSaJjRNofs3PrIKGmO/9QM VmLN+YgUqayzXD2tTVkpcA1QSxyMBRBQsRCFH7Ji5WV5k+m9+4178AVUCv2EI6t5IkYt Gwfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=Avfow5ySEDXBCsumF6lr6WNRUBxTxQLuOxm/xeb7YQM=; b=vigzHfDX4slbebqObINrxi04t5dXrFqdPrxqjACmkXgBRUC4ieBxkTem61UgPxxPnV v824jvREEecrINopHoFSC0J2fhKsk9OMeKMQ6l5Qk3j7OfD/utdw8ssf2VShjX74Ea7m HLW2iA3Cdm1Dye4lSjS+ACMhDQ20405YkPLufaU/Dj/NZPMV7I/dsNfcJQFbc4qTSBpl dj5iC0LxfGE6Uqvm6Syc33zxjaz61jlt/uys0EH/eLgsMXV4ryecK4UrJY1ktK0aK01C GU0q6xHy/LK4EoUPgi37CLSknGciGMu2nkZ4fPATIWxNlyEDvzEVF1AToifBPu+IKeXo qDSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XAokAd29; 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 t7si4424442yba.672.2018.01.28.15.37.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 28 Jan 2018 15:37:04 -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=XAokAd29; 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]:45032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwVU-00012i-3q for patch@linaro.org; Sun, 28 Jan 2018 18:37:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwB8-0002n8-CV for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efwB7-0008Sv-0C for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:02 -0500 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:43758) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efwB6-0008SE-PK for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:00 -0500 Received: by mail-pf0-x243.google.com with SMTP id y26so3252579pfi.10 for ; Sun, 28 Jan 2018 15:16:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Avfow5ySEDXBCsumF6lr6WNRUBxTxQLuOxm/xeb7YQM=; b=XAokAd29bJ4ZxoIYXsmfSKuAEW8eqq6wo9uVdJnXin571mPJQLo8P04dtpyCX1L8dP mP+UNZuyNwcmXjYF1oiWpc8ng2/0pd6SHkOOG1aucVObbVpfARn0tMS0+u0JKlWdmADg fIgwOgVgZcBDr+6SgF14GmxIqG7jSXTc7Jse4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Avfow5ySEDXBCsumF6lr6WNRUBxTxQLuOxm/xeb7YQM=; b=fxc21IUe0vPeQ+ZAUapH9sZRgJ2Xjr4ahffKMBue4Jo7TGCPYczWxs3DDGIddmi6/9 u6XYoN6AfnPFeZEPaA164ewZz2yyC7iKan3YMHIdtUBUEp9/zL+1Hq02nzFJbW1aD4eR whIobYIMPvDMqdMD1CyViOWRcdiVQJGCh19f3anIPjlGre1vODhe01cw9Rd5TC1Xpu5h vKh2DbYGh27+I3k3h1GSc0gSf08FtIOr9RO3ycMcaHvl6tEG8AKMlTxxgyj6zKJVBtom wk7ELdfWGilm49y7oaxJaBn6l3JNE0yomBOkeU2sgQ2rOOzVLegcMOcfMkLKbDcH8ykk jDMg== X-Gm-Message-State: AKwxytdwzsy49GaQUjnmchYDkWiYLFRw97upwmFGnoHrgFo7Fs9cG1jb 5j33FSwXsJMvO2VhqgqzyNoy5qrXiSA= X-Received: by 2002:a17:902:5a0b:: with SMTP id q11-v6mr20128838pli.207.1517181359522; Sun, 28 Jan 2018 15:15:59 -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 r27sm26949344pfj.75.2018.01.28.15.15.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Jan 2018 15:15:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 28 Jan 2018 15:15:03 -0800 Message-Id: <20180128231528.22719-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180128231528.22719-1-richard.henderson@linaro.org> References: <20180128231528.22719-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:c00::243 Subject: [Qemu-devel] [PULL v4 18/43] 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: , Cc: peter.maydell@linaro.org 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 bd8fe6af78..586ea1e555 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -341,6 +341,7 @@ int hppa_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, #else int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, int 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 3d668a3a4f..c468b12e73 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,