From patchwork Fri Dec 29 06:31:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 122906 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4332154qgn; Thu, 28 Dec 2017 22:46:51 -0800 (PST) X-Google-Smtp-Source: ACJfBovoxz+d2R8c6JzFMyZPsbHSIOywrOSPi1N0KXIIJ+nkZHEONEp9vQdM4BzgPirkuxBaCoid X-Received: by 10.129.175.72 with SMTP id x8mr22919156ywj.277.1514530011766; Thu, 28 Dec 2017 22:46:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514530011; cv=none; d=google.com; s=arc-20160816; b=DK/2MtnKOUYl3GoSLtckW0YMNJj3kFCxFQk/mPqtHlVSQSn2PEdieJB+nXGMcJqYsx cx7/42B8q3sMsnV2vpkYLZcdjwMffcXYM0biScrRUGQzVGNKCZPB5GIIkI8uF3LqQv7+ G+sbN9eSfiudqyqUmGeXuuolrOAEnvudjnIqsmQLZKBe/EmYjXRMVonDD2ZwkPuxUd1T bRYprznrEeckmpxvX/JnKI+4KEM0ZREL9ezgTpm/KoTOxZLsRQ5FF3MsJ/DSGUsl8QGr lUZEzsNf9LHtBVwfk6PHxRaOfTS4kB02tz6lE7eF1IWM1adb7HWMMr9t5eLwq7gcQu5N 4E8g== 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=ftyxlT95Rrnhzjh6FDPg4X0fxz62LsH+eIi8JPG1YeI=; b=Lm/rV0FkQfbtXlWW8Dgt3zlAYaEuCrOVQI1TX3GCw5YTImXCGn4J5F1rnb/FNdH2Fp JOqs9KFXhE0NOaU66glTSz9yX6c2SgrR0BMxk6j97LvZ7R/aA34kVCjGnUlxnrxaZCja AGPgSVfUkQhWUQwu0qk+mHR0/v25nYEZ5WOZ9JmaLox8T0yVnejr2fLVH6LaVxzHnzqD G/tmD/1FAO7brcVms0GDla4mhWb7zWIqCAI8820L4w1j5kOOOeg5yaFnRcN+NXPj8/ld AHvRW1XA7XrHvBzGwvQJOEizf8w2p2Epv0VzoADfvCEJxIvaZja53NqgXuClXUTG/55+ 4SLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LrGIwCfb; 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 g7si287213ybm.307.2017.12.28.22.46.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Dec 2017 22:46:51 -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=LrGIwCfb; 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]:57013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUoRP-0006oV-5J for patch@linaro.org; Fri, 29 Dec 2017 01:46:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUoDI-000343-6Z for qemu-devel@nongnu.org; Fri, 29 Dec 2017 01:32:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eUoDG-0004io-Tw for qemu-devel@nongnu.org; Fri, 29 Dec 2017 01:32:16 -0500 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:33154) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eUoDG-0004iB-Mr for qemu-devel@nongnu.org; Fri, 29 Dec 2017 01:32:14 -0500 Received: by mail-pl0-x242.google.com with SMTP id 1so21073905plv.0 for ; Thu, 28 Dec 2017 22:32:14 -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=ftyxlT95Rrnhzjh6FDPg4X0fxz62LsH+eIi8JPG1YeI=; b=LrGIwCfbOgikdloDNfENJc/T7jTRT8HywQ16i0lP7KfUQiuq1Fx+H1bZcfi7Xo/BlM lBAJuzrsLJVFpIPGQbPKmWP+nUc83IADzyY/pyEtukljOnTwfH3v5fx1xfGE5/J/LQU6 r/lMJTRk1+6tLnV0FhBsgXy3rGWSQKyMB7e30= 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=ftyxlT95Rrnhzjh6FDPg4X0fxz62LsH+eIi8JPG1YeI=; b=UXSrfPXJVW7ES8wkrklCE801C34ZmdUjZSv3KtsmR70kb66cFa0d4Qa4Dk4hV2ouoB KYx9h2AMwm8e1va/jI+1u01EL6SWtyOhk61V9Pm+F4ay6hCPOdE5maxcsA8DKwKxtSwt Xfu7/WkGyfCO9bK33BW/Qk/5Ew0yjVxoW+yczFpxwbMHJaBbFq4ZgJMAZrPBGmIkcIeW Wpq6fTmnKCca/JbtC0bkBIZRHZ3J7K3yrhFBmBQl+uHbQqjta5jdtTGwW+UEiydhhtwP e/3GMPWxLd3nUpPpQh40Dl5wQGbatpTz6yMNmKoy+eZywYtYLL3kwjTuvzUePfIcP9OF KxaQ== X-Gm-Message-State: AKGB3mJq+MFN0ksSszugQD9qTvW4u6eV2LUNvPDHnj2ziCzfyQxSAyo0 3ylKO7WP8by8jt00Tay1kNWj1mAVLbI= X-Received: by 10.84.128.227 with SMTP id a90mr2301452pla.97.1514529133392; Thu, 28 Dec 2017 22:32:13 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-183-164.tukw.qwest.net. [97.113.183.164]) by smtp.gmail.com with ESMTPSA id c28sm76539063pfe.69.2017.12.28.22.32.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Dec 2017 22:32:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 28 Dec 2017 22:31:26 -0800 Message-Id: <20171229063145.29167-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171229063145.29167-1-richard.henderson@linaro.org> References: <20171229063145.29167-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:c01::242 Subject: [Qemu-devel] [PATCH 19/38] 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: deller@gmx.de 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 d09f9faa86..bd91ec57e6 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -342,6 +342,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 fbda7956bc..8e10649aaa 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -51,6 +51,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; @@ -151,6 +156,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 e66ca26941..74ab34f306 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 d928bfe335..ce2a6c21d6 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2115,12 +2115,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 */ @@ -2137,7 +2150,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,