1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #ifndef _PCI_AGPVAR_H_
33 #define _PCI_AGPVAR_H_
34
35 #include <sys/lock.h>
36 #include <dev/pci/vga_pcivar.h>
37
38
39 #ifdef AGP_DEBUG
40 #define AGP_DPF(fmt, arg...) do { printf("agp: " fmt ,##arg); } while (0)
41 #else
42 #define AGP_DPF(fmt, arg...) do {} while (0)
43 #endif
44
45 #define AGPUNIT(x) minor(x)
46
47 struct agp_methods {
48 u_int32_t (*get_aperture)(struct vga_pci_softc *);
49 int (*set_aperture)(struct vga_pci_softc *, u_int32_t);
50 int (*bind_page)(struct vga_pci_softc *, off_t, bus_addr_t);
51 int (*unbind_page)(struct vga_pci_softc *, off_t);
52 void (*flush_tlb)(struct vga_pci_softc *);
53 int (*enable)(struct vga_pci_softc *, u_int32_t mode);
54 struct agp_memory *
55 (*alloc_memory)(struct vga_pci_softc *, int, vsize_t);
56 int (*free_memory)(struct vga_pci_softc *, struct agp_memory *);
57 int (*bind_memory)(struct vga_pci_softc *, struct agp_memory *,
58 off_t);
59 int (*unbind_memory)(struct vga_pci_softc *, struct agp_memory *);
60 };
61
62 #define AGP_GET_APERTURE(sc) ((sc)->sc_methods->get_aperture(sc))
63 #define AGP_SET_APERTURE(sc,a) ((sc)->sc_methods->set_aperture((sc),(a)))
64 #define AGP_BIND_PAGE(sc,o,p) ((sc)->sc_methods->bind_page((sc),(o),(p)))
65 #define AGP_UNBIND_PAGE(sc,o) ((sc)->sc_methods->unbind_page((sc), (o)))
66 #define AGP_FLUSH_TLB(sc) ((sc)->sc_methods->flush_tlb(sc))
67 #define AGP_ENABLE(sc,m) ((sc)->sc_methods->enable((sc),(m)))
68 #define AGP_ALLOC_MEMORY(sc,t,s) ((sc)->sc_methods->alloc_memory((sc),(t),(s)))
69 #define AGP_FREE_MEMORY(sc,m) ((sc)->sc_methods->free_memory((sc),(m)))
70 #define AGP_BIND_MEMORY(sc,m,o) ((sc)->sc_methods->bind_memory((sc),(m),(o)))
71 #define AGP_UNBIND_MEMORY(sc,m) ((sc)->sc_methods->unbind_memory((sc),(m)))
72
73
74
75
76
77 struct agp_gatt {
78 u_int32_t ag_entries;
79 u_int32_t *ag_virtual;
80 bus_addr_t ag_physical;
81 bus_dmamap_t ag_dmamap;
82 bus_dma_segment_t ag_dmaseg;
83 size_t ag_size;
84 };
85
86
87
88
89
90
91 int agp_find_caps(pci_chipset_tag_t, pcitag_t);
92 int agp_map_aperture(struct vga_pci_softc *, u_int32_t, u_int32_t);
93 struct agp_gatt *
94 agp_alloc_gatt(struct vga_pci_softc *);
95 void agp_free_gatt(struct vga_pci_softc *, struct agp_gatt *);
96 void agp_flush_cache(void);
97 int agp_generic_attach(struct vga_pci_softc *);
98 int agp_generic_detach(struct vga_pci_softc *);
99 int agp_generic_enable(struct vga_pci_softc *, u_int32_t);
100 struct agp_memory *
101 agp_generic_alloc_memory(struct vga_pci_softc *, int, vsize_t size);
102 int agp_generic_free_memory(struct vga_pci_softc *, struct agp_memory *);
103 int agp_generic_bind_memory(struct vga_pci_softc *, struct agp_memory *,
104 off_t);
105 int agp_generic_unbind_memory(struct vga_pci_softc *, struct agp_memory *);
106
107 int agp_ali_attach(struct vga_pci_softc *, struct pci_attach_args *,
108 struct pci_attach_args *);
109 int agp_amd_attach(struct vga_pci_softc *, struct pci_attach_args *,
110 struct pci_attach_args *);
111 int agp_i810_attach(struct vga_pci_softc *, struct pci_attach_args *,
112 struct pci_attach_args *);
113 int agp_intel_attach(struct vga_pci_softc *, struct pci_attach_args *,
114 struct pci_attach_args *);
115 int agp_via_attach(struct vga_pci_softc *, struct pci_attach_args *,
116 struct pci_attach_args *);
117 int agp_sis_attach(struct vga_pci_softc *, struct pci_attach_args *,
118 struct pci_attach_args *);
119
120 int agp_alloc_dmamem(bus_dma_tag_t, size_t, int, bus_dmamap_t *,
121 caddr_t *, bus_addr_t *, bus_dma_segment_t *, int, int *);
122 void agp_free_dmamem(bus_dma_tag_t, size_t, bus_dmamap_t,
123 caddr_t, bus_dma_segment_t *, int nseg) ;
124
125 #endif