gart.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. extern int agp_amd64_init(void);
  25. static inline void enable_gart_translation(struct pci_dev *dev, u64 addr)
  26. {
  27. u32 tmp, ctl;
  28. /* address of the mappings table */
  29. addr >>= 12;
  30. tmp = (u32) addr<<4;
  31. tmp &= ~0xf;
  32. pci_write_config_dword(dev, AMD64_GARTTABLEBASE, tmp);
  33. /* Enable GART translation for this hammer. */
  34. pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl);
  35. ctl |= GARTEN;
  36. ctl &= ~(DISGARTCPU | DISGARTIO);
  37. pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, ctl);
  38. }
  39. static inline int aperture_valid(u64 aper_base, u32 aper_size, u32 min_size)
  40. {
  41. if (!aper_base)
  42. return 0;
  43. if (aper_base + aper_size > 0x100000000ULL) {
  44. printk(KERN_INFO "Aperture beyond 4GB. Ignoring.\n");
  45. return 0;
  46. }
  47. if (e820_any_mapped(aper_base, aper_base + aper_size, E820_RAM)) {
  48. printk(KERN_INFO "Aperture pointing to e820 RAM. Ignoring.\n");
  49. return 0;
  50. }
  51. if (aper_size < min_size) {
  52. printk(KERN_INFO "Aperture too small (%d MB) than (%d MB)\n",
  53. aper_size>>20, min_size>>20);
  54. return 0;
  55. }
  56. return 1;
  57. }
  58. #endif /* ASM_X86__GART_H */