From patchwork Sun Apr 16 23:23:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 9683247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C44B60138 for ; Sun, 16 Apr 2017 23:25:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E46227BA5 for ; Sun, 16 Apr 2017 23:25:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 636D027CF3; Sun, 16 Apr 2017 23:25:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B6E0E27BA5 for ; Sun, 16 Apr 2017 23:25:40 +0000 (UTC) Received: from localhost ([::1]:33911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztY4-0003lU-1O for patchwork-qemu-devel@patchwork.kernel.org; Sun, 16 Apr 2017 19:25:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztWd-0003jY-Gp for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cztWc-0007vJ-L7 for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:11 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:34661) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cztWc-0007up-Fr for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:10 -0400 Received: by mail-pf0-x244.google.com with SMTP id g23so7372895pfj.1 for ; Sun, 16 Apr 2017 16:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=/7nCUc5Oqr0hH5gdktnbwA7Ic/u4eLetTKmxuFQa0V4=; b=ryDaaFq9q+ap6xtTEQKyS7Kvr9LkXCGf7JgTqpv/Fybgsr0uBlAhC/4Q3fSdWNyPM0 LnoZsSXOmEhh4zT1PIVV9uOD068B0H42tuC07MFsDsmVk7pMUXWKZq4Jq7Kx389R03zd 47eSjEp7ic+7F/tFxul7LOunCLci7n8TZub0+Yzy7kFG06SY7Z75K2e9jtAcQYaSyb0D b4BZyJiGQwT88nvG+OovEa4nj9GMBygvMRxnQKnVJ0jB7ZAjXMMVs6pWWdgFBF36o0/L qCway+H2GUiMbewBPdfuUGrRb5A6rr0ePImt6bW8Rq6ALO61q+dDza58APXpzSuKewWW nGEA== 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:in-reply-to:references; bh=/7nCUc5Oqr0hH5gdktnbwA7Ic/u4eLetTKmxuFQa0V4=; b=OMH2QHt1Nwtuqfs9h/NVS708dO0UlBS7FmZCtGpXtfXeXZrz+sbXJFtoHs1XwZVEkt u0EJmXulw/m1wEJf8RhQXuHBNz/L2m8x7WbzD7DQDEtcC680jduDryUzul6cak/OtL04 A/e+ZxfZgDUzRx3M+fVM4YXiP8RCFOkcSzEE/T2nYVUCEjQbrK3Ky9xvflKUANxttzWm UWnlx/B+g+O1ksGi/QktE2MiFsiQ+FBmhjqc4lWBoQK+cDvySe0NMzJ41p4rr19Wk/IN 0DLuNNRXjVRLva2d98goqwhGH1FzzdiJ78rOjSvlCcawCoY6XZURArM0m+W+993YfDEB i83g== X-Gm-Message-State: AN3rC/7sKN/FsNsmm43scH9kGjxoVHknbH6UnOdTrj5Dr56IjFixEwou yD4aPKT3+7ANkQ== X-Received: by 10.98.192.129 with SMTP id g1mr8897471pfk.254.1492385049588; Sun, 16 Apr 2017 16:24:09 -0700 (PDT) Received: from localhost (z24.124-44-184.ppp.wakwak.ne.jp. [124.44.184.24]) by smtp.gmail.com with ESMTPSA id s14sm14059208pgs.0.2017.04.16.16.24.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Apr 2017 16:24:09 -0700 (PDT) From: Stafford Horne To: qemu-devel@nongnu.org Date: Mon, 17 Apr 2017 08:23:51 +0900 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH 2/7] target/openrisc: add shutdown logic 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: Stafford Horne , openrisc@lists.librecores.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In openrisc simulators we use hooks like 'l.nop 1' to cause the simulator to exit. Implement that for qemu too. Reported-by: Waldemar Brodkorb Signed-off-by: Stafford Horne --- target/openrisc/helper.h | 1 + target/openrisc/sys_helper.c | 17 +++++++++++++++++ target/openrisc/translate.c | 5 ++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/target/openrisc/helper.h b/target/openrisc/helper.h index 4fd1a6b..b7838f5 100644 --- a/target/openrisc/helper.h +++ b/target/openrisc/helper.h @@ -59,3 +59,4 @@ DEF_HELPER_FLAGS_1(rfe, 0, void, env) /* sys */ DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) DEF_HELPER_FLAGS_4(mfspr, TCG_CALL_NO_WG, tl, env, tl, tl, tl) +DEF_HELPER_1(nop, void, i32) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 60c3193..2eaff87 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -22,6 +22,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "sysemu/sysemu.h" #define TO_SPR(group, number) (((group) << 11) + (number)) @@ -286,3 +287,19 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, /* for rd is passed in, if rd unchanged, just keep it back. */ return rd; } + +/* In openrisc simulators nop can be used to do intersting + * things like shut down the simulator */ +void HELPER(nop)(uint32_t arg) +{ +#ifndef CONFIG_USER_ONLY + switch (arg) { + case 0x001: /* NOP_EXIT */ + case 0x00c: /* NOP_EXIT_SILENT */ + qemu_system_shutdown_request(); + break; + default: + break; + } +#endif +} diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 7c4cbf2..74df245 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -755,8 +755,11 @@ static void dec_misc(DisasContext *dc, uint32_t insn) switch (op1) { case 0x01: /* l.nop */ LOG_DIS("l.nop %d\n", I16); + { + TCGv_i32 arg = tcg_const_i32(I16); + gen_helper_nop(arg); + } break; - default: gen_illegal_exception(dc); break;