1139825Simp#-
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: releng/10.3/sys/dev/agp/agp_if.m 235782 2012-05-22 10:59:26Z kib $
2761452Sdfr#
2861452Sdfr
2961452Sdfr#include <sys/bus.h>
3061452Sdfr
3161452Sdfr#
3261452Sdfr# The AGP interface is used internally to the agp driver to isolate the
3361452Sdfr# differences between various AGP chipsets into chipset mini drivers. It
3461452Sdfr# should not be used outside the AGP driver. The kernel api for accessing
35173573Sjhb# AGP functionality is described in <dev/agp/agpvar.h>
3661452Sdfr#
3761452SdfrINTERFACE agp;
3861452Sdfr
39235782SkibCODE {
40235782Skib	static int
41235782Skib	null_agp_chipset_flush(device_t dev)
42235782Skib	{
43235782Skib		return (ENXIO);
44235782Skib	}
45235782Skib};
46235782Skib
4761452Sdfr#
4861452Sdfr# Return the current aperture size.
4961452Sdfr#
5061452SdfrMETHOD u_int32_t get_aperture {
5161452Sdfr	device_t	dev;
5261452Sdfr};
5361452Sdfr
5461452Sdfr#
5561452Sdfr# Set the size of the aperture. Return EINVAL on error or 0 on success.
5661452Sdfr#
5761452SdfrMETHOD int set_aperture {
5861452Sdfr	device_t	dev;
5961452Sdfr	u_int32_t	aperture;
6061452Sdfr};
6161452Sdfr
6261452Sdfr#
6361452Sdfr# Bind a single page in the AGP aperture to a given physical address.
6461452Sdfr# The offset is a byte offset within the aperture which must be
6561452Sdfr# aligned to an AGP page boundary.
6661452Sdfr#
6761452SdfrMETHOD int bind_page {
6861452Sdfr	device_t	dev;
6961452Sdfr	vm_offset_t	offset;
7061452Sdfr	vm_offset_t	physical;
7161452Sdfr};
7261452Sdfr
7361452Sdfr#
7461452Sdfr# Unbind a single page in the AGP aperture.
7561452Sdfr#
7661452SdfrMETHOD int unbind_page {
7761452Sdfr	device_t	dev;
7861452Sdfr	vm_offset_t	offset;
7961452Sdfr};
8061452Sdfr
8161452Sdfr#
8261452Sdfr# Flush the GATT TLB. This is used after a call to bind_page to
8361452Sdfr# ensure that any mappings cached in the chipset are discarded.
8461452Sdfr#
8561452SdfrMETHOD void flush_tlb {
8661452Sdfr	device_t	dev;
8761452Sdfr};
8861452Sdfr
8961452Sdfr#
9061452Sdfr# Enable the agp hardware with the relavent mode. The mode bits are
91173573Sjhb# defined in <dev/agp/agpreg.h>
9261452Sdfr#
9361452SdfrMETHOD int enable {
9461452Sdfr	device_t	dev;
9561452Sdfr	u_int32_t	mode;
9661452Sdfr};
9761452Sdfr
9861452Sdfr#
9961452Sdfr# Allocate memory of a given type. The type is a chipset-specific
10061452Sdfr# code which is used by certain integrated agp graphics chips
10161452Sdfr# (basically just the i810 for now) to access special features of
10261452Sdfr# the chipset. An opaque handle representing the memory region is
10361452Sdfr# returned and can be used as an argument to free_memory, bind_memory 
10461452Sdfr# and unbind_memory.
10561452Sdfr#
10661452Sdfr# The size is specified in bytes but must be a multiple of the AGP
10761452Sdfr# page size.
10861452Sdfr#
10961452SdfrMETHOD struct agp_memory * alloc_memory {
11061452Sdfr	device_t	dev;
11161452Sdfr	int		type;
11261452Sdfr	vm_size_t	size;
11361452Sdfr};
11461452Sdfr
11561452Sdfr#
11661452Sdfr# Free a memory region previously allocated with alloc_memory. Return
11761452Sdfr# EBUSY if the memory is bound.
11861452Sdfr#
11961452SdfrMETHOD int free_memory {
12061452Sdfr	device_t	dev;
12161452Sdfr	struct agp_memory *mem;
12261452Sdfr};
12361452Sdfr
12461452Sdfr#
12561452Sdfr# Bind a memory region to a specific byte offset within the chipset's
12661452Sdfr# AGP aperture. This effectively defines a range of contiguous
12761452Sdfr# physical address which alias the (possibly uncontiguous) pages in
12861452Sdfr# the memory region.
12961452Sdfr#
13061452SdfrMETHOD int bind_memory {
13161452Sdfr	device_t	dev;
13261452Sdfr	struct agp_memory *mem;
13361452Sdfr	vm_offset_t	offset;
13461452Sdfr};
13561452Sdfr
13661452Sdfr#
13761452Sdfr# Unbind a memory region bound with bind_memory.
13861452Sdfr#
13961452SdfrMETHOD int unbind_memory {
14061452Sdfr	device_t	dev;
14161452Sdfr	struct agp_memory *handle;
14261452Sdfr};
143235782Skib
144235782SkibMETHOD int chipset_flush {
145235782Skib	device_t	dev;
146235782Skib} DEFAULT null_agp_chipset_flush;
147