]>
git.proxmox.com Git - mirror_qemu.git/blob - hw/virtio/virtio-config-io.c
4 * Copyright IBM, Corp. 2007
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "qemu/osdep.h"
13 #include "hw/virtio/virtio.h"
16 uint32_t virtio_config_readb(VirtIODevice
*vdev
, uint32_t addr
)
18 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
21 if (addr
+ sizeof(val
) > vdev
->config_len
) {
25 k
->get_config(vdev
, vdev
->config
);
27 val
= ldub_p(vdev
->config
+ addr
);
31 uint32_t virtio_config_readw(VirtIODevice
*vdev
, uint32_t addr
)
33 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
36 if (addr
+ sizeof(val
) > vdev
->config_len
) {
40 k
->get_config(vdev
, vdev
->config
);
42 val
= lduw_p(vdev
->config
+ addr
);
46 uint32_t virtio_config_readl(VirtIODevice
*vdev
, uint32_t addr
)
48 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
51 if (addr
+ sizeof(val
) > vdev
->config_len
) {
55 k
->get_config(vdev
, vdev
->config
);
57 val
= ldl_p(vdev
->config
+ addr
);
61 void virtio_config_writeb(VirtIODevice
*vdev
, uint32_t addr
, uint32_t data
)
63 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
66 if (addr
+ sizeof(val
) > vdev
->config_len
) {
70 stb_p(vdev
->config
+ addr
, val
);
73 k
->set_config(vdev
, vdev
->config
);
77 void virtio_config_writew(VirtIODevice
*vdev
, uint32_t addr
, uint32_t data
)
79 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
82 if (addr
+ sizeof(val
) > vdev
->config_len
) {
86 stw_p(vdev
->config
+ addr
, val
);
89 k
->set_config(vdev
, vdev
->config
);
93 void virtio_config_writel(VirtIODevice
*vdev
, uint32_t addr
, uint32_t data
)
95 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
98 if (addr
+ sizeof(val
) > vdev
->config_len
) {
102 stl_p(vdev
->config
+ addr
, val
);
105 k
->set_config(vdev
, vdev
->config
);
109 uint32_t virtio_config_modern_readb(VirtIODevice
*vdev
, uint32_t addr
)
111 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
114 if (addr
+ sizeof(val
) > vdev
->config_len
) {
118 k
->get_config(vdev
, vdev
->config
);
120 val
= ldub_p(vdev
->config
+ addr
);
124 uint32_t virtio_config_modern_readw(VirtIODevice
*vdev
, uint32_t addr
)
126 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
129 if (addr
+ sizeof(val
) > vdev
->config_len
) {
133 k
->get_config(vdev
, vdev
->config
);
135 val
= lduw_le_p(vdev
->config
+ addr
);
139 uint32_t virtio_config_modern_readl(VirtIODevice
*vdev
, uint32_t addr
)
141 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
144 if (addr
+ sizeof(val
) > vdev
->config_len
) {
148 k
->get_config(vdev
, vdev
->config
);
150 val
= ldl_le_p(vdev
->config
+ addr
);
154 void virtio_config_modern_writeb(VirtIODevice
*vdev
,
155 uint32_t addr
, uint32_t data
)
157 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
160 if (addr
+ sizeof(val
) > vdev
->config_len
) {
164 stb_p(vdev
->config
+ addr
, val
);
167 k
->set_config(vdev
, vdev
->config
);
171 void virtio_config_modern_writew(VirtIODevice
*vdev
,
172 uint32_t addr
, uint32_t data
)
174 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
177 if (addr
+ sizeof(val
) > vdev
->config_len
) {
181 stw_le_p(vdev
->config
+ addr
, val
);
184 k
->set_config(vdev
, vdev
->config
);
188 void virtio_config_modern_writel(VirtIODevice
*vdev
,
189 uint32_t addr
, uint32_t data
)
191 VirtioDeviceClass
*k
= VIRTIO_DEVICE_GET_CLASS(vdev
);
194 if (addr
+ sizeof(val
) > vdev
->config_len
) {
198 stl_le_p(vdev
->config
+ addr
, val
);
201 k
->set_config(vdev
, vdev
->config
);