From nobody Tue May 14 22:32:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16454713560351023.2030609354805; Mon, 21 Feb 2022 11:22:36 -0800 (PST) Received: from localhost ([::1]:54220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMEGY-0007Kn-FW for importer@patchew.org; Mon, 21 Feb 2022 14:22:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nME9Z-0003U5-FL for qemu-devel@nongnu.org; Mon, 21 Feb 2022 14:15:22 -0500 Received: from [2a00:1450:4864:20::330] (port=34510 helo=mail-wm1-x330.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nME9X-0001eH-Hy for qemu-devel@nongnu.org; Mon, 21 Feb 2022 14:15:21 -0500 Received: by mail-wm1-x330.google.com with SMTP id l2-20020a7bc342000000b0037fa585de26so119903wmj.1 for ; Mon, 21 Feb 2022 11:15:19 -0800 (PST) Received: from liavpc.localdomain ([2a10:800a:bb8:1:6510:42ac:bb55:9590]) by smtp.gmail.com with ESMTPSA id b7sm40563258wrp.23.2022.02.21.11.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 11:15:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q+4euos2X2sE9Kn//yFjNOTsm9gej+U7wgc1A9eCeFA=; b=GW1oUqII+7uf45rFXqcY4maiFLVOj0/xw41RZ/KJjMM7SHJbl/G5LXw3CqIkVEzkVp AzA9J1ONeMLML8G7lll+EAwxudIfjceWdA3SUL2R5nzSai4QfdXTn1eJMFbp+EnUn4NJ HAdI327T7TBufFYUtb5Ahn0Ku2GtGqVej1iEmvx+mRgOO/++pa5JGgpuL5/UUS6WfzBN 1qMI2AUJm2FZvFxDkBZMCn/m+2z6KEpsZnvd9VZOObicCkjzwCeiAKWl0+UlEmbv5JFv ysRQq3nKBUwUgf4KQendB1BVN/eTaPLi5OQiOsGwxlu3w5o/bFvgDxW9PSUlAWzCV+jW lwWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q+4euos2X2sE9Kn//yFjNOTsm9gej+U7wgc1A9eCeFA=; b=hdUsruBXsHvo3zVyvES+XjakCq7kLzQuIEC5fE0YLo25k9o3NDjGo9XK8bTs8xN2dU U9qGh1K/+YR2URChvBC3B56DBHh8huCUPDGAGxKnWDz6ySE/jwnCTEcYgcXyK0x67xYi i1tTxQsljCI3T0Op5RQE7a7IbWtAibuw+eRo6Lw3/m+OLZLzYw42QU0x+72hWHa7A46Y GXGFn8SNW5AaRIBNHBaFwiNyLqGdsW+FqAgzLJCI13clPTp7CYHw/l7aF0rrZf83AZbT f3GEPsrAmRWKLd28XIxmpwc0RYTb+HR+np93NAh69NrpY4dfT9KlEj6huhTN5ZpxwxnY 53EQ== X-Gm-Message-State: AOAM5318HiGajFjMLWX07A/XG6l+f+kQF0dkZJn0dIJqxaKmmxCXkSxD 2EU4jgLfC2RNg3v/Ht5UFe0uCe8HptxaAw== X-Google-Smtp-Source: ABdhPJxzvRjcUCxe9dHf+FiGL12NlP+HYdRLR8vYd3TmRC6v5jMui6K06RMwVOOKPe6BaC0LpZsjIw== X-Received: by 2002:a05:600c:3486:b0:37c:d45c:179f with SMTP id a6-20020a05600c348600b0037cd45c179fmr382301wmq.6.1645470917746; Mon, 21 Feb 2022 11:15:17 -0800 (PST) From: Liav Albani To: qemu-devel@nongnu.org Subject: [PATCH v2 1/2] hw/isa: add function to check for existence of device by its type Date: Mon, 21 Feb 2022 21:13:22 +0200 Message-Id: <20220221191323.617323-2-liavalb@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221191323.617323-1-liavalb@gmail.com> References: <20220221191323.617323-1-liavalb@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::330 (failed) 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::330; envelope-from=liavalb@gmail.com; helo=mail-wm1-x330.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: ani@anisinha.ca, imammedo@redhat.com, Liav Albani , mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645471357333100001 Content-Type: text/plain; charset="utf-8" This function enumerates all attached ISA devices in the machine, and tries to compare a given device type name to the enumerated devices. For example, this can help other code to determine if a i8042 controller exists in the machine. Signed-off-by: Liav Albani --- hw/isa/isa-bus.c | 23 +++++++++++++++++++++++ include/hw/isa/isa.h | 1 + 2 files changed, 24 insertions(+) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 6c31398dda..663aa36d29 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -222,6 +222,29 @@ void isa_build_aml(ISABus *bus, Aml *scope) } } =20 +bool isa_check_device_existence(const char *typename) +{ + /* + * If there's no ISA bus, we know for sure that the checked ISA device= type + * doesn't exist in the machine. + */ + if (isabus =3D=3D NULL) { + return false; + } + + BusChild *kid; + ISADevice *dev; + + QTAILQ_FOREACH(kid, &isabus->parent_obj.children, sibling) { + dev =3D ISA_DEVICE(kid->child); + const char *object_type =3D object_get_typename(OBJECT(dev)); + if (object_type && strcmp(object_type, typename) =3D=3D 0) { + return true; + } + } + return false; +} + static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent) { ISADevice *d =3D ISA_DEVICE(dev); diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index d4417b34b6..65f0c7e28c 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -99,6 +99,7 @@ IsaDma *isa_get_dma(ISABus *bus, int nchan); MemoryRegion *isa_address_space(ISADevice *dev); MemoryRegion *isa_address_space_io(ISADevice *dev); ISADevice *isa_new(const char *name); +bool isa_check_device_existence(const char *typename); ISADevice *isa_try_new(const char *name); bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp); ISADevice *isa_create_simple(ISABus *bus, const char *name); --=20 2.35.1 From nobody Tue May 14 22:32:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645471686351740.0809182618467; Mon, 21 Feb 2022 11:28:06 -0800 (PST) Received: from localhost ([::1]:60950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMELt-0003W4-5f for importer@patchew.org; Mon, 21 Feb 2022 14:28:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nME9b-0003VW-GZ for qemu-devel@nongnu.org; Mon, 21 Feb 2022 14:15:23 -0500 Received: from [2a00:1450:4864:20::436] (port=38768 helo=mail-wr1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nME9Z-0001eS-VN for qemu-devel@nongnu.org; Mon, 21 Feb 2022 14:15:23 -0500 Received: by mail-wr1-x436.google.com with SMTP id d27so28794686wrb.5 for ; Mon, 21 Feb 2022 11:15:21 -0800 (PST) Received: from liavpc.localdomain ([2a10:800a:bb8:1:6510:42ac:bb55:9590]) by smtp.gmail.com with ESMTPSA id b7sm40563258wrp.23.2022.02.21.11.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 11:15:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y/McU+O8wGOej6ngpTyjfRmYL1is5tFLApI7iXTkHog=; b=WvOvI0IttkZ+tMC1Ex3gEENDbtfPlc38x/rN/P+2VO0awQebVVGV6ose3YaNLJ6gue FjDUTSXSbIMhTvUyuQZX3NfoBiJH+YSUQluEuP9R4gbPJsKz0GEVSo9kIUqLDUvSD8kt hDbUds8FTFQ8smYtY/D9tN0xieLNBRPVLnvk0fHT5U7H2AyZi0nnFDGbr4TTFtY3/pZi EuXXq/4UVge+G7DsNqxlv9jsKmK58IH83attOgOIgYmvn+fGPTwNB96uCzxvsDksFVjC LIPsJtrbtWdX6vkcVlPrvs5bvwDXL3mIqvNlCzAKqBXCM8ymOK/KGazbxdcaJx5Z7h2N NVZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y/McU+O8wGOej6ngpTyjfRmYL1is5tFLApI7iXTkHog=; b=PO9XtOkGlAItgxAolQFJr6vRflOa4fdbEmkfe5wmsSvOWZAjpU4b6dXPRKAqllWCCH WuhNqxuUsdU5i7H2xp2ou+DFitCauPKUg6FAn6mE7wK1cJJZ3/zAbPnGi5d9Dqrur3Fy ydzDjKAymbD0xvN0SI5TFTHdGw0a7hlgHxVhL+xyLYYkiOkS/VPBl7/2YD0kA1uSrnB2 ZcjjpvuCmxWmBIMed8r0o+Xc/QfKjgu5kjcojZlgBIgQ4xN/UaJWPKqz7SL11KtnMNaO zGtYUzQg2ht6hPSyqMW/pVq6AnFma0cqSoswC4cOZJFTnr0tN9SSKGI//I0ZuOuu3cY5 ds6A== X-Gm-Message-State: AOAM533CViLX1UrNotODurpWyCw2Hl4KpBJg+tXRLlMaR3lmbqd90kN6 QWgXM+uYKjXR2bUcOko0zw/LPjCpjADDjA== X-Google-Smtp-Source: ABdhPJxpkuXL3tKbX82vDuHFsuLoK9741RO9yHc5l1FbU9k8TFXWUROd/IW/c9Sf4yVJcVkRocFI9g== X-Received: by 2002:a5d:64e3:0:b0:1e4:a380:bb6f with SMTP id g3-20020a5d64e3000000b001e4a380bb6fmr17410836wri.463.1645470920564; Mon, 21 Feb 2022 11:15:20 -0800 (PST) From: Liav Albani To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Date: Mon, 21 Feb 2022 21:13:23 +0200 Message-Id: <20220221191323.617323-3-liavalb@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221191323.617323-1-liavalb@gmail.com> References: <20220221191323.617323-1-liavalb@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::436 (failed) 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::436; envelope-from=liavalb@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: ani@anisinha.ca, imammedo@redhat.com, Liav Albani , mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645471688232100001 Content-Type: text/plain; charset="utf-8" This can allow the guest OS to determine more easily if i8042 controller is present in the system or not, so it doesn't need to do probing of the controller, but just initialize it immediately, before enumerating the ACPI AML namespace. Signed-off-by: Liav Albani --- hw/acpi/aml-build.c | 7 ++++++- hw/i386/acpi-build.c | 5 +++++ hw/i386/acpi-microvm.c | 5 +++++ include/hw/acpi/acpi-defs.h | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 8966e16320..ef5f4cad87 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -2152,7 +2152,12 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, con= st AcpiFadtData *f, build_append_int_noprefix(tbl, 0, 1); /* DAY_ALRM */ build_append_int_noprefix(tbl, 0, 1); /* MON_ALRM */ build_append_int_noprefix(tbl, f->rtc_century, 1); /* CENTURY */ - build_append_int_noprefix(tbl, 0, 2); /* IAPC_BOOT_ARCH */ + /* IAPC_BOOT_ARCH */ + if (f->rev =3D=3D 1) { + build_append_int_noprefix(tbl, 0, 2); + } else { + build_append_int_noprefix(tbl, f->iapc_boot_arch, 2); + } build_append_int_noprefix(tbl, 0, 1); /* Reserved */ build_append_int_noprefix(tbl, f->flags, 4); /* Flags */ =20 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index ebd47aa26f..5dc625b8d8 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -192,6 +192,11 @@ static void init_common_fadt_data(MachineState *ms, Ob= ject *o, .address =3D object_property_get_uint(o, ACPI_PM_PROP_GPE0_BLK= , NULL) }, }; + if (isa_check_device_existence("i8042")) { + /* Indicates if i8042 is present or not */ + fadt.iapc_boot_arch =3D (1 << 1); + } + =20 *data =3D fadt; } =20 diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index 68ca7e7fc2..756c69b3b0 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -189,6 +189,11 @@ static void acpi_build_microvm(AcpiBuildTables *tables, .reset_val =3D ACPI_GED_RESET_VALUE, }; =20 + if (isa_check_device_existence("i8042")) { + /* Indicates if i8042 is present or not */ + pmfadt.iapc_boot_arch =3D (1 << 1); + } + table_offsets =3D g_array_new(false, true /* clear */, sizeof(uint32_t)); bios_linker_loader_alloc(tables->linker, diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index c97e8633ad..2b42e4192b 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -77,6 +77,7 @@ typedef struct AcpiFadtData { uint16_t plvl2_lat; /* P_LVL2_LAT */ uint16_t plvl3_lat; /* P_LVL3_LAT */ uint16_t arm_boot_arch; /* ARM_BOOT_ARCH */ + uint16_t iapc_boot_arch; /* IAPC_BOOT_ARCH */ uint8_t minor_ver; /* FADT Minor Version */ =20 /* --=20 2.35.1