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