ofw_pci.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* $OpenBSD: ofw_pci.h,v 1.4 2008/06/26 05:42:17 ray Exp $ */
  2. /* $NetBSD: ofw_pci.h,v 1.4 2001/02/17 16:28:37 mrg Exp $ */
  3. /*-
  4. * Copyright (c) 1999 The NetBSD Foundation, Inc.
  5. * All rights reserved.
  6. *
  7. * This code is derived from software contributed to The NetBSD Foundation
  8. * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
  9. * NASA Ames Research Center.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  22. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  24. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. * POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #ifndef _DEV_OFW_OFW_PCI_H_
  33. #define _DEV_OFW_OFW_PCI_H_
  34. /*
  35. * PCI Bus Binding to:
  36. *
  37. * IEEE Std 1275-1994
  38. * Standard for Boot (Initialization Configuration) Firmware
  39. *
  40. * Revision 2.1
  41. */
  42. /*
  43. * Section 2.2.1. Physical Address Formats
  44. *
  45. * A PCI physical address is represented by 3 address cells:
  46. *
  47. * phys.hi cell: npt000ss bbbbbbbb dddddfff rrrrrrrr
  48. * phys.mid cell: hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh
  49. * phys.lo cell: llllllll llllllll llllllll llllllll
  50. *
  51. * n nonrelocatable
  52. * p prefetchable
  53. * t aliased below 1MB (memory) or 64k (i/o)
  54. * ss space code
  55. * b bus number
  56. * d device number
  57. * f function number
  58. * r register number
  59. * h high 32-bits of PCI address
  60. * l low 32-bits of PCI address
  61. */
  62. #define OFW_PCI_PHYS_HI_NONRELOCATABLE 0x80000000
  63. #define OFW_PCI_PHYS_HI_PREFETCHABLE 0x40000000
  64. #define OFW_PCI_PHYS_HI_ALIASED 0x20000000
  65. #define OFW_PCI_PHYS_HI_SPACEMASK 0x03000000
  66. #define OFW_PCI_PHYS_HI_BUSMASK 0x00ff0000
  67. #define OFW_PCI_PHYS_HI_BUSSHIFT 16
  68. #define OFW_PCI_PHYS_HI_DEVICEMASK 0x0000f800
  69. #define OFW_PCI_PHYS_HI_DEVICESHIFT 11
  70. #define OFW_PCI_PHYS_HI_FUNCTIONMASK 0x00000700
  71. #define OFW_PCI_PHYS_HI_FUNCTIONSHIFT 8
  72. #define OFW_PCI_PHYS_HI_REGISTERMASK 0x000000ff
  73. #define OFW_PCI_PHYS_HI_SPACE_CONFIG 0x00000000
  74. #define OFW_PCI_PHYS_HI_SPACE_IO 0x01000000
  75. #define OFW_PCI_PHYS_HI_SPACE_MEM32 0x02000000
  76. #define OFW_PCI_PHYS_HI_SPACE_MEM64 0x03000000
  77. #define OFW_PCI_PHYS_HI_BUS(hi) \
  78. (((hi) & OFW_PCI_PHYS_HI_BUSMASK) >> OFW_PCI_PHYS_HI_BUSSHIFT)
  79. #define OFW_PCI_PHYS_HI_DEVICE(hi) \
  80. (((hi) & OFW_PCI_PHYS_HI_DEVICEMASK) >> OFW_PCI_PHYS_HI_DEVICESHIFT)
  81. #define OFW_PCI_PHYS_HI_FUNCTION(hi) \
  82. (((hi) & OFW_PCI_PHYS_HI_FUNCTIONMASK) >> OFW_PCI_PHYS_HI_FUNCTIONSHIFT)
  83. /*
  84. * This has the 3 32bit cell values, plus 2 more to make up a 64-bit size.
  85. */
  86. struct ofw_pci_register {
  87. u_int32_t phys_hi;
  88. u_int32_t phys_mid;
  89. u_int32_t phys_lo;
  90. u_int32_t size_hi;
  91. u_int32_t size_lo;
  92. };
  93. #endif /* _DEV_OFW_OFW_PCI_H_ */