gart.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef _ASM_X86_GART_H
  2. #define _ASM_X86_GART_H
  3. #include <asm/e820.h>
  4. extern void set_up_gart_resume(u32, u32);
  5. extern int fallback_aper_order;
  6. extern int fallback_aper_force;
  7. extern int fix_aperture;
  8. /* PTE bits. */
  9. #define GPTE_VALID 1
  10. #define GPTE_COHERENT 2
  11. /* Aperture control register bits. */
  12. #define GARTEN (1<<0)
  13. #define DISGARTCPU (1<<4)
  14. #define DISGARTIO (1<<5)
  15. /* GART cache control register bits. */
  16. #define INVGART (1<<0)
  17. #define GARTPTEERR (1<<1)
  18. /* K8 On-cpu GART registers */
  19. #define AMD64_GARTAPERTURECTL 0x90
  20. #define AMD64_GARTAPERTUREBASE 0x94
  21. #define AMD64_GARTTABLEBASE 0x98
  22. #define AMD64_GARTCACHECTL 0x9c
  23. #define AMD64_GARTEN (1<<0)
  24. #ifdef CONFIG_GART_IOMMU
  25. extern int gart_iommu_aperture;
  26. extern int gart_iommu_aperture_allowed;
  27. extern int gart_iommu_aperture_disabled;
  28. extern void early_gart_iommu_check(void);
  29. extern int gart_iommu_init(void);
  30. extern void __init gart_parse_options(char *);
  31. extern void gart_iommu_hole_init(void);
  32. #else
  33. #define gart_iommu_aperture 0
  34. #define gart_iommu_aperture_allowed 0
  35. #define gart_iommu_aperture_disabled 1
  36. static inline void early_gart_iommu_check(void)
  37. {
  38. }
  39. static inline void gart_parse_options(char *options)
  40. {
  41. }
  42. static inline void gart_iommu_hole_init(void)
  43. {
  44. }
  45. #endif
  46. extern int agp_amd64_init(void);
  47. static inline void enable_gart_translation(struct pci_dev *dev, u64 addr)
  48. {
  49. u32 tmp, ctl;
  50. /* address of the mappings table */
  51. addr >>= 12;
  52. tmp = (u32) addr<<4;
  53. tmp &= ~0xf;
  54. pci_write_config_dword(dev, AMD64_GARTTABLEBASE, tmp);
  55. /* Enable GART translation for this hammer. */
  56. pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl);
  57. ctl |= GARTEN;
  58. ctl &= ~(DISGARTCPU | DISGARTIO);
  59. pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, ctl);
  60. }
  61. static inline int aperture_valid(u64 aper_base, u32 aper_size, u32 min_size)
  62. {
  63. if (!aper_base)
  64. return 0;
  65. if (aper_base + aper_size > 0x100000000ULL) {
  66. printk(KERN_INFO "Aperture beyond 4GB. Ignoring.\n");
  67. return 0;
  68. }
  69. if (e820_any_mapped(aper_base, aper_base + aper_size, E820_RAM)) {
  70. printk(KERN_INFO "Aperture pointing to e820 RAM. Ignoring.\n");
  71. return 0;
  72. }
  73. if (aper_size < min_size) {
  74. printk(KERN_INFO "Aperture too small (%d MB) than (%d MB)\n",
  75. aper_size>>20, min_size>>20);
  76. return 0;
  77. }
  78. return 1;
  79. }
  80. #endif /* _ASM_X86_GART_H */