From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PULL 12/43] target/hppa: Fill in hppa_cpu_do_interrupt/hppa_cpu_exec_interrupt
Date: Sun, 21 Jan 2018 19:41:46 -0800 [thread overview]
Message-ID: <20180122034217.19593-13-richard.henderson@linaro.org> (raw)
In-Reply-To: <20180122034217.19593-1-richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/hppa/cpu.c | 2 +
target/hppa/helper.c | 63 -----------------
target/hppa/int_helper.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++
target/hppa/translate.c | 16 ++++-
target/hppa/Makefile.objs | 1 +
5 files changed, 192 insertions(+), 66 deletions(-)
create mode 100644 target/hppa/int_helper.c
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index 9962ab71ee..ca619578dd 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -106,8 +106,10 @@ static void hppa_cpu_initfn(Object *obj)
CPUHPPAState *env = &cpu->env;
cs->env_ptr = env;
+ cs->exception_index = -1;
cpu_hppa_loaded_fr0(env);
set_snan_bit_is_one(true, &env->fp_status);
+ cpu_hppa_put_psw(env, PSW_W);
}
static ObjectClass *hppa_cpu_class_by_name(const char *cpu_model)
diff --git a/target/hppa/helper.c b/target/hppa/helper.c
index 48ac80cb2d..6e8758f82c 100644
--- a/target/hppa/helper.c
+++ b/target/hppa/helper.c
@@ -67,69 +67,6 @@ void cpu_hppa_put_psw(CPUHPPAState *env, target_ureg psw)
env->psw_cb = cb;
}
-void hppa_cpu_do_interrupt(CPUState *cs)
-{
- HPPACPU *cpu = HPPA_CPU(cs);
- CPUHPPAState *env = &cpu->env;
- int i = cs->exception_index;
-
- if (qemu_loglevel_mask(CPU_LOG_INT)) {
- static const char * const names[] = {
- [EXCP_HPMC] = "high priority machine check",
- [EXCP_POWER_FAIL] = "power fail interrupt",
- [EXCP_RC] = "recovery counter trap",
- [EXCP_EXT_INTERRUPT] = "external interrupt",
- [EXCP_LPMC] = "low priority machine check",
- [EXCP_ITLB_MISS] = "instruction tlb miss fault",
- [EXCP_IMP] = "instruction memory protection trap",
- [EXCP_ILL] = "illegal instruction trap",
- [EXCP_BREAK] = "break instruction trap",
- [EXCP_PRIV_OPR] = "privileged operation trap",
- [EXCP_PRIV_REG] = "privileged register trap",
- [EXCP_OVERFLOW] = "overflow trap",
- [EXCP_COND] = "conditional trap",
- [EXCP_ASSIST] = "assist exception trap",
- [EXCP_DTLB_MISS] = "data tlb miss fault",
- [EXCP_NA_ITLB_MISS] = "non-access instruction tlb miss",
- [EXCP_NA_DTLB_MISS] = "non-access data tlb miss",
- [EXCP_DMP] = "data memory protection trap",
- [EXCP_DMB] = "data memory break trap",
- [EXCP_TLB_DIRTY] = "tlb dirty bit trap",
- [EXCP_PAGE_REF] = "page reference trap",
- [EXCP_ASSIST_EMU] = "assist emulation trap",
- [EXCP_HPT] = "high-privilege transfer trap",
- [EXCP_LPT] = "low-privilege transfer trap",
- [EXCP_TB] = "taken branch trap",
- [EXCP_DMAR] = "data memory access rights trap",
- [EXCP_DMPI] = "data memory protection id trap",
- [EXCP_UNALIGN] = "unaligned data reference trap",
- [EXCP_PER_INTERRUPT] = "performance monitor interrupt",
- [EXCP_SYSCALL] = "syscall",
- [EXCP_SYSCALL_LWS] = "syscall-lws",
- };
- static int count;
- const char *name = NULL;
-
- if (i >= 0 && i < ARRAY_SIZE(names)) {
- name = names[i];
- }
- if (name) {
- qemu_log("INT %6d: %s ia_f=" TARGET_FMT_lx "\n",
- ++count, name, env->iaoq_f);
- } else {
- qemu_log("INT %6d: unknown %d ia_f=" TARGET_FMT_lx "\n",
- ++count, i, env->iaoq_f);
- }
- }
- cs->exception_index = -1;
-}
-
-bool hppa_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
-{
- abort();
- return false;
-}
-
void hppa_cpu_dump_state(CPUState *cs, FILE *f,
fprintf_function cpu_fprintf, int flags)
{
diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c
new file mode 100644
index 0000000000..34413c30e1
--- /dev/null
+++ b/target/hppa/int_helper.c
@@ -0,0 +1,176 @@
+/*
+ * HPPA interrupt helper routines
+ *
+ * Copyright (c) 2017 Richard Henderson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/main-loop.h"
+#include "cpu.h"
+#include "exec/exec-all.h"
+#include "exec/helper-proto.h"
+#include "qom/cpu.h"
+
+
+void hppa_cpu_do_interrupt(CPUState *cs)
+{
+ HPPACPU *cpu = HPPA_CPU(cs);
+ CPUHPPAState *env = &cpu->env;
+ int i = cs->exception_index;
+ target_ureg iaoq_f = env->iaoq_f;
+ target_ureg iaoq_b = env->iaoq_b;
+
+#ifndef CONFIG_USER_ONLY
+ target_ureg old_psw;
+
+ /* As documented in pa2.0 -- interruption handling. */
+ /* step 1 */
+ env->cr[CR_IPSW] = old_psw = cpu_hppa_get_psw(env);
+
+ /* step 2 -- note PSW_W == 0 for !HPPA64. */
+ cpu_hppa_put_psw(env, PSW_W | (i == EXCP_HPMC ? PSW_M : 0));
+
+ /* step 3 */
+ env->cr[CR_IIAOQ] = iaoq_f;
+ env->cr_back[1] = iaoq_b;
+
+ /* step 5 */
+ /* ISR and IOR will be set elsewhere. */
+ switch (i) {
+ case EXCP_ILL:
+ case EXCP_BREAK:
+ case EXCP_PRIV_REG:
+ case EXCP_PRIV_OPR:
+ /* IIR set via translate.c. */
+ break;
+
+ case EXCP_OVERFLOW:
+ case EXCP_COND:
+ case EXCP_ASSIST:
+ case EXCP_DTLB_MISS:
+ case EXCP_NA_ITLB_MISS:
+ case EXCP_NA_DTLB_MISS:
+ case EXCP_DMAR:
+ case EXCP_DMPI:
+ case EXCP_UNALIGN:
+ case EXCP_DMP:
+ case EXCP_DMB:
+ case EXCP_TLB_DIRTY:
+ case EXCP_PAGE_REF:
+ case EXCP_ASSIST_EMU:
+ {
+ /* Avoid reading directly from the virtual address, lest we
+ raise another exception from some sort of TLB issue. */
+ vaddr vaddr;
+ hwaddr paddr;
+
+ paddr = vaddr = iaoq_f & -4;
+ env->cr[CR_IIR] = ldl_phys(cs->as, paddr);
+ }
+ break;
+
+ default:
+ /* Other exceptions do not set IIR. */
+ break;
+ }
+
+ /* step 6 */
+ if (old_psw & PSW_Q) {
+ env->shadow[0] = env->gr[1];
+ env->shadow[1] = env->gr[8];
+ env->shadow[2] = env->gr[9];
+ env->shadow[3] = env->gr[16];
+ env->shadow[4] = env->gr[17];
+ env->shadow[5] = env->gr[24];
+ env->shadow[6] = env->gr[25];
+ }
+
+ /* step 7 */
+ env->iaoq_f = env->cr[CR_IVA] + 32 * i;
+ env->iaoq_b = env->iaoq_f + 4;
+#endif
+
+ if (qemu_loglevel_mask(CPU_LOG_INT)) {
+ static const char * const names[] = {
+ [EXCP_HPMC] = "high priority machine check",
+ [EXCP_POWER_FAIL] = "power fail interrupt",
+ [EXCP_RC] = "recovery counter trap",
+ [EXCP_EXT_INTERRUPT] = "external interrupt",
+ [EXCP_LPMC] = "low priority machine check",
+ [EXCP_ITLB_MISS] = "instruction tlb miss fault",
+ [EXCP_IMP] = "instruction memory protection trap",
+ [EXCP_ILL] = "illegal instruction trap",
+ [EXCP_BREAK] = "break instruction trap",
+ [EXCP_PRIV_OPR] = "privileged operation trap",
+ [EXCP_PRIV_REG] = "privileged register trap",
+ [EXCP_OVERFLOW] = "overflow trap",
+ [EXCP_COND] = "conditional trap",
+ [EXCP_ASSIST] = "assist exception trap",
+ [EXCP_DTLB_MISS] = "data tlb miss fault",
+ [EXCP_NA_ITLB_MISS] = "non-access instruction tlb miss",
+ [EXCP_NA_DTLB_MISS] = "non-access data tlb miss",
+ [EXCP_DMP] = "data memory protection trap",
+ [EXCP_DMB] = "data memory break trap",
+ [EXCP_TLB_DIRTY] = "tlb dirty bit trap",
+ [EXCP_PAGE_REF] = "page reference trap",
+ [EXCP_ASSIST_EMU] = "assist emulation trap",
+ [EXCP_HPT] = "high-privilege transfer trap",
+ [EXCP_LPT] = "low-privilege transfer trap",
+ [EXCP_TB] = "taken branch trap",
+ [EXCP_DMAR] = "data memory access rights trap",
+ [EXCP_DMPI] = "data memory protection id trap",
+ [EXCP_UNALIGN] = "unaligned data reference trap",
+ [EXCP_PER_INTERRUPT] = "performance monitor interrupt",
+ [EXCP_SYSCALL] = "syscall",
+ [EXCP_SYSCALL_LWS] = "syscall-lws",
+ };
+ static int count;
+ const char *name = NULL;
+ char unknown[16];
+
+ if (i >= 0 && i < ARRAY_SIZE(names)) {
+ name = names[i];
+ }
+ if (!name) {
+ snprintf(unknown, sizeof(unknown), "unknown %d", i);
+ name = unknown;
+ }
+ qemu_log("INT %6d: %s @ " TARGET_FMT_lx "," TARGET_FMT_lx
+ " -> " TREG_FMT_lx " " TARGET_FMT_lx "\n",
+ ++count, name,
+ (target_ulong)iaoq_f,
+ (target_ulong)iaoq_b,
+ env->iaoq_f,
+ (target_ulong)env->cr[CR_IOR]);
+ }
+ cs->exception_index = -1;
+}
+
+bool hppa_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
+{
+#ifndef CONFIG_USER_ONLY
+ HPPACPU *cpu = HPPA_CPU(cs);
+ CPUHPPAState *env = &cpu->env;
+
+ /* If interrupts are requested and enabled, raise them. */
+ if ((env->psw & PSW_I) && (interrupt_request & CPU_INTERRUPT_HARD)) {
+ cs->exception_index = EXCP_EXT_INTERRUPT;
+ hppa_cpu_do_interrupt(cs);
+ return true;
+ }
+#endif
+ return false;
+}
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 89c22a4c3e..58837044a6 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -278,6 +278,7 @@ typedef struct DisasContext {
DisasCond null_cond;
TCGLabel *null_lab;
+ uint32_t insn;
int mmu_idx;
int privilege;
bool psw_n_nonzero;
@@ -712,17 +713,25 @@ static DisasJumpType gen_excp(DisasContext *ctx, int exception)
return DISAS_NORETURN;
}
+static DisasJumpType gen_excp_iir(DisasContext *ctx, int exc)
+{
+ TCGv_reg tmp = tcg_const_reg(ctx->insn);
+ tcg_gen_st_reg(tmp, cpu_env, offsetof(CPUHPPAState, cr[CR_IIR]));
+ tcg_temp_free(tmp);
+ return gen_excp(ctx, exc);
+}
+
static DisasJumpType gen_illegal(DisasContext *ctx)
{
nullify_over(ctx);
- return nullify_end(ctx, gen_excp(ctx, EXCP_ILL));
+ return nullify_end(ctx, gen_excp_iir(ctx, EXCP_ILL));
}
#define CHECK_MOST_PRIVILEGED(EXCP) \
do { \
if (ctx->privilege != 0) { \
nullify_over(ctx); \
- return nullify_end(ctx, gen_excp(ctx, EXCP)); \
+ return nullify_end(ctx, gen_excp_iir(ctx, EXCP)); \
} \
} while (0)
@@ -1882,7 +1891,7 @@ static DisasJumpType trans_break(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
nullify_over(ctx);
- return nullify_end(ctx, gen_excp(ctx, EXCP_BREAK));
+ return nullify_end(ctx, gen_excp_iir(ctx, EXCP_BREAK));
}
static DisasJumpType trans_sync(DisasContext *ctx, uint32_t insn,
@@ -4259,6 +4268,7 @@ static void hppa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
ctx->null_cond.c = TCG_COND_NEVER;
ret = DISAS_NEXT;
} else {
+ ctx->insn = insn;
ret = translate_one(ctx, insn);
assert(ctx->null_lab == NULL);
}
diff --git a/target/hppa/Makefile.objs b/target/hppa/Makefile.objs
index d89285307b..dcd60a6839 100644
--- a/target/hppa/Makefile.objs
+++ b/target/hppa/Makefile.objs
@@ -1 +1,2 @@
obj-y += translate.o helper.o cpu.o op_helper.o gdbstub.o mem_helper.o
+obj-y += int_helper.o
--
2.14.3
next prev parent reply other threads:[~2018-01-22 3:42 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 3:41 [Qemu-devel] [PULL 00/43] Add hppa-softmmu Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 01/43] target/hppa: Skeleton support for hppa-softmmu Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 02/43] target/hppa: Define the rest of the PSW Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 03/43] target/hppa: Disable gateway page emulation for system mode Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 04/43] target/hppa: Define hardware exception types Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 05/43] target/hppa: Split address size from register size Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 06/43] target/hppa: Implement mmu_idx from IA privilege level Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 07/43] target/hppa: Implement the system mask instructions Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 08/43] target/hppa: Add space registers Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 09/43] target/hppa: Add control registers Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 10/43] target/hppa: Adjust insn mask for mfctl, w Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 11/43] target/hppa: Implement rfi Richard Henderson
2018-01-22 3:41 ` Richard Henderson [this message]
2018-01-22 3:41 ` [Qemu-devel] [PULL 13/43] target/hppa: Implement unaligned access trap Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 14/43] target/hppa: Use space registers in data operations Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 15/43] target/hppa: Avoid privilege level decrease during branches Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 16/43] target/hppa: Implement IASQ Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 17/43] target/hppa: Implement tlb_fill Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 18/43] target/hppa: Implement external interrupts Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 19/43] target/hppa: Implement the interval timer Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 20/43] target/hppa: Log unimplemented instructions Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 21/43] target/hppa: Implement I*TLBA and I*TLBP insns Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 22/43] target/hppa: Implement P*TLB and P*TLBE insns Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 23/43] target/hppa: Implement LDWA Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 24/43] target/hppa: Implement LPA Richard Henderson
2018-01-22 3:41 ` [Qemu-devel] [PULL 25/43] target/hppa: Implement LCI Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 26/43] target/hppa: Implement SYNCDMA insn Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 27/43] target/hppa: Implement halt and reset instructions Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 28/43] target/hppa: Optimize for flat addressing space Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 29/43] target/hppa: Add system registers to gdbstub Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 30/43] target/hppa: Add migration for the cpu Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 31/43] target/hppa: Implement B,GATE insn Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 32/43] target/hppa: Only use EXCP_DTLB_MISS Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 33/43] qom: Add MMU_DEBUG_LOAD Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 34/43] target/hppa: Use MMU_DEBUG_LOAD when reloading for CR[IIR] Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 35/43] target/hppa: Increase number of temp regs Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 36/43] target/hppa: Fix comment Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 37/43] target/hppa: Implement LDSID for system mode Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 38/43] target/hppa: Implement a pause instruction Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 39/43] target/hppa: Implement STWA Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 40/43] target/hppa: Enable MTTCG Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 41/43] hw/hppa: Implement DINO system board Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 42/43] pc-bios: Add hppa-firmware.img and git submodule Richard Henderson
2018-01-22 3:42 ` [Qemu-devel] [PULL 43/43] hw/hppa: Add MAINTAINERS entry Richard Henderson
2018-01-22 4:27 ` [Qemu-devel] [PULL 00/43] Add hppa-softmmu no-reply
2018-01-22 4:38 ` no-reply
2018-01-22 4:57 ` no-reply
2018-01-23 10:14 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180122034217.19593-13-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).