From patchwork Sun Jan 28 23:15:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 126126 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp1987971ljd; Sun, 28 Jan 2018 15:46:22 -0800 (PST) X-Google-Smtp-Source: AH8x224+J5tdOtwXpsZ6q8ViAnVn9jtfZIOkcZVEbup//Z85oQM0m7D+cjHB+2v1sbMU108bC025 X-Received: by 10.129.80.8 with SMTP id e8mr16098297ywb.304.1517183182315; Sun, 28 Jan 2018 15:46:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517183182; cv=none; d=google.com; s=arc-20160816; b=GWQnDNglyBfOi+6igG6IShmOAIk7Dtr3/DQayQlq/6SMM6VA+1CUMeyqVo2KEBu4/w dqqMyFYnYFeuTXUwpoTh0C2VYRe3+BkBv6RynJD07ENllacrl6YTf4wa/AixU/ED1C5Q ScfnQgBdykVhkiVNkUMOpCCJ/jUGoNTTk9pbcDI83lmh2EdyFnx7Uu3UBququWrVuO7K VpeV+83bE2zFT1HSUn/XJHzW/I9JH2uFs6njblnzG8rBxYWeqJxnrI8Sc29S/Q71AiC+ RwbUGR8zzsyE7wwkRwtlQ0D20+gOscUSPfxaruiwpE5r1schTVrz5BuTyBTYve86idi4 djtQ== 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=Sb2WLrayN8kguBCHkSb4tiXS7CFi6uvOmPEFlCZuQjs=; b=k/0vyjURPv9ujMU5AbL/v1AYw4AoPXxVFzz6SUh57xODtYpCsEAuV9RsahFarMaFKZ 22xGTz/NNKF+s3GU0munBwCQAkWjkuOWOG9sp2A3agl/wyIy4FGBylzoY6VuhDr6Dws5 flKGi8sYX1UvAJZ2TgQENxZLr38H0y4HpBdIjyhMn6E31yjXQdPk/pgZzCptnIbiRaaB yY+/IEuKIOUow3K2aCuS0+TGEks2lJS+ZrOHRFzBtCWcOH76OXchaOrp2RlXweHi5N6v cGSPkMuenZ1KFeIMkTnmM+T/ubghoLxyAnLojtbfNnnVtkNjb1Grqt9izURlG78UAHEj 9Wdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=D1Nin2I2; 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 k3si3948320ybj.748.2018.01.28.15.46.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 28 Jan 2018 15:46:22 -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=D1Nin2I2; 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]:45133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efweT-0001GA-NK for patch@linaro.org; Sun, 28 Jan 2018 18:46:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwBL-0002y3-Ft for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efwBK-0000Ch-B1 for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:15 -0500 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:42893) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efwBK-0000CD-4K for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:14 -0500 Received: by mail-pf0-x243.google.com with SMTP id b25so3257050pfd.9 for ; Sun, 28 Jan 2018 15:16: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=Sb2WLrayN8kguBCHkSb4tiXS7CFi6uvOmPEFlCZuQjs=; b=D1Nin2I2bQ/PQUPwjTODsEHti8oGkGBPyMXXCBevE4EC6ObYvH31lKSuOH/TuUGpoT BqbT6I8ByeoPcK3FWlbqx5m9NnHURlYWq2C2wVOklfOy1mNt8b8qxmUxViWfYra/ukbS Z4kusbrEFN664HgAjn/f085wxjQjgdXIesmKs= 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=Sb2WLrayN8kguBCHkSb4tiXS7CFi6uvOmPEFlCZuQjs=; b=WiLWRnyVEQBgufO+ES1DHidY9eqP7o/AAosbrNwMzxpHfFmNl5K7cLsKrNSzdslnPv LGAeOcNFdSmMU2TLao3WmMQ+5dizPwISXNuZDsNRm7YXMuaW+S/6P2paOXLvyPH9FNDV ezn0LRxMT/doMEE4W3NpIRisnuQnEW6uKBihtigWcUhS7snHJuz1WXcw8D4AnI8QHe34 L1g5/lhWUfIxj0vn5uJlxqIBVhmCFW2MpaOUWyUTLBJfOeji/ScGm5USsfdeOfMoxAhe 2WHSFKIe2K9dX252EiAQ0KGbO579ZQyEhru4hMswyKN6T1ZX1gJbidWF1uA4bQrrauEV OOqQ== X-Gm-Message-State: AKwxytdql2H9xbxsXqSrAd+DGVeNq9iCGcw+NwXcikkZhD2uBBllE5CI Eg7YJjfAeZYG5io88wvYMR9vBn4cQDE= X-Received: by 2002:a17:902:595d:: with SMTP id e29-v6mr20481353plj.436.1517181372904; Sun, 28 Jan 2018 15:16:12 -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.16.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Jan 2018 15:16:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 28 Jan 2018 15:15:12 -0800 Message-Id: <20180128231528.22719-28-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 27/43] 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: peter.maydell@linaro.org, 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 ef2951386c..37160f0d91 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; }