/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2000 Doug Rabson4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef _PCI_AGPPRIV_H_29#define _PCI_AGPPRIV_H_3031/*32* This file *must not* be included by code outside the agp driver itself.33*/3435#include <sys/agpio.h>36#include <dev/agp/agpvar.h>3738#ifdef AGP_DEBUG39#define AGP_DPF(fmt, ...) do { \40printf("agp: " fmt, ##__VA_ARGS__); \41} while (0)42#else43#define AGP_DPF(fmt, ...) do {} while (0)44#endif4546#include "agp_if.h"4748/*49* Data structure to describe an AGP memory allocation.50*/51TAILQ_HEAD(agp_memory_list, agp_memory);52struct agp_memory {53TAILQ_ENTRY(agp_memory) am_link; /* wiring for the tailq */54int am_id; /* unique id for block */55vm_size_t am_size; /* number of bytes allocated */56int am_type; /* chipset specific type */57struct vm_object *am_obj; /* VM object owning pages */58vm_offset_t am_physical; /* bogus hack for i810 */59vm_offset_t am_offset; /* page offset if bound */60int am_is_bound; /* non-zero if bound */61};6263/*64* All chipset drivers must have this at the start of their softc.65*/66struct agp_softc {67struct resource *as_aperture; /* location of aperture */68int as_aperture_rid;69u_int32_t as_maxmem; /* allocation upper bound */70u_int32_t as_allocated; /* amount allocated */71enum agp_acquire_state as_state;72struct agp_memory_list as_memory; /* list of allocated memory */73int as_nextid; /* next memory block id */74int as_isopen; /* user device is open */75struct cdev *as_devnode; /* from make_dev */76struct cdev *as_devalias;77struct mtx as_lock; /* lock for access to GATT */78};7980struct agp_gatt {81u_int32_t ag_entries;82u_int32_t *ag_virtual;83vm_offset_t ag_physical;84};8586u_int8_t agp_find_caps(device_t dev);87struct agp_gatt *agp_alloc_gatt(device_t dev);88void agp_set_aperture_resource(device_t dev, int rid);89void agp_free_cdev(device_t dev);90void agp_free_gatt(struct agp_gatt *gatt);91void agp_free_res(device_t dev);92int agp_generic_attach(device_t dev);93int agp_generic_detach(device_t dev);94u_int32_t agp_generic_get_aperture(device_t dev);95int agp_generic_set_aperture(device_t dev,96u_int32_t aperture);97int agp_generic_enable(device_t dev, u_int32_t mode);98struct agp_memory *agp_generic_alloc_memory(device_t dev, int type,99vm_size_t size);100int agp_generic_free_memory(device_t dev,101struct agp_memory *mem);102int agp_generic_bind_memory(device_t dev,103struct agp_memory *mem,104vm_offset_t offset);105int agp_generic_unbind_memory(device_t dev,106struct agp_memory *mem);107108#endif /* !_PCI_AGPPRIV_H_ */109110111