From patchwork Wed Jan 24 23:26:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 125731 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp736220ljf; Wed, 24 Jan 2018 15:39:13 -0800 (PST) X-Google-Smtp-Source: AH8x225OLxGTPjtqtY52NBJMuMDNEjE5pNQQk0Ph2I0t6Sps16RbuMfKhp/13TJZMTf6+UmnLCO7 X-Received: by 10.37.60.7 with SMTP id j7mr5400502yba.39.1516837153292; Wed, 24 Jan 2018 15:39:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516837153; cv=none; d=google.com; s=arc-20160816; b=xMxi0qbsQrvnNEcQEw7/me3iAF/b4HNWCgBBBrQwRTuWBe+9UVUd9DN+pPU126d8Ku Elc7xlLFoWZEWz4ZuFH08NfqFExG9KxrtInyNJNhFpWPg08iUwD3d/TvpRpgPa2d9LCF +dlGPWy3svTr9CwOLdKvjj+f3LZbCE3MeIItYCQGExG5YebKJYAMgiaJTgieB3Y8x9k5 S9TUBiBLW6pr6n8F1LUShtRT0pcXHeaP99LWFSQmuDiDqv57W2/KuHQosn/KnQIHBL8J EF/uQGOzAXSDTMjAo9KDtz7h6SwWcXOIsUVyABR/UFvJ6Jq7G4rVLaWAdCvI+iO26+WE IVxg== 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=Jz9a0SHM1j6sy0TDh85R+Hbc1trXnrF4FvsYuaL1xsE=; b=FHKoA/KKdOQUWQx6zzigoCWoci0vbcL3z+Cq8txbWSKKLzSwNi8vageh9x0LPD5kxE g4bmpovwGq4aLyCyHgP18kMZAo3JkRnlLuB/L1JQFh6f7M6sfp0eHxjtv9NOysdLz5hv TXRJM1RRqi0nTe8/fLL5vT7tmKu+h+TetbjlGqdC4AtHO3437ZllRs3tShjTzaVFIheZ pZWlfqFycR6yWYdj+vgWcHA/aRsPhU7k1bIhJM24agOHlrr9zfvrIWAjej2XqN5A3v/p UUDIZdeneKr6SxfCquhVO07EZQNRAFoYrXpMxPaSLUFqRTPdxnexOPhdXJPcyJrPOS/N 24lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EmBIVCO8; 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 a14si3005630ybk.580.2018.01.24.15.39.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Jan 2018 15:39:13 -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=EmBIVCO8; 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]:54521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeUdM-0004xA-L9 for patch@linaro.org; Wed, 24 Jan 2018 18:39:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeURj-0004tX-VD for qemu-devel@nongnu.org; Wed, 24 Jan 2018 18:27:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeURi-0001zR-Tn for qemu-devel@nongnu.org; Wed, 24 Jan 2018 18:27:11 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:46052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eeURi-0001zE-N0 for qemu-devel@nongnu.org; Wed, 24 Jan 2018 18:27:10 -0500 Received: by mail-pg0-x241.google.com with SMTP id m136so3804330pga.12 for ; Wed, 24 Jan 2018 15:27:10 -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=Jz9a0SHM1j6sy0TDh85R+Hbc1trXnrF4FvsYuaL1xsE=; b=EmBIVCO8gjKaYgfgg0g9puZ4d5O7z4KpdGf9mjmS0TRMnPN7E4jAs9qbq7kHg8rYVa +4dEsjj+BawbKRu2AvcPmTcnZ9q55zV0txWjz4h5SUNPI0cCmEDKoua22TlxFHnUnEd6 ri90q9R2vi4/aRbo+px4d5wxD/97XmG7daOCE= 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=Jz9a0SHM1j6sy0TDh85R+Hbc1trXnrF4FvsYuaL1xsE=; b=NyrR/SzI0NJqvWlKOK7x5RcX1//WXyZ3WsWYLlsy71UzCWU1nl+oXyOoYdn02hrors IS0zU581G2cqggADLcQZ9990jMWym31EtKjyEsNzr3u/v+l19iyma3T/EKNbUYB6i0cN RH0WyCW4ELuyRqgf9b1bnVj1aVVlzKzINyc9v2y9FS3DdznACsakQvaN1AJQJHy6ce/E ILr7QxuiMccxW+9CEKL8PLokrI0RMnItS6Jgs/yT6sA14L0+cS6WVDSzRTTUOdDRpyZT gdP1H0dAQC6f6DtpmULo6DRYSnHwvXSfzTnkDCq1kTtHJf0NHdbpr1lEuDHBhhrKTuT+ emoQ== X-Gm-Message-State: AKwxytfxMAdqBCsqGYYxedJAHYnmil3trun13kM2fg9C5597roWK2qcQ ATZyRtPOR6Nxgj1M/i0NL7JmlOFdNfg= X-Received: by 2002:a17:902:6c41:: with SMTP id h1-v6mr9452126pln.25.1516836429418; Wed, 24 Jan 2018 15:27:09 -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.27.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jan 2018 15:27:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 24 Jan 2018 15:26:07 -0800 Message-Id: <20180124232625.30105-28-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::241 Subject: [Qemu-devel] [PATCH v3 27/45] target/hppa: Implement halt and reset instructions 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: Helge Deller Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller Real hardware would use an external device to control the power. But for the moment let's invent instructions in reserved space, to be used by our custom firmware. Signed-off-by: Helge Deller Signed-off-by: Richard Henderson --- target/hppa/helper.h | 2 ++ target/hppa/op_helper.c | 13 +++++++++++++ target/hppa/translate.c | 25 ++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) -- 2.14.3 diff --git a/target/hppa/helper.h b/target/hppa/helper.h index 1e733b7926..31320740da 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -80,6 +80,8 @@ DEF_HELPER_FLAGS_4(fmpynfadd_d, TCG_CALL_NO_RWG, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_0(read_interval_timer, TCG_CALL_NO_RWG, tr) #ifndef CONFIG_USER_ONLY +DEF_HELPER_1(shutdown, noreturn, env) +DEF_HELPER_1(reset, noreturn, env) DEF_HELPER_1(rfi, void, env) DEF_HELPER_1(rfi_r, void, env) DEF_HELPER_FLAGS_2(write_interval_timer, TCG_CALL_NO_RWG, void, env, tr) diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index d270f94e31..c2eeced0e9 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -22,6 +22,7 @@ #include "exec/exec-all.h" #include "exec/helper-proto.h" #include "exec/cpu_ldst.h" +#include "sysemu/sysemu.h" #include "qemu/timer.h" @@ -639,6 +640,18 @@ void HELPER(write_interval_timer)(CPUHPPAState *env, target_ureg val) timer_mod(cpu->alarm_timer, timeout); } +void HELPER(shutdown)(CPUHPPAState *env) +{ + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + helper_excp(env, EXCP_HLT); +} + +void HELPER(reset)(CPUHPPAState *env) +{ + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); + helper_excp(env, EXCP_HLT); +} + target_ureg HELPER(swap_system_mask)(CPUHPPAState *env, target_ureg nsm) { target_ulong psw = env->psw; diff --git a/target/hppa/translate.c b/target/hppa/translate.c index f3942b1baf..8c1ae4db78 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2302,6 +2302,18 @@ static DisasJumpType trans_rfi(DisasContext *ctx, uint32_t insn, /* Exit the TB to recognize new interrupts. */ return nullify_end(ctx, DISAS_NORETURN); } + +static DisasJumpType gen_hlt(DisasContext *ctx, int reset) +{ + CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); + nullify_over(ctx); + if (reset) { + gen_helper_reset(cpu_env); + } else { + gen_helper_shutdown(cpu_env); + } + return nullify_end(ctx, DISAS_NORETURN); +} #endif /* !CONFIG_USER_ONLY */ static const DisasInsn table_system[] = { @@ -4519,7 +4531,18 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn) case 0x15: /* unassigned */ case 0x1D: /* unassigned */ case 0x37: /* unassigned */ - case 0x3F: /* unassigned */ + break; + case 0x3F: +#ifndef CONFIG_USER_ONLY + /* Unassigned, but use as system-halt. */ + if (insn == 0xfffdead0) { + return gen_hlt(ctx, 0); /* halt system */ + } + if (insn == 0xfffdead1) { + return gen_hlt(ctx, 1); /* reset system */ + } +#endif + break; default: break; }