From nobody Sat Nov 23 22:59:14 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1730812102; cv=none; d=zohomail.com; s=zohoarc; b=bagietImvui7ihFJ+i3cCVBFLEL7N6LSKjiGn0OpDPVhElDrpmA6UBz09tEEMVY/MwvwwHjD0dN4Q8YwWcwpBhFMO1LpKoIB5+I2pytuVSTP6Dv4IYG4yYGmwCYACpNCkihC2XSbrziCf8WW3C/6Uw3nwwprHf+36PleiEIH7qE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730812102; h=Content-Type: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=haV4HgajOuBZyaKR8WLf7rNEDHwvap87jZ2MipEC/AA=; b=fUFSYM36u9bXVJzBAPKZ/tIt5rw8UBq+CO7/0K/l4McuF6XGLjfmhgSRBxebkf7i8CmatAIxIzSeJnoizST0aFbQZmTJUOGhvTwIh8OOapFyNcxU+BejJPAtJhYZ4h3M4fF9l2IDtP3QrDBdFiFXqIngxfw67RIVGmq6X28v2iE= 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 1730812102701504.55560206605503; Tue, 5 Nov 2024 05:08:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8JHN-00085Q-QO; Tue, 05 Nov 2024 08:07:30 -0500 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 1t8JHJ-0007XX-5u for qemu-devel@nongnu.org; Tue, 05 Nov 2024 08:07:25 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t8JHG-0002ik-Li for qemu-devel@nongnu.org; Tue, 05 Nov 2024 08:07:24 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4315e62afe0so46604425e9.1 for ; Tue, 05 Nov 2024 05:07:22 -0800 (PST) Received: from localhost.localdomain (86.red-88-29-160.dynamicip.rima-tde.net. [88.29.160.86]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd8e8471sm226896305e9.4.2024.11.05.05.07.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Nov 2024 05:07:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730812041; x=1731416841; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=haV4HgajOuBZyaKR8WLf7rNEDHwvap87jZ2MipEC/AA=; b=s1Aiu+VY1z0Dm2oTkkBy6GKbQsiTcUGXL1TDRUg1ujpQLdQtoFGAFnbVFYCScpwBH4 9UyngPnCQre4b8mfU6IzxXwc/MwnBctuc/iYS/kTCzHsPCc8e86fpVhha57CTRLq3mgp d7gUBTscT7zlyzZuWu2f3n6EofCAq1qDYvCwvtll3e+2/iV8/LwLzylRHvO4rtFvg4TM zf9CoFOnFaTYkYJ0LyuufnvucqdCXZg0uhmwkueQ9N9kSwBVsFKv0Ox5dw7Gz9SJUL41 XxoiGmXzO2ah9VPUWUva42gyZYYTVhVCVB9ckwZP5r2v8ciV5co29hVlZF73reXFobEB CStg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730812041; x=1731416841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=haV4HgajOuBZyaKR8WLf7rNEDHwvap87jZ2MipEC/AA=; b=GevW/asssy0w7/rFCpDZH3IjsNzxnhOYQecdYXWT+44AY357ximmYoeycFrKG5K8Aa Kf0bVmYSyfu/skXgai56mQtioLNXz6iXiVf+H46D5htLAGpTMhjUjbAU1yooUWNZPW/0 Oc15UKzbrYjSKLTEV816Fte4VB+LKOkplbhms1AIyx1yAnQk6Q/JyXm3Sz/das9yp+T3 Udf72BPGvrTE4sgH3doIDh9Aiba51A6a4sZIPu5bb+L8REUpkgJsRZqRWFyHdaBIQJt7 7Uy+AvWfiLf9DQZnmHWGff4rx7IwOBkUBhMstZhKyqDKPeNRP4QnVyqKSKySNSWs02mJ TSyA== X-Gm-Message-State: AOJu0Yx9q/vL9/6X0vonIyNu2ZqzqvD+rNQ6Q//C4PO5KkPSLxe9Z1PN aZZkdYelQ/UmgI5dCGrhYmMMRh14RFY9EAU+xxv0HvuBwZSSWbpfa9+OLZdiTQrov6s+zl9pkkO kPts= X-Google-Smtp-Source: AGHT+IGOxoQTQL0IN3l6/4lLVFzW5l8bscs5mxyfdsvU2fYef9lc8d5j10xjA9v1TTrFGkS6DR2PFA== X-Received: by 2002:a05:600c:4f83:b0:42c:c28c:e477 with SMTP id 5b1f17b1804b1-4319ad089b0mr277982415e9.23.1730812040858; Tue, 05 Nov 2024 05:07:20 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Anton Johansson Cc: "Edgar E. Iglesias" , Peter Maydell , Alistair Francis , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Jason Wang , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 17/19] hw/microblaze: Support various endianness for s3adsp1800 machines Date: Tue, 5 Nov 2024 14:04:29 +0100 Message-ID: <20241105130431.22564-18-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241105130431.22564-1-philmd@linaro.org> References: <20241105130431.22564-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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=unavailable 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 @linaro.org) X-ZM-MESSAGEID: 1730812103360116600 Introduce an abstract machine parent class which defines the 'little_endian' property. Duplicate the current machine, which endian is tied to the binary endianness, to one big endian and a little endian machine; updating the machine description. Keep the current default machine for each binary. 'petalogix-s3adsp1800' machine is aliased as: - 'petalogix-s3adsp1800-be' on big-endian binary, - 'petalogix-s3adsp1800-le' on little-endian one. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/microblaze/petalogix_s3adsp1800_mmu.c | 55 +++++++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petal= ogix_s3adsp1800_mmu.c index 8407dbee12a..f5195327b76 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -55,8 +55,17 @@ #define ETHLITE_IRQ 1 #define UARTLITE_IRQ 3 =20 +typedef struct PetalogixS3adsp1800MachineClass { + MachineClass parent_obj; + + bool little_endian; +} PetalogixS3adsp1800MachineClass; + #define TYPE_PETALOGIX_S3ADSP1800_MACHINE \ - MACHINE_TYPE_NAME("petalogix-s3adsp1800") + MACHINE_TYPE_NAME("petalogix-s3adsp1800-common") +DECLARE_CLASS_CHECKERS(PetalogixS3adsp1800MachineClass, + PETALOGIX_S3ADSP1800_MACHINE, + TYPE_PETALOGIX_S3ADSP1800_MACHINE) =20 static void petalogix_s3adsp1800_init(MachineState *machine) @@ -71,11 +80,13 @@ petalogix_s3adsp1800_init(MachineState *machine) MemoryRegion *phys_ram =3D g_new(MemoryRegion, 1); qemu_irq irq[32]; MemoryRegion *sysmem =3D get_system_memory(); + PetalogixS3adsp1800MachineClass *pmc; =20 + pmc =3D PETALOGIX_S3ADSP1800_MACHINE_GET_CLASS(machine); cpu =3D MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU)); object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort= ); object_property_set_bool(OBJECT(cpu), "little-endian", - !TARGET_BIG_ENDIAN, &error_abort); + pmc->little_endian, &error_abort); qdev_realize(DEVICE(cpu), NULL, &error_abort); =20 /* Attach emulated BRAM through the LMB. */ @@ -123,33 +134,63 @@ petalogix_s3adsp1800_init(MachineState *machine) qemu_configure_nic_device(dev, true, NULL); qdev_prop_set_uint32(dev, "tx-ping-pong", 0); qdev_prop_set_uint32(dev, "rx-ping-pong", 0); - qdev_prop_set_bit(dev, "access-little-endian", !TARGET_BIG_ENDIAN); + qdev_prop_set_bit(dev, "access-little-endian", pmc->little_endian); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, ETHLITE_BASEADDR); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[ETHLITE_IRQ]); =20 create_unimplemented_device("xps_gpio", GPIO_BASEADDR, 0x10000); =20 - microblaze_load_kernel(cpu, !TARGET_BIG_ENDIAN, ddr_base, ram_size, + microblaze_load_kernel(cpu, pmc->little_endian, ddr_base, ram_size, machine->initrd_filename, BINARY_DEVICE_TREE_FILE, NULL); } =20 -static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc, void = *data) +static void petalogix_s3adsp1800_machine_class_init_be(ObjectClass *oc, vo= id *data) { MachineClass *mc =3D MACHINE_CLASS(oc); + PetalogixS3adsp1800MachineClass *pmc =3D PETALOGIX_S3ADSP1800_MACHINE_= CLASS(oc); =20 - mc->desc =3D "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800"; + pmc->little_endian =3D false; + mc->desc =3D "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (= big endian)"; mc->init =3D petalogix_s3adsp1800_init; +#if TARGET_BIG_ENDIAN mc->is_default =3D true; + mc->alias =3D "petalogix-s3adsp1800"; +#endif +} + +static void petalogix_s3adsp1800_machine_class_init_le(ObjectClass *oc, vo= id *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + PetalogixS3adsp1800MachineClass *pmc =3D PETALOGIX_S3ADSP1800_MACHINE_= CLASS(oc); + + pmc->little_endian =3D true; + mc->desc =3D "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (= little endian)"; + mc->init =3D petalogix_s3adsp1800_init; +#if !TARGET_BIG_ENDIAN + mc->is_default =3D true; + mc->alias =3D "petalogix-s3adsp1800"; +#endif } =20 static const TypeInfo petalogix_s3adsp1800_machine_types[] =3D { { .name =3D TYPE_PETALOGIX_S3ADSP1800_MACHINE, .parent =3D TYPE_MACHINE, - .class_init =3D petalogix_s3adsp1800_machine_class_init, + .abstract =3D true, + .class_size =3D sizeof(PetalogixS3adsp1800MachineClass), + }, + { + .name =3D MACHINE_TYPE_NAME("petalogix-s3adsp1800-be"), + .parent =3D TYPE_PETALOGIX_S3ADSP1800_MACHINE, + .class_init =3D petalogix_s3adsp1800_machine_class_init_be, + }, + { + .name =3D MACHINE_TYPE_NAME("petalogix-s3adsp1800-le"), + .parent =3D TYPE_PETALOGIX_S3ADSP1800_MACHINE, + .class_init =3D petalogix_s3adsp1800_machine_class_init_le, }, }; =20 --=20 2.45.2