On 27/01/2026 17.15, [email protected] wrote:
From: Jared Rossi <[email protected]>
Define common functionality for interacting with virtio-pci devices.
Signed-off-by: Jared Rossi <[email protected]>
---
...
+/* virtio spec v1.3 section 4.1.2.1 */
+void virtio_pci_id2type(VDev *vdev, uint16_t device_id)
+{
+ switch (device_id) {
+ case 0x1001:
When using modern-only mode for a virtio-block device ("-device
virtio-blk-pci,disable-legacy=on,..."), the virtio-block device should come
up with a different device ID, I think it's 0x1042 ... shouldn't this get
added here, too?
+/*
+ * Wrappers to byte swap common data sizes then write
+ */
+int vpci_write_byte(uint64_t offset, uint8_t pcias, uint8_t data)
+{
+ return pci_write(virtio_get_device()->pci_fh, offset, pcias, (uint64_t)
data, 1);
+}
I'm a little bit torn ... would it be nicer to have a "VDev *vdev" as a
parameter for these functions, so we don't have this hidden state via
virtio_get_device() here? ... OTOH, that makes the calling functions a
little bit more clunky ... does anybody else got an opinion on this?
Thomas