pci.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #ifndef _ASM_X86_PCI_H
  2. #define _ASM_X86_PCI_H
  3. #include <linux/mm.h> /* for struct page */
  4. #include <linux/types.h>
  5. #include <linux/slab.h>
  6. #include <linux/string.h>
  7. #include <asm/scatterlist.h>
  8. #include <asm/io.h>
  9. #ifdef __KERNEL__
  10. struct pci_sysdata {
  11. int domain; /* PCI domain */
  12. int node; /* NUMA node */
  13. #ifdef CONFIG_X86_64
  14. void *iommu; /* IOMMU private data */
  15. #endif
  16. };
  17. extern int pci_routeirq;
  18. extern int noioapicquirk;
  19. extern int noioapicreroute;
  20. /* scan a bus after allocating a pci_sysdata for it */
  21. extern struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops,
  22. int node);
  23. extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
  24. static inline int pci_domain_nr(struct pci_bus *bus)
  25. {
  26. struct pci_sysdata *sd = bus->sysdata;
  27. return sd->domain;
  28. }
  29. static inline int pci_proc_domain(struct pci_bus *bus)
  30. {
  31. return pci_domain_nr(bus);
  32. }
  33. /* Can be used to override the logic in pci_scan_bus for skipping
  34. already-configured bus numbers - to be used for buggy BIOSes
  35. or architectures with incomplete PCI setup by the loader */
  36. #ifdef CONFIG_PCI
  37. extern unsigned int pcibios_assign_all_busses(void);
  38. #else
  39. #define pcibios_assign_all_busses() 0
  40. #endif
  41. extern unsigned long pci_mem_start;
  42. #define PCIBIOS_MIN_IO 0x1000
  43. #define PCIBIOS_MIN_MEM (pci_mem_start)
  44. #define PCIBIOS_MIN_CARDBUS_IO 0x4000
  45. void pcibios_config_init(void);
  46. struct pci_bus *pcibios_scan_root(int bus);
  47. void pcibios_set_master(struct pci_dev *dev);
  48. void pcibios_penalize_isa_irq(int irq, int active);
  49. struct irq_routing_table *pcibios_get_irq_routing_table(void);
  50. int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
  51. #define HAVE_PCI_MMAP
  52. extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
  53. enum pci_mmap_state mmap_state,
  54. int write_combine);
  55. #ifdef CONFIG_PCI
  56. extern void early_quirks(void);
  57. static inline void pci_dma_burst_advice(struct pci_dev *pdev,
  58. enum pci_dma_burst_strategy *strat,
  59. unsigned long *strategy_parameter)
  60. {
  61. *strat = PCI_DMA_BURST_INFINITY;
  62. *strategy_parameter = ~0UL;
  63. }
  64. #else
  65. static inline void early_quirks(void) { }
  66. #endif
  67. extern void pci_iommu_alloc(void);
  68. /* MSI arch hook */
  69. #define arch_setup_msi_irqs arch_setup_msi_irqs
  70. #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
  71. #if defined(CONFIG_X86_64) || defined(CONFIG_DMAR) || defined(CONFIG_DMA_API_DEBUG)
  72. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
  73. dma_addr_t ADDR_NAME;
  74. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
  75. __u32 LEN_NAME;
  76. #define pci_unmap_addr(PTR, ADDR_NAME) \
  77. ((PTR)->ADDR_NAME)
  78. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
  79. (((PTR)->ADDR_NAME) = (VAL))
  80. #define pci_unmap_len(PTR, LEN_NAME) \
  81. ((PTR)->LEN_NAME)
  82. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
  83. (((PTR)->LEN_NAME) = (VAL))
  84. #else
  85. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME[0];
  86. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) unsigned LEN_NAME[0];
  87. #define pci_unmap_addr(PTR, ADDR_NAME) sizeof((PTR)->ADDR_NAME)
  88. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
  89. do { break; } while (pci_unmap_addr(PTR, ADDR_NAME))
  90. #define pci_unmap_len(PTR, LEN_NAME) sizeof((PTR)->LEN_NAME)
  91. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
  92. do { break; } while (pci_unmap_len(PTR, LEN_NAME))
  93. #endif
  94. #endif /* __KERNEL__ */
  95. #ifdef CONFIG_X86_64
  96. #include "pci_64.h"
  97. #endif
  98. void dma32_reserve_bootmem(void);
  99. /* implement the pci_ DMA API in terms of the generic device dma_ one */
  100. #include <asm-generic/pci-dma-compat.h>
  101. /* generic pci stuff */
  102. #include <asm-generic/pci.h>
  103. #define PCIBIOS_MAX_MEM_32 0xffffffff
  104. #ifdef CONFIG_NUMA
  105. /* Returns the node based on pci bus */
  106. static inline int __pcibus_to_node(const struct pci_bus *bus)
  107. {
  108. const struct pci_sysdata *sd = bus->sysdata;
  109. return sd->node;
  110. }
  111. static inline const struct cpumask *
  112. cpumask_of_pcibus(const struct pci_bus *bus)
  113. {
  114. int node;
  115. node = __pcibus_to_node(bus);
  116. return (node == -1) ? cpu_online_mask :
  117. cpumask_of_node(node);
  118. }
  119. #endif
  120. #endif /* _ASM_X86_PCI_H */