1
0

virtio_mmio.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-9-16 GuEe-GUI the first version
  9. * 2021-11-11 GuEe-GUI modify to virtio common interface
  10. */
  11. #ifndef __VIRTIO_MMIO_H__
  12. #define __VIRTIO_MMIO_H__
  13. #include <rtdef.h>
  14. struct virtio_mmio_config
  15. {
  16. rt_uint32_t magic; /* [0x00]<RO> Magic value */
  17. rt_uint32_t version; /* [0x04]<RO> Device version number */
  18. rt_uint32_t device_id; /* [0x08]<RO> Virtio Subsystem Device ID */
  19. rt_uint32_t vendor_id; /* [0x0c]<RO> Virtio Subsystem Vendor ID */
  20. rt_uint32_t device_features; /* [0x10]<RO> Flags representing features the device supports */
  21. rt_uint32_t device_features_sel; /* [0x14]<WO> Device (host) features word selection. */
  22. rt_uint32_t res0[2]; /* [0x18] */
  23. rt_uint32_t driver_features; /* [0x20]<WO> Device features understood and activated by the driver */
  24. rt_uint32_t driver_features_sel; /* [0x24]<WO> Activated (guest) features word selection */
  25. rt_uint32_t guest_page_size; /* [0x28]<WO> Guest page size, this value should be a power of 2 */
  26. rt_uint32_t res1[1]; /* [0x2c] */
  27. rt_uint32_t queue_sel; /* [0x30]<WO> Virtual queue index */
  28. rt_uint32_t queue_num_max; /* [0x34]<RO> Maximum virtual queue size */
  29. rt_uint32_t queue_num; /* [0x38]<WO> Virtual queue size */
  30. rt_uint32_t queue_align; /* [0x3c]<WO> Used Ring alignment in the virtual queue */
  31. rt_uint32_t queue_pfn; /* [0x40]<RW> Guest physical page number of the virtual queue */
  32. rt_uint32_t queue_ready; /* [0x44]<RW> Virtual queue ready bit */
  33. rt_uint32_t res2[2]; /* [0x48] */
  34. rt_uint32_t queue_notify; /* [0x50]<WO> Queue notifier */
  35. rt_uint32_t res3[3]; /* [0x54] */
  36. rt_uint32_t interrupt_status; /* [0x60]<RO> Interrupt status */
  37. rt_uint32_t interrupt_ack; /* [0x64]<WO> Interrupt acknowledge */
  38. rt_uint32_t res4[2]; /* [0x68] */
  39. rt_uint32_t status; /* [0x70]<RW> Device status */
  40. rt_uint32_t res5[3]; /* [0x74] */
  41. rt_uint32_t queue_desc_low; /* [0x80]<WO> Virtual queue’s Descriptor Area 64 bit long physical address */
  42. rt_uint32_t queue_desc_high; /* [0x84]<WO> */
  43. rt_uint32_t res6[2]; /* [0x88] */
  44. rt_uint32_t queue_driver_low; /* [0x90]<WO> Virtual queue’s Driver Area 64 bit long physical address */
  45. rt_uint32_t queue_driver_high; /* [0x94]<WO> */
  46. rt_uint32_t res7[2]; /* [0x98] */
  47. rt_uint32_t queue_device_low; /* [0xa0]<WO> Virtual queue’s Device Area 64 bit long physical address */
  48. rt_uint32_t queue_device_high; /* [0xa4]<WO> */
  49. rt_uint32_t res8[21]; /* [0xa8] */
  50. rt_uint32_t config_generation; /* [0xfc]<RO> Configuration atomicity value */
  51. rt_uint32_t config[]; /* [0x100+]<RO> Configuration space */
  52. /*
  53. * According to the compiler's optimization ways, we should force compiler not
  54. * to optimization here, but it will cause some compilers generate memory access
  55. * instructions fail. So we allow user to choose a toggle of optimize here.
  56. */
  57. #ifdef RT_USING_VIRTIO_MMIO_ALIGN
  58. } __attribute__((packed));
  59. #else
  60. };
  61. #endif
  62. #endif /* __VIRTIO_MMIO_H__ */