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