1 /* $OpenBSD: agpvar.h,v 1.40 2024/10/10 03:36:10 jsg 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 struct agp_attach_args { 36 char *aa_busname; 37 struct pci_attach_args *aa_pa; 38 }; 39 40 struct agpbus_attach_args { 41 char *aa_busname; /*so pci doesn't conflict*/ 42 struct pci_attach_args *aa_pa; 43 const struct agp_methods *aa_methods; 44 bus_addr_t aa_apaddr; 45 bus_size_t aa_apsize; 46 }; 47 48 enum agp_acquire_state { 49 AGP_ACQUIRE_FREE, 50 AGP_ACQUIRE_USER, 51 AGP_ACQUIRE_KERNEL 52 }; 53 54 /* 55 * This structure is used to query the state of the AGP system. 56 */ 57 struct agp_info { 58 u_int32_t ai_mode; 59 bus_addr_t ai_aperture_base; 60 bus_size_t ai_aperture_size; 61 vsize_t ai_memory_allowed; 62 vsize_t ai_memory_used; 63 u_int32_t ai_devid; 64 }; 65 66 struct agp_methods { 67 void (*bind_page)(void *, bus_addr_t, paddr_t, int); 68 void (*unbind_page)(void *, bus_addr_t); 69 void (*flush_tlb)(void *); 70 int (*enable)(void *, u_int32_t mode); 71 }; 72 73 /* 74 * All chipset drivers must have this at the start of their softc. 75 */ 76 struct agp_softc { 77 struct device sc_dev; 78 79 const struct agp_methods *sc_methods; /* callbacks */ 80 void *sc_chipc; /* chipset softc */ 81 82 bus_dma_tag_t sc_dmat; 83 bus_space_tag_t sc_memt; 84 pci_chipset_tag_t sc_pc; 85 pcitag_t sc_pcitag; 86 bus_addr_t sc_apaddr; 87 bus_size_t sc_apsize; 88 pcireg_t sc_id; 89 90 int sc_capoff; 91 enum agp_acquire_state sc_state; 92 93 u_int32_t sc_maxmem; /* mem upper bound */ 94 u_int32_t sc_allocated; /* amount allocated */ 95 }; 96 97 struct agp_gatt { 98 u_int32_t ag_entries; 99 u_int32_t *ag_virtual; 100 bus_addr_t ag_physical; 101 bus_dmamap_t ag_dmamap; 102 bus_dma_segment_t ag_dmaseg; 103 size_t ag_size; 104 }; 105 106 /* 107 * Functions private to the AGP code. 108 */ 109 struct device *agp_attach_bus(struct pci_attach_args *, 110 const struct agp_methods *, bus_addr_t, bus_size_t, 111 struct device *); 112 struct agp_gatt * 113 agp_alloc_gatt(bus_dma_tag_t, u_int32_t); 114 void agp_free_gatt(bus_dma_tag_t, struct agp_gatt *); 115 void agp_flush_cache(void); 116 int agp_generic_enable(struct agp_softc *, u_int32_t); 117 118 int agp_alloc_dmamem(bus_dma_tag_t, size_t, bus_dmamap_t *, 119 bus_addr_t *, bus_dma_segment_t *); 120 void agp_free_dmamem(bus_dma_tag_t, size_t, bus_dmamap_t, 121 bus_dma_segment_t *); 122 int agpdev_print(void *, const char *); 123 int agpbus_probe(struct agp_attach_args *aa); 124 125 paddr_t agp_mmap(struct agp_softc *, off_t, int); 126 127 /* 128 * Kernel API 129 */ 130 /* 131 * Find the AGP device and return it. 132 */ 133 void *agp_find_device(int); 134 135 /* 136 * Return the current owner of the AGP chipset. 137 */ 138 enum agp_acquire_state agp_state(void *); 139 140 /* 141 * Query the state of the AGP system. 142 */ 143 void agp_get_info(void *, struct agp_info *); 144 145 /* 146 * Acquire the AGP chipset for use by the kernel. Returns EBUSY if the 147 * AGP chipset is already acquired by another user. 148 */ 149 int agp_acquire(void *); 150 151 /* 152 * Release the AGP chipset. 153 */ 154 int agp_release(void *); 155 156 /* 157 * Enable the agp hardware with the relevant mode. The mode bits are 158 * defined in <dev/pci/agpreg.h> 159 */ 160 int agp_enable(void *, u_int32_t); 161 162 #endif /* !_PCI_AGPVAR_H_ */ 163