agp_if.m revision 173573
1154133Sharti#- 2154133Sharti# Copyright (c) 2000 Doug Rabson 3154133Sharti# All rights reserved. 4154133Sharti# 5154133Sharti# Redistribution and use in source and binary forms, with or without 6154133Sharti# modification, are permitted provided that the following conditions 7154133Sharti# are met: 8154133Sharti# 1. Redistributions of source code must retain the above copyright 9154133Sharti# notice, this list of conditions and the following disclaimer. 10154133Sharti# 2. Redistributions in binary form must reproduce the above copyright 11154133Sharti# notice, this list of conditions and the following disclaimer in the 12154133Sharti# documentation and/or other materials provided with the distribution. 13154133Sharti# 14154133Sharti# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15154133Sharti# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16154133Sharti# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17154133Sharti# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18154133Sharti# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19154133Sharti# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20154133Sharti# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21154133Sharti# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22154133Sharti# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23154133Sharti# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24154133Sharti# SUCH DAMAGE. 25154133Sharti# 26154133Sharti# $FreeBSD: head/sys/dev/agp/agp_if.m 173573 2007-11-12 21:51:38Z jhb $ 27154133Sharti# 28154133Sharti 29154133Sharti#include <sys/bus.h> 30154133Sharti 31154133Sharti# 32154133Sharti# The AGP interface is used internally to the agp driver to isolate the 33154133Sharti# differences between various AGP chipsets into chipset mini drivers. It 34154133Sharti# should not be used outside the AGP driver. The kernel api for accessing 35160341Sharti# AGP functionality is described in <dev/agp/agpvar.h> 36154133Sharti# 37154133ShartiINTERFACE agp; 38154133Sharti 39154133Sharti# 40154133Sharti# Return the current aperture size. 41154133Sharti# 42154133ShartiMETHOD u_int32_t get_aperture { 43154133Sharti device_t dev; 44154133Sharti}; 45154133Sharti 46154133Sharti# 47154133Sharti# Set the size of the aperture. Return EINVAL on error or 0 on success. 48154133Sharti# 49154133ShartiMETHOD int set_aperture { 50154133Sharti device_t dev; 51154133Sharti u_int32_t aperture; 52154133Sharti}; 53154133Sharti 54160341Sharti# 55154133Sharti# Bind a single page in the AGP aperture to a given physical address. 56154133Sharti# The offset is a byte offset within the aperture which must be 57154133Sharti# aligned to an AGP page boundary. 58154133Sharti# 59154133ShartiMETHOD int bind_page { 60160341Sharti device_t dev; 61160341Sharti vm_offset_t offset; 62160341Sharti vm_offset_t physical; 63160341Sharti}; 64160341Sharti 65160341Sharti# 66154133Sharti# Unbind a single page in the AGP aperture. 67154133Sharti# 68154133ShartiMETHOD int unbind_page { 69154133Sharti device_t dev; 70154133Sharti vm_offset_t offset; 71154133Sharti}; 72154133Sharti 73154133Sharti# 74154133Sharti# Flush the GATT TLB. This is used after a call to bind_page to 75154133Sharti# ensure that any mappings cached in the chipset are discarded. 76154133Sharti# 77154133ShartiMETHOD void flush_tlb { 78154133Sharti device_t dev; 79154133Sharti}; 80154133Sharti 81154133Sharti# 82154133Sharti# Enable the agp hardware with the relavent mode. The mode bits are 83154133Sharti# defined in <dev/agp/agpreg.h> 84154133Sharti# 85154133ShartiMETHOD int enable { 86154133Sharti device_t dev; 87154133Sharti u_int32_t mode; 88295435Skib}; 89154133Sharti 90154133Sharti# 91154133Sharti# Allocate memory of a given type. The type is a chipset-specific 92154133Sharti# code which is used by certain integrated agp graphics chips 93154133Sharti# (basically just the i810 for now) to access special features of 94154133Sharti# the chipset. An opaque handle representing the memory region is 95154133Sharti# returned and can be used as an argument to free_memory, bind_memory 96160341Sharti# and unbind_memory. 97154133Sharti# 98160341Sharti# The size is specified in bytes but must be a multiple of the AGP 99154133Sharti# page size. 100160341Sharti# 101160341ShartiMETHOD struct agp_memory * alloc_memory { 102160341Sharti device_t dev; 103160341Sharti int type; 104160341Sharti vm_size_t size; 105160341Sharti}; 106160341Sharti 107160341Sharti# 108160341Sharti# Free a memory region previously allocated with alloc_memory. Return 109160341Sharti# EBUSY if the memory is bound. 110160341Sharti# 111160341ShartiMETHOD int free_memory { 112160341Sharti device_t dev; 113160341Sharti struct agp_memory *mem; 114160341Sharti}; 115160341Sharti 116160341Sharti# 117160341Sharti# Bind a memory region to a specific byte offset within the chipset's 118154133Sharti# AGP aperture. This effectively defines a range of contiguous 119154133Sharti# physical address which alias the (possibly uncontiguous) pages in 120154133Sharti# the memory region. 121154133Sharti# 122154133ShartiMETHOD int bind_memory { 123160341Sharti device_t dev; 124160341Sharti struct agp_memory *mem; 125160341Sharti vm_offset_t offset; 126160341Sharti}; 127154133Sharti 128154133Sharti# 129160341Sharti# Unbind a memory region bound with bind_memory. 130154133Sharti# 131160341ShartiMETHOD int unbind_memory { 132154133Sharti device_t dev; 133154133Sharti struct agp_memory *handle; 134154133Sharti}; 135160341Sharti