From patchwork Wed Sep 2 19:34:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 11751683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0FD1739 for ; Wed, 2 Sep 2020 19:43:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 932782083B for ; Wed, 2 Sep 2020 19:43:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="AdSgpqQN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 932782083B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDYf1-0003HJ-JC for patchwork-qemu-devel@patchwork.kernel.org; Wed, 02 Sep 2020 15:43:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDYXW-00063P-KP for qemu-devel@nongnu.org; Wed, 02 Sep 2020 15:35:26 -0400 Received: from mout.gmx.net ([212.227.15.19]:35401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDYXG-0002mi-BO for qemu-devel@nongnu.org; Wed, 02 Sep 2020 15:35:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1599075301; bh=3jEXDEPVrlMf+yryMh7E9PXSMoaXapVGrOE9AK5e98c=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=AdSgpqQN2O2mlGP0SD+V+5KnLp5u8tFHqoKLldzq56MvoQZ7Ru8WB2ZK37MJUD3Nn khCm5BkYcm6znF1AO3Jk7rQqApZTefcPrcuYJckZTV8VlXFRCpd0q1vwnBD1/q66Mv 59MyCU6AxLqcX+x9/AxdPRfIIQKeiiDkx9x67LII= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from ls3530.fritz.box ([92.116.155.63]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mzhj9-1kZ3Qq0wC1-00vfEp; Wed, 02 Sep 2020 21:35:01 +0200 From: Helge Deller To: qemu-devel@nongnu.org Subject: [PATCH v3 6/8] hw/hppa: Add power button emulation Date: Wed, 2 Sep 2020 21:34:54 +0200 Message-Id: <20200902193456.29844-7-deller@gmx.de> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200902193456.29844-1-deller@gmx.de> References: <20200902193456.29844-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:eSBC7BE1uOPycPNte5Go1YEXxj9kylGHPVy60O8IYgfyYjjAZdN xwl/jx4B28Qv4+u1azESx1OsvtkjXLKvpNXqDNRJk7t4CSdeczHbcH3V3vQsYGCNf0K72/K jtAf8XcNSzrlszzQDR+E+lEKv7Y1++dvx62etAygeKInIBPkzjNf8fJ97Y6CaRWiGiPiI1k Ycz7UHc/Xfuor4ybxqoFg== X-UI-Out-Filterresults: notjunk:1;V03:K0:iiJSehEN6vI=:JYXyATntJVzTXhXQ2M/AOh 9udaotF2buggRT6kO744DF+Ivx+Ak+f7nFXDATCZxTJXumd3d5Wt6eSDGN+KF77WHpFAKXMHl V02YQaCyhj6LH5S96nPA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KAQoMk5k+2TXdQKOpm8xrgAggkWSndZ3jGecERwFGeiXIVAI1bcXexvVr60aop4YtGIyv0HRh NWS3qMWyHLypaTlP/ Received-SPF: pass client-ip=212.227.15.19; envelope-from=deller@gmx.de; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/02 15:35:08 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Helge Deller , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Emulate a power button switch, tell SeaBIOS the address via fw_cfg and bind the power button to the qemu UI. Signed-off-by: Helge Deller Reviewed-by: Richard Henderson --- hw/hppa/machine.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) -- 2.21.3 diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 2bed49807b..d5164457ee 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -12,6 +12,7 @@ #include "qemu/error-report.h" #include "sysemu/reset.h" #include "sysemu/sysemu.h" +#include "sysemu/runstate.h" #include "hw/rtc/mc146818rtc.h" #include "hw/timer/i8254.h" #include "hw/char/serial.h" @@ -27,6 +28,30 @@ #define MIN_SEABIOS_HPPA_VERSION 1 /* require at least this fw version */ +#define HPA_POWER_BUTTON (FIRMWARE_END - 0x10) + +static void hppa_powerdown_req(Notifier *n, void *opaque) +{ + hwaddr soft_power_reg = HPA_POWER_BUTTON; + uint32_t val; + + val = ldl_be_phys(&address_space_memory, soft_power_reg); + if ((val >> 8) == 0) { + /* immediately shut down when under hardware control */ + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + return; + } + + /* clear bit 31 to indicate that the power switch was pressed. */ + val &= ~1; + stl_be_phys(&address_space_memory, soft_power_reg, val); +} + +static Notifier hppa_system_powerdown_notifier = { + .notify = hppa_powerdown_req +}; + + static ISABus *hppa_isa_bus(void) { ISABus *isa_bus; @@ -86,6 +111,10 @@ static FWCfgState *create_fw_cfg(MachineState *ms) fw_cfg_add_file(fw_cfg, "/etc/cpu/btlb_entries", g_memdup(&val, sizeof(val)), sizeof(val)); + val = cpu_to_le64(HPA_POWER_BUTTON); + fw_cfg_add_file(fw_cfg, "/etc/power-button-addr", + g_memdup(&val, sizeof(val)), sizeof(val)); + fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_order[0]); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); @@ -177,6 +206,9 @@ static void machine_hppa_init(MachineState *machine) } } + /* register power switch emulation */ + qemu_register_powerdown_notifier(&hppa_system_powerdown_notifier); + /* Load firmware. Given that this is not "real" firmware, but one explicitly written for the emulation, we might as well load it directly from an ELF image. */