amd_iommu_init.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
  3. * Author: Joerg Roedel <joerg.roedel@amd.com>
  4. * Leo Duran <leo.duran@amd.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/pci.h>
  20. #include <linux/acpi.h>
  21. #include <linux/gfp.h>
  22. #include <linux/list.h>
  23. #include <asm/pci-direct.h>
  24. #include <asm/amd_iommu_types.h>
  25. #include <asm/gart.h>
  26. /*
  27. * definitions for the ACPI scanning code
  28. */
  29. #define UPDATE_LAST_BDF(x) do {\
  30. if ((x) > amd_iommu_last_bdf) \
  31. amd_iommu_last_bdf = (x); \
  32. } while (0);
  33. #define DEVID(bus, devfn) (((bus) << 8) | (devfn))
  34. #define PCI_BUS(x) (((x) >> 8) & 0xff)
  35. #define IVRS_HEADER_LENGTH 48
  36. #define TBL_SIZE(x) (1 << (PAGE_SHIFT + get_order(amd_iommu_last_bdf * (x))))
  37. #define ACPI_IVHD_TYPE 0x10
  38. #define ACPI_IVMD_TYPE_ALL 0x20
  39. #define ACPI_IVMD_TYPE 0x21
  40. #define ACPI_IVMD_TYPE_RANGE 0x22
  41. #define IVHD_DEV_ALL 0x01
  42. #define IVHD_DEV_SELECT 0x02
  43. #define IVHD_DEV_SELECT_RANGE_START 0x03
  44. #define IVHD_DEV_RANGE_END 0x04
  45. #define IVHD_DEV_ALIAS 0x42
  46. #define IVHD_DEV_ALIAS_RANGE 0x43
  47. #define IVHD_DEV_EXT_SELECT 0x46
  48. #define IVHD_DEV_EXT_SELECT_RANGE 0x47
  49. #define IVHD_FLAG_HT_TUN_EN 0x00
  50. #define IVHD_FLAG_PASSPW_EN 0x01
  51. #define IVHD_FLAG_RESPASSPW_EN 0x02
  52. #define IVHD_FLAG_ISOC_EN 0x03
  53. #define IVMD_FLAG_EXCL_RANGE 0x08
  54. #define IVMD_FLAG_UNITY_MAP 0x01
  55. #define ACPI_DEVFLAG_INITPASS 0x01
  56. #define ACPI_DEVFLAG_EXTINT 0x02
  57. #define ACPI_DEVFLAG_NMI 0x04
  58. #define ACPI_DEVFLAG_SYSMGT1 0x10
  59. #define ACPI_DEVFLAG_SYSMGT2 0x20
  60. #define ACPI_DEVFLAG_LINT0 0x40
  61. #define ACPI_DEVFLAG_LINT1 0x80
  62. #define ACPI_DEVFLAG_ATSDIS 0x10000000
  63. struct ivhd_header {
  64. u8 type;
  65. u8 flags;
  66. u16 length;
  67. u16 devid;
  68. u16 cap_ptr;
  69. u64 mmio_phys;
  70. u16 pci_seg;
  71. u16 info;
  72. u32 reserved;
  73. } __attribute__((packed));
  74. struct ivhd_entry {
  75. u8 type;
  76. u16 devid;
  77. u8 flags;
  78. u32 ext;
  79. } __attribute__((packed));
  80. struct ivmd_header {
  81. u8 type;
  82. u8 flags;
  83. u16 length;
  84. u16 devid;
  85. u16 aux;
  86. u64 resv;
  87. u64 range_start;
  88. u64 range_length;
  89. } __attribute__((packed));