1 /* $OpenBSD: vga_pcivar.h,v 1.5 2002/07/12 20:17:03 mickey Exp $ */ 2 /* $NetBSD: vga_pcivar.h,v 1.1 1998/03/22 15:16:19 drochner Exp $ */ 3 4 /* 5 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 6 * All rights reserved. 7 * 8 * Author: Chris G. Demetriou 9 * 10 * Permission to use, copy, modify and distribute this software and 11 * its documentation is hereby granted, provided that both the copyright 12 * notice and this permission notice appear in all copies of the 13 * software, derivative works or modified versions, and any portions 14 * thereof, and that both notices appear in supporting documentation. 15 * 16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 * 20 * Carnegie Mellon requests users of this software to return to 21 * 22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 23 * School of Computer Science 24 * Carnegie Mellon University 25 * Pittsburgh PA 15213-3890 26 * 27 * any improvements or extensions that they make and grant Carnegie the 28 * rights to redistribute these changes. 29 */ 30 31 #ifndef _PCI_VGA_PCIVAR_H_ 32 #define _PCI_VGA_PCIVAR_H_ 33 34 #define DEVICE_IS_VGA_PCI(class, id) \ 35 (((PCI_CLASS(class) == PCI_CLASS_DISPLAY && \ 36 PCI_SUBCLASS(class) == PCI_SUBCLASS_DISPLAY_VGA) || \ 37 (PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && \ 38 PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) ? 1 : 0) 39 40 enum agp_acquire_state { 41 AGP_ACQUIRE_FREE, 42 AGP_ACQUIRE_USER, 43 AGP_ACQUIRE_KERNEL 44 }; 45 46 /* 47 * Data structure to describe an AGP memory allocation. 48 */ 49 TAILQ_HEAD(agp_memory_list, agp_memory); 50 struct agp_memory { 51 TAILQ_ENTRY(agp_memory) am_link; /* wiring for the tailq */ 52 int am_id; /* unique id for block */ 53 vsize_t am_size; /* number of bytes allocated */ 54 int am_type; /* chipset specific type */ 55 off_t am_offset; /* page offset if bound */ 56 int am_is_bound; /* non-zero if bound */ 57 bus_addr_t am_physical; 58 caddr_t am_virtual; 59 bus_dmamap_t am_dmamap; 60 int am_nseg; 61 bus_dma_segment_t *am_dmaseg; 62 }; 63 64 struct vga_pci_softc { 65 struct device sc_dev; 66 67 #if 0 68 struct vga_config *sc_vc; /* VGA configuration */ 69 #endif 70 71 /* agp stuff */ 72 bus_space_tag_t sc_bt, sc_memt; 73 bus_space_handle_t sc_bh; 74 bus_addr_t sc_apaddr; 75 bus_size_t sc_apsize; 76 bus_dma_tag_t sc_dmat; 77 struct lock sc_lock; /* lock for access to GATT */ 78 pcitag_t sc_pcitag; /* PCI tag, in case we need it. */ 79 pcireg_t sc_id; 80 pci_chipset_tag_t sc_pc; 81 82 struct agp_methods *sc_methods; 83 void *sc_chipc; /* chipset-dependent state */ 84 85 int sc_opened; 86 int sc_capoff; 87 int sc_apflags; 88 int sc_nextid; /* next memory block id */ 89 90 u_int32_t sc_maxmem; /* allocation upper bound */ 91 u_int32_t sc_allocated; /* amount allocated */ 92 enum agp_acquire_state sc_state; 93 struct agp_memory_list sc_memory; /* list of allocated memory */ 94 }; 95 96 struct agp_product { 97 int ap_vendor; 98 int ap_product; 99 int (*ap_attach)(struct vga_pci_softc *, 100 struct pci_attach_args *, struct pci_attach_args *); 101 }; 102 /* MD-defined */ 103 extern const struct agp_product agp_products[]; 104 105 int vga_pci_cnattach(bus_space_tag_t, bus_space_tag_t, 106 pci_chipset_tag_t, int, int, int); 107 108 #endif /* _PCI_VGA_PCIVAR_H_ */ 109