From nobody Wed Nov 19 08:46:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.49 as permitted sender) client-ip=209.85.208.49; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f49.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1615316897; cv=none; d=zohomail.com; s=zohoarc; b=e88JoxdpS/sHoCyD4p6JR22VuQqm2mEj+0ImKr3YmCR+sb5tSOZcIaiYbBv9kt300dPpknw16E3/8BmHAJ+2FyqEfwm2081qoPzHg7xTAIS75n2BkN5RRBR6JiMyBg4IIINQeF8ZtHd8+4C7pLQWEHHs93P6sTsWsC3y1fRvHxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615316897; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8d+eN5pLgED+uqQ3pUk7CcgP+iDLiwuObCJhPjjUbm4=; b=d34dDz0Wp+uj8eg8RvG8/RlKHTlV+oJwy8iGAUs9Lc2fab+VS6F/Ohm/MP1ZSgaeIE1CITZJbfdgSjwbywc3VvO8fJgDoAE4RKpXtTc446J6KoyZfzcNQUuV/zH4OOuxg64SCROKQyaJQSINU4QtdtxAPztkxovUY3Kh7MBr9aY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mx.zohomail.com with SMTPS id 1615316897976600.4456594368613; Tue, 9 Mar 2021 11:08:17 -0800 (PST) Received: by mail-ed1-f49.google.com with SMTP id d13so22544646edp.4 for ; Tue, 09 Mar 2021 11:08:17 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id cb17sm9754784edb.10.2021.03.09.11.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 11:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8d+eN5pLgED+uqQ3pUk7CcgP+iDLiwuObCJhPjjUbm4=; b=WnJomdkMzB/mzeeMwmKHfuFq8bg08VOaEoI7AdNDlB6kbLhdLCf38t0rZjHPNQUwuv kBmHcZH1QtTsFCcqB4w2ArVxxNa2fhc7O5aRPihzK3OVKjccrnM1sulrvp8RYd5W/Pae eFN8jCyqW0hUqEWrE3ErMz0YDoAhREMuOfK+GzDZbWp2sh9WAHy2/omcXHzlixoKMX9l DsUhzLUWZlCb60gvVGFbQNdQkLuBQdaDtFOeEzYvqMEd+C624Edhu/tIKrOJ3RJT5YdY RL+aEhcI1MUizFLWkxEbCKvTC40lI3ez6qnBEq5wrsXARd63ol97uN3zhH7dd/FYQrAY Ik/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=8d+eN5pLgED+uqQ3pUk7CcgP+iDLiwuObCJhPjjUbm4=; b=cf0ikqHsLcoVFOH96fThfZ2PBTplbbbrGLNou0JhL4ZwdZTkz4QGCxFdK6a17bzJx0 pUkghkBkXL2RiU2o5Sw5Lq69mZAwz8Vt2rKCBUWA+wXtRrjHYrpCAi7rbp4USkSJ01eZ zXgdOV4o3tfrsKkCdDbXhWFpPGRPIbSNsyG0ksWiv3lBIerykhFE8MBEF4E947exUz1m l5MV87pkwyYdoK0OgppLfIOzg+1YODOtwfwNqp1F4XmQf16WFYyqYjeyRcpWwTbfwFul QwNwyVWaWr//tSVksXWgrmH3GjB6T8UQmkpL9HI8cPSFlmQYvwq3iolsVQKXii5FffdZ Zgeg== X-Gm-Message-State: AOAM532mqiW6sZkrKUd0YQc78UGzFhlkMQoP+tSc+LUMyPFDlfS3hwuC H7WWCg4+K3uOKlBjDOkTj0g= X-Google-Smtp-Source: ABdhPJxUW2RkLWjHUP2PwSclq/EFESGJi9Im/qRwp+XO9jVAZGi6+nKgFTJG8UGS5//tV2zGbPDbbA== X-Received: by 2002:a05:6402:484:: with SMTP id k4mr5810888edv.321.1615316896217; Tue, 09 Mar 2021 11:08:16 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jiaxun Yang , David Gibson , Huacai Chen , "Dr . David Alan Gilbert" , Gerd Hoffmann Subject: [PATCH 2/3] hw/usb/hcd-uhci: Expose generic prototypes to local header Date: Tue, 9 Mar 2021 20:08:01 +0100 Message-Id: <20210309190802.830969-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210309190802.830969-1-f4bug@amsat.org> References: <20210309190802.830969-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Extract generic UHCI prototypes into a new "hcd-uhci.h" local header so we can reuse them in other units. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/usb/hcd-uhci.h | 93 +++++++++++++++++++++++++++++++++++++++++++++++ hw/usb/hcd-uhci.c | 60 ++---------------------------- 2 files changed, 96 insertions(+), 57 deletions(-) create mode 100644 hw/usb/hcd-uhci.h diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h new file mode 100644 index 00000000000..e61d8fcb192 --- /dev/null +++ b/hw/usb/hcd-uhci.h @@ -0,0 +1,93 @@ +/* + * USB UHCI controller emulation + * + * Copyright (c) 2005 Fabrice Bellard + * + * Copyright (c) 2008 Max Krasnyansky + * Magor rewrite of the UHCI data structures parser and frame processor + * Support for fully async operation and multiple outstanding transact= ions + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#ifndef HW_USB_HCD_UHCI_H +#define HW_USB_HCD_UHCI_H + +#include "exec/memory.h" +#include "qemu/timer.h" +#include "hw/pci/pci.h" +#include "hw/usb.h" + +typedef struct UHCIQueue UHCIQueue; + +#define NB_PORTS 2 + +typedef struct UHCIPort { + USBPort port; + uint16_t ctrl; +} UHCIPort; + +typedef struct UHCIState { + PCIDevice dev; + MemoryRegion io_bar; + USBBus bus; /* Note unused when we're a companion controller */ + uint16_t cmd; /* cmd register */ + uint16_t status; + uint16_t intr; /* interrupt enable register */ + uint16_t frnum; /* frame number */ + uint32_t fl_base_addr; /* frame list base address */ + uint8_t sof_timing; + uint8_t status2; /* bit 0 and 1 are used to generate UHCI_STS_USBINT */ + int64_t expire_time; + QEMUTimer *frame_timer; + QEMUBH *bh; + uint32_t frame_bytes; + uint32_t frame_bandwidth; + bool completions_only; + UHCIPort ports[NB_PORTS]; + + /* Interrupts that should be raised at the end of the current frame. = */ + uint32_t pending_int_mask; + + /* Active packets */ + QTAILQ_HEAD(, UHCIQueue) queues; + uint8_t num_ports_vmstate; + + /* Properties */ + char *masterbus; + uint32_t firstport; + uint32_t maxframes; +} UHCIState; + +#define TYPE_UHCI "pci-uhci-usb" +DECLARE_INSTANCE_CHECKER(UHCIState, UHCI, TYPE_UHCI) + +typedef struct UHCIInfo { + const char *name; + uint16_t vendor_id; + uint16_t device_id; + uint8_t revision; + uint8_t irq_pin; + void (*realize)(PCIDevice *dev, Error **errp); + bool unplug; +} UHCIInfo; + +void uhci_data_class_init(ObjectClass *klass, void *data); +void usb_uhci_common_realize(PCIDevice *dev, Error **errp); + +#endif diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 5969eb86b31..d6338c33d86 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -40,6 +40,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qom/object.h" +#include "hcd-uhci.h" =20 #define FRAME_TIMER_FREQ 1000 =20 @@ -50,8 +51,6 @@ =20 #define MAX_FRAMES_PER_TICK (QH_VALID / 2) =20 -#define NB_PORTS 2 - enum { TD_RESULT_STOP_FRAME =3D 10, TD_RESULT_COMPLETE, @@ -62,20 +61,8 @@ enum { =20 typedef struct UHCIState UHCIState; typedef struct UHCIAsync UHCIAsync; -typedef struct UHCIQueue UHCIQueue; -typedef struct UHCIInfo UHCIInfo; typedef struct UHCIPCIDeviceClass UHCIPCIDeviceClass; =20 -struct UHCIInfo { - const char *name; - uint16_t vendor_id; - uint16_t device_id; - uint8_t revision; - uint8_t irq_pin; - void (*realize)(PCIDevice *dev, Error **errp); - bool unplug; -}; - struct UHCIPCIDeviceClass { PCIDeviceClass parent_class; UHCIInfo info; @@ -107,43 +94,6 @@ struct UHCIQueue { int8_t valid; }; =20 -typedef struct UHCIPort { - USBPort port; - uint16_t ctrl; -} UHCIPort; - -struct UHCIState { - PCIDevice dev; - MemoryRegion io_bar; - USBBus bus; /* Note unused when we're a companion controller */ - uint16_t cmd; /* cmd register */ - uint16_t status; - uint16_t intr; /* interrupt enable register */ - uint16_t frnum; /* frame number */ - uint32_t fl_base_addr; /* frame list base address */ - uint8_t sof_timing; - uint8_t status2; /* bit 0 and 1 are used to generate UHCI_STS_USBINT */ - int64_t expire_time; - QEMUTimer *frame_timer; - QEMUBH *bh; - uint32_t frame_bytes; - uint32_t frame_bandwidth; - bool completions_only; - UHCIPort ports[NB_PORTS]; - - /* Interrupts that should be raised at the end of the current frame. = */ - uint32_t pending_int_mask; - - /* Active packets */ - QTAILQ_HEAD(, UHCIQueue) queues; - uint8_t num_ports_vmstate; - - /* Properties */ - char *masterbus; - uint32_t firstport; - uint32_t maxframes; -}; - typedef struct UHCI_TD { uint32_t link; uint32_t ctrl; /* see TD_CTRL_xxx */ @@ -160,10 +110,6 @@ static void uhci_async_cancel(UHCIAsync *async); static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td); static void uhci_resume(void *opaque); =20 -#define TYPE_UHCI "pci-uhci-usb" -DECLARE_INSTANCE_CHECKER(UHCIState, UHCI, - TYPE_UHCI) - static inline int32_t uhci_queue_token(UHCI_TD *td) { if ((td->token & (0xf << 15)) =3D=3D 0) { @@ -1213,7 +1159,7 @@ static USBPortOps uhci_port_ops =3D { static USBBusOps uhci_bus_ops =3D { }; =20 -static void usb_uhci_common_realize(PCIDevice *dev, Error **errp) +void usb_uhci_common_realize(PCIDevice *dev, Error **errp) { Error *err =3D NULL; PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(dev); @@ -1335,7 +1281,7 @@ static const TypeInfo uhci_pci_type_info =3D { }, }; =20 -static void uhci_data_class_init(ObjectClass *klass, void *data) +void uhci_data_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); DeviceClass *dc =3D DEVICE_CLASS(klass); --=20 2.26.2