gart.h 1.7 KB

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