dbgp.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. const struct device *ctrlr = hcd_to_bus(hcd)->controller;
  11. struct physdev_dbgp_op dbgp;
  12. if (!xen_initial_domain())
  13. return 0;
  14. dbgp.op = op;
  15. #ifdef CONFIG_PCI
  16. if (ctrlr->bus == &pci_bus_type) {
  17. const struct pci_dev *pdev = to_pci_dev(ctrlr);
  18. dbgp.u.pci.seg = pci_domain_nr(pdev->bus);
  19. dbgp.u.pci.bus = pdev->bus->number;
  20. dbgp.u.pci.devfn = pdev->devfn;
  21. dbgp.bus = PHYSDEVOP_DBGP_BUS_PCI;
  22. } else
  23. #endif
  24. dbgp.bus = PHYSDEVOP_DBGP_BUS_UNKNOWN;
  25. return HYPERVISOR_physdev_op(PHYSDEVOP_dbgp_op, &dbgp);
  26. }
  27. int xen_dbgp_reset_prep(struct usb_hcd *hcd)
  28. {
  29. return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_PREPARE);
  30. }
  31. int xen_dbgp_external_startup(struct usb_hcd *hcd)
  32. {
  33. return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_DONE);
  34. }
  35. #ifndef CONFIG_EARLY_PRINTK_DBGP
  36. #include <linux/export.h>
  37. EXPORT_SYMBOL_GPL(xen_dbgp_reset_prep);
  38. EXPORT_SYMBOL_GPL(xen_dbgp_external_startup);
  39. #endif