From nobody Sat Nov 23 18:20:21 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=1731934931; cv=none; d=zohomail.com; s=zohoarc; b=fHUmyUfArCTgKpm/sRQ+ltUy/BCgvpKyMD7ClwKrwP4HAQcuK9JwcIDkRJDggjQJZp6AQqAq8DrF9AlyLjrw5venEtPPe65s0sKhF3XKNyRl6WIwK+zGHx053aNfcXndCCHUGSmkE82fqqa9aJfhrXUrzbQEmjyIE0bfacx8Pfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731934931; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gTRgv2swMMRQLOEh0jdwrtgy201rtzP+J8h2YvJfYEw=; b=ni7QLggmUYof6v9ElYY5SVAw9j2vn2GkOvQNQ/ewbEas764K9FGj5sowd1YyKNUyzLo81L8CzKMzNoVYm31zc+HzL871CBd+DWZg9NnzH3/+vEkfeDFf8yH221rUie4E50rfF54y/EA+Ba4EVdPOdhIwpW7qzVtMqYhlyrAh6d0= 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 1731934931223324.0883348373103; Mon, 18 Nov 2024 05:02:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tD1Nk-0007HM-1d; Mon, 18 Nov 2024 08:01:32 -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 1tD1NV-0007EO-SH for qemu-devel@nongnu.org; Mon, 18 Nov 2024 08:01:20 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tD1NU-00071z-2Z for qemu-devel@nongnu.org; Mon, 18 Nov 2024 08:01:17 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-38230ed9baeso1672643f8f.1 for ; Mon, 18 Nov 2024 05:01:13 -0800 (PST) Received: from localhost.localdomain ([176.187.198.1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ae161d8sm13025177f8f.78.2024.11.18.05.01.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Nov 2024 05:01:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731934872; x=1732539672; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gTRgv2swMMRQLOEh0jdwrtgy201rtzP+J8h2YvJfYEw=; b=I5VuzzaP9ybIllvJXyf3/FDYTbAKnP8l/m3g1pYa0HBZl240BEV5dsO9qdW4LH8ybH 0ZuW1f5IXRrBXhKa/kKlgHYiTVSOiHtNpRNr/98dPdAnTUaSBD/B5BXY7ovBJck3GG1x R60UlJ4rFUSQ2ajBMfeg8suuwnr6JhMTtwyNRiqT7H90aQ5BH3g8DGjZ7B/Vn53reurr Bhvufyn/sn6STZTyGJ3E87uvet4j+tOgQcUD3lJmAcRcIBktjhIr65JWu0xdvXvz1hR4 swAOjNb4rkCvurFD+ZmLsbaQtxAJbIgVsVXVBqiB74t/fn+i8VLmULcudQ0x3Sg/a/Vq Ob4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731934872; x=1732539672; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gTRgv2swMMRQLOEh0jdwrtgy201rtzP+J8h2YvJfYEw=; b=wB+pC7v7Ltih5sMSIhUXZecuNTAF7SjOWprpE4h9nLPu+rP3yuEFw/6pFSXAvgs0cm hnYVeLowNtd055yALOQNy1wWfTyLl0YBoaldGnJCXmxBVgpxuYg0RdBfi+BZmwSjpInm eEoBRXLB4NF7nohx9fXcb/64WOgDUlwYRQoLWwBaf0wck37bfwEByN+PTC+ccaGzpNlf 2nDaPSzwrv1UKrnIXpRSnIniK527L+Smhl5dB/Cpcck6Y+dJqSLdnab4yhNIVOHfoVwe iQ5jWbY8sahUP++R5iU+xIBP18CRnn4swrgEsNYOBiOlHmoAdrxr9jg3//NHtO9+J1f6 nShw== X-Gm-Message-State: AOJu0Yz8+S7Mtry2bUe7ZyTU+SjQ3btsG5NMnQxxS1oNRKhSu/89iL17 +tf3usJnwe1oNhTUaYJh7XbZ9/7JySnGI/YZb1p+RB3v5uPn3ViUUPNSFusgeHkErwAwxVAcKzx 3 X-Google-Smtp-Source: AGHT+IGZP3cwR15Elcgtrn+x/Zn035cI3RQ5T5U3eSZrmGNSKSZyqHxK2RNp6bfluEAXkux3f5rWlA== X-Received: by 2002:a5d:598e:0:b0:37c:cee0:96e6 with SMTP id ffacd0b85a97d-38225a0d457mr11458759f8f.27.1731934871672; Mon, 18 Nov 2024 05:01:11 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Gavin Shan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Michael Rolnik , Iris Artin Subject: [PATCH-for-9.2] hw/avr/arduino: Check for CPU types in machine_run_board_init() Date: Mon, 18 Nov 2024 14:01:09 +0100 Message-ID: <20241118130109.7838-1-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 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::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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.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: 1731934932418116600 Leverage the common code introduced in commit c9cf636d48 ("machine: Add a valid_cpu_types property") to check for the single valid CPU type. This allows reporting an error for invalid CPUs: $ qemu-system-avr -M 2009 -cpu avr51-avr-cpu qemu-system-avr: Invalid CPU model: avr51 The only valid type is: avr5 Reported-by: Iris Artin Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/avr/arduino.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/avr/arduino.c b/hw/avr/arduino.c index 48ef478346..a8da2728f0 100644 --- a/hw/avr/arduino.c +++ b/hw/avr/arduino.c @@ -71,6 +71,10 @@ static void arduino_machine_class_init(ObjectClass *oc, = void *data) =20 static void arduino_duemilanove_class_init(ObjectClass *oc, void *data) { + static const char * const valid_cpu_types[] =3D { + AVR_CPU_TYPE_NAME("avr5"), + NULL + }; MachineClass *mc =3D MACHINE_CLASS(oc); ArduinoMachineClass *amc =3D ARDUINO_MACHINE_CLASS(oc); =20 @@ -80,12 +84,17 @@ static void arduino_duemilanove_class_init(ObjectClass = *oc, void *data) */ mc->desc =3D "Arduino Duemilanove (ATmega168)", mc->alias =3D "2009"; + mc->valid_cpu_types =3D valid_cpu_types; amc->mcu_type =3D TYPE_ATMEGA168_MCU; amc->xtal_hz =3D 16 * 1000 * 1000; }; =20 static void arduino_uno_class_init(ObjectClass *oc, void *data) { + static const char * const valid_cpu_types[] =3D { + AVR_CPU_TYPE_NAME("avr5"), + NULL + }; MachineClass *mc =3D MACHINE_CLASS(oc); ArduinoMachineClass *amc =3D ARDUINO_MACHINE_CLASS(oc); =20 @@ -95,12 +104,17 @@ static void arduino_uno_class_init(ObjectClass *oc, vo= id *data) */ mc->desc =3D "Arduino UNO (ATmega328P)"; mc->alias =3D "uno"; + mc->valid_cpu_types =3D valid_cpu_types; amc->mcu_type =3D TYPE_ATMEGA328_MCU; amc->xtal_hz =3D 16 * 1000 * 1000; }; =20 static void arduino_mega_class_init(ObjectClass *oc, void *data) { + static const char * const valid_cpu_types[] =3D { + AVR_CPU_TYPE_NAME("avr51"), + NULL + }; MachineClass *mc =3D MACHINE_CLASS(oc); ArduinoMachineClass *amc =3D ARDUINO_MACHINE_CLASS(oc); =20 @@ -110,12 +124,17 @@ static void arduino_mega_class_init(ObjectClass *oc, = void *data) */ mc->desc =3D "Arduino Mega (ATmega1280)"; mc->alias =3D "mega"; + mc->valid_cpu_types =3D valid_cpu_types; amc->mcu_type =3D TYPE_ATMEGA1280_MCU; amc->xtal_hz =3D 16 * 1000 * 1000; }; =20 static void arduino_mega2560_class_init(ObjectClass *oc, void *data) { + static const char * const valid_cpu_types[] =3D { + AVR_CPU_TYPE_NAME("avr6"), + NULL + }; MachineClass *mc =3D MACHINE_CLASS(oc); ArduinoMachineClass *amc =3D ARDUINO_MACHINE_CLASS(oc); =20 @@ -125,6 +144,7 @@ static void arduino_mega2560_class_init(ObjectClass *oc= , void *data) */ mc->desc =3D "Arduino Mega 2560 (ATmega2560)"; mc->alias =3D "mega2560"; + mc->valid_cpu_types =3D valid_cpu_types; amc->mcu_type =3D TYPE_ATMEGA2560_MCU; amc->xtal_hz =3D 16 * 1000 * 1000; /* CSTCE16M0V53-R0 */ }; --=20 2.45.2