pci-edu.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Edu PCI device header.
  3. *
  4. * Copyright (C) 2016 Red Hat, Inc.
  5. *
  6. * Authors:
  7. * Peter Xu <peterx@redhat.com>,
  8. *
  9. * This work is licensed under the terms of the GNU LGPL, version 2 or
  10. * later.
  11. *
  12. * Edu device is a virtualized device in QEMU. Please refer to
  13. * docs/specs/edu.txt in QEMU repository for EDU device manual.
  14. */
  15. #ifndef __PCI_EDU_H__
  16. #define __PCI_EDU_H__
  17. #include "pci.h"
  18. #include "asm/io.h"
  19. #define PCI_VENDOR_ID_QEMU 0x1234
  20. #define PCI_DEVICE_ID_EDU 0x11e8
  21. /* The only bar used by EDU device */
  22. #define EDU_BAR 0
  23. #define EDU_MAGIC 0xed
  24. #define EDU_VERSION 0x100
  25. #define EDU_DMA_BUF_SIZE (1 << 20)
  26. #define EDU_INPUT_BUF_SIZE 256
  27. #define EDU_REG_ID 0x0
  28. #define EDU_REG_ALIVE 0x4
  29. #define EDU_REG_FACTORIAL 0x8
  30. #define EDU_REG_STATUS 0x20
  31. #define EDU_REG_INTR_STATUS 0x24
  32. #define EDU_REG_INTR_RAISE 0x60
  33. #define EDU_REG_INTR_ACK 0x64
  34. #define EDU_REG_DMA_SRC 0x80
  35. #define EDU_REG_DMA_DST 0x88
  36. #define EDU_REG_DMA_COUNT 0x90
  37. #define EDU_REG_DMA_CMD 0x98
  38. #define EDU_CMD_DMA_START 0x01
  39. #define EDU_CMD_DMA_FROM 0x02
  40. #define EDU_CMD_DMA_TO 0x00
  41. #define EDU_STATUS_FACTORIAL 0x1
  42. #define EDU_STATUS_INT_ENABLE 0x80
  43. #define EDU_DMA_START 0x40000
  44. #define EDU_DMA_SIZE_MAX 4096
  45. struct pci_edu_dev {
  46. struct pci_dev pci_dev;
  47. volatile void *reg_base;
  48. };
  49. #define edu_reg(d, r) (volatile void *)((d)->reg_base + (r))
  50. static inline uint64_t edu_reg_readq(struct pci_edu_dev *dev, int reg)
  51. {
  52. return __raw_readq(edu_reg(dev, reg));
  53. }
  54. static inline uint32_t edu_reg_readl(struct pci_edu_dev *dev, int reg)
  55. {
  56. return __raw_readl(edu_reg(dev, reg));
  57. }
  58. static inline void edu_reg_writeq(struct pci_edu_dev *dev, int reg,
  59. uint64_t val)
  60. {
  61. __raw_writeq(val, edu_reg(dev, reg));
  62. }
  63. static inline void edu_reg_writel(struct pci_edu_dev *dev, int reg,
  64. uint32_t val)
  65. {
  66. __raw_writel(val, edu_reg(dev, reg));
  67. }
  68. bool edu_init(struct pci_edu_dev *dev);
  69. void edu_dma(struct pci_edu_dev *dev, iova_t iova,
  70. size_t size, unsigned int dev_offset, bool from_device);
  71. #endif