aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/gart.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-x86/gart.h')
-rw-r--r--include/asm-x86/gart.h84
1 files changed, 61 insertions, 23 deletions
diff --git a/include/asm-x86/gart.h b/include/asm-x86/gart.h
index 90958ed993fa..33b9aeeb35a2 100644
--- a/include/asm-x86/gart.h
+++ b/include/asm-x86/gart.h
@@ -1,34 +1,72 @@
1#ifndef _ASM_X8664_IOMMU_H 1#ifndef _ASM_X8664_GART_H
2#define _ASM_X8664_IOMMU_H 1 2#define _ASM_X8664_GART_H 1
3 3
4extern void pci_iommu_shutdown(void); 4#include <asm/e820.h>
5extern void no_iommu_init(void); 5#include <asm/iommu.h>
6extern int force_iommu, no_iommu; 6
7extern int iommu_detected; 7extern void set_up_gart_resume(u32, u32);
8#ifdef CONFIG_GART_IOMMU 8
9extern void gart_iommu_init(void);
10extern void gart_iommu_shutdown(void);
11extern void __init gart_parse_options(char *);
12extern void early_gart_iommu_check(void);
13extern void gart_iommu_hole_init(void);
14extern int fallback_aper_order; 9extern int fallback_aper_order;
15extern int fallback_aper_force; 10extern int fallback_aper_force;
16extern int gart_iommu_aperture;
17extern int gart_iommu_aperture_allowed;
18extern int gart_iommu_aperture_disabled;
19extern int fix_aperture; 11extern int fix_aperture;
20#else
21#define gart_iommu_aperture 0
22#define gart_iommu_aperture_allowed 0
23 12
24static inline void early_gart_iommu_check(void) 13/* PTE bits. */
14#define GPTE_VALID 1
15#define GPTE_COHERENT 2
16
17/* Aperture control register bits. */
18#define GARTEN (1<<0)
19#define DISGARTCPU (1<<4)
20#define DISGARTIO (1<<5)
21
22/* GART cache control register bits. */
23#define INVGART (1<<0)
24#define GARTPTEERR (1<<1)
25
26/* K8 On-cpu GART registers */
27#define AMD64_GARTAPERTURECTL 0x90
28#define AMD64_GARTAPERTUREBASE 0x94
29#define AMD64_GARTTABLEBASE 0x98
30#define AMD64_GARTCACHECTL 0x9c
31#define AMD64_GARTEN (1<<0)
32
33static inline void enable_gart_translation(struct pci_dev *dev, u64 addr)
25{ 34{
35 u32 tmp, ctl;
36
37 /* address of the mappings table */
38 addr >>= 12;
39 tmp = (u32) addr<<4;
40 tmp &= ~0xf;
41 pci_write_config_dword(dev, AMD64_GARTTABLEBASE, tmp);
42
43 /* Enable GART translation for this hammer. */
44 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl);
45 ctl |= GARTEN;
46 ctl &= ~(DISGARTCPU | DISGARTIO);
47 pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, ctl);
26} 48}
27 49
28static inline void gart_iommu_shutdown(void) 50static inline int aperture_valid(u64 aper_base, u32 aper_size, u32 min_size)
29{ 51{
30} 52 if (!aper_base)
53 return 0;
31 54
32#endif 55 if (aper_base + aper_size > 0x100000000ULL) {
56 printk(KERN_ERR "Aperture beyond 4GB. Ignoring.\n");
57 return 0;
58 }
59 if (e820_any_mapped(aper_base, aper_base + aper_size, E820_RAM)) {
60 printk(KERN_ERR "Aperture pointing to e820 RAM. Ignoring.\n");
61 return 0;
62 }
63 if (aper_size < min_size) {
64 printk(KERN_ERR "Aperture too small (%d MB) than (%d MB)\n",
65 aper_size>>20, min_size>>20);
66 return 0;
67 }
68
69 return 1;
70}
33 71
34#endif 72#endif