conf_space_capability_vpd.c 906 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * PCI Backend - Configuration space overlay for Vital Product Data
  3. *
  4. * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
  5. */
  6. #include <linux/pci.h>
  7. #include "conf_space.h"
  8. #include "conf_space_capability.h"
  9. static int vpd_address_write(struct pci_dev *dev, int offset, u16 value,
  10. void *data)
  11. {
  12. /* Disallow writes to the vital product data */
  13. if (value & PCI_VPD_ADDR_F)
  14. return PCIBIOS_SET_FAILED;
  15. else
  16. return pci_write_config_word(dev, offset, value);
  17. }
  18. static const struct config_field caplist_vpd[] = {
  19. {
  20. .offset = PCI_VPD_ADDR,
  21. .size = 2,
  22. .u.w.read = pciback_read_config_word,
  23. .u.w.write = vpd_address_write,
  24. },
  25. {
  26. .offset = PCI_VPD_DATA,
  27. .size = 4,
  28. .u.dw.read = pciback_read_config_dword,
  29. .u.dw.write = NULL,
  30. },
  31. {}
  32. };
  33. struct pciback_config_capability pciback_config_capability_vpd = {
  34. .capability = PCI_CAP_ID_VPD,
  35. .fields = caplist_vpd,
  36. };