1.\" $NetBSD: agp.4,v 1.17 2017/07/03 21:30:58 wiz Exp $ 2.\" 3.\" Copyright (c) 2001 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Gregory McGarry. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd October 3, 2010 31.Dt AGP 4 32.Os 33.Sh NAME 34.Nm agp 35.Nd accelerated graphics port driver 36.Sh SYNOPSIS 37.Cd "agp* at pchb?" 38.Sh DESCRIPTION 39The 40.Nm 41driver provides machine-independent support for the accelerated 42graphics port (AGP) found on many PC-based and PCI systems. 43The AGP specification was designed by Intel. 44.Pp 45The AGP chipset is positioned between the PCI-Host bridge and the 46graphics accelerator to provide a high-performance dedicated graphics 47bus for moving large amounts of data directly from host memory to the 48graphics accelerator. 49The specification currently supports a peak bandwidth of 528 MB/s. 50AGP uses a Graphics Address Remapping Table (GART) to provide a 51physically-contiguous view of scattered pages in host memory for 52DMA transfers. 53.Pp 54The 55.Nm 56driver supports the following chipsets: 57.Pp 58.Bl -dash -compact -offset indent 59.It 60ALI M1541 host-to-AGP bridge 61.It 62AMD 751 and 761 host-to-AGP bridges 63.It 64Intel 82810, 82810-DC100, 82810E, and 82815 SVGA controllers 65.It 66SiS 5591 host-to-AGP bridge 67.It 68VIA 69.El 70.Pp 71The 72.Nm 73driver also provides an interface to user processes for use by X 74servers. 75A user process communicates to the device initially by means of 76.Xr ioctl 2 77calls. 78The calls supported are: 79.Bl -tag -width indent 80.It Dv AGPIOC_INFO 81Get AGP information, setting the members in the 82.Em agp_info 83structure as defined in <sys/agpio.h>: 84.Bd -literal 85typedef struct _agp_info { 86 agp_version version; /* version of the driver */ 87 uint32_t bridge_id; /* bridge vendor/device */ 88 uint32_t agp_mode; /* mode info of bridge */ 89 off_t aper_base; /* base of aperture */ 90 size_t aper_size; /* size of aperture */ 91 size_t pg_total; /* max pages (swap + system) */ 92 size_t pg_system; /* max pages (system) */ 93 size_t pg_used; /* current pages used */ 94} agp_info; 95.Ed 96.It Dv AGPIOC_ACQUIRE 97Acquire AGP. 98.It Dv AGPIOC_RELEASE 99Release AGP. 100.It Dv AGPIOC_SETUP 101Set up AGP, using the members in the 102.Em agp_setup 103structure as defined in <sys/agpio.h>: 104.Bd -literal 105typedef struct _agp_setup { 106 uint32_t agp_mode; /* mode info of bridge */ 107} agp_setup; 108.Ed 109.It Dv AGPIOC_ALLOCATE 110Allocate AGP space, using and setting the members in the 111.Em agp_allocate 112structure as defined in <sys/agpio.h>: 113.Bd -literal 114typedef struct _agp_allocate { 115 int key; /* tag of allocation */ 116 size_t pg_count; /* number of pages */ 117 uint32_t type; /* 0 == normal, other devspec */ 118 uint32_t physical; /* device specific (some devices 119 * need a phys address of the 120 * actual page behind the gatt 121 * table) */ 122} agp_allocate; 123.Ed 124.It Dv AGPIOC_DEALLOCATE 125Deallocate AGP space. 126.It Dv AGPIOC_BIND 127Bind AGP space, using the members in the 128.Em agp_bind 129structure as defined in <sys/agpio.h>: 130.Bd -literal 131typedef struct _agp_bind { 132 int key; /* tag of allocation */ 133 off_t pg_start; /* starting page to populate */ 134} agp_bind; 135.Ed 136.It Dv AGPIOC_UNBIND 137Unbind AGP space, using the members in the 138.Em agp_unbind 139structure as defined in <sys/agpio.h>: 140.Bd -literal 141typedef struct _agp_unbind { 142 int key; /* tag of allocation */ 143 uint32_t priority; /* priority for paging out */ 144} agp_unbind; 145.Ed 146.El 147.Sh FILES 148.Bl -tag -width /dev/agpgart -compact 149.It Pa /dev/agp? 150AGP GART device special files 151.It Pa /dev/agpgart 152AGP GART device special file 153.El 154.Sh EXAMPLES 155This short code fragment is an example of opening the AGP device 156and performing some basic operations: 157.Bd -literal 158#include <sys/types.h> 159#include <sys/ioctl.h> 160#include <sys/agpio.h> 161#include <fcntl.h> 162#include <err.h> 163 164int 165main(int argc, char **argv) 166{ 167 int fd; 168 agp_info info; 169 agp_allocate alloc; 170 agp_setup setup; 171 agp_bind bind; 172 agp_unbind unbind; 173 174 fd = open("/dev/agp0", O_RDWR); 175 if (fd < 0) 176 err(1, "open"); 177 178 if (ioctl(fd, AGPIOC_INFO, &info) < 0) 179 err(2, "ioctl AGPIOC_INFO"); 180 181 printf("version: %u.%u\\n", info.version.major, 182 info.version.minor); 183 184 printf("id: %x\\n", info.bridge_id); 185 printf("mode: %x\\n", info.agp_mode); 186 printf("base: %x\\n", info.aper_base); 187 printf("size: %uM\\n", info.aper_size); 188 printf("total mem: %u\\n", info.pg_total); 189 printf("system mem: %u\\n", info.pg_system); 190 printf("used mem: %u\\n\\n", info.pg_used); 191 192 setup.agp_mode = info.agp_mode; 193 194 if (ioctl(fd, AGPIOC_SETUP, &setup) < 0) 195 err(3, "ioctl AGPIOC_SETUP"); 196 197 if (ioctl(fd, AGPIOC_ACQUIRE, 0) < 0) 198 err(3, "ioctl AGPIOC_ACQUIRE"); 199 200 alloc.type = 0; 201 alloc.pg_count = 64; 202 203 if (ioctl(fd, AGPIOC_ALLOCATE, &alloc) < 0) 204 err(4, "ioctl AGPIOC_ALLOCATE"); 205 206 printf("alloc key %d, paddr %x\\n", alloc.key, alloc.physical); 207 if (ioctl(fd, AGPIOC_INFO, &info) < 0) 208 err(5, "ioctl AGPIOC_INFO"); 209 210 bind.key = alloc.key; 211 bind.pg_start = 0x1000; 212 213 if (ioctl(fd, AGPIOC_BIND, &bind) < 0) 214 err(6, "ioctl AGPIOC_BIND"); 215 216 printf("used mem now: %u\\n\\n", info.pg_used); 217 218 unbind.key = alloc.key; 219 unbind.priority = 0; 220 221 if (ioctl(fd, AGPIOC_UNBIND, &unbind) < 0) 222 err(6, "ioctl AGPIOC_BIND"); 223 224 if (ioctl(fd, AGPIOC_DEALLOCATE, &alloc.key) < 0) 225 err(6, "ioctl AGPIOC_DEALLOCATE"); 226 227 if (ioctl(fd, AGPIOC_RELEASE, 0) < 0) 228 err(7, "ioctl AGPIOC_RELEASE"); 229 230 close(fd); 231 232 printf("agp test successful\\n"); 233 234 return 0; 235} 236.Ed 237.Sh SEE ALSO 238.Xr ioctl 2 , 239.Xr pci 4 240.Sh HISTORY 241The 242.Nm 243driver first appeared in 244.Fx 4.1 . 245It was adopted in 246.Nx 1.6 . 247