From patchwork Fri Jan 15 20:11:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 363757 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp173769jap; Fri, 15 Jan 2021 12:15:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT8FCaJnarX0s3qSkjWiP6ouJEyvQNhwowD/JZJlVIybW5Pqo2fAh4ulba4oUCHGyZMznx X-Received: by 2002:a25:3801:: with SMTP id f1mr20888365yba.321.1610741749659; Fri, 15 Jan 2021 12:15:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610741749; cv=none; d=google.com; s=arc-20160816; b=US6BoDJ24DPHQMISL38GvQK8St+v/5HhpJ0kRnZmmk5TEkOb3OepWs3b82zRNvVcjK ZVOOCjFtVaeSCeCniQuo/y/n3gdqqI0qdnZseM4m5Dbw+D2NLyx91fiqvLvKUTnfp1uv CN65+vNT3muNTdDSOedJFo4C8NwpqM68iIw/oREQdedpOciT1v/k+r0j0DfvumkwapvJ ncBYm9m4f5nMD9EcnnrtbuFu3R9UqVFjw29Wjqz/U5P+6qL0cNxWsjAxGRE4lKbVgZ7H 0JTO2+CVGqVsoNS3ee6QpwOqcMqwlkHJrRg63AeAjz1UDGrxO0V8dHka00l/Pyx6j2e1 SltA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rTWJIJzyn/d0f9c+f8XIvnchNfg5WqrGoOxuJbOhu5Q=; b=WNeYLY0ssfKC5n9enX0ZIZge5XGOztVd0391Sw9z8Hsr1crlJs7OnLfPIavVfSt1DY 0JiS01WyP0G6/PY7yac+Q84haxg/DKFojPzhUybmFKNNsS63B72+nKS12N/SpCqv/QXy m4NFMNY8JWMzuBF/q3xcTNWnCsYfko9oVTGcd487A+yYO4KdEH39wgVUfsblJ8FFDPeV TS+tVMuGkirhT1IL9XWPnuJwHzmoG2aeP3Y6GJjZOxvoOJS7vyQXFkLHJHchvLfa6XgU +BEbzPZQrhvDCHdr9/dHKsi9/FhfX6DemuArE9T4kRAGVWNsPtc8ls9AZsUofQiNoqp8 4H7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D0uQ59eX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v76si637644ybb.485.2021.01.15.12.15.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jan 2021 12:15:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D0uQ59eX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0VVd-0000lz-1g for patch@linaro.org; Fri, 15 Jan 2021 15:15:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0VSA-0005lM-Nh for qemu-devel@nongnu.org; Fri, 15 Jan 2021 15:12:14 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:41981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0VS9-0008Fo-0H for qemu-devel@nongnu.org; Fri, 15 Jan 2021 15:12:14 -0500 Received: by mail-wr1-x430.google.com with SMTP id a12so10468946wrv.8 for ; Fri, 15 Jan 2021 12:12:12 -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 :mime-version:content-transfer-encoding; bh=rTWJIJzyn/d0f9c+f8XIvnchNfg5WqrGoOxuJbOhu5Q=; b=D0uQ59eXKZOhx+K/zSQh1FEawYj/m1Qu8m4pE2PJ9FR+KxDom+MVM3EpOCqZ1NpPX/ X2ZG7rx6f8vgsRiabCkjEljxtdSvKT0hhek/RX6faLHHGSUoDXA/pAgmbUQ5WhuWSMFP uBdGJ4QyFvEYfCiAv3kg8kFb/wzHRh2lECfrik6uSBDdX/GR9XJjam1dwumXe4PU9om+ ErbUz4t0MT3OdIVj4lMzHyTxuvbExYhF3ISHXmudyqaoT62RgTWCxjDj0Kar6s364+NA TrEnQHN/Hgilw7cWBc2STR/AfDAVZb9TuTHCy5aP6cjJdp77jrqhLxDQm+5nPsOiQTZI EcNw== 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:mime-version:content-transfer-encoding; bh=rTWJIJzyn/d0f9c+f8XIvnchNfg5WqrGoOxuJbOhu5Q=; b=b9gC1VEKvUVXsKARoS7p1v2BvhsHOFLdTs1CfnD2QGSGbaJlVddFYwV30xnDmuTqzT 27fCwO3DmToaPP6QGPqiomcIUUM8xKiWlP8paHRdXqyLm1DnQhHO5BKHQDzlxuw6usr7 7uoiExxFpNBWZjgaP/yonMCcp2dthgh7fydrJOaMGVa51qfFSZXD/6iF37eXdskJbsxe efT3AgRe3d/yUG/udvAqPAIzmowitjHY5cmaWKryMz4zojGXCO9dqmTlo6r/s/CBy9rV 4S58IO0FNIyY/+pL73qbDZJDrYTX/IWj7lHGdEaHSctQhD6caXmmG9gHpXph/xOESJwM dBQQ== X-Gm-Message-State: AOAM531Y35mcFYmOZR8YJYOq2e+Q7NKiuX6viTTcXjAVo36hzhp1M1ib qmQjZlUKUrZi34fADeyI+lX0HHd21wbm6A== X-Received: by 2002:a5d:4104:: with SMTP id l4mr15266186wrp.340.1610741531220; Fri, 15 Jan 2021 12:12:11 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id b3sm10353807wrn.70.2021.01.15.12.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 12:12:10 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 02/11] hw/m68k/next-cube: Move register/interrupt functionality into a device Date: Fri, 15 Jan 2021 20:11:57 +0000 Message-Id: <20210115201206.17347-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210115201206.17347-1-peter.maydell@linaro.org> References: <20210115201206.17347-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: Thomas Huth , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Currently the next-cube board code open-codes a lot of handling of interrupts and some miscellaneous registers. Move this into a proper QOM device. In the real hardware this functionality seems to be the responsibility of the Peripheral Controller (PC) chip, so name the device that. There are several different things that will need to be moved into this device: * the mmio_iops register set * the scr_ops register set * the next_irq IRQ handling To ease review, we structure the change as a sequence of commits: in this first commit we create the skeleton of the NeXTPC device with no content, but with a backdoor pointer to the NeXTState machine's state struct so we can move parts of the code and still have refactored and non-refactored code using the same struct data fields. Further commits will move functionality into the new device piece by piece. At the end we will be able to remove the backdoor pointer because all the data fields will be in the NeXTPC struct and not the NeXTState struct. We'll add the VMState for the new device at the end of all that; this is in theory a migration compatibility break but this machine does not currently support migration at all anyway. Signed-off-by: Peter Maydell --- hw/m68k/next-cube.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 2.20.1 diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c index f622d6589c8..dccf3eb4313 100644 --- a/hw/m68k/next-cube.c +++ b/hw/m68k/next-cube.c @@ -90,6 +90,16 @@ struct NeXTState { NextRtc rtc; }; +#define TYPE_NEXT_PC "next-pc" +OBJECT_DECLARE_SIMPLE_TYPE(NeXTPC, NEXT_PC) + +struct NeXTPC { + SysBusDevice parent_obj; + + /* Temporary until all functionality has been moved into this device */ + NeXTState *ns; +}; + /* Thanks to NeXT forums for this */ /* static const uint8_t rtc_ram3[32] = { @@ -857,6 +867,31 @@ static void next_escc_init(M68kCPU *cpu) sysbus_mmio_map(s, 0, 0x2118000); } +static void next_pc_reset(DeviceState *dev) +{ +} + +static void next_pc_realize(DeviceState *dev, Error **errp) +{ +} + +static void next_pc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->desc = "NeXT Peripheral Controller"; + dc->realize = next_pc_realize; + dc->reset = next_pc_reset; + /* We will add the VMState in a later commit */ +} + +static const TypeInfo next_pc_info = { + .name = TYPE_NEXT_PC, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(NeXTPC), + .class_init = next_pc_class_init, +}; + static void next_cube_init(MachineState *machine) { M68kCPU *cpu; @@ -871,6 +906,7 @@ static void next_cube_init(MachineState *machine) const char *bios_name = machine->firmware ?: ROM_FILE; NeXTState *ns = NEXT_MACHINE(machine); DeviceState *dev; + DeviceState *pcdev; /* Initialize the cpu core */ cpu = M68K_CPU(cpu_create(machine->cpu_type)); @@ -884,6 +920,12 @@ static void next_cube_init(MachineState *machine) env->vbr = 0; env->sr = 0x2700; + /* Peripheral Controller */ + pcdev = qdev_new(TYPE_NEXT_PC); + sysbus_realize_and_unref(SYS_BUS_DEVICE(pcdev), &error_fatal); + /* Temporary while we refactor this code */ + NEXT_PC(pcdev)->ns = ns; + /* Set internal registers to initial values */ /* 0x0000XX00 << vital bits */ ns->scr1 = 0x00011102; @@ -978,6 +1020,7 @@ static const TypeInfo next_typeinfo = { static void next_register_type(void) { type_register_static(&next_typeinfo); + type_register_static(&next_pc_info); } type_init(next_register_type)