From nobody Sat Apr 27 02:39:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588168404; cv=none; d=zohomail.com; s=zohoarc; b=ZtSHKVJYrekGzjW+b6+hK4XBKO+12diwMoaRMtuyzsbObcny2591H7YtPnq6fHlS9KcmPTHGLMFeemWGGm/YuJXLKb7VfmFN42OOPGcmYjMHfcczW10VNBKdTz9Kr9BUYSWiyDPje9EDV/YaTnofk4TdCCvNN/AheMmOuA8bsPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588168404; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=tryiyeWosPOrgs0V9GQ1exOpDQMeYhuFem5aIEYlaaE=; b=nb6WCgcXqQ5PqYfidmvfoRvjIGP+jU68eyyHljr/wdYILOfxorgq3oZU6MthliSI5lWaAA/4RMT7mtmb3EvCiSnRw4ewBDAV5qBr8/BOmr08TeUNEc5WNWs9Y2fFQvhlr+ADCH2WKngK5AI9QO7kwQmaqMo+XDnikHkI3XcqYAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1588168404947753.6826669497767; Wed, 29 Apr 2020 06:53:24 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 8EF8710C195B; Wed, 29 Apr 2020 13:53:20 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 51A2E10C1955 for ; Wed, 29 Apr 2020 13:53:08 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-9m7jrC2gPtOVB2Ff3fjqTg-1; Wed, 29 Apr 2020 09:46:58 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D95245F for ; Wed, 29 Apr 2020 13:46:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AC9560BF4; Wed, 29 Apr 2020 13:46:53 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 18C199D99; Wed, 29 Apr 2020 15:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o1ac3GcktkeUPN5aoWYqkesehQO3xXcBazmEkVXGXB8=; b=DW7KlvtLk9jUVGSbYvSfcI0GvDZz7p0E6wDdZhWpwnRVihLqO4tF1lq8vlCAJGE9ywXWbz mqDz+pICpu+/u3uUQzi3ftpp91+WQi/iJtPk4mj3nkYEO/kOvJwgvGSrOwWee9rWvgiks7 kzTGEs84oFE3JmsZFarFnJzLlrEPvbU= X-MC-Unique: 9m7jrC2gPtOVB2Ff3fjqTg-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 29 Apr 2020 15:46:35 +0200 Message-Id: <20200429134643.2001-2-kraxel@redhat.com> In-Reply-To: <20200429134643.2001-1-kraxel@redhat.com> References: <20200429134643.2001-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: KVZUCCKAVYCEHB3M5O3QXLB3PII4FMTM X-Message-ID-Hash: KVZUCCKAVYCEHB3M5O3QXLB3PII4FMTM X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v3 1/9] virtio-mmio: device probing and initialization. List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: +++++++++ X-Spam-Level: ********* Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spam: Yes X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add virtio_mmio_setup_one() to setup virtio mmio devices. Add vp_init_mmio() to initialize device struct. Because virtio-pci and virtio-mmio are quite simliar we reuse the infrastructure we already have for virtio-pci and just setup struct vp_cap for virtio-mmio. Signed-off-by: Gerd Hoffmann --- Makefile | 2 +- src/hw/virtio-mmio.h | 76 ++++++++++++++++++++++++++++++++++++++++++++ src/hw/virtio-pci.h | 1 + src/hw/virtio-mmio.c | 58 +++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 src/hw/virtio-mmio.h create mode 100644 src/hw/virtio-mmio.c diff --git a/Makefile b/Makefile index 5f7d5370198a..985ef591a13b 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ SRC32FLAT=3D$(SRCBOTH) post.c e820map.c malloc.c romfile.= c x86.c optionroms.c \ fw/coreboot.c fw/lzmadecode.c fw/multiboot.c fw/csm.c fw/biostables.c \ fw/paravirt.c fw/shadow.c fw/pciinit.c fw/smm.c fw/smp.c fw/mtrr.c fw/= xen.c \ fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c \ - hw/virtio-ring.c hw/virtio-pci.c hw/virtio-blk.c hw/virtio-scsi.c \ + hw/virtio-ring.c hw/virtio-pci.c hw/virtio-mmio.c hw/virtio-blk.c hw/v= irtio-scsi.c \ hw/tpm_drivers.c hw/nvme.c SRC32SEG=3Dstring.c output.c pcibios.c apm.c stacks.c hw/pci.c hw/serialio= .c DIRS=3Dsrc src/hw src/fw vgasrc diff --git a/src/hw/virtio-mmio.h b/src/hw/virtio-mmio.h new file mode 100644 index 000000000000..9e0dae421009 --- /dev/null +++ b/src/hw/virtio-mmio.h @@ -0,0 +1,76 @@ +#ifndef _VIRTIO_MMIO_H +#define _VIRTIO_MMIO_H + +struct vp_device; + +typedef struct virtio_mmio_cfg { + u32 magic; + u32 version; + u32 device_id; + u32 vendor_id; + + u32 device_feature; + u32 device_feature_select; + u32 res_18; + u32 res_1c; + + u32 guest_feature; + u32 guest_feature_select; + u32 legacy_guest_page_size; + u32 res_2c; + + u32 queue_select; + u32 queue_num_max; + u32 queue_num; + u32 legacy_queue_align; + + u32 legacy_queue_pfn; + u32 queue_ready; + u32 res_48; + u32 res_4c; + + u32 queue_notify; + u32 res_54; + u32 res_58; + u32 res_5c; + + u32 irq_status; + u32 irq_ack; + u32 res_68; + u32 res_6c; + + u32 device_status; + u32 res_74; + u32 res_78; + u32 res_7c; + + u32 queue_desc_lo; + u32 queue_desc_hi; + u32 res_88; + u32 res_8c; + + u32 queue_driver_lo; + u32 queue_driver_hi; + u32 res_98; + u32 res_9c; + + u32 queue_device_lo; + u32 queue_device_hi; + u32 res_a8; + u32 shm_sel; + + u32 shmem_len_lo; + u32 shmem_len_hi; + u32 shmem_base_lo; + u32 shmem_base_hi; + + u32 res_c0_f7[14]; + + u32 res_f8; + u32 config_generation; +} virtio_mmio_cfg; + +void virtio_mmio_setup_one(u64 mmio); +void vp_init_mmio(struct vp_device *vp, void *mmio); + +#endif /* _VIRTIO_MMIO_H */ diff --git a/src/hw/virtio-pci.h b/src/hw/virtio-pci.h index 492e5c7c9166..269626448558 100644 --- a/src/hw/virtio-pci.h +++ b/src/hw/virtio-pci.h @@ -111,6 +111,7 @@ struct vp_device { struct vp_cap common, notify, isr, device, legacy; u32 notify_off_multiplier; u8 use_modern; + u8 use_mmio; }; =20 u64 _vp_read(struct vp_cap *cap, u32 offset, u8 size); diff --git a/src/hw/virtio-mmio.c b/src/hw/virtio-mmio.c new file mode 100644 index 000000000000..0d6ef6e2f19d --- /dev/null +++ b/src/hw/virtio-mmio.c @@ -0,0 +1,58 @@ +#include "config.h" // CONFIG_DEBUG_LEVEL +#include "malloc.h" // free +#include "output.h" // dprintf +#include "stacks.h" // run_thread +#include "string.h" // memset +#include "virtio-pci.h" +#include "virtio-ring.h" +#include "virtio-mmio.h" + +void virtio_mmio_setup_one(u64 addr) +{ + u32 magic, version, devid; + void *mmio; + + if (addr >=3D 0x100000000) { + dprintf(1, "virtio-mmio: %llx: above 4G\n", addr); + return; + } + + mmio =3D (void*)(u32)(addr); + magic =3D readl(mmio); + if (magic !=3D 0x74726976) { + dprintf(1, "virtio-mmio: %llx: magic mismatch\n", addr); + return; + } + version =3D readl(mmio+4); + if (version !=3D 1 /* legacy */ && + version !=3D 2 /* 1.0 */) { + dprintf(1, "virtio-mmio: %llx: unknown version %d\n", addr, versio= n); + return; + } + devid =3D readl(mmio+8); + dprintf(1, "virtio-mmio: %llx: device id %x%s\n", + addr, devid, version =3D=3D 1 ? " (legacy)" : ""); + switch (devid) { + case 2: /* blk */ + /* TODO */ + break; + case 8: /* scsi */ + /* TODO */ + break; + default: + break; + } +} + +void vp_init_mmio(struct vp_device *vp, void *mmio) +{ + memset(vp, 0, sizeof(*vp)); + vp->use_mmio =3D 1; + vp->common.mode =3D VP_ACCESS_MMIO; + vp->common.memaddr =3D mmio; + vp->device.mode =3D VP_ACCESS_MMIO; + vp->device.memaddr =3D mmio + 0x100; + vp_reset(vp); + vp_set_status(vp, VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER); +} --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Sat Apr 27 02:39:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588168427; cv=none; d=zohomail.com; s=zohoarc; b=Ce0Pfhw6flWRo61ggh4jlPdhcFU4S4r1NMaOoUCBMBJzw6yGLaFGFdyCEha5fPTP9X+p6Ee1VpOb3ikT0+wvGRhLEiKje1pSEnK7KZa+B7Ivkgsne+xcS+Byql1OQqtDK3ikQgZNaLP7bOTjIJX6xChfzX+KAHSuYoAgqrp8jqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588168427; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=MwloAa4u7F70S2fySVnpIK0AFwQM2MUj7p3G5hbkr1w=; b=dlHKZJMAVcqSu8OUg9H+OFCXMPPjzk3U2bhM7nR0O9vstIlt+0C8NrpMf0UTDcgcomUoodLJK4EMV+3gP7Fq5DOcQ66oZTR7E/tCiLUdNxx9QV9yNZ5SxsY1pUrEo5NsFEOMgJ+T3L2U3cilsB3C3ju0wkR6ggr6rZYJtntOj5E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 15881684276531017.5917936983093; Wed, 29 Apr 2020 06:53:47 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 99DB110C1963; Wed, 29 Apr 2020 13:53:43 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 75C2D10C1951 for ; Wed, 29 Apr 2020 13:53:05 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288--HNzZJvfM4uksYPuF7TaDA-1; Wed, 29 Apr 2020 09:46:55 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7309280058A for ; Wed, 29 Apr 2020 13:46:54 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCC9C38F; Wed, 29 Apr 2020 13:46:53 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 1B5FF9D9B; Wed, 29 Apr 2020 15:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MOkgIlEw0GKmYZABAz6WoX9ib6y5sw03PWFACNKSNWs=; b=DVrSdLfS0sq/PgpuFqzGd0NTOG6D6WvWwKUecs6W3AXLBsq7J3PGBewzFBqCoaq+1volW8 b/VijdjZBa47bCzsNVKYPiiKbHVD1QzzliVQ//tG7hfW2zhl1EC6wMJI/l5GWiXFFJtIGX 9/D7YVcvWWHy3I7XSDxayAzw9AcrVe0= X-MC-Unique: -HNzZJvfM4uksYPuF7TaDA-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 29 Apr 2020 15:46:36 +0200 Message-Id: <20200429134643.2001-3-kraxel@redhat.com> In-Reply-To: <20200429134643.2001-1-kraxel@redhat.com> References: <20200429134643.2001-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: GZLOCJGRGTHNI7HIYFSKZL2E5ODB5GT4 X-Message-ID-Hash: GZLOCJGRGTHNI7HIYFSKZL2E5ODB5GT4 X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v3 2/9] virtio-mmio: add support to vp_*() functions List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add support for virtio-mmio to the vp_*() helper functions. Both legacy and 1.0 virto-mmio versions are supported. They are very simliar anyway, only the virtqueue initialization is slightly different. Signed-off-by: Gerd Hoffmann --- src/hw/virtio-pci.c | 68 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/src/hw/virtio-pci.c b/src/hw/virtio-pci.c index d5435218fb0a..213c49777c40 100644 --- a/src/hw/virtio-pci.c +++ b/src/hw/virtio-pci.c @@ -23,6 +23,7 @@ #include "pci_regs.h" // PCI_BASE_ADDRESS_0 #include "string.h" // memset #include "virtio-pci.h" +#include "virtio-mmio.h" #include "virtio-ring.h" =20 u64 _vp_read(struct vp_cap *cap, u32 offset, u8 size) @@ -189,7 +190,11 @@ u64 vp_get_features(struct vp_device *vp) { u32 f0, f1; =20 - if (vp->use_modern) { + if (vp->use_mmio) { + vp_write(&vp->common, virtio_mmio_cfg, device_feature_select, 0); + f0 =3D vp_read(&vp->common, virtio_mmio_cfg, device_feature); + f1 =3D 0; + } else if (vp->use_modern) { vp_write(&vp->common, virtio_pci_common_cfg, device_feature_select= , 0); f0 =3D vp_read(&vp->common, virtio_pci_common_cfg, device_feature); vp_write(&vp->common, virtio_pci_common_cfg, device_feature_select= , 1); @@ -208,7 +213,10 @@ void vp_set_features(struct vp_device *vp, u64 feature= s) f0 =3D features; f1 =3D features >> 32; =20 - if (vp->use_modern) { + if (vp->use_mmio) { + vp_write(&vp->common, virtio_mmio_cfg, guest_feature_select, f0); + vp_write(&vp->common, virtio_mmio_cfg, guest_feature, f0); + } else if (vp->use_modern) { vp_write(&vp->common, virtio_pci_common_cfg, guest_feature_select,= 0); vp_write(&vp->common, virtio_pci_common_cfg, guest_feature, f0); vp_write(&vp->common, virtio_pci_common_cfg, guest_feature_select,= 1); @@ -220,7 +228,9 @@ void vp_set_features(struct vp_device *vp, u64 features) =20 u8 vp_get_status(struct vp_device *vp) { - if (vp->use_modern) { + if (vp->use_mmio) { + return vp_read(&vp->common, virtio_mmio_cfg, device_status); + } else if (vp->use_modern) { return vp_read(&vp->common, virtio_pci_common_cfg, device_status); } else { return vp_read(&vp->legacy, virtio_pci_legacy, status); @@ -231,7 +241,9 @@ void vp_set_status(struct vp_device *vp, u8 status) { if (status =3D=3D 0) /* reset */ return; - if (vp->use_modern) { + if (vp->use_mmio) { + vp_write(&vp->common, virtio_mmio_cfg, device_status, status); + } else if (vp->use_modern) { vp_write(&vp->common, virtio_pci_common_cfg, device_status, status= ); } else { vp_write(&vp->legacy, virtio_pci_legacy, status, status); @@ -240,7 +252,9 @@ void vp_set_status(struct vp_device *vp, u8 status) =20 u8 vp_get_isr(struct vp_device *vp) { - if (vp->use_modern) { + if (vp->use_mmio) { + return vp_read(&vp->common, virtio_mmio_cfg, irq_status); + } else if (vp->use_modern) { return vp_read(&vp->isr, virtio_pci_isr, isr); } else { return vp_read(&vp->legacy, virtio_pci_legacy, isr); @@ -249,7 +263,10 @@ u8 vp_get_isr(struct vp_device *vp) =20 void vp_reset(struct vp_device *vp) { - if (vp->use_modern) { + if (vp->use_mmio) { + vp_write(&vp->common, virtio_mmio_cfg, device_status, 0); + vp_read(&vp->common, virtio_mmio_cfg, irq_status); + } else if (vp->use_modern) { vp_write(&vp->common, virtio_pci_common_cfg, device_status, 0); vp_read(&vp->isr, virtio_pci_isr, isr); } else { @@ -260,7 +277,9 @@ void vp_reset(struct vp_device *vp) =20 void vp_notify(struct vp_device *vp, struct vring_virtqueue *vq) { - if (vp->use_modern) { + if (vp->use_mmio) { + vp_write(&vp->common, virtio_mmio_cfg, queue_notify, vq->queue_ind= ex); + } else if (vp->use_modern) { u32 offset =3D vq->queue_notify_off * vp->notify_off_multiplier; switch (vp->notify.mode) { case VP_ACCESS_IO: @@ -305,14 +324,21 @@ int vp_find_vq(struct vp_device *vp, int queue_index, =20 =20 /* select the queue */ - if (vp->use_modern) { + if (vp->use_mmio) { + vp_write(&vp->common, virtio_mmio_cfg, queue_select, queue_index); + } else if (vp->use_modern) { vp_write(&vp->common, virtio_pci_common_cfg, queue_select, queue_in= dex); } else { vp_write(&vp->legacy, virtio_pci_legacy, queue_sel, queue_index); } =20 /* check if the queue is available */ - if (vp->use_modern) { + if (vp->use_mmio) { + num =3D vp_read(&vp->common, virtio_mmio_cfg, queue_num_max); + if (num > MAX_QUEUE_NUM) + num =3D MAX_QUEUE_NUM; + vp_write(&vp->common, virtio_mmio_cfg, queue_num, num); + } else if (vp->use_modern) { num =3D vp_read(&vp->common, virtio_pci_common_cfg, queue_size); if (num > MAX_QUEUE_NUM) { vp_write(&vp->common, virtio_pci_common_cfg, queue_size, @@ -332,7 +358,9 @@ int vp_find_vq(struct vp_device *vp, int queue_index, } =20 /* check if the queue is already active */ - if (vp->use_modern) { + if (vp->use_mmio) { + /* TODO */; + } else if (vp->use_modern) { if (vp_read(&vp->common, virtio_pci_common_cfg, queue_enable)) { dprintf(1, "ERROR: queue already active\n"); goto fail; @@ -354,7 +382,25 @@ int vp_find_vq(struct vp_device *vp, int queue_index, * NOTE: vr->desc is initialized by vring_init() */ =20 - if (vp->use_modern) { + if (vp->use_mmio) { + if (vp_read(&vp->common, virtio_mmio_cfg, version) =3D=3D 2) { + vp_write(&vp->common, virtio_mmio_cfg, queue_desc_lo, + (unsigned long)virt_to_phys(vr->desc)); + vp_write(&vp->common, virtio_mmio_cfg, queue_desc_hi, 0); + vp_write(&vp->common, virtio_mmio_cfg, queue_driver_lo, + (unsigned long)virt_to_phys(vr->avail)); + vp_write(&vp->common, virtio_mmio_cfg, queue_driver_hi, 0); + vp_write(&vp->common, virtio_mmio_cfg, queue_device_lo, + (unsigned long)virt_to_phys(vr->used)); + vp_write(&vp->common, virtio_mmio_cfg, queue_device_hi, 0); + vp_write(&vp->common, virtio_mmio_cfg, queue_ready, 1); + } else { + vp_write(&vp->common, virtio_mmio_cfg, legacy_guest_page_size, + (unsigned long)1 << PAGE_SHIFT); + vp_write(&vp->common, virtio_mmio_cfg, legacy_queue_pfn, + (unsigned long)virt_to_phys(vr->desc) >> PAGE_SHIFT); + } + } else if (vp->use_modern) { vp_write(&vp->common, virtio_pci_common_cfg, queue_desc_lo, (unsigned long)virt_to_phys(vr->desc)); vp_write(&vp->common, virtio_pci_common_cfg, queue_desc_hi, 0); --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Sat Apr 27 02:39:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588168489; cv=none; d=zohomail.com; s=zohoarc; b=hS6kV87C9iBL1EzYFHKpK30TYgvhA1EdZb9CYBG5KGjdR2QbEorM5pTswcbvAjB0CgFJROzo3Tw8CtJ9i3i62HtP7zmyc/gnl2y9ca+Boqlo+5z+lfvP7EM6fg/fVPHeEborJY7J4EG0a0CGJqAnIqYLTauyHdt1Rq7HS1rfpuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588168489; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=C5jydro/J0Dqv0tp1HnX+c1VYYDfVVEAjAbAQICQrQ4=; b=Io1JR/9vjGqFXibIJRTciyMjtzksIsxnXLvvLH+iyuAi7Je3uwuZzIDoi9Ln3poT5vILTRDtMuMfCk2rvJFiqoTqmMqKOf5U8py1Q6nfeXe4EbRV6bsFWdn56GbKvBAg3la0EfrsdwhNp7fbyuyqXJ0EJQWPnUOSxzDqTsY28PM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1588168489699185.53277028908064; Wed, 29 Apr 2020 06:54:49 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 9555310C1974; Wed, 29 Apr 2020 13:54:45 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 1C8E910C195B for ; Wed, 29 Apr 2020 13:53:17 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-zZ42Jii_NgeIwWxbTvQUsA-1; Wed, 29 Apr 2020 09:46:58 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 252A31895A29 for ; Wed, 29 Apr 2020 13:46:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D5035C1BE; Wed, 29 Apr 2020 13:46:53 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 1DB359D9C; Wed, 29 Apr 2020 15:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pMcXC7ZarWjLVEQ8PsMvk5s9rlknnvdnBddCYygrqE4=; b=CV4A0mSWlFnZVbvkpmSx01ouPfrcMAV/0YMVqDgvwyEQd3ndPQMgOWAuE4m00TrgVURYHy oFZ5CG1jEJRGW8rpVirKhAhMkFk+yHRZXZhP2tYKjqGhaKY+HC38wB9z/RBrRovnl/meeE nkXpiPFZerxbHePNMyK5NUM8lPL0dX0= X-MC-Unique: zZ42Jii_NgeIwWxbTvQUsA-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 29 Apr 2020 15:46:37 +0200 Message-Id: <20200429134643.2001-4-kraxel@redhat.com> In-Reply-To: <20200429134643.2001-1-kraxel@redhat.com> References: <20200429134643.2001-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam: Yes Message-ID-Hash: 53ORDTIX4PVKBI7ZS62ID65LGWMB3DPK X-Message-ID-Hash: 53ORDTIX4PVKBI7ZS62ID65LGWMB3DPK X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v3 3/9] virtio-mmio: add support for scsi devices. List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: +++++ X-Spam-Level: ***** Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add new fields to struct virtio_lun_s for mmio support, add mmio parameter to virtio_scsi_init_lun(), so both pci and mmio devices can be handled. Add and use bootprio_find_scsi_mmio_device() to figure boot priority of devices connected to a virtio-mmio scsi controller. Finally add init_virtio_scsi_mmio() to initialize one virtio-mmio scsi controller. Signed-off-by: Gerd Hoffmann --- src/hw/virtio-scsi.h | 1 + src/util.h | 1 + src/boot.c | 10 ++++++ src/hw/virtio-mmio.c | 3 +- src/hw/virtio-scsi.c | 73 +++++++++++++++++++++++++++++++++++++------- 5 files changed, 76 insertions(+), 12 deletions(-) diff --git a/src/hw/virtio-scsi.h b/src/hw/virtio-scsi.h index 7532cc98e56e..8f01de4cba99 100644 --- a/src/hw/virtio-scsi.h +++ b/src/hw/virtio-scsi.h @@ -43,5 +43,6 @@ struct virtio_scsi_resp_cmd { struct disk_op_s; int virtio_scsi_process_op(struct disk_op_s *op); void virtio_scsi_setup(void); +void init_virtio_scsi_mmio(void *data); =20 #endif /* _VIRTIO_SCSI_H */ diff --git a/src/util.h b/src/util.h index 94592a2d2e8d..1c82e09ed87b 100644 --- a/src/util.h +++ b/src/util.h @@ -31,6 +31,7 @@ u8 is_bootprio_strict(void); struct pci_device; int bootprio_find_pci_device(struct pci_device *pci); int bootprio_find_scsi_device(struct pci_device *pci, int target, int lun); +int bootprio_find_scsi_mmio_device(void *mmio, int target, int lun); int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave= ); int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid); int bootprio_find_pci_rom(struct pci_device *pci, int instance); diff --git a/src/boot.c b/src/boot.c index 4f12988f687c..f2f084bea843 100644 --- a/src/boot.c +++ b/src/boot.c @@ -328,6 +328,16 @@ int bootprio_find_scsi_device(struct pci_device *pci, = int target, int lun) return find_prio(desc); } =20 +int bootprio_find_scsi_mmio_device(void *mmio, int target, int lun) +{ + if (!CONFIG_BOOTORDER) + return -1; + char desc[256]; + snprintf(desc, sizeof(desc), "/virtio-mmio@%016x/*@0/*@%x,%x", + (u32)mmio, target, lun); + return find_prio(desc); +} + int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave) { if (CONFIG_CSM) diff --git a/src/hw/virtio-mmio.c b/src/hw/virtio-mmio.c index 0d6ef6e2f19d..daca8a098a0b 100644 --- a/src/hw/virtio-mmio.c +++ b/src/hw/virtio-mmio.c @@ -4,6 +4,7 @@ #include "stacks.h" // run_thread #include "string.h" // memset #include "virtio-pci.h" +#include "virtio-scsi.h" #include "virtio-ring.h" #include "virtio-mmio.h" =20 @@ -37,7 +38,7 @@ void virtio_mmio_setup_one(u64 addr) /* TODO */ break; case 8: /* scsi */ - /* TODO */ + run_thread(init_virtio_scsi_mmio, mmio); break; default: break; diff --git a/src/hw/virtio-scsi.c b/src/hw/virtio-scsi.c index a5332848b8c8..59f1c654d76b 100644 --- a/src/hw/virtio-scsi.c +++ b/src/hw/virtio-scsi.c @@ -22,10 +22,13 @@ #include "virtio-pci.h" #include "virtio-ring.h" #include "virtio-scsi.h" +#include "virtio-mmio.h" =20 struct virtio_lun_s { struct drive_s drive; struct pci_device *pci; + void *mmio; + char name[16]; struct vring_virtqueue *vq; struct vp_device *vp; u16 target; @@ -94,7 +97,8 @@ virtio_scsi_process_op(struct disk_op_s *op) } =20 static void -virtio_scsi_init_lun(struct virtio_lun_s *vlun, struct pci_device *pci, +virtio_scsi_init_lun(struct virtio_lun_s *vlun, + struct pci_device *pci, void *mmio, struct vp_device *vp, struct vring_virtqueue *vq, u16 target, u16 lun) { @@ -102,10 +106,15 @@ virtio_scsi_init_lun(struct virtio_lun_s *vlun, struc= t pci_device *pci, vlun->drive.type =3D DTYPE_VIRTIO_SCSI; vlun->drive.cntl_id =3D pci->bdf; vlun->pci =3D pci; + vlun->mmio =3D mmio; vlun->vp =3D vp; vlun->vq =3D vq; vlun->target =3D target; vlun->lun =3D lun; + if (vlun->pci) + snprintf(vlun->name, sizeof(vlun->name), "pci:%pP", vlun->pci); + if (vlun->mmio) + snprintf(vlun->name, sizeof(vlun->name), "mmio:%08x", (u32)vlun->m= mio); } =20 static int @@ -114,12 +123,17 @@ virtio_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv) u8 skip_nonbootable =3D is_bootprio_strict(); struct virtio_lun_s *tmpl_vlun =3D container_of(tmpl_drv, struct virtio_lun_s, drive); - int prio =3D bootprio_find_scsi_device(tmpl_vlun->pci, tmpl_vlun->targ= et, tmpl_vlun->lun); + int prio =3D -1; + + if (tmpl_vlun->pci) + prio =3D bootprio_find_scsi_device(tmpl_vlun->pci, tmpl_vlun->targ= et, tmpl_vlun->lun); + if (tmpl_vlun->mmio) + prio =3D bootprio_find_scsi_mmio_device(tmpl_vlun->mmio, tmpl_vlun= ->target, tmpl_vlun->lun); =20 if (skip_nonbootable && prio < 0) { - dprintf(1, "skipping init of a non-bootable virtio-scsi dev at %pP= ," + dprintf(1, "skipping init of a non-bootable virtio-scsi dev at %s," " target %d, lun %d\n", - tmpl_vlun->pci, tmpl_vlun->target, tmpl_vlun->lun); + tmpl_vlun->name, tmpl_vlun->target, tmpl_vlun->lun); return -1; } =20 @@ -128,11 +142,12 @@ virtio_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv) warn_noalloc(); return -1; } - virtio_scsi_init_lun(vlun, tmpl_vlun->pci, tmpl_vlun->vp, tmpl_vlun->v= q, - tmpl_vlun->target, lun); + virtio_scsi_init_lun(vlun, tmpl_vlun->pci, tmpl_vlun->mmio,tmpl_vlun->= vp, + tmpl_vlun->vq, tmpl_vlun->target, lun); =20 - boot_lchs_find_scsi_device(vlun->pci, vlun->target, vlun->lun, - &(vlun->drive.lchs)); + if (vlun->pci) + boot_lchs_find_scsi_device(vlun->pci, vlun->target, vlun->lun, + &(vlun->drive.lchs)); int ret =3D scsi_drive_setup(&vlun->drive, "virtio-scsi", prio); if (ret) goto fail; @@ -144,13 +159,13 @@ fail: } =20 static int -virtio_scsi_scan_target(struct pci_device *pci, struct vp_device *vp, +virtio_scsi_scan_target(struct pci_device *pci, void *mmio, struct vp_devi= ce *vp, struct vring_virtqueue *vq, u16 target) { =20 struct virtio_lun_s vlun0; =20 - virtio_scsi_init_lun(&vlun0, pci, vp, vq, target, 0); + virtio_scsi_init_lun(&vlun0, pci, mmio, vp, vq, target, 0); =20 int ret =3D scsi_rep_luns_scan(&vlun0.drive, virtio_scsi_add_lun); return ret < 0 ? 0 : ret; @@ -198,7 +213,43 @@ init_virtio_scsi(void *data) =20 int i, tot; for (tot =3D 0, i =3D 0; i < 256; i++) - tot +=3D virtio_scsi_scan_target(pci, vp, vq, i); + tot +=3D virtio_scsi_scan_target(pci, NULL, vp, vq, i); + + if (!tot) + goto fail; + + return; + +fail: + vp_reset(vp); + free(vp); + free(vq); +} + +void +init_virtio_scsi_mmio(void *mmio) +{ + dprintf(1, "found virtio-scsi-mmio at %p\n", mmio); + struct vring_virtqueue *vq =3D NULL; + struct vp_device *vp =3D malloc_high(sizeof(*vp)); + if (!vp) { + warn_noalloc(); + return; + } + vp_init_mmio(vp, mmio); + u8 status =3D VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER; + + if (vp_find_vq(vp, 2, &vq) < 0 ) { + dprintf(1, "fail to find vq for virtio-scsi-mmio %p\n", mmio); + goto fail; + } + + status |=3D VIRTIO_CONFIG_S_DRIVER_OK; + vp_set_status(vp, status); + + int i, tot; + for (tot =3D 0, i =3D 0; i < 256; i++) + tot +=3D virtio_scsi_scan_target(NULL, mmio, vp, vq, i); =20 if (!tot) goto fail; --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Sat Apr 27 02:39:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588168441; cv=none; d=zohomail.com; s=zohoarc; b=NI5id4a2pcH5UWt1+RbaS8P8C9fVWI+neMKqFINzVj/1VAVH/9iakEjgYyYtieImsChZoyjnltPtitykb4LbsZ5iPIzAUGBPEiLHP5S0BOjZzG2AozBZD4yRXdcUei+cWEYekW0ytMX8pwuD3eNf99UW9uKSp3TDycnhqIVXxkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588168441; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=Kb5V0ED7ZMo/ynfsRvJKKdGD3M6SYt8V4Eq1flEvVTs=; b=kqTN4HKqptCNONnvJQGqAlbL2PNuOqUxHikpVyc5JoI1cvvZbSErStIZ9laupniYK523YVkpYbhkW6IzPIGJpi1/joh0BQKNY1ezygIHPZHgSUjaePrFagvJEhYCTT5pUr8kImJYaLAiLa87BkgsRQHAfIjt8vgrDPU4gxNKF7U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1588168441666231.64775647763145; Wed, 29 Apr 2020 06:54:01 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 55B8910C195A; Wed, 29 Apr 2020 13:53:58 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 4D2D110C1955 for ; Wed, 29 Apr 2020 13:53:11 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-78-3gTqKZ5QMZSpWpX9FVwISw-1; Wed, 29 Apr 2020 09:46:57 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 067BB8014D9 for ; Wed, 29 Apr 2020 13:46:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D5C75C254; Wed, 29 Apr 2020 13:46:53 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 2001D9D9D; Wed, 29 Apr 2020 15:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=quWAAn4fxZWSlrGQ93mywPE1P7/Rdy1EE2FRq4Ish9s=; b=Iv2aqs2itEGsdg2Xb8/d3BzwrPMwzilMQbPR4xYWT/qMfGIatsN0O8f4Qq9ACaGBxutLjp AtbMj7vhlX+4l0I9LtUS92Lk8VSAgXgz3o7adcavR9GwJ9NtW8VBZxFHmFr3yoUZ4tdQtf netJJ6JxCMEnzGOG5e5TEyo5GqfXKHw= X-MC-Unique: 3gTqKZ5QMZSpWpX9FVwISw-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 29 Apr 2020 15:46:38 +0200 Message-Id: <20200429134643.2001-5-kraxel@redhat.com> In-Reply-To: <20200429134643.2001-1-kraxel@redhat.com> References: <20200429134643.2001-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: VLBIQVK2S72KY4JSUOQ6DX7QTSJUBMGV X-Message-ID-Hash: VLBIQVK2S72KY4JSUOQ6DX7QTSJUBMGV X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v3 4/9] virtio-mmio: add support for block devices. List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: +++++++++ X-Spam-Level: ********* Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spam: Yes X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add and use bootprio_find_mmio_device() to figure the boot priority of virtio-mmio block devices. Add init_virtio_blk_mmio to initialize one virtio-mmio block device. Signed-off-by: Gerd Hoffmann --- src/hw/virtio-blk.h | 1 + src/util.h | 1 + src/boot.c | 9 ++++++ src/hw/virtio-blk.c | 71 ++++++++++++++++++++++++++++++++++++++++++++ src/hw/virtio-mmio.c | 3 +- 5 files changed, 84 insertions(+), 1 deletion(-) diff --git a/src/hw/virtio-blk.h b/src/hw/virtio-blk.h index 157bed62744a..d20461a2a3b2 100644 --- a/src/hw/virtio-blk.h +++ b/src/hw/virtio-blk.h @@ -39,5 +39,6 @@ struct virtio_blk_outhdr { struct disk_op_s; int virtio_blk_process_op(struct disk_op_s *op); void virtio_blk_setup(void); +void init_virtio_blk_mmio(void *mmio); =20 #endif /* _VIRTIO_BLK_H */ diff --git a/src/util.h b/src/util.h index 1c82e09ed87b..4f27fc307439 100644 --- a/src/util.h +++ b/src/util.h @@ -30,6 +30,7 @@ void bcv_prepboot(void); u8 is_bootprio_strict(void); struct pci_device; int bootprio_find_pci_device(struct pci_device *pci); +int bootprio_find_mmio_device(void *mmio); int bootprio_find_scsi_device(struct pci_device *pci, int target, int lun); int bootprio_find_scsi_mmio_device(void *mmio, int target, int lun); int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave= ); diff --git a/src/boot.c b/src/boot.c index f2f084bea843..cc87b1d98476 100644 --- a/src/boot.c +++ b/src/boot.c @@ -316,6 +316,15 @@ int bootprio_find_pci_device(struct pci_device *pci) return find_prio(desc); } =20 +int bootprio_find_mmio_device(void *mmio) +{ + if (!CONFIG_BOOTORDER) + return -1; + char desc[256]; + snprintf(desc, sizeof(desc), "/virtio-mmio@%016x/*", (u32)mmio); + return find_prio(desc); +} + int bootprio_find_scsi_device(struct pci_device *pci, int target, int lun) { if (!CONFIG_BOOTORDER) diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c index a5e28fc858b1..3b198965c8ba 100644 --- a/src/hw/virtio-blk.c +++ b/src/hw/virtio-blk.c @@ -20,6 +20,7 @@ #include "string.h" // memset #include "util.h" // usleep, bootprio_find_pci_device, is_bootprio_strict #include "virtio-pci.h" +#include "virtio-mmio.h" #include "virtio-ring.h" #include "virtio-blk.h" =20 @@ -193,6 +194,76 @@ fail: free(vdrive); } =20 +void +init_virtio_blk_mmio(void *mmio) +{ + u8 status =3D VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER; + dprintf(1, "found virtio-blk-mmio at %p\n", mmio); + struct virtiodrive_s *vdrive =3D malloc_low(sizeof(*vdrive)); + if (!vdrive) { + warn_noalloc(); + return; + } + memset(vdrive, 0, sizeof(*vdrive)); + vdrive->drive.type =3D DTYPE_VIRTIO_BLK; + vdrive->drive.cntl_id =3D (u32)mmio; + + vp_init_mmio(&vdrive->vp, mmio); + if (vp_find_vq(&vdrive->vp, 0, &vdrive->vq) < 0 ) { + dprintf(1, "fail to find vq for virtio-blk-mmio %p\n", mmio); + goto fail; + } + + struct vp_device *vp =3D &vdrive->vp; + u64 features =3D vp_get_features(vp); + u64 version1 =3D 1ull << VIRTIO_F_VERSION_1; + u64 blk_size =3D 1ull << VIRTIO_BLK_F_BLK_SIZE; + + features =3D features & (version1 | blk_size); + vp_set_features(vp, features); + status |=3D VIRTIO_CONFIG_S_FEATURES_OK; + vp_set_status(vp, status); + if (!(vp_get_status(vp) & VIRTIO_CONFIG_S_FEATURES_OK)) { + dprintf(1, "device didn't accept features: %p\n", mmio); + goto fail; + } + + vdrive->drive.sectors =3D + vp_read(&vp->device, struct virtio_blk_config, capacity); + if (features & blk_size) { + vdrive->drive.blksize =3D + vp_read(&vp->device, struct virtio_blk_config, blk_size); + } else { + vdrive->drive.blksize =3D DISK_SECTOR_SIZE; + } + if (vdrive->drive.blksize !=3D DISK_SECTOR_SIZE) { + dprintf(1, "virtio-blk-mmio %p block size %d is unsupported\n", + mmio, vdrive->drive.blksize); + goto fail; + } + dprintf(1, "virtio-blk-mmio %p blksize=3D%d sectors=3D%u\n", + mmio, vdrive->drive.blksize, (u32)vdrive->drive.sectors); + + vdrive->drive.pchs.cylinder =3D + vp_read(&vp->device, struct virtio_blk_config, cylinders); + vdrive->drive.pchs.head =3D + vp_read(&vp->device, struct virtio_blk_config, heads); + vdrive->drive.pchs.sector =3D + vp_read(&vp->device, struct virtio_blk_config, sectors); + + char *desc =3D znprintf(MAXDESCSIZE, "Virtio disk mmio:%p", mmio); + boot_add_hd(&vdrive->drive, desc, bootprio_find_mmio_device(mmio)); + + status |=3D VIRTIO_CONFIG_S_DRIVER_OK; + vp_set_status(&vdrive->vp, status); + return; + +fail: + vp_reset(&vdrive->vp); + free(vdrive->vq); + free(vdrive); +} + void virtio_blk_setup(void) { diff --git a/src/hw/virtio-mmio.c b/src/hw/virtio-mmio.c index daca8a098a0b..adb28f730592 100644 --- a/src/hw/virtio-mmio.c +++ b/src/hw/virtio-mmio.c @@ -4,6 +4,7 @@ #include "stacks.h" // run_thread #include "string.h" // memset #include "virtio-pci.h" +#include "virtio-blk.h" #include "virtio-scsi.h" #include "virtio-ring.h" #include "virtio-mmio.h" @@ -35,7 +36,7 @@ void virtio_mmio_setup_one(u64 addr) addr, devid, version =3D=3D 1 ? " (legacy)" : ""); switch (devid) { case 2: /* blk */ - /* TODO */ + run_thread(init_virtio_blk_mmio, mmio); break; case 8: /* scsi */ run_thread(init_virtio_scsi_mmio, mmio); --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Sat Apr 27 02:39:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588168453; cv=none; d=zohomail.com; s=zohoarc; b=ZnR3X2dqUjzl7oglMc8EB/n5XCCoxzWdiy+dxS7SwSjjwF/3KHNpKqLB5iGW5Gm4oNK4cXvJBI00rtCjiuIXzPBLj5XajDXewwUWy1358oQZ8Om7B8zzgdyeso0vpUvhlopPf0VCI9lPItcrcLa3+oadg8guoPGPWi5ljCQ4KEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588168453; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=MykWMFmCZGrcTOH+6XEM1dmuzDiw4PMo43qtXAs9qtw=; b=L2whQURhnPC7++n01o2pr5zOkckvkl3opZ4HO1rZSLCqZ9SJw4vEZb1CJm093RwF/V8Lx2B0enA3m4l/IgPrywJuDi7JwTy6j78R4X1FOu1svuGkLusI8a+nfLgij/fpSUDtO6QqlZIZpCXUmxJ+TgWF4jM/T88f6L2IwFRS4Ig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 15881684534631006.5037676470826; Wed, 29 Apr 2020 06:54:13 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 579FB10C1955; Wed, 29 Apr 2020 13:54:09 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 6027E10C1957 for ; Wed, 29 Apr 2020 13:53:11 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-224-Qsf4B0SoOIWAdWaMXyKanQ-1; Wed, 29 Apr 2020 09:46:59 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BD7F107ACF5 for ; Wed, 29 Apr 2020 13:46:58 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4E26648C8; Wed, 29 Apr 2020 13:46:55 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 2254E9D9E; Wed, 29 Apr 2020 15:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JKI0AUE4AHASTrOVJStgoJlZDoAkFbdaDWc/a1YzEnE=; b=bI7dUxpCbb+j8C0/8KueBy0Un9Con5TrLtfDutJ4JFC8wiV13AI5GUfAJirs41VyPR7Mxc wFitsxVpFJGrWmIMcu7WGQykDAfXiQkSCUUO3Rej5snjlEAlke1Z+7IF/nCe+RQpiiMMwY DIxs+s6EGJAXRF2Cv+JpxpTXxXnBYSc= X-MC-Unique: Qsf4B0SoOIWAdWaMXyKanQ-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 29 Apr 2020 15:46:39 +0200 Message-Id: <20200429134643.2001-6-kraxel@redhat.com> In-Reply-To: <20200429134643.2001-1-kraxel@redhat.com> References: <20200429134643.2001-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: O5JN5MLCDGRPB4TQ6SQIW5DO6BCMGQFP X-Message-ID-Hash: O5JN5MLCDGRPB4TQ6SQIW5DO6BCMGQFP X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v3 5/9] virtio-mmio: print device type List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: +++++++++ X-Spam-Level: ********* Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spam: Yes X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" --- src/hw/virtio-mmio.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/hw/virtio-mmio.c b/src/hw/virtio-mmio.c index adb28f730592..dabef7b7e53a 100644 --- a/src/hw/virtio-mmio.c +++ b/src/hw/virtio-mmio.c @@ -11,6 +11,19 @@ =20 void virtio_mmio_setup_one(u64 addr) { + static const char *names[] =3D { + [ 1 ] =3D "net", + [ 2 ] =3D "blk", + [ 3 ] =3D "console", + [ 4 ] =3D "rng", + [ 8 ] =3D "scsi", + [ 9 ] =3D "9p", + [ 16 ] =3D "gpu", + [ 19 ] =3D "vsock", + [ 18 ] =3D "input", + [ 26 ] =3D "fs", + }; + const char *name; u32 magic, version, devid; void *mmio; =20 @@ -32,8 +45,12 @@ void virtio_mmio_setup_one(u64 addr) return; } devid =3D readl(mmio+8); - dprintf(1, "virtio-mmio: %llx: device id %x%s\n", - addr, devid, version =3D=3D 1 ? " (legacy)" : ""); + + name =3D (devid < ARRAY_SIZE(names) && names[devid] !=3D NULL) + ? names[devid] : "unknown"; + dprintf(1, "virtio-mmio: %llx: device id %x (%s%s)\n", + addr, devid, name, version =3D=3D 1 ? ", legacy" : ""); + switch (devid) { case 2: /* blk */ run_thread(init_virtio_blk_mmio, mmio); --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Sat Apr 27 02:39:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588168464; cv=none; d=zohomail.com; s=zohoarc; b=h0RoifMdni+Po9GNPw5CBpbVWX/4GYO0YZhJN8UGarBjuFODwGttoNVTuBgCEAAebQNIHn8b4t88/p5FR8ROYjDwvkA5ruyungjnR84jb/q6DdhoW63+Yi/ZkG4DS3UIyN5X3zHgSQx3C/CopBRc5BjPX4xdcKgnDY9zsiYtf3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588168464; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=jhX1uwZEJ7HKyPKgZOyqrCA1A/IogczMqwP1IqizOEg=; b=JJZHUys1j6E+TpwEcmftKE+OrkkbMU0VSl+gLiFazqQvpXzhsaslD/JT3v1nzcS5pbi/6kY3UXh2SXnUltowMiqHQ652ctxr4GWj+PbhT1qbTYaiCL89t8I/AUjFhxeF39gYJhrEYcIH+07Mkj884zlolLLHuNHOrurLy2wWviQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1588168464670394.2675240794583; Wed, 29 Apr 2020 06:54:24 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 5159110C1962; Wed, 29 Apr 2020 13:54:21 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 328A510C1954 for ; Wed, 29 Apr 2020 13:53:11 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-lRuAmGUHPiySDHe-hfO5yw-1; Wed, 29 Apr 2020 09:46:59 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3EA1E1009615 for ; Wed, 29 Apr 2020 13:46:58 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id E51ED648D2; Wed, 29 Apr 2020 13:46:55 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 24D4D9D9F; Wed, 29 Apr 2020 15:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3gqf7sqAN84AZD2SPOEBWjlwOfgVepZODYFWIExJPhc=; b=cDRntSpgpFV4hpgZL4iURRbta4hSaEQqnxqOYYsKvWEo7SnQj/i4wQh7KrllQppPDx0hgD TgMWMMhEXXQVJvNSlegneQ/SBYsSEHNbNa9H5S+LF7922vFFfEF8XoH12PpaH5dIrkWRyA rWyYRP0+k+gZLjdhjxwnPp1UWTmrcrM= X-MC-Unique: lRuAmGUHPiySDHe-hfO5yw-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 29 Apr 2020 15:46:40 +0200 Message-Id: <20200429134643.2001-7-kraxel@redhat.com> In-Reply-To: <20200429134643.2001-1-kraxel@redhat.com> References: <20200429134643.2001-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: NIEKNIXOWJNWZQLWT2GXXI7FKCFWYN52 X-Message-ID-Hash: NIEKNIXOWJNWZQLWT2GXXI7FKCFWYN52 X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v3 6/9] acpi: add xsdt support List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In case a xsdt table is present (and located below 4G) prefer it over rsdt. Signed-off-by: Gerd Hoffmann --- src/std/acpi.h | 11 +++++++++++ src/fw/biostables.c | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/std/acpi.h b/src/std/acpi.h index c01fa7be827c..81c22757f50e 100644 --- a/src/std/acpi.h +++ b/src/std/acpi.h @@ -132,6 +132,17 @@ struct rsdt_descriptor_rev1 /* ACPI tables */ } PACKED; =20 +/* + * ACPI 2.0 eXtended System Description Table (XSDT) + */ +#define XSDT_SIGNATURE 0x54445358 // XSDT +struct xsdt_descriptor_rev2 +{ + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + u64 table_offset_entry[0]; /* Array of pointers to other */ + /* ACPI tables */ +} PACKED; + /* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */ diff --git a/src/fw/biostables.c b/src/fw/biostables.c index fe8626efc05d..0d4fdb9c22e8 100644 --- a/src/fw/biostables.c +++ b/src/fw/biostables.c @@ -141,18 +141,38 @@ find_acpi_table(u32 signature) if (!RsdpAddr || RsdpAddr->signature !=3D RSDP_SIGNATURE) return NULL; struct rsdt_descriptor_rev1 *rsdt =3D (void*)RsdpAddr->rsdt_physical_a= ddress; + struct xsdt_descriptor_rev2 *xsdt =3D + RsdpAddr->xsdt_physical_address >=3D 0x100000000 + ? NULL : (void*)(u32)(RsdpAddr->xsdt_physical_address); dprintf(4, "rsdt=3D%p\n", rsdt); - if (!rsdt || rsdt->signature !=3D RSDT_SIGNATURE) - return NULL; - void *end =3D (void*)rsdt + rsdt->length; - int i; - for (i=3D0; (void*)&rsdt->table_offset_entry[i] < end; i++) { - struct acpi_table_header *tbl =3D (void*)rsdt->table_offset_entry[= i]; - if (!tbl || tbl->signature !=3D signature) - continue; - dprintf(4, "table(%x)=3D%p\n", signature, tbl); - return tbl; + dprintf(4, "xsdt=3D%p\n", xsdt); + + if (xsdt && xsdt->signature =3D=3D XSDT_SIGNATURE) { + void *end =3D (void*)xsdt + xsdt->length; + int i; + for (i=3D0; (void*)&xsdt->table_offset_entry[i] < end; i++) { + if (xsdt->table_offset_entry[i] >=3D 0x100000000) + continue; /* above 4G */ + struct acpi_table_header *tbl =3D (void*)(u32)xsdt->table_offs= et_entry[i]; + if (!tbl || tbl->signature !=3D signature) + continue; + dprintf(1, "table(%x)=3D%p (via xsdt)\n", signature, tbl); + return tbl; + } } + + if (rsdt && rsdt->signature =3D=3D RSDT_SIGNATURE) { + void *end =3D (void*)rsdt + rsdt->length; + int i; + for (i=3D0; (void*)&rsdt->table_offset_entry[i] < end; i++) { + struct acpi_table_header *tbl =3D (void*)rsdt->table_offset_en= try[i]; + if (!tbl || tbl->signature !=3D signature) + continue; + dprintf(1, "table(%x)=3D%p (via rsdt)\n", signature, tbl); + return tbl; + } + } + dprintf(4, "no table %x found\n", signature); return NULL; } --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Sat Apr 27 02:39:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588168501; cv=none; d=zohomail.com; s=zohoarc; b=UC95Rwljca4jK7A8N3JNuDsepDZUi4icMlrFiUlDcDsod96EVVhI35TxHM9CvtD5mNaE7xr0EZlJJ6XUdRQAoTRsSsvu60YGXyMLlZL+3OfNETMK2FfZJLQl39Hucx9UL01zJcJ3Gg8xbVQ/wBOKrM4qGP1C2p0mS4gC8i2KGbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588168501; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=CwiYpB/hKy8gAR3UMyKoV23KIbnpiUaHZ5+aafO0W3A=; b=d5JUJnqH0I+PlgCehA5mZJ81nqdheYmm826KkCKwJu0uUnGRLakZdXeEbeG2EEEWnpGse5ogQH0Wcz0+HN4sJwn7Gq/NxQmzoPPv2avjAQeBQHnMkx4nGA4e3wB4sH6gF5cIOU7gR7jyjQ/6mrmZRVo9/iy/VsV42gsfMmuxDSI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1588168501970657.9049517605105; Wed, 29 Apr 2020 06:55:01 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id D04E910C1958; Wed, 29 Apr 2020 13:54:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id C4E2B10C195E for ; Wed, 29 Apr 2020 13:53:23 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-wmJMKs-4PqWWGkwPxPHjeg-1; Wed, 29 Apr 2020 09:47:01 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F337945F for ; Wed, 29 Apr 2020 13:47:00 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C8F11001281; Wed, 29 Apr 2020 13:46:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 2746B9DA0; Wed, 29 Apr 2020 15:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D8a86RW1IOuzwiwYk1Fdm138bfrBUsE3XQKruQ93O0Q=; b=OQ1rSW+r2oebqljudWVyUfMBUDcyWprzxoEnlEpUTO6IiijuNTRWYoVT5N83ovMi89+C+o /M+PaRlXR6gJ7zXg0e0FlZ9hhfj3uJXQev/OrT+TLi+DgEz1FoP9omil7GPrf/fTxVdc9G 3Fy3I55sfWHfIfu4KKC3Hvsz2J7vcGA= X-MC-Unique: wmJMKs-4PqWWGkwPxPHjeg-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 29 Apr 2020 15:46:41 +0200 Message-Id: <20200429134643.2001-8-kraxel@redhat.com> In-Reply-To: <20200429134643.2001-1-kraxel@redhat.com> References: <20200429134643.2001-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Level: ***** Message-ID-Hash: Q4Q5IAN3XO7IVYJO5WLNDT4NRAUBMULT X-Message-ID-Hash: Q4Q5IAN3XO7IVYJO5WLNDT4NRAUBMULT X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v3 7/9] acpi: add dsdt parser List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Create a list of devices found in the DSDT table. Add helper functions to find devices, walk the list and figure device informations like mmio ranges and irqs. Signed-off-by: Gerd Hoffmann --- Makefile | 2 +- src/util.h | 11 + src/fw/biostables.c | 9 + src/fw/dsdt_parser.c | 668 +++++++++++++++++++++++++++++++++++++++++++ src/fw/paravirt.c | 5 +- src/Kconfig | 7 + 6 files changed, 699 insertions(+), 3 deletions(-) create mode 100644 src/fw/dsdt_parser.c diff --git a/Makefile b/Makefile index 985ef591a13b..f02eda314784 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ SRC32FLAT=3D$(SRCBOTH) post.c e820map.c malloc.c romfile.= c x86.c optionroms.c \ hw/pcidevice.c hw/ahci.c hw/pvscsi.c hw/usb-xhci.c hw/usb-hub.c hw/sdc= ard.c \ fw/coreboot.c fw/lzmadecode.c fw/multiboot.c fw/csm.c fw/biostables.c \ fw/paravirt.c fw/shadow.c fw/pciinit.c fw/smm.c fw/smp.c fw/mtrr.c fw/= xen.c \ - fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c \ + fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c f= w/dsdt_parser.c \ hw/virtio-ring.c hw/virtio-pci.c hw/virtio-mmio.c hw/virtio-blk.c hw/v= irtio-scsi.c \ hw/tpm_drivers.c hw/nvme.c SRC32SEG=3Dstring.c output.c pcibios.c apm.c stacks.c hw/pci.c hw/serialio= .c diff --git a/src/util.h b/src/util.h index 4f27fc307439..0de35229dc0c 100644 --- a/src/util.h +++ b/src/util.h @@ -94,6 +94,17 @@ void display_uuid(void); void copy_table(void *pos); void smbios_setup(void); =20 +// fw/dsdt_parser.c +struct acpi_device; +void acpi_dsdt_parse(void); +struct acpi_device *acpi_dsdt_find_string(struct acpi_device *prev, const = char *hid); +struct acpi_device *acpi_dsdt_find_eisaid(struct acpi_device *prev, u16 ei= said); +char *acpi_dsdt_name(struct acpi_device *dev); +int acpi_dsdt_present_eisaid(u16 eisaid); +int acpi_dsdt_find_io(struct acpi_device *dev, u64 *min, u64 *max); +int acpi_dsdt_find_mem(struct acpi_device *dev, u64 *min, u64 *max); +int acpi_dsdt_find_irq(struct acpi_device *dev, u64 *irq); + // fw/coreboot.c extern const char *CBvendor, *CBpart; struct cbfs_file; diff --git a/src/fw/biostables.c b/src/fw/biostables.c index 0d4fdb9c22e8..0597459e9875 100644 --- a/src/fw/biostables.c +++ b/src/fw/biostables.c @@ -4,6 +4,14 @@ // // This file may be distributed under the terms of the GNU LGPLv3 license. =20 +#include "byteorder.h" // le32_to_cpu +#include "config.h" // CONFIG_* +// Support for manipulating bios tables (pir, mptable, acpi, smbios). +// +// Copyright (C) 2008,2009 Kevin O'Connor +// +// This file may be distributed under the terms of the GNU LGPLv3 license. + #include "byteorder.h" // le32_to_cpu #include "config.h" // CONFIG_* #include "hw/pci.h" // pci_config_writeb @@ -256,6 +264,7 @@ find_acpi_features(void) void *p =3D fadt; acpi_set_reset_reg(p + 116, *(u8 *)(p + 128)); } + acpi_dsdt_parse(); } =20 =20 diff --git a/src/fw/dsdt_parser.c b/src/fw/dsdt_parser.c new file mode 100644 index 000000000000..87c1a3ac3a00 --- /dev/null +++ b/src/fw/dsdt_parser.c @@ -0,0 +1,668 @@ +// Support for parsing dsdt acpi tables +// +// Copyright (C) 2008,2009 Kevin O'Connor +// +// This file may be distributed under the terms of the GNU LGPLv3 license. + +#include "config.h" // CONFIG_* +#include "list.h" // hlist_* +#include "malloc.h" // malloc_* +#include "output.h" // dprintf +#include "string.h" // memcpy +#include "util.h" +#include "std/acpi.h" // struct rsdp_descriptor + +/**************************************************************** + * DSDT parser + ****************************************************************/ + +struct acpi_device { + struct hlist_node node; + char name[16]; + u8 *hid_aml; + u8 *sta_aml; + u8 *crs_data; + int crs_size; +}; +static struct hlist_head acpi_devices VARVERIFY32INIT; +static const int parse_dumpdevs =3D 0; + +struct parse_state { + char name[32]; + struct acpi_device *dev; + int error; + int depth; +}; + +static void parse_termlist(struct parse_state *s, + u8 *ptr, int offset, int pkglength); + +static void hex(const u8 *ptr, int count, int lvl, const char *item) +{ + int l =3D 0, i; + + do { + dprintf(lvl, "%s: %04x: ", item, l); + for (i =3D l; i < l+16; i +=3D 4) + dprintf(lvl, "%02x %02x %02x %02x ", + ptr[i+0], ptr[i+1], ptr[i+2], ptr[i+3]); + for (i =3D l; i < l+16; i++) + dprintf(lvl, "%c", (ptr[i] > 0x20 && ptr[i] < 0x80) + ? ptr[i] : '.'); + dprintf(lvl, "\n"); + l +=3D 16; + } while (l < count); +} + +static u64 parse_resource_int(u8 *ptr, int count) +{ + u64 value =3D 0; + int index =3D 0; + + for (index =3D 0; index < count; index++) + value |=3D (u64)ptr[index] << (index * 8); + return value; +} + +static int parse_resource_bit(u8 *ptr, int count) +{ + int bit; + + for (bit =3D 0; bit < count*8; bit++) + if (ptr[bit/8] & (1 << (bit%8))) + return bit; + return 0; +} + +static int parse_resource(u8 *ptr, int length, int *type, u64 *min, u64 *m= ax) +{ + int rname, rsize; + u64 len; + + *type =3D -1; + *min =3D 0; + *max =3D 0; + len =3D 0; + if (!(ptr[0] & 0x80)) { + /* small resource */ + rname =3D (ptr[0] >> 3) & 0x0f; + rsize =3D ptr[0] & 0x07; + rsize++; + switch (rname) { + case 0x04: /* irq */ + *min =3D parse_resource_bit(ptr + 1, rsize); + *max =3D *min; + *type =3D 3; + break; + case 0x0f: /* end marker */ + return 0; + case 0x08: /* io */ + *min =3D parse_resource_int(ptr + 2, 2); + *max =3D parse_resource_int(ptr + 4, 2); + if (*min =3D=3D *max) { + *max =3D *min + ptr[7] - 1; + *type =3D 1; + } + break; + case 0x09: /* fixed io */ + *min =3D parse_resource_int(ptr + 2, 2); + *max =3D *min + ptr[4] - 1; + *type =3D 1; + break; + default: + dprintf(3, "%s: small: 0x%x (len %d)\n", + __func__, rname, rsize); + break; + } + } else { + /* large resource */ + rname =3D ptr[0] & 0x7f; + rsize =3D ptr[2] << 8 | ptr[1]; + rsize +=3D 3; + switch (rname) { + case 0x06: /* 32-bit Fixed Location Memory Range Descriptor */ + *min =3D parse_resource_int(ptr + 4, 4); + len =3D parse_resource_int(ptr + 8, 4); + *max =3D *min + len - 1; + *type =3D 0; + break; + case 0x07: /* DWORD Address Space Descriptor */ + *min =3D parse_resource_int(ptr + 10, 4); + *max =3D parse_resource_int(ptr + 14, 4); + *type =3D ptr[3]; + break; + case 0x08: /* WORD Address Space Descriptor */ + *min =3D parse_resource_int(ptr + 8, 2); + *max =3D parse_resource_int(ptr + 10, 2); + *type =3D ptr[3]; + break; + case 0x09: /* irq */ + *min =3D parse_resource_int(ptr + 5, 4); + *max =3D *min; + *type =3D 3; + break; + case 0x0a: /* QWORD Address Space Descriptor */ + *min =3D parse_resource_int(ptr + 14, 8); + *max =3D parse_resource_int(ptr + 22, 8); + *type =3D ptr[3]; + break; + default: + dprintf(3, "%s: large: 0x%x (len %d)\n", __func__, rname, rsiz= e); + break; + } + } + return rsize; +} + +static int find_resource(u8 *ptr, int len, int kind, u64 *min, u64 *max) +{ + int type, size, offset =3D 0; + + do { + size =3D parse_resource(ptr + offset, len - offset, + &type, min, max); + if (kind =3D=3D type) + return 0; + offset +=3D size; + } while (size > 0 && offset < len); + return -1; +} + +static int print_resources(const char *prefix, u8 *ptr, int len) +{ + static const char *typename[] =3D { "mem", "i/o", "bus" }; + int type, size, offset =3D 0; + u64 min, max; + + do { + size =3D parse_resource(ptr + offset, len - offset, + &type, &min, &max); + switch (type) { + case 0: + case 1: + case 2: + dprintf(1, "%s%s 0x%llx -> 0x%llx\n", + prefix, typename[type], min, max); + break; + case 3: + dprintf(1, "%sirq %lld\n", prefix, min); + break; + } + offset +=3D size; + } while (size > 0 && offset < len); + return -1; +} + +static int parse_nameseg(u8 *ptr, char **dst) +{ + if (dst && *dst) { + *(dst[0]++) =3D ptr[0]; + if (ptr[1] !=3D '_') + *(dst[0]++) =3D ptr[1]; + if (ptr[2] !=3D '_') + *(dst[0]++) =3D ptr[2]; + if (ptr[3] !=3D '_') + *(dst[0]++) =3D ptr[3]; + *(dst[0]) =3D 0; + } + return 4; +} + +static int parse_namestring(struct parse_state *s, + u8 *ptr, const char *item) +{ + char *dst =3D s->name; + int offset =3D 0; + int i, count; + + for (;;) { + switch (ptr[offset]) { + case 0: /* null name */ + offset++; + *(dst++) =3D 0; + break; + case 0x2e: + offset++; + offset +=3D parse_nameseg(ptr + offset, &dst); + *(dst++) =3D '.'; + offset +=3D parse_nameseg(ptr + offset, &dst); + break; + case 0x2f: + offset++; + count =3D ptr[offset]; + offset++; + for (i =3D 0; i < count; i++) { + if (i) + *(dst++) =3D '.'; + offset +=3D parse_nameseg(ptr + offset, &dst); + } + break; + case '\\': + *(dst++) =3D '\\'; + offset++; + continue; + case '^': + *(dst++) =3D '^'; + offset++; + continue; + case 'A' ... 'Z': + case '_': + offset +=3D parse_nameseg(ptr, &dst); + break; + default: + hex(ptr, 16, 3, __func__); + s->error =3D 1; + break; + } + break; + } + dprintf(5, "%s: %d %s '%s'\n", __func__, s->depth, + item, s->name); + return offset; +} + +static int parse_termarg_int(u8 *ptr, int *error, u64 *dst) +{ + u64 value; + int offset =3D 1; + + switch (ptr[0]) { + case 0x00: /* zero */ + value =3D 0; + break; + case 0x01: /* one */ + value =3D 1; + break; + case 0x0a: /* byte prefix */ + value =3D ptr[1]; + offset++; + break; + case 0x0b: /* word prefix */ + value =3D ptr[1] | + ((unsigned long)ptr[2] << 8); + offset +=3D 2; + break; + case 0x0c: /* dword prefix */ + value =3D ptr[1] | + ((unsigned long)ptr[2] << 8) | + ((unsigned long)ptr[3] << 16) | + ((unsigned long)ptr[4] << 24); + offset +=3D 4; + break; + default: + value =3D 0; + hex(ptr, 16, 3, __func__); + if (error) + *error =3D 1; + break; + } + + if (dst) + *dst =3D value; + dprintf(5, "%s: 0x%llx\n", __func__, value); + return offset; +} + +static int parse_pkglength(u8 *ptr, int *pkglength) +{ + int offset =3D 2; + + *pkglength =3D 0; + switch (ptr[0] >> 6) { + case 3: + *pkglength |=3D ptr[3] << 20; + offset++; + case 2: + *pkglength |=3D ptr[2] << 12; + offset++; + case 1: + *pkglength |=3D ptr[1] << 4; + *pkglength |=3D ptr[0] & 0x0f; + return offset; + case 0: + default: + *pkglength |=3D ptr[0] & 0x3f; + return 1; + } +} + +static int parse_pkg_common(struct parse_state *s, + u8 *ptr, const char *item, int *pkglength) +{ + int offset; + + offset =3D parse_pkglength(ptr, pkglength); + offset +=3D parse_namestring(s, ptr + offset, item); + return offset; +} + +static int parse_pkg_scope(struct parse_state *s, + u8 *ptr) +{ + int offset, pkglength; + + offset =3D parse_pkg_common(s, ptr, "scope", &pkglength); + parse_termlist(s, ptr, offset, pkglength); + return pkglength; +} + +static int parse_pkg_device(struct parse_state *s, + u8 *ptr) +{ + int offset, pkglength; + + offset =3D parse_pkg_common(s, ptr, "device", &pkglength); + + s->dev =3D malloc_tmp(sizeof(struct acpi_device)); + if (!s->dev) { + warn_noalloc(); + s->error =3D 1; + return pkglength; + } + + memset(s->dev, 0, sizeof(struct acpi_device)); + hlist_add_head(&s->dev->node, &acpi_devices); + strtcpy(s->dev->name, s->name, sizeof(s->name)); + parse_termlist(s, ptr, offset, pkglength); + s->dev =3D NULL; + + return pkglength; +} + +static int parse_pkg_buffer(struct parse_state *s, + u8 *ptr) +{ + u64 blen; + int pkglength, offset; + + offset =3D parse_pkglength(ptr, &pkglength); + offset +=3D parse_termarg_int(ptr + offset, &s->error, &blen); + if (s->dev && strcmp(s->name, "_CRS") =3D=3D 0) { + s->dev->crs_data =3D ptr + offset; + s->dev->crs_size =3D blen; + } + return pkglength; +} + +static int parse_pkg_skip(struct parse_state *s, + u8 *ptr, int op, int name) +{ + int pkglength, offset; + char item[8]; + + snprintf(item, sizeof(item), "op %x", op); + offset =3D parse_pkglength(ptr, &pkglength); + if (name) { + parse_namestring(s, ptr + offset, item); + } else { + dprintf(5, "%s: %s (%d)\n", __func__, item, pkglength); + } + return pkglength; +} + +static int parse_termobj(struct parse_state *s, + u8 *ptr) +{ + int offset =3D 1; + + if (s->depth =3D=3D 16) { + dprintf(1, "%s: deep recursion\n", __func__); + s->error =3D 1; + return offset; + } + + s->depth++; + switch (ptr[0]) { + case 0x00: /* zero */ + break; + case 0x01: /* one */ + break; + case 0x08: /* name op */ + offset +=3D parse_namestring(s, ptr + offset, "name"); + offset +=3D parse_termobj(s, ptr + offset); + if (s->dev && strcmp(s->name, "_HID") =3D=3D 0) + s->dev->hid_aml =3D ptr; + if (s->dev && strcmp(s->name, "_STA") =3D=3D 0) + s->dev->sta_aml =3D ptr; + break; + case 0x0a: /* byte prefix */ + offset++; + break; + case 0x0b: /* word prefix */ + offset +=3D 2; + break; + case 0x0c: /* dword prefix */ + offset +=3D 4; + break; + case 0x0d: /* string prefix */ + while (ptr[offset]) + offset++; + offset++; + break; + case 0x10: /* scope op */ + offset +=3D parse_pkg_scope(s, ptr + offset); + break; + case 0x11: /* buffer op */ + offset +=3D parse_pkg_buffer(s, ptr + offset); + break; + case 0x12: /* package op */ + case 0x13: /* var package op */ + offset +=3D parse_pkg_skip(s, ptr + offset, ptr[0], 0); + break; + case 0x14: /* method op */ + offset +=3D parse_pkg_skip(s, ptr + offset, ptr[0], 1); + if (s->dev && strcmp(s->name, "_STA") =3D=3D 0) + s->dev->sta_aml =3D ptr; + break; + case 0x5b: /* ext op prefix */ + offset++; + switch (ptr[1]) { + case 0x01: /* mutex op */ + offset +=3D parse_namestring(s, ptr + offset, "mutex"); + offset++; /* sync flags */ + break; + case 0x80: /* op region op */ + offset +=3D parse_namestring(s, ptr + offset, "op region"); + offset++; /* region space */ + offset +=3D parse_termarg_int(ptr + offset, &s->error, NULL); + offset +=3D parse_termarg_int(ptr + offset, &s->error, NULL); + break; + case 0x81: /* field op */ + case 0x83: /* processor op */ + case 0x84: /* power resource op */ + case 0x85: /* thermal zone op */ + offset +=3D parse_pkg_skip(s, ptr + offset, 0x5b00 | ptr[1], 1= ); + break; + case 0x82: /* device op */ + offset +=3D parse_pkg_device(s, ptr + offset); + break; + default: + hex(ptr, 16, 3, __func__); + s->error =3D 1; + break; + } + break; + default: + hex(ptr, 16, 3, __func__); + s->error =3D 1; + break; + } + s->depth--; + + return offset; +} + +static void parse_termlist(struct parse_state *s, + u8 *ptr, int offset, int pkglength) +{ + for (;;) { + offset +=3D parse_termobj(s, ptr + offset); + if (offset =3D=3D pkglength) + return; + if (offset > pkglength) { + dprintf(1, "%s: overrun: %d/%d\n", __func__, + offset, pkglength); + s->error =3D 1; + return; + } + if (s->error) { + dprintf(1, "%s: parse error, skip from %d/%d\n", __func__, + offset, pkglength); + s->error =3D 0; + return; + } + } +} + +static struct acpi_device *acpi_dsdt_find(struct acpi_device *prev, + const u8 *aml, int size) +{ + struct acpi_device *dev; + struct hlist_node *node; + + if (!prev) + node =3D acpi_devices.first; + else + node =3D prev->node.next; + + for (; node !=3D NULL; node =3D dev->node.next) { + dev =3D container_of(node, struct acpi_device, node); + if (!aml) + return dev; + if (!dev->hid_aml) + continue; + if (memcmp(dev->hid_aml + 5, aml, size) =3D=3D 0) + return dev; + } + return NULL; +} + +static int acpi_dsdt_present(struct acpi_device *dev) +{ + if (!dev) + return 0; /* no */ + if (!dev->sta_aml) + return 1; /* yes */ + if (dev->sta_aml[0] =3D=3D 0x14) + return -1; /* unknown (can't evaluate method) */ + if (dev->sta_aml[0] =3D=3D 0x08) { + u64 value =3D 0; + parse_termarg_int(dev->sta_aml + 5, NULL, &value); + if (value =3D=3D 0) + return 0; /* no */ + else + return 1; /* yes */ + } + return -1; /* unknown (should not happen) */ +} + +/**************************************************************** + * DSDT parser, public interface + ****************************************************************/ + +struct acpi_device *acpi_dsdt_find_string(struct acpi_device *prev, + const char *hid) +{ + if (!CONFIG_ACPI_PARSE) + return NULL; + + u8 aml[10]; + int len =3D snprintf((char*)aml, sizeof(aml), "\x0d%s", hid); + return acpi_dsdt_find(prev, aml, len); +} + +struct acpi_device *acpi_dsdt_find_eisaid(struct acpi_device *prev, u16 ei= said) +{ + if (!CONFIG_ACPI_PARSE) + return NULL; + u8 aml[] =3D { + 0x0c, 0x41, 0xd0, + eisaid >> 8, + eisaid & 0xff + }; + return acpi_dsdt_find(prev, aml, 5); +} + +char *acpi_dsdt_name(struct acpi_device *dev) +{ + if (!CONFIG_ACPI_PARSE || !dev) + return NULL; + return dev->name; +} + +int acpi_dsdt_find_io(struct acpi_device *dev, u64 *min, u64 *max) +{ + if (!CONFIG_ACPI_PARSE || !dev || !dev->crs_data) + return -1; + return find_resource(dev->crs_data, dev->crs_size, + 1 /* I/O */, min, max); +} + +int acpi_dsdt_find_mem(struct acpi_device *dev, u64 *min, u64 *max) +{ + if (!CONFIG_ACPI_PARSE || !dev || !dev->crs_data) + return -1; + return find_resource(dev->crs_data, dev->crs_size, + 0 /* mem */, min, max); +} + +int acpi_dsdt_find_irq(struct acpi_device *dev, u64 *irq) +{ + u64 max; + if (!CONFIG_ACPI_PARSE || !dev || !dev->crs_data) + return -1; + return find_resource(dev->crs_data, dev->crs_size, + 3 /* irq */, irq, &max); +} + +int acpi_dsdt_present_eisaid(u16 eisaid) +{ + if (!CONFIG_ACPI_PARSE) + return -1; /* unknown */ + if (hlist_empty(&acpi_devices)) + return -1; /* unknown (no dsdt table) */ + + struct acpi_device *dev =3D acpi_dsdt_find_eisaid(NULL, eisaid); + return acpi_dsdt_present(dev); +} + +void acpi_dsdt_parse(void) +{ + if (!CONFIG_ACPI_PARSE) + return; + + struct fadt_descriptor_rev1 *fadt =3D find_acpi_table(FACP_SIGNATURE); + if (!fadt) + return; + u8 *dsdt =3D (void*)(fadt->dsdt); + if (!dsdt) + return; + + u32 length =3D *(u32*)(dsdt + 4); + u32 offset =3D 0x24; + dprintf(1, "ACPI: parse DSDT at %p (len %d)\n", dsdt, length); + + struct parse_state s; + memset(&s, 0, sizeof(s)); + parse_termlist(&s, dsdt, offset, length); + + if (!parse_dumpdevs) + return; + + struct acpi_device *dev; + dprintf(1, "ACPI: dumping dsdt devices\n"); + for (dev =3D acpi_dsdt_find(NULL, NULL, 0); + dev !=3D NULL; + dev =3D acpi_dsdt_find(dev, NULL, 0)) { + dprintf(1, " %s", acpi_dsdt_name(dev)); + if (dev->hid_aml) + dprintf(1, ", hid"); + if (dev->sta_aml) + dprintf(1, ", sta (0x%x)", dev->sta_aml[0]); + if (dev->crs_data) + dprintf(1, ", crs"); + dprintf(1, "\n"); + if (dev->crs_data) + print_resources(" ", dev->crs_data, dev->crs_size); + } +} diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 119280c574fd..9247288a28c3 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -233,9 +233,10 @@ qemu_platform_setup(void) =20 RsdpAddr =3D find_acpi_rsdp(); =20 - if (RsdpAddr) + if (RsdpAddr) { + acpi_dsdt_parse(); return; - + } /* If present, loader should have installed an RSDP. * Not installed? We might still be able to continue * using the builtin RSDP. diff --git a/src/Kconfig b/src/Kconfig index 6606ce4d46c9..3a8ffa15fded 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -524,6 +524,13 @@ menu "BIOS Tables" This option can be disabled for QEMU 1.6 and older to save some space in the ROM file. If unsure, say Y. + config ACPI_PARSE + bool "Include ACPI DSDT parser." + default y + help + Support parsing ACPI DSDT for device probing. + Needed to find virtio-mmio devices. + If unsure, say Y. endmenu =20 source vgasrc/Kconfig --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Sat Apr 27 02:39:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588168039; cv=none; d=zohomail.com; s=zohoarc; b=IQak/pD7OAMV3YBmo03fMYaNvxIh3NKKjolXGzYgc3kLj70XCR5FZNKQJTbSaBpi5Y7Cl4n9lVXsGT3jlt4ZiQjrCwEbYQaM4clFPyrdnyeNqtNZDHk6l6W4O2+2LFxqtcPmhD0tqNkFWtMK7HEeEzPssTCrc7a8yLF+ugQLTgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588168039; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=HGdnkM17HL9uaCtrakhAYhMPEz8tSMrXplJ+zuuUge4=; b=BlJxMGZP6wBCDDArMRpCphLsidgQPLH8memcf9ehUm+rjEHeB6KOA3+INjNVPiNusYAhDYKCe4Nkgv/ZlYIPSVF0qBXjKPpBJkjTDo3xQ+oDd7cwEqTLbD2mLj19UcSyy+7N/GgxifKsl2aFvPasinfQCzSqFBIRQg5z6smZZXQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1588168039293771.6058795095751; Wed, 29 Apr 2020 06:47:19 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 83FF010C1951; Wed, 29 Apr 2020 13:47:15 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 9202A10C1955 for ; Wed, 29 Apr 2020 13:47:01 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-mv3LQlE7MxaxlrT3R7bQHw-1; Wed, 29 Apr 2020 09:46:58 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7F01835B8C for ; Wed, 29 Apr 2020 13:46:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id 953655C1BE; Wed, 29 Apr 2020 13:46:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 29F699DA1; Wed, 29 Apr 2020 15:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5wcnUNBZABa0/rohONyzEk4ZrPmX9TlkuAzzfKGIgAg=; b=I7VcwYcGmpziKRIrrGcss0Y87NpqWvKntpF6irB2OW4y9brkkVNukuLzC/QIsEs8qq5nM0 e5RzLXewAzm1C66u5/Sf/JKshv5SeKHTAvi3NpBzMNAsCdicaLyhe1ftoX1+wqUDbDmZSn Hc7AgeE8kY3kiblYQqpVYTCFiAltcBw= X-MC-Unique: mv3LQlE7MxaxlrT3R7bQHw-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 29 Apr 2020 15:46:42 +0200 Message-Id: <20200429134643.2001-9-kraxel@redhat.com> In-Reply-To: <20200429134643.2001-1-kraxel@redhat.com> References: <20200429134643.2001-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 6F3Y3G2QF2EKYXEI4UIWHN6IZXOF5B7B X-Message-ID-Hash: 6F3Y3G2QF2EKYXEI4UIWHN6IZXOF5B7B X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v3 8/9] acpi: skip kbd init if not present List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Don't initialize the ps/2 keyboard in case the device is not listed in the ACPi DSDT table. Signed-off-by: Gerd Hoffmann --- src/hw/ps2port.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hw/ps2port.c b/src/hw/ps2port.c index 2c334c06b7eb..c82521b42e16 100644 --- a/src/hw/ps2port.c +++ b/src/hw/ps2port.c @@ -542,6 +542,10 @@ ps2port_setup(void) ASSERT32FLAT(); if (! CONFIG_PS2PORT) return; + if (acpi_dsdt_present_eisaid(0x0303) =3D=3D 0) { + dprintf(1, "ACPI: no PS/2 keyboard present\n"); + return; + } dprintf(3, "init ps2port\n"); =20 enable_hwirq(1, FUNC16(entry_09)); --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Sat Apr 27 02:39:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588168416; cv=none; d=zohomail.com; s=zohoarc; b=hHDNNMv4yian0Zw/prgA4KUeIcz3UB3j214W2tKl6jAc6FuyaTQbOB3s3/VIueFGghm7WH9uPXaTIZQ/XhZ70FhfYl0BIfPFQwR7zMQjdex3N0fkka2Lr//790Kih6RMK3eTf6HrVu1qDxdGFrk2sWLdQSw1fHe1s6u70vXcCko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588168416; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=KvC1ZtFcv65UWpi4buuxuRz2D5pIAXgoGqgVAAaXrik=; b=WZSILpIsNDVgvjzIZZKeRovHhazDO2eZ4dHTlYKvCyYglROQjHM02w0QrE05yjczmapALzaOGwGJufBw8CvmkMQV/a8CQya2FRisk3UV2N/0IbCAYIwwd/s4xpQPwruDx3CLT18bhnpkTX571ZOqKB+NiOz+766pB2QiZ0DGIEU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1588168416331138.1478026467894; Wed, 29 Apr 2020 06:53:36 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id AC63510C195E; Wed, 29 Apr 2020 13:53:32 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 4F6CA10C1954 for ; Wed, 29 Apr 2020 13:53:08 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-121-weQ_VCgNMOum9d4iLvThBg-1; Wed, 29 Apr 2020 09:46:59 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 175711895A2C for ; Wed, 29 Apr 2020 13:46:58 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8B005C221; Wed, 29 Apr 2020 13:46:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 2C75F9DA2; Wed, 29 Apr 2020 15:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cbPoJuA3NkvZHGUElZUzbW5N5JE/kVRmUzCGboPqtjg=; b=cTnvgziF/4OAGhAlb3srkoEhsn4Jut9zJDjZipqN8bHSLZaM7HED8xffEbIcRI3hXsDac4 LvbXNoLjqoQnbcEcLee/gWAj90st92ZZXNfPi7d1GvjeVer6+2O5kbditmtNoIl0fg4dsq B8p+0SwnZa5Z44KWyqWR5x10NGAUCfQ= X-MC-Unique: weQ_VCgNMOum9d4iLvThBg-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 29 Apr 2020 15:46:43 +0200 Message-Id: <20200429134643.2001-10-kraxel@redhat.com> In-Reply-To: <20200429134643.2001-1-kraxel@redhat.com> References: <20200429134643.2001-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: CSJTBIHPDTIYHHERPUROOCEBNEHAQXCM X-Message-ID-Hash: CSJTBIHPDTIYHHERPUROOCEBNEHAQXCM X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v3 9/9] acpi: find and register virtio-mmio devices List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Seach for virtio-mmio devices in the DSDT table, register the devices found. Signed-off-by: Gerd Hoffmann --- src/hw/virtio-mmio.h | 1 + src/fw/paravirt.c | 2 ++ src/hw/virtio-mmio.c | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/hw/virtio-mmio.h b/src/hw/virtio-mmio.h index 9e0dae421009..69fbd23c3101 100644 --- a/src/hw/virtio-mmio.h +++ b/src/hw/virtio-mmio.h @@ -70,6 +70,7 @@ typedef struct virtio_mmio_cfg { u32 config_generation; } virtio_mmio_cfg; =20 +void virtio_mmio_setup_acpi(void); void virtio_mmio_setup_one(u64 mmio); void vp_init_mmio(struct vp_device *vp, void *mmio); =20 diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 9247288a28c3..e446569345c1 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -16,6 +16,7 @@ #include "hw/pci_regs.h" // PCI_DEVICE_ID #include "hw/serialio.h" // PORT_SERIAL1 #include "hw/rtc.h" // CMOS_* +#include "hw/virtio-mmio.h" // virtio_mmio_acpi #include "malloc.h" // malloc_tmp #include "output.h" // dprintf #include "paravirt.h" // qemu_cfg_preinit @@ -235,6 +236,7 @@ qemu_platform_setup(void) =20 if (RsdpAddr) { acpi_dsdt_parse(); + virtio_mmio_setup_acpi(); return; } /* If present, loader should have installed an RSDP. diff --git a/src/hw/virtio-mmio.c b/src/hw/virtio-mmio.c index dabef7b7e53a..44344a4993f4 100644 --- a/src/hw/virtio-mmio.c +++ b/src/hw/virtio-mmio.c @@ -3,12 +3,32 @@ #include "output.h" // dprintf #include "stacks.h" // run_thread #include "string.h" // memset +#include "util.h" // acpi_dsdt_* #include "virtio-pci.h" #include "virtio-blk.h" #include "virtio-scsi.h" #include "virtio-ring.h" #include "virtio-mmio.h" =20 +void virtio_mmio_setup_acpi(void) +{ + static const char *virtio_hid =3D "LNRO0005"; + struct acpi_device *dev; + u64 mem, irq, unused; + + for (dev =3D acpi_dsdt_find_string(NULL, virtio_hid); + dev !=3D NULL; + dev =3D acpi_dsdt_find_string(dev, virtio_hid)) { + if (acpi_dsdt_find_mem(dev, &mem, &unused) < 0) + continue; + if (acpi_dsdt_find_irq(dev, &irq) < 0) + continue; + dprintf(1, "ACPI: virtio-mmio device %s at 0x%llx, irq %lld\n", + acpi_dsdt_name(dev), mem, irq); + virtio_mmio_setup_one(mem); + } +} + void virtio_mmio_setup_one(u64 addr) { static const char *names[] =3D { --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org