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$ 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> 37173573Sjhb#include <dev/agp/agpvar.h> 3861452Sdfr 3961452Sdfr#ifdef AGP_DEBUG 40186384Srnoland#define AGP_DPF(fmt, ...) do { \ 41186385Srnoland printf("agp: " fmt, ##__VA_ARGS__); \ 4261452Sdfr} while (0) 4361452Sdfr#else 44186384Srnoland#define AGP_DPF(fmt, ...) do {} while (0) 4561452Sdfr#endif 4661452Sdfr 4761452Sdfr#include "agp_if.h" 4861452Sdfr 4961452Sdfr/* 5061452Sdfr * Data structure to describe an AGP memory allocation. 5161452Sdfr */ 5261452SdfrTAILQ_HEAD(agp_memory_list, agp_memory); 5361452Sdfrstruct agp_memory { 5461452Sdfr TAILQ_ENTRY(agp_memory) am_link; /* wiring for the tailq */ 5561452Sdfr int am_id; /* unique id for block */ 5661452Sdfr vm_size_t am_size; /* number of bytes allocated */ 5763010Sdfr int am_type; /* chipset specific type */ 5861452Sdfr struct vm_object *am_obj; /* VM object owning pages */ 5961452Sdfr vm_offset_t am_physical; /* bogus hack for i810 */ 6061452Sdfr vm_offset_t am_offset; /* page offset if bound */ 6161452Sdfr int am_is_bound; /* non-zero if bound */ 6261452Sdfr}; 6361452Sdfr 6461452Sdfr/* 6561452Sdfr * All chipset drivers must have this at the start of their softc. 6661452Sdfr */ 6761452Sdfrstruct agp_softc { 6861452Sdfr struct resource *as_aperture; /* location of aperture */ 69171433Sanholt int as_aperture_rid; 7061452Sdfr u_int32_t as_maxmem; /* allocation upper bound */ 7161452Sdfr u_int32_t as_allocated; /* amount allocated */ 7261452Sdfr enum agp_acquire_state as_state; 7361452Sdfr struct agp_memory_list as_memory; /* list of allocated memory */ 7461452Sdfr int as_nextid; /* next memory block id */ 7561452Sdfr int as_isopen; /* user device is open */ 76235782Skib struct cdev *as_devnode; /* from make_dev */ 77129579Smux struct mtx as_lock; /* lock for access to GATT */ 7861452Sdfr}; 7961452Sdfr 8061452Sdfrstruct agp_gatt { 8161452Sdfr u_int32_t ag_entries; 8261452Sdfr u_int32_t *ag_virtual; 8361452Sdfr vm_offset_t ag_physical; 8461452Sdfr}; 8561452Sdfr 8661452Sdfru_int8_t agp_find_caps(device_t dev); 8761452Sdfrstruct agp_gatt *agp_alloc_gatt(device_t dev); 88171433Sanholtvoid agp_set_aperture_resource(device_t dev, int rid); 89173203Sjhbvoid agp_free_cdev(device_t dev); 9061452Sdfrvoid agp_free_gatt(struct agp_gatt *gatt); 91173203Sjhbvoid agp_free_res(device_t dev); 9261452Sdfrint agp_generic_attach(device_t dev); 9361452Sdfrint agp_generic_detach(device_t dev); 94189578Simpu_int32_t agp_generic_get_aperture(device_t dev); 95171433Sanholtint agp_generic_set_aperture(device_t dev, 96171433Sanholt u_int32_t aperture); 9761452Sdfrint agp_generic_enable(device_t dev, u_int32_t mode); 9861452Sdfrstruct agp_memory *agp_generic_alloc_memory(device_t dev, int type, 9961452Sdfr vm_size_t size); 10061452Sdfrint agp_generic_free_memory(device_t dev, 10161452Sdfr struct agp_memory *mem); 10261452Sdfrint agp_generic_bind_memory(device_t dev, 10361452Sdfr struct agp_memory *mem, 10461452Sdfr vm_offset_t offset); 10561452Sdfrint agp_generic_unbind_memory(device_t dev, 10661452Sdfr struct agp_memory *mem); 10761452Sdfr 10861452Sdfr#endif /* !_PCI_AGPPRIV_H_ */ 109