/src/qemu/hw/virtio/vhost-user-rtc-pci.c
Line | Count | Source |
1 | | /* |
2 | | * Vhost-user RTC virtio device PCI glue |
3 | | * |
4 | | * Copyright (c) 2025 Manos Pitsidianakis <manos.pitsidianakis@linaro.org> |
5 | | * Copyright 2026 Panasonic Automotive Systems Co., Ltd. |
6 | | * |
7 | | * SPDX-License-Identifier: GPL-2.0-or-later |
8 | | */ |
9 | | |
10 | | #include "qemu/osdep.h" |
11 | | #include "hw/virtio/vhost-user-rtc.h" |
12 | | #include "hw/virtio/virtio-pci.h" |
13 | | |
14 | | struct VHostUserRTCPCI { |
15 | | VirtIOPCIProxy parent_obj; |
16 | | VHostUserRTC vdev; |
17 | | }; |
18 | | |
19 | | typedef struct VHostUserRTCPCI VHostUserRTCPCI; |
20 | | |
21 | | #define TYPE_VHOST_USER_RTC_PCI "vhost-user-rtc-pci-base" |
22 | | |
23 | | DECLARE_INSTANCE_CHECKER(VHostUserRTCPCI, VHOST_USER_RTC_PCI, |
24 | | TYPE_VHOST_USER_RTC_PCI) |
25 | | |
26 | | static void vhost_user_rtc_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) |
27 | 0 | { |
28 | 0 | VHostUserRTCPCI *dev = VHOST_USER_RTC_PCI(vpci_dev); |
29 | 0 | DeviceState *vdev = DEVICE(&dev->vdev); |
30 | |
|
31 | 0 | vpci_dev->nvectors = 1; |
32 | |
|
33 | 0 | qdev_realize(vdev, BUS(&vpci_dev->bus), errp); |
34 | 0 | } |
35 | | |
36 | | static void vhost_user_rtc_pci_class_init(ObjectClass *klass, const void *data) |
37 | 61 | { |
38 | 61 | DeviceClass *dc = DEVICE_CLASS(klass); |
39 | 61 | VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); |
40 | 61 | PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); |
41 | 61 | k->realize = vhost_user_rtc_pci_realize; |
42 | 61 | set_bit(DEVICE_CATEGORY_MISC, dc->categories); |
43 | 61 | pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; |
44 | 61 | pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */ |
45 | 61 | pcidev_k->revision = 0x00; |
46 | 61 | pcidev_k->class_id = PCI_CLASS_SYSTEM_RTC; |
47 | 61 | } |
48 | | |
49 | | static void vhost_user_rtc_pci_instance_init(Object *obj) |
50 | 0 | { |
51 | 0 | VHostUserRTCPCI *dev = VHOST_USER_RTC_PCI(obj); |
52 | |
|
53 | 0 | virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), |
54 | 0 | TYPE_VHOST_USER_RTC); |
55 | 0 | } |
56 | | |
57 | | static const VirtioPCIDeviceTypeInfo vhost_user_rtc_pci_info = { |
58 | | .base_name = TYPE_VHOST_USER_RTC_PCI, |
59 | | .non_transitional_name = "vhost-user-rtc-pci", |
60 | | .instance_size = sizeof(VHostUserRTCPCI), |
61 | | .instance_init = vhost_user_rtc_pci_instance_init, |
62 | | .class_init = vhost_user_rtc_pci_class_init, |
63 | | }; |
64 | | |
65 | | static void vhost_user_rtc_pci_register(void) |
66 | 61 | { |
67 | 61 | virtio_pci_types_register(&vhost_user_rtc_pci_info); |
68 | 61 | } |
69 | | |
70 | | type_init(vhost_user_rtc_pci_register); |