dbgp.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <linux/pci.h>
  2. #include <linux/usb.h>
  3. #include <linux/usb/ehci_def.h>
  4. #include <linux/usb/hcd.h>
  5. #include <asm/xen/hypercall.h>
  6. #include <xen/interface/physdev.h>
  7. #include <xen/xen.h>
  8. static int xen_dbgp_op(struct usb_hcd *hcd, int op)
  9. {
  10. #ifdef CONFIG_PCI
  11. const struct device *ctrlr = hcd_to_bus(hcd)->controller;
  12. #endif
  13. struct physdev_dbgp_op dbgp;
  14. if (!xen_initial_domain())
  15. return 0;
  16. dbgp.op = op;
  17. #ifdef CONFIG_PCI
  18. if (dev_is_pci(ctrlr)) {
  19. const struct pci_dev *pdev = to_pci_dev(ctrlr);
  20. dbgp.u.pci.seg = pci_domain_nr(pdev->bus);
  21. dbgp.u.pci.bus = pdev->bus->number;
  22. dbgp.u.pci.devfn = pdev->devfn;
  23. dbgp.bus = PHYSDEVOP_DBGP_BUS_PCI;
  24. } else
  25. #endif
  26. dbgp.bus = PHYSDEVOP_DBGP_BUS_UNKNOWN;
  27. return HYPERVISOR_physdev_op(PHYSDEVOP_dbgp_op, &dbgp);
  28. }
  29. int xen_dbgp_reset_prep(struct usb_hcd *hcd)
  30. {
  31. return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_PREPARE);
  32. }
  33. int xen_dbgp_external_startup(struct usb_hcd *hcd)
  34. {
  35. return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_DONE);
  36. }
  37. #ifndef CONFIG_EARLY_PRINTK_DBGP
  38. #include <linux/export.h>
  39. EXPORT_SYMBOL_GPL(xen_dbgp_reset_prep);
  40. EXPORT_SYMBOL_GPL(xen_dbgp_external_startup);
  41. #endif