1 .\" $NetBSD: agp.4,v 1.11 2005/12/26 19:48:12 perry Exp $
3 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Gregory McGarry.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
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.
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.
30 .Dd September 11, 2001
35 .Nd accelerated graphics port driver
41 driver provides machine-independent support for the accelerated
42 graphics port (AGP) found on many PC-based and PCI systems. The AGP
43 specification was designed by Intel.
45 The AGP chipset is positioned between the PCI-Host bridge and the
46 graphics accelerator to provide a high-performance dedicated graphics
47 bus for moving large amounts of data directly from host memory to the
48 graphics accelerator. The specification currently supports a peak
49 bandwidth of 528 MB/s. AGP uses a Graphics Address Remapping Table
50 (GART) to provide a physically-contiguous view of scattered pages in
51 host memory for DMA transfers.
55 driver supports the following chipsets:
57 .Bl -dash -compact -offset indent
59 ALI M1541 host-to-AGP bridge
61 AMD 751 and 761 host-to-AGP bridges
63 Intel 82810, 82810-DC100, 82810E, and 82815 SVGA controllers
65 SiS 5591 host-to-AGP bridge
72 driver also provides an interface to user processes for use by X
73 servers. A user process communicates to the device initially by means
76 calls. The calls supported are:
77 .Bl -tag -width indent
79 Get AGP information, setting the members in the
81 structure as defined in \*[Lt]sys/agpio.h\*[Gt]:
83 typedef struct _agp_info {
84 agp_version version; /* version of the driver */
85 uint32_t bridge_id; /* bridge vendor/device */
86 uint32_t agp_mode; /* mode info of bridge */
87 off_t aper_base; /* base of aperture */
88 size_t aper_size; /* size of aperture */
89 size_t pg_total; /* max pages (swap + system) */
90 size_t pg_system; /* max pages (system) */
91 size_t pg_used; /* current pages used */
99 Set up AGP, using the members in the
101 structure as defined in \*[Lt]sys/agpio.h\*[Gt]:
103 typedef struct _agp_setup {
104 uint32_t agp_mode; /* mode info of bridge */
107 .It Dv AGPIOC_ALLOCATE
108 Allocate AGP space, using and setting the members in the
110 structure as defined in \*[Lt]sys/agpio.h\*[Gt]:
112 typedef struct _agp_allocate {
113 int key; /* tag of allocation */
114 size_t pg_count; /* number of pages */
115 uint32_t type; /* 0 == normal, other devspec */
116 paddr_t physical; /* device specific (some devices
117 * need a phys address of the
118 * actual page behind the gatt
122 .It Dv AGPIOC_DEALLOCATE
123 Deallocate AGP space.
125 Bind AGP space, using the members in the
127 structure as defined in \*[Lt]sys/agpio.h\*[Gt]:
129 typedef struct _agp_bind {
130 int key; /* tag of allocation */
131 off_t pg_start; /* starting page to populate */
135 Unbind AGP space, using the members in the
137 structure as defined in \*[Lt]sys/agpio.h\*[Gt]:
139 typedef struct _agp_unbind {
140 int key; /* tag of allocation */
141 uint32_t priority; /* priority for paging out */
146 .Bl -tag -width /dev/agpgart -compact
148 AGP GART device special files
150 AGP GART device special file
153 This short code fragment is an example of opening the AGP device
154 and performing some basic operations:
156 #include \*[Lt]sys/types.h\*[Gt]
157 #include \*[Lt]sys/ioctl.h\*[Gt]
158 #include \*[Lt]sys/agpio.h\*[Gt]
159 #include \*[Lt]fcntl.h\*[Gt]
160 #include \*[Lt]err.h\*[Gt]
163 main(int argc, char **argv)
172 fd = open("/dev/agp0", O_RDWR);
176 if (ioctl(fd, AGPIOC_INFO, \*[Am]info) \*[Lt] 0)
177 err(2, "ioctl AGPIOC_INFO");
179 printf("version: %u.%u\\n", info.version.major,
182 printf("id: %x\\n", info.bridge_id);
183 printf("mode: %x\\n", info.agp_mode);
184 printf("base: %x\\n", info.aper_base);
185 printf("size: %uM\\n", info.aper_size);
186 printf("total mem: %u\\n", info.pg_total);
187 printf("system mem: %u\\n", info.pg_system);
188 printf("used mem: %u\\n\\n", info.pg_used);
190 setup.agp_mode = info.agp_mode;
192 if (ioctl(fd, AGPIOC_SETUP, \*[Am]setup) \*[Lt] 0)
193 err(3, "ioctl AGPIOC_SETUP");
195 if (ioctl(fd, AGPIOC_ACQUIRE, 0) \*[Lt] 0)
196 err(3, "ioctl AGPIOC_ACQUIRE");
201 if (ioctl(fd, AGPIOC_ALLOCATE, \*[Am]alloc) \*[Lt] 0)
202 err(4, "ioctl AGPIOC_ALLOCATE");
204 printf("alloc key %d, paddr %x\\n", alloc.key, alloc.physical);
205 if (ioctl(fd, AGPIOC_INFO, \*[Am]info) \*[Lt] 0)
206 err(5, "ioctl AGPIOC_INFO");
208 bind.key = alloc.key;
209 bind.pg_start = 0x1000;
211 if (ioctl(fd, AGPIOC_BIND, \*[Am]bind) \*[Lt] 0)
212 err(6, "ioctl AGPIOC_BIND");
214 printf("used mem now: %u\\n\\n", info.pg_used);
216 unbind.key = alloc.key;
219 if (ioctl(fd, AGPIOC_UNBIND, \*[Am]unbind) \*[Lt] 0)
220 err(6, "ioctl AGPIOC_BIND");
222 if (ioctl(fd, AGPIOC_DEALLOCATE, \*[Am]alloc.key) \*[Lt] 0)
223 err(6, "ioctl AGPIOC_DEALLOCATE");
225 if (ioctl(fd, AGPIOC_RELEASE, 0) \*[Lt] 0)
226 err(7, "ioctl AGPIOC_RELEASE");
230 printf("agp test successful\\n");
241 driver first appeared in