160727d8bSWarner Losh#- 259747216SDoug Rabson# Copyright (c) 2000 Doug Rabson 359747216SDoug Rabson# All rights reserved. 459747216SDoug Rabson# 559747216SDoug Rabson# Redistribution and use in source and binary forms, with or without 659747216SDoug Rabson# modification, are permitted provided that the following conditions 759747216SDoug Rabson# are met: 859747216SDoug Rabson# 1. Redistributions of source code must retain the above copyright 959747216SDoug Rabson# notice, this list of conditions and the following disclaimer. 1059747216SDoug Rabson# 2. Redistributions in binary form must reproduce the above copyright 1159747216SDoug Rabson# notice, this list of conditions and the following disclaimer in the 1259747216SDoug Rabson# documentation and/or other materials provided with the distribution. 1359747216SDoug Rabson# 1459747216SDoug Rabson# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1559747216SDoug Rabson# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1659747216SDoug Rabson# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1759747216SDoug Rabson# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1859747216SDoug Rabson# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1959747216SDoug Rabson# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2059747216SDoug Rabson# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2159747216SDoug Rabson# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2259747216SDoug Rabson# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2359747216SDoug Rabson# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2459747216SDoug Rabson# SUCH DAMAGE. 2559747216SDoug Rabson# 2659747216SDoug Rabson# 2759747216SDoug Rabson 2859747216SDoug Rabson#include <sys/bus.h> 2959747216SDoug Rabson 3059747216SDoug Rabson# 3159747216SDoug Rabson# The AGP interface is used internally to the agp driver to isolate the 3259747216SDoug Rabson# differences between various AGP chipsets into chipset mini drivers. It 3359747216SDoug Rabson# should not be used outside the AGP driver. The kernel api for accessing 34dbac8ff4SJohn Baldwin# AGP functionality is described in <dev/agp/agpvar.h> 3559747216SDoug Rabson# 3659747216SDoug RabsonINTERFACE agp; 3759747216SDoug Rabson 38*28d86329SKonstantin BelousovCODE { 39*28d86329SKonstantin Belousov static int 40*28d86329SKonstantin Belousov null_agp_chipset_flush(device_t dev) 41*28d86329SKonstantin Belousov { 42*28d86329SKonstantin Belousov return (ENXIO); 43*28d86329SKonstantin Belousov } 44*28d86329SKonstantin Belousov}; 45*28d86329SKonstantin Belousov 4659747216SDoug Rabson# 4759747216SDoug Rabson# Return the current aperture size. 4859747216SDoug Rabson# 4959747216SDoug RabsonMETHOD u_int32_t get_aperture { 5059747216SDoug Rabson device_t dev; 5159747216SDoug Rabson}; 5259747216SDoug Rabson 5359747216SDoug Rabson# 5459747216SDoug Rabson# Set the size of the aperture. Return EINVAL on error or 0 on success. 5559747216SDoug Rabson# 5659747216SDoug RabsonMETHOD int set_aperture { 5759747216SDoug Rabson device_t dev; 5859747216SDoug Rabson u_int32_t aperture; 5959747216SDoug Rabson}; 6059747216SDoug Rabson 6159747216SDoug Rabson# 6259747216SDoug Rabson# Bind a single page in the AGP aperture to a given physical address. 6359747216SDoug Rabson# The offset is a byte offset within the aperture which must be 6459747216SDoug Rabson# aligned to an AGP page boundary. 6559747216SDoug Rabson# 6659747216SDoug RabsonMETHOD int bind_page { 6759747216SDoug Rabson device_t dev; 6859747216SDoug Rabson vm_offset_t offset; 6959747216SDoug Rabson vm_offset_t physical; 7059747216SDoug Rabson}; 7159747216SDoug Rabson 7259747216SDoug Rabson# 7359747216SDoug Rabson# Unbind a single page in the AGP aperture. 7459747216SDoug Rabson# 7559747216SDoug RabsonMETHOD int unbind_page { 7659747216SDoug Rabson device_t dev; 7759747216SDoug Rabson vm_offset_t offset; 7859747216SDoug Rabson}; 7959747216SDoug Rabson 8059747216SDoug Rabson# 8159747216SDoug Rabson# Flush the GATT TLB. This is used after a call to bind_page to 8259747216SDoug Rabson# ensure that any mappings cached in the chipset are discarded. 8359747216SDoug Rabson# 8459747216SDoug RabsonMETHOD void flush_tlb { 8559747216SDoug Rabson device_t dev; 8659747216SDoug Rabson}; 8759747216SDoug Rabson 8859747216SDoug Rabson# 8959747216SDoug Rabson# Enable the agp hardware with the relavent mode. The mode bits are 90dbac8ff4SJohn Baldwin# defined in <dev/agp/agpreg.h> 9159747216SDoug Rabson# 9259747216SDoug RabsonMETHOD int enable { 9359747216SDoug Rabson device_t dev; 9459747216SDoug Rabson u_int32_t mode; 9559747216SDoug Rabson}; 9659747216SDoug Rabson 9759747216SDoug Rabson# 9859747216SDoug Rabson# Allocate memory of a given type. The type is a chipset-specific 9959747216SDoug Rabson# code which is used by certain integrated agp graphics chips 10059747216SDoug Rabson# (basically just the i810 for now) to access special features of 10159747216SDoug Rabson# the chipset. An opaque handle representing the memory region is 10259747216SDoug Rabson# returned and can be used as an argument to free_memory, bind_memory 10359747216SDoug Rabson# and unbind_memory. 10459747216SDoug Rabson# 10559747216SDoug Rabson# The size is specified in bytes but must be a multiple of the AGP 10659747216SDoug Rabson# page size. 10759747216SDoug Rabson# 10859747216SDoug RabsonMETHOD struct agp_memory * alloc_memory { 10959747216SDoug Rabson device_t dev; 11059747216SDoug Rabson int type; 11159747216SDoug Rabson vm_size_t size; 11259747216SDoug Rabson}; 11359747216SDoug Rabson 11459747216SDoug Rabson# 11559747216SDoug Rabson# Free a memory region previously allocated with alloc_memory. Return 11659747216SDoug Rabson# EBUSY if the memory is bound. 11759747216SDoug Rabson# 11859747216SDoug RabsonMETHOD int free_memory { 11959747216SDoug Rabson device_t dev; 12059747216SDoug Rabson struct agp_memory *mem; 12159747216SDoug Rabson}; 12259747216SDoug Rabson 12359747216SDoug Rabson# 12459747216SDoug Rabson# Bind a memory region to a specific byte offset within the chipset's 12559747216SDoug Rabson# AGP aperture. This effectively defines a range of contiguous 12659747216SDoug Rabson# physical address which alias the (possibly uncontiguous) pages in 12759747216SDoug Rabson# the memory region. 12859747216SDoug Rabson# 12959747216SDoug RabsonMETHOD int bind_memory { 13059747216SDoug Rabson device_t dev; 13159747216SDoug Rabson struct agp_memory *mem; 13259747216SDoug Rabson vm_offset_t offset; 13359747216SDoug Rabson}; 13459747216SDoug Rabson 13559747216SDoug Rabson# 13659747216SDoug Rabson# Unbind a memory region bound with bind_memory. 13759747216SDoug Rabson# 13859747216SDoug RabsonMETHOD int unbind_memory { 13959747216SDoug Rabson device_t dev; 14059747216SDoug Rabson struct agp_memory *handle; 14159747216SDoug Rabson}; 142*28d86329SKonstantin Belousov 143*28d86329SKonstantin BelousovMETHOD int chipset_flush { 144*28d86329SKonstantin Belousov device_t dev; 145*28d86329SKonstantin Belousov} DEFAULT null_agp_chipset_flush; 146