xref: /netbsd-src/share/man/man4/agp.4 (revision 9fbd88883c38d0c0fbfcbe66d76fe6b0fab3f9de)
1.\"     $NetBSD: agp.4,v 1.6 2001/11/12 07:33:40 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.  The specification currently supports a peak bandwidth of 528 MB/s.
55.Pp
56The
57.Nm
58driver supports the following chipsets:
59.Pp
60.Bl -dash -compact indent
61.It
62ALI M1541 host-to-AGP bridge
63.It
64AMD 751 and 761 host-to-AGP bridges
65.It
66Intel 82810, 82810-DC100, 82810E, and 82815 SVGA controllers
67.It
68SiS 5591 host-to-AGP bridge
69.It
70VIA
71.El
72.Pp
73The
74.Nm
75driver also provides an interface to user processes for use by X
76servers.  A user process communicates to the device initially by means
77of
78.Xr ioctl 2
79calls.  The calls supported are:
80.Bl -tag -width indent
81.It Dv AGPIOC_INFO
82Get AGP information, setting the members in the
83.Em agp_info
84structure as defined in <sys/agpio.h>:
85.Bd -literal
86typedef struct _agp_info {
87        agp_version version;    /* version of the driver        */
88        u_int32_t bridge_id;    /* bridge vendor/device         */
89        u_int32_t agp_mode;     /* mode info of bridge          */
90        off_t aper_base;        /* base of aperture             */
91        size_t aper_size;       /* size of aperture             */
92        size_t pg_total;        /* max pages (swap + system)    */
93        size_t pg_system;       /* max pages (system)           */
94        size_t pg_used;         /* current pages used           */
95} agp_info;
96.Ed
97.It Dv AGPIOC_ACQUIRE
98Acquire AGP.
99.It Dv AGPIOC_RELEASE
100Release AGP.
101.It Dv AGPIOC_SETUP
102Setup AGP, using the members in the
103.Em agp_setup
104structure as defined in <sys/agpio.h>:
105.Bd -literal
106typedef struct _agp_setup {
107        u_int32_t agp_mode;     /* mode info of bridge          */
108} agp_setup;
109.Ed
110.It Dv AGPIOC_ALLOCATE
111Allocate AGP space, using and setting the members in the
112.Em agp_allocate
113structure as defined in <sys/agpio.h>:
114.Bd -literal
115typedef struct _agp_allocate {
116        int key;                /* tag of allocation            */
117        size_t pg_count;        /* number of pages              */
118        u_int32_t type;         /* 0 == normal, other devspec   */
119        paddr_t physical;       /* device specific (some devices
120                                 * need a phys address of the
121                                 * actual page behind the gatt
122                                 * table)                       */
123} agp_allocate;
124.Ed
125.It Dv AGPIOC_DEALLOCATE
126Deallocate AGP space.
127.It Dv AGPIOC_BIND
128Bind AGP space, using the members in the
129.Em agp_bind
130structure as defined in <sys/agpio.h>:
131.Bd -literal
132typedef struct _agp_bind {
133        int key;                /* tag of allocation            */
134        off_t pg_start;         /* starting page to populate    */
135} agp_bind;
136.Ed
137.It Dv AGPIOC_UNBIND
138Unbind AGP space, using the members in the
139.Em agp_unbind
140structure as defined in <sys/agpio.h>:
141.Bd -literal
142typedef struct _agp_unbind {
143        int key;                /* tag of allocation            */
144        u_int32_t priority;     /* priority for paging out      */
145} agp_unbind;
146.Ed
147.El
148.Sh FILES
149.Bl -tag -width /dev/agpgart -compact
150.It Pa /dev/agp?
151AGP GART device special files
152.It Pa /dev/agpgart
153AGP GART device special file
154.El
155.Sh EXAMPLES
156This short code fragment is an example of opening the AGP device
157and performing some basic operations:
158.Bd -literal
159#include <sys/types.h>
160#include <sys/ioctl.h>
161#include <sys/agpio.h>
162#include <fcntl.h>
163#include <err.h>
164
165int
166main(int argc, char **argv)
167{
168	int fd;
169	agp_info info;
170	agp_allocate alloc;
171	agp_setup setup;
172	agp_bind bind;
173	agp_unbind unbind;
174
175	fd = open("/dev/agp0", O_RDWR);
176	if (fd < 0)
177		err(1, "open");
178
179	if (ioctl(fd, AGPIOC_INFO, &info) < 0)
180		err(2, "ioctl AGPIOC_INFO");
181
182	printf("version:	%u.%u\\n", info.version.major,
183	    info.version.minor);
184
185	printf("id:		%x\\n", info.bridge_id);
186	printf("mode:		%x\\n", info.agp_mode);
187	printf("base:		%x\\n", info.aper_base);
188	printf("size:		%uM\\n", info.aper_size);
189	printf("total mem:	%u\\n", info.pg_total);
190	printf("system mem:	%u\\n", info.pg_system);
191	printf("used mem:	%u\\n\\n", info.pg_used);
192
193	setup.agp_mode = info.agp_mode;
194
195	if (ioctl(fd, AGPIOC_SETUP, &setup) < 0)
196		err(3, "ioctl AGPIOC_SETUP");
197
198	if (ioctl(fd, AGPIOC_ACQUIRE, 0) < 0)
199		err(3, "ioctl AGPIOC_ACQUIRE");
200
201	alloc.type = 0;
202	alloc.pg_count = 64;
203
204	if (ioctl(fd, AGPIOC_ALLOCATE, &alloc) < 0)
205		err(4, "ioctl AGPIOC_ALLOCATE");
206
207	printf("alloc key %d, paddr %x\\n", alloc.key, alloc.physical);
208	if (ioctl(fd, AGPIOC_INFO, &info) < 0)
209		err(5, "ioctl AGPIOC_INFO");
210
211	bind.key = alloc.key;
212	bind.pg_start = 0x1000;
213
214	if (ioctl(fd, AGPIOC_BIND, &bind) < 0)
215		err(6, "ioctl AGPIOC_BIND");
216
217	printf("used mem now:	%u\\n\\n", info.pg_used);
218
219	unbind.key = alloc.key;
220	unbind.priority = 0;
221
222	if (ioctl(fd, AGPIOC_UNBIND, &unbind) < 0)
223		err(6, "ioctl AGPIOC_BIND");
224
225	if (ioctl(fd, AGPIOC_DEALLOCATE, &alloc.key) < 0)
226		err(6, "ioctl AGPIOC_DEALLOCATE");
227
228	if (ioctl(fd, AGPIOC_RELEASE, 0) < 0)
229		err(7, "ioctl AGPIOC_RELEASE");
230
231	close(fd);
232
233	printf("agp test successful\\n");
234
235	return 0;
236}
237.Ed
238.Sh SEE ALSO
239.Xr ioctl 2 ,
240.Xr pci 4
241.Sh HISTORY
242The
243.Nm
244driver first appeared in
245.Fx 4.1 .
246It was adopted in
247.Nx 1.6 .
248