agppriv.h revision 173203
161452Sdfr/*- 261452Sdfr * Copyright (c) 2000 Doug Rabson 361452Sdfr * All rights reserved. 461452Sdfr * 561452Sdfr * Redistribution and use in source and binary forms, with or without 661452Sdfr * modification, are permitted provided that the following conditions 761452Sdfr * are met: 861452Sdfr * 1. Redistributions of source code must retain the above copyright 961452Sdfr * notice, this list of conditions and the following disclaimer. 1061452Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1161452Sdfr * notice, this list of conditions and the following disclaimer in the 1261452Sdfr * documentation and/or other materials provided with the distribution. 1361452Sdfr * 1461452Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1561452Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1661452Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1761452Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1861452Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1961452Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2061452Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2161452Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2261452Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2361452Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2461452Sdfr * SUCH DAMAGE. 2561452Sdfr * 2661452Sdfr * $FreeBSD: head/sys/dev/agp/agppriv.h 173203 2007-10-30 22:09:16Z jhb $ 2761452Sdfr */ 2861452Sdfr 2961452Sdfr#ifndef _PCI_AGPPRIV_H_ 3061452Sdfr#define _PCI_AGPPRIV_H_ 3161452Sdfr 3261452Sdfr/* 3361452Sdfr * This file *must not* be included by code outside the agp driver itself. 3461452Sdfr */ 3561452Sdfr 3661452Sdfr#include <sys/agpio.h> 3761452Sdfr#include <pci/agpvar.h> 3861452Sdfr 3961452Sdfr#define AGP_DEBUGxx 4061452Sdfr 4161452Sdfr#ifdef AGP_DEBUG 4261452Sdfr#define AGP_DPF(x...) do { \ 4361452Sdfr printf("agp: "); \ 4461452Sdfr printf(##x); \ 4561452Sdfr} while (0) 4661452Sdfr#else 4761452Sdfr#define AGP_DPF(x...) do {} while (0) 4861452Sdfr#endif 4961452Sdfr 5061452Sdfr#include "agp_if.h" 5161452Sdfr 5261452Sdfr/* 5361452Sdfr * Data structure to describe an AGP memory allocation. 5461452Sdfr */ 5561452SdfrTAILQ_HEAD(agp_memory_list, agp_memory); 5661452Sdfrstruct agp_memory { 5761452Sdfr TAILQ_ENTRY(agp_memory) am_link; /* wiring for the tailq */ 5861452Sdfr int am_id; /* unique id for block */ 5961452Sdfr vm_size_t am_size; /* number of bytes allocated */ 6063010Sdfr int am_type; /* chipset specific type */ 6161452Sdfr struct vm_object *am_obj; /* VM object owning pages */ 6261452Sdfr vm_offset_t am_physical; /* bogus hack for i810 */ 6361452Sdfr vm_offset_t am_offset; /* page offset if bound */ 6461452Sdfr int am_is_bound; /* non-zero if bound */ 6561452Sdfr}; 6661452Sdfr 6761452Sdfr/* 6861452Sdfr * All chipset drivers must have this at the start of their softc. 6961452Sdfr */ 7061452Sdfrstruct agp_softc { 7161452Sdfr struct resource *as_aperture; /* location of aperture */ 72171433Sanholt int as_aperture_rid; 7361452Sdfr u_int32_t as_maxmem; /* allocation upper bound */ 7461452Sdfr u_int32_t as_allocated; /* amount allocated */ 7561452Sdfr enum agp_acquire_state as_state; 7661452Sdfr struct agp_memory_list as_memory; /* list of allocated memory */ 7761452Sdfr int as_nextid; /* next memory block id */ 7861452Sdfr int as_isopen; /* user device is open */ 79130585Sphk struct cdev *as_devnode; /* from make_dev */ 80129579Smux struct mtx as_lock; /* lock for access to GATT */ 8161452Sdfr}; 8261452Sdfr 8361452Sdfrstruct agp_gatt { 8461452Sdfr u_int32_t ag_entries; 8561452Sdfr u_int32_t *ag_virtual; 8661452Sdfr vm_offset_t ag_physical; 8761452Sdfr}; 8861452Sdfr 8961501Sdfrvoid agp_flush_cache(void); 9061452Sdfru_int8_t agp_find_caps(device_t dev); 9161452Sdfrstruct agp_gatt *agp_alloc_gatt(device_t dev); 92171433Sanholtvoid agp_set_aperture_resource(device_t dev, int rid); 93173203Sjhbvoid agp_free_cdev(device_t dev); 9461452Sdfrvoid agp_free_gatt(struct agp_gatt *gatt); 95173203Sjhbvoid agp_free_res(device_t dev); 9661452Sdfrint agp_generic_attach(device_t dev); 9761452Sdfrint agp_generic_detach(device_t dev); 98171433Sanholtint agp_generic_get_aperture(device_t dev); 99171433Sanholtint agp_generic_set_aperture(device_t dev, 100171433Sanholt u_int32_t aperture); 10161452Sdfrint agp_generic_enable(device_t dev, u_int32_t mode); 10261452Sdfrstruct agp_memory *agp_generic_alloc_memory(device_t dev, int type, 10361452Sdfr vm_size_t size); 10461452Sdfrint agp_generic_free_memory(device_t dev, 10561452Sdfr struct agp_memory *mem); 10661452Sdfrint agp_generic_bind_memory(device_t dev, 10761452Sdfr struct agp_memory *mem, 10861452Sdfr vm_offset_t offset); 10961452Sdfrint agp_generic_unbind_memory(device_t dev, 11061452Sdfr struct agp_memory *mem); 11161452Sdfr 11261452Sdfr#endif /* !_PCI_AGPPRIV_H_ */ 113