1 /* $OpenBSD: agpvar.h,v 1.3 2002/07/25 23:31:04 fgsch Exp $ */ 2 /* $NetBSD: agpvar.h,v 1.4 2001/10/01 21:54:48 fvdl Exp $ */ 3 4 /*- 5 * Copyright (c) 2000 Doug Rabson 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD: src/sys/pci/agppriv.h,v 1.3 2000/07/12 10:13:04 dfr Exp $ 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 * This structure is used to query the state of the AGP system. 40 */ 41 struct agp_info { 42 u_int32_t ai_mode; 43 bus_addr_t ai_aperture_base; 44 bus_size_t ai_aperture_size; 45 vsize_t ai_memory_allowed; 46 vsize_t ai_memory_used; 47 u_int32_t ai_devid; 48 }; 49 50 struct agp_memory_info { 51 vsize_t ami_size; /* size in bytes */ 52 bus_addr_t ami_physical; /* bogus hack for i810 */ 53 off_t ami_offset; /* page offset if bound */ 54 int ami_is_bound; /* non-zero if bound */ 55 }; 56 57 /* #define AGP_DEBUG */ 58 #ifdef AGP_DEBUG 59 #define AGP_DPF(x...) do { \ 60 printf("agp: "); \ 61 printf(##x); \ 62 } while (0) 63 #else 64 #define AGP_DPF(x...) do {} while (0) 65 #endif 66 67 #define AGPUNIT(x) minor(x) 68 69 struct agp_methods { 70 u_int32_t (*get_aperture)(struct vga_pci_softc *); 71 int (*set_aperture)(struct vga_pci_softc *, u_int32_t); 72 int (*bind_page)(struct vga_pci_softc *, off_t, bus_addr_t); 73 int (*unbind_page)(struct vga_pci_softc *, off_t); 74 void (*flush_tlb)(struct vga_pci_softc *); 75 int (*enable)(struct vga_pci_softc *, u_int32_t mode); 76 struct agp_memory * 77 (*alloc_memory)(struct vga_pci_softc *, int, vsize_t); 78 int (*free_memory)(struct vga_pci_softc *, struct agp_memory *); 79 int (*bind_memory)(struct vga_pci_softc *, struct agp_memory *, 80 off_t); 81 int (*unbind_memory)(struct vga_pci_softc *, struct agp_memory *); 82 }; 83 84 #define AGP_GET_APERTURE(sc) ((sc)->sc_methods->get_aperture(sc)) 85 #define AGP_SET_APERTURE(sc,a) ((sc)->sc_methods->set_aperture((sc),(a))) 86 #define AGP_BIND_PAGE(sc,o,p) ((sc)->sc_methods->bind_page((sc),(o),(p))) 87 #define AGP_UNBIND_PAGE(sc,o) ((sc)->sc_methods->unbind_page((sc), (o))) 88 #define AGP_FLUSH_TLB(sc) ((sc)->sc_methods->flush_tlb(sc)) 89 #define AGP_ENABLE(sc,m) ((sc)->sc_methods->enable((sc),(m))) 90 #define AGP_ALLOC_MEMORY(sc,t,s) ((sc)->sc_methods->alloc_memory((sc),(t),(s))) 91 #define AGP_FREE_MEMORY(sc,m) ((sc)->sc_methods->free_memory((sc),(m))) 92 #define AGP_BIND_MEMORY(sc,m,o) ((sc)->sc_methods->bind_memory((sc),(m),(o))) 93 #define AGP_UNBIND_MEMORY(sc,m) ((sc)->sc_methods->unbind_memory((sc),(m))) 94 95 /* 96 * All chipset drivers must have this at the start of their softc. 97 */ 98 99 struct agp_gatt { 100 u_int32_t ag_entries; 101 u_int32_t *ag_virtual; 102 bus_addr_t ag_physical; 103 bus_dmamap_t ag_dmamap; 104 bus_dma_segment_t ag_dmaseg; 105 size_t ag_size; 106 }; 107 108 109 /* 110 * Functions private to the AGP code. 111 */ 112 113 int agp_find_caps(pci_chipset_tag_t, pcitag_t); 114 int agp_map_aperture(struct vga_pci_softc *); 115 struct agp_gatt * 116 agp_alloc_gatt(struct vga_pci_softc *); 117 void agp_free_gatt(struct vga_pci_softc *, struct agp_gatt *); 118 void agp_flush_cache(void); 119 int agp_generic_attach(struct vga_pci_softc *); 120 int agp_generic_detach(struct vga_pci_softc *); 121 int agp_generic_enable(struct vga_pci_softc *, u_int32_t); 122 struct agp_memory * 123 agp_generic_alloc_memory(struct vga_pci_softc *, int, vsize_t size); 124 int agp_generic_free_memory(struct vga_pci_softc *, struct agp_memory *); 125 int agp_generic_bind_memory(struct vga_pci_softc *, struct agp_memory *, 126 off_t); 127 int agp_generic_unbind_memory(struct vga_pci_softc *, struct agp_memory *); 128 129 int agp_ali_attach(struct vga_pci_softc *, struct pci_attach_args *, 130 struct pci_attach_args *); 131 int agp_amd_attach(struct vga_pci_softc *, struct pci_attach_args *, 132 struct pci_attach_args *); 133 int agp_i810_attach(struct vga_pci_softc *, struct pci_attach_args *, 134 struct pci_attach_args *); 135 int agp_intel_attach(struct vga_pci_softc *, struct pci_attach_args *, 136 struct pci_attach_args *); 137 int agp_via_attach(struct vga_pci_softc *, struct pci_attach_args *, 138 struct pci_attach_args *); 139 int agp_sis_attach(struct vga_pci_softc *, struct pci_attach_args *, 140 struct pci_attach_args *); 141 142 int agp_alloc_dmamem(bus_dma_tag_t, size_t, int, bus_dmamap_t *, 143 caddr_t *, bus_addr_t *, bus_dma_segment_t *, int, int *); 144 void agp_free_dmamem(bus_dma_tag_t, size_t, bus_dmamap_t, 145 caddr_t, bus_dma_segment_t *, int nseg) ; 146 147 #endif /* !_PCI_AGPVAR_H_ */ 148