/*-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_AGPVAR_H_29#define _PCI_AGPVAR_H_3031/*32* The AGP chipset can be acquired by user or kernel code. If the33* chipset has already been acquired, it cannot be acquired by another34* user until the previous user has released it.35*/36enum agp_acquire_state {37AGP_ACQUIRE_FREE,38AGP_ACQUIRE_USER,39AGP_ACQUIRE_KERNEL40};4142/*43* This structure is used to query the state of the AGP system.44*/45struct agp_info {46u_int32_t ai_mode;47vm_offset_t ai_aperture_base;48vm_size_t ai_aperture_size;49vm_size_t ai_memory_allowed;50vm_size_t ai_memory_used;51u_int32_t ai_devid;52};5354struct agp_memory_info {55vm_size_t ami_size; /* size in bytes */56vm_offset_t ami_physical; /* bogus hack for i810 */57vm_offset_t ami_offset; /* page offset if bound */58int ami_is_bound; /* non-zero if bound */59};6061/*62* Find the AGP device and return it.63*/64device_t agp_find_device(void);6566/*67* Return the current owner of the AGP chipset.68*/69enum agp_acquire_state agp_state(device_t dev);7071/*72* Query the state of the AGP system.73*/74void agp_get_info(device_t dev, struct agp_info *info);7576/*77* Acquire the AGP chipset for use by the kernel. Returns EBUSY if the78* AGP chipset is already acquired by another user.79*/80int agp_acquire(device_t dev);8182/*83* Release the AGP chipset.84*/85int agp_release(device_t dev);8687/*88* Enable the agp hardware with the relavent mode. The mode bits are89* defined in <dev/agp/agpreg.h>90*/91int agp_enable(device_t dev, u_int32_t mode);9293/*94* Allocate physical memory suitable for mapping into the AGP95* aperture. The value returned is an opaque handle which can be96* passed to agp_bind(), agp_unbind() or agp_deallocate().97*/98void *agp_alloc_memory(device_t dev, int type, vm_size_t bytes);99100/*101* Free memory which was allocated with agp_allocate().102*/103void agp_free_memory(device_t dev, void *handle);104105/*106* Bind memory allocated with agp_allocate() at a given offset within107* the AGP aperture. Returns EINVAL if the memory is already bound or108* the offset is not at an AGP page boundary.109*/110int agp_bind_memory(device_t dev, void *handle, vm_offset_t offset);111112/*113* Unbind memory from the AGP aperture. Returns EINVAL if the memory114* is not bound.115*/116int agp_unbind_memory(device_t dev, void *handle);117118/*119* Retrieve information about a memory block allocated with120* agp_alloc_memory().121*/122void agp_memory_info(device_t dev, void *handle, struct agp_memory_info *mi);123124/*125* Bind a set of pages at a given offset within the AGP aperture.126* Returns EINVAL if the given size or offset is not at an AGP page boundary.127*/128int agp_bind_pages(device_t dev, vm_page_t *pages, vm_size_t size,129vm_offset_t offset);130131/*132* Unbind a set of pages from the AGP aperture.133* Returns EINVAL if the given size or offset is not at an AGP page boundary.134*/135int agp_unbind_pages(device_t dev, vm_size_t size, vm_offset_t offset);136137#define AGP_NORMAL_MEMORY 0138139#define AGP_USER_TYPES (1 << 16)140#define AGP_USER_MEMORY (AGP_USER_TYPES)141#define AGP_USER_CACHED_MEMORY (AGP_USER_TYPES + 1)142143#endif /* !_PCI_AGPVAR_H_ */144145146