From nobody Wed Nov 27 17:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1697756130; cv=none; d=zohomail.com; s=zohoarc; b=NXRoE8NWmDITHEiUYsLmvUxttwke7WsINK7BSI8Az3ZCjnNRonw6tZRBn15ez8pyC+I1BXy+ZH9sfkCMkzSyK10Qeyl3twHfa1+gnlJrrW95dqLMz/inPVO1on6DY5LUJ7EJTFqhTO9s7/n9SndLx3zxWb6KbIJo/yHYuUaXcY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697756130; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4INrmS9SAQotBwdp2g/S/UHNXRwl/DdYHQtyVl4j7rc=; b=DEf8ouwKnpSxiKn2ajQev3gbOMpjynBH5JPZ5uHbYIXwte6gV73pDVqA7aCzbWQLjwgviTnMlCqctnOXXASbGul5ZDDvsajz0ocTk0Xghuu1ZIja2LaLouvndbpUgcuS3rmZHSvR0YsGQQcf9Whp96Lbl9QCv7y38Egvc2Bxl6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697756130545930.5701239696912; Thu, 19 Oct 2023 15:55:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtbtL-0008Au-9q; Thu, 19 Oct 2023 18:53:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtbtI-00088M-Gb for qemu-devel@nongnu.org; Thu, 19 Oct 2023 18:53:20 -0400 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtbtG-0002g3-21 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 18:53:20 -0400 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EC3136124A; Thu, 19 Oct 2023 22:53:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8106DC433C8; Thu, 19 Oct 2023 22:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697755996; bh=P9lOt1zhr8EoLg+6EC27KcemcHD4V4dF6HhXq1h5+cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BUcJwrUc2pJYCaRx6ItSNt19pjmTx3fRf3nbZOgxaRZ1KQnt9BakSQI/UCRmGQLmv IdGxmh1BPwqMdosUSj20Kpr4pDE7LNO8Tdopj1cXMeeRvh5Q7V8r5ac3nMw1m9mhOJ DG2ioL+IVn5wKdSrSGZg51bqAYJdpiqDDaNHw5jforneb8kaK8TGDXVGs22/MS1nr2 k+c4YtyrIQmrRlPmr2GKtuVWY4TVWNeRSKkAVGpJp33WVkxt3Zy6bwM2MMe2bUfCYv DzVSlFzzVLCr5yX8c/KhV1R0ezdwG6M05Hf3irZC0UCdb32iMyiB32tcnRJKxZUG3w wxUHIxCZj/F+g== From: deller@kernel.org To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson Subject: [PULL 09/11] hw/hppa: Provide RTC and DebugOutputPort on CPU #0 Date: Fri, 20 Oct 2023 00:52:55 +0200 Message-ID: <20231019225257.383071-10-deller@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019225257.383071-1-deller@kernel.org> References: <20231019225257.383071-1-deller@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2604:1380:4641:c500::1; envelope-from=deller@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1697756131224100001 Content-Type: text/plain; charset="utf-8" From: Helge Deller For SeaBIOS-hppa, the RTC and DebugOutputPort were in the I/O area of the LASI chip of the emulated B160L machine. Since we will add other machines without a LASI chip, move the emulated devices into the I/O area of CPU#0 instead. Signed-off-by: Helge Deller --- hw/hppa/hppa_hardware.h | 1 - hw/hppa/machine.c | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/hw/hppa/hppa_hardware.h b/hw/hppa/hppa_hardware.h index a5ac3dd0fd..a9be7bb851 100644 --- a/hw/hppa/hppa_hardware.h +++ b/hw/hppa/hppa_hardware.h @@ -18,7 +18,6 @@ #define LASI_UART_HPA 0xffd05000 #define LASI_SCSI_HPA 0xffd06000 #define LASI_LAN_HPA 0xffd07000 -#define LASI_RTC_HPA 0xffd09000 #define LASI_LPT_HPA 0xffd02000 #define LASI_AUDIO_HPA 0xffd04000 #define LASI_PS2KBD_HPA 0xffd08000 diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index de925259ea..d459ba631b 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -103,6 +103,63 @@ static ISABus *hppa_isa_bus(void) return isa_bus; } =20 +/* + * Helper functions to emulate RTC clock and DebugOutputPort + */ +static time_t rtc_ref; + +static uint64_t io_cpu_read(void *opaque, hwaddr addr, unsigned size) +{ + uint64_t val =3D 0; + + switch (addr) { + case 0: /* RTC clock */ + val =3D time(NULL); + val +=3D rtc_ref; + break; + case 8: /* DebugOutputPort */ + return 0xe9; /* readback */ + } + return val; +} + +static void io_cpu_write(void *opaque, hwaddr addr, + uint64_t val, unsigned size) +{ + unsigned char ch; + Chardev *debugout; + + switch (addr) { + case 0: /* RTC clock */ + rtc_ref =3D val - time(NULL); + break; + case 8: /* DebugOutputPort */ + ch =3D val; + debugout =3D serial_hd(0); + if (debugout) { + qemu_chr_fe_write_all(debugout->be, &ch, 1); + } else { + fprintf(stderr, "%c", ch); + } + break; + } +} + +static const MemoryRegionOps hppa_io_helper_ops =3D { + .read =3D io_cpu_read, + .write =3D io_cpu_write, + .endianness =3D DEVICE_BIG_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 8, + }, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 8, + }, +}; + + static uint64_t cpu_hppa_to_phys(void *opaque, uint64_t addr) { addr &=3D (0x10000000 - 1); @@ -151,6 +208,10 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCI= Bus *pci_bus) fw_cfg_add_file(fw_cfg, "/etc/hppa/power-button-addr", g_memdup(&val, sizeof(val)), sizeof(val)); =20 + val =3D cpu_to_le64(CPU_HPA + 16); + fw_cfg_add_file(fw_cfg, "/etc/hppa/rtc-addr", + g_memdup(&val, sizeof(val)), sizeof(val)); + val =3D cpu_to_le64(CPU_HPA + 24); fw_cfg_add_file(fw_cfg, "/etc/hppa/DebugOutputPort", g_memdup(&val, sizeof(val)), sizeof(val)); @@ -222,6 +283,12 @@ static void machine_hppa_init(MachineState *machine) g_free(name); } =20 + /* RTC and DebugOutputPort on CPU #0 */ + cpu_region =3D g_new(MemoryRegion, 1); + memory_region_init_io(cpu_region, OBJECT(cpu[0]), &hppa_io_helper_ops, + cpu[0], "cpu0-io-rtc", 2 * sizeof(uint64_t)); + memory_region_add_subregion(addr_space, CPU_HPA + 16, cpu_region); + /* Main memory region. */ if (machine->ram_size > 3 * GiB) { error_report("RAM size is currently restricted to 3GB"); --=20 2.41.0