gart.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #ifdef CONFIG_GART_IOMMU
  24. extern int gart_iommu_aperture;
  25. extern int gart_iommu_aperture_allowed;
  26. extern int gart_iommu_aperture_disabled;
  27. extern void early_gart_iommu_check(void);
  28. extern int gart_iommu_init(void);
  29. extern void __init gart_parse_options(char *);
  30. extern void gart_iommu_hole_init(void);
  31. #else
  32. #define gart_iommu_aperture 0
  33. #define gart_iommu_aperture_allowed 0
  34. #define gart_iommu_aperture_disabled 1
  35. static inline void early_gart_iommu_check(void)
  36. {
  37. }
  38. static inline void gart_parse_options(char *options)
  39. {
  40. }
  41. static inline void gart_iommu_hole_init(void)
  42. {
  43. }
  44. #endif
  45. extern int agp_amd64_init(void);
  46. static inline void enable_gart_translation(struct pci_dev *dev, u64 addr)
  47. {
  48. u32 tmp, ctl;
  49. /* address of the mappings table */
  50. addr >>= 12;
  51. tmp = (u32) addr<<4;
  52. tmp &= ~0xf;
  53. pci_write_config_dword(dev, AMD64_GARTTABLEBASE, tmp);
  54. /* Enable GART translation for this hammer. */
  55. pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl);
  56. ctl |= GARTEN;
  57. ctl &= ~(DISGARTCPU | DISGARTIO);
  58. pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, ctl);
  59. }
  60. static inline int aperture_valid(u64 aper_base, u32 aper_size, u32 min_size)
  61. {
  62. if (!aper_base)
  63. return 0;
  64. if (aper_base + aper_size > 0x100000000ULL) {
  65. printk(KERN_INFO "Aperture beyond 4GB. Ignoring.\n");
  66. return 0;
  67. }
  68. if (e820_any_mapped(aper_base, aper_base + aper_size, E820_RAM)) {
  69. printk(KERN_INFO "Aperture pointing to e820 RAM. Ignoring.\n");
  70. return 0;
  71. }
  72. if (aper_size < min_size) {
  73. printk(KERN_INFO "Aperture too small (%d MB) than (%d MB)\n",
  74. aper_size>>20, min_size>>20);
  75. return 0;
  76. }
  77. return 1;
  78. }
  79. #endif /* _ASM_X86_GART_H */