pci-bridge.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifdef __KERNEL__
  2. #ifndef _ASM_PCI_BRIDGE_H
  3. #define _ASM_PCI_BRIDGE_H
  4. /*
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License
  7.  * as published by the Free Software Foundation; either version
  8.  * 2 of the License, or (at your option) any later version.
  9.  */
  10. struct device_node;
  11. struct pci_controller;
  12. /*
  13.  * pci_io_base returns the memory address at which you can access
  14.  * the I/O space for PCI bus number `bus' (or NULL on error).
  15.  */
  16. extern void *pci_bus_io_base(unsigned int bus);
  17. extern unsigned long pci_bus_io_base_phys(unsigned int bus);
  18. extern unsigned long pci_bus_mem_base_phys(unsigned int bus);
  19. /* Get the PCI host controller for a bus */
  20. extern struct pci_controller* pci_bus_to_hose(int bus);
  21. /* Get the PCI host controller for an OF device */
  22. extern struct pci_controller*
  23. pci_find_hose_for_OF_device(struct device_node* node);
  24. enum phb_types { 
  25. phb_type_unknown    = 0x0,
  26. phb_type_hypervisor = 0x1,
  27. phb_type_python     = 0x10,
  28. phb_type_speedwagon = 0x11
  29. };
  30. /*
  31.  * Structure of a PCI controller (host bridge)
  32.  */
  33. struct pci_controller {
  34. char what[8];                     /* Eye catcher      */
  35. enum phb_types type;              /* Type of hardware */
  36. struct pci_controller *next;
  37. struct pci_bus *bus;
  38. void *arch_data;
  39. int first_busno;
  40. int last_busno;
  41. void *io_base_virt;
  42. unsigned long io_base_phys;
  43. /* Some machines (PReP) have a non 1:1 mapping of
  44.  * the PCI memory space in the CPU bus space
  45.  */
  46. unsigned long pci_mem_offset;
  47. unsigned long pci_io_offset;
  48. struct pci_ops *ops;
  49. volatile unsigned long *cfg_addr;
  50. volatile unsigned char *cfg_data;
  51. volatile unsigned long *phb_regs;
  52. volatile unsigned long *chip_regs;
  53. /* Currently, we limit ourselves to 1 IO range and 3 mem
  54.  * ranges since the common pci_bus structure can't handle more
  55.  */
  56. struct resource io_resource;
  57. struct resource mem_resources[3];
  58. int mem_resource_count;
  59. int    global_number;
  60. int    local_number;
  61. int    system_bus_number;
  62. unsigned long buid;
  63. unsigned long dma_window_base_cur;
  64. unsigned long dma_window_size;
  65. };
  66. /* This version handles the new Uni-N host bridge, the iobase is now
  67.  * a per-device thing. I also added the memory base so PReP can
  68.  * be fixed to return 0xc0000000 (I didn't actually implement it)
  69.  *
  70.  * pci_dev_io_base() returns either a virtual (ioremap'ed) address or
  71.  * a physical address. In-kernel clients will use logical while the
  72.  * sys_pciconfig_iobase syscall returns a physical one to userland.
  73.  */
  74. void *pci_dev_io_base(unsigned char bus, unsigned char devfn, int physical);
  75. void *pci_dev_mem_base(unsigned char bus, unsigned char devfn);
  76. /* Returns the root-bridge number (Uni-N number) of a device */
  77. int pci_dev_root_bridge(unsigned char bus, unsigned char devfn);
  78. /*
  79.  * pci_device_loc returns the bus number and device/function number
  80.  * for a device on a PCI bus, given its device_node struct.
  81.  * It returns 0 if OK, -1 on error.
  82.  */
  83. int pci_device_loc(struct device_node *dev, unsigned char *bus_ptr,
  84.    unsigned char *devfn_ptr);
  85. struct bridge_data {
  86. volatile unsigned int *cfg_addr;
  87. volatile unsigned char *cfg_data;
  88. void *io_base; /* virtual */
  89. unsigned long io_base_phys;
  90. int bus_number;
  91. int max_bus;
  92. struct bridge_data *next;
  93. struct device_node *node;
  94. };
  95. #endif
  96. #endif /* __KERNEL__ */