Print this page
4023 - Typo in file(1) manpage and various others
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man7i/agpgart_io.7i
+++ new/usr/src/man/man7i/agpgart_io.7i
1 1 '\" te
2 2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
3 3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 -.TH AGPGART_IO 7I "Sep 25, 2008"
6 +.TH AGPGART_IO 7I "Sep 10, 2013"
7 7 .SH NAME
8 8 agpgart_io \- Solaris agpgart driver I/O control operations
9 9 .SH SYNOPSIS
10 10 .LP
11 11 .nf
12 12 #include <sys/agpgart.h>
13 13 .fi
14 14
15 15 .SH DESCRIPTION
16 16 .sp
17 17 .LP
18 18 The Accelerated Graphics Port (AGP) is a PCI bus technology enhancement that
19 19 improves 3D graphics performance by using low-cost system memory. AGP chipsets
20 20 use the Graphics Address Remapping Table (GART) to map discontiguous system
21 21 memory into a contiguous PCI memory range (known as the AGP Aperture), enabling
22 22 the graphics card to utilize the mapped aperture range as video memory.
23 23 .sp
24 24 .LP
25 25 The \fBagpgart\fR driver creates a pseudo device node at \fB/dev/agpgart\fR and
26 26 provides a set of ioctls for managing allocation/deallocation of system
27 27 memory, setting mappings between system memory and aperture range, and setting
28 28 up AGP devices. The \fBagpgart\fR driver manages both pseudo and real device
29 29 nodes, but to initiate AGP-related operations you operate only on the
30 30 \fB/dev/agpgart\fR pseudo device node. To do this, open \fB/dev/agpgart\fR. The
31 31 macro defined for the pseudo device node name is:
32 32 .sp
33 33 .in +2
34 34 .nf
35 35 #define AGP_DEVICE "/dev/agpgart"
36 36 .fi
37 37 .in -2
38 38
39 39 .sp
40 40 .LP
41 41 The \fBagpgart_io\fR driver implementation is AGP architecture-dependent and
42 42 cannot be made generic. Currently, the \fBagpgart_io\fR driver only supports
43 43 specific AGP systems. To determine if a system is supported, run an
44 44 \fBopen\fR(2) system call on the AGP_DEVICE node. (Note that \fBopen\fR(2)
45 45 fails if a system is not supported). After the AGP_DEVICE is opened, you can
46 46 use \fBkstat\fR(1M) to read the system architecture type.
47 47 .sp
48 48 .LP
49 49 In addition to AGP system support, the \fBagpgart\fR ioctls can also be used on
50 50 Intel integrated graphics devices (IGD). IGD devices usually have no dedicated
51 51 video memory and must use system memory as video memory. IGD devices contain
52 52 translation tables (referred to as \fBGTT\fR tables) that are similar to the
53 53 GART translation table for address mapping purposes.
54 54 .sp
55 55 .LP
56 56 Processes must open the \fBagpgart_io\fR driver utilizing a GRAPHICS_ACCESS
57 57 privilege. Then all the ioctls can be called by this processes with the saved
58 58 file descriptor. With the exception of AGPIOC_INFO, the AGPIOC_ACQUIRE ioctl
59 59 must be called before any other ioctl. Once a process has acquired GART, it
60 60 cannot be acquired by another process until the former process calls
61 61 AGPIOC_RELEASE.
62 62 .sp
63 63 .LP
64 64 If the AGP_DEVICE fails to open, it may be due to one of the following reasons:
65 65 .sp
66 66 .ne 2
67 67 .na
68 68 \fBEAGAIN\fR
69 69 .ad
70 70 .sp .6
71 71 .RS 4n
72 72 GART table allocation failed.
73 73 .RE
74 74
75 75 .sp
76 76 .ne 2
77 77 .na
78 78 \fBEIO\fR
79 79 .ad
80 80 .sp .6
81 81 .RS 4n
82 82 Internal hardware initialization failed.
83 83 .RE
84 84
85 85 .sp
86 86 .ne 2
87 87 .na
88 88 \fBENXIO\fR
89 89 .ad
90 90 .sp .6
91 91 .RS 4n
92 92 Getting device soft state error. (This is unlikely to happen.)
93 93 .RE
94 94
95 95 .sp
96 96 .ne 2
97 97 .na
98 98 \fB EPERM\fR
99 99 .ad
100 100 .sp .6
101 101 .RS 4n
102 102 Without enough privilege.
103 103 .RE
104 104
105 105 .SH IOCTLS
106 106 .sp
107 107 .LP
108 108 With the exception of GPIOC_INFO, all ioctls shown in this section are
109 109 protected by GRAPHICS_ACCESS privilege. (Only processes with GRAPHICS_ACCESS
110 110 privilege in its effective set can access the privileged ioctls).
111 111 .sp
112 112 .LP
113 113 Common ioctl error codes are shown below. (Additional error codes may be
114 114 displayed by individual ioctls.)
115 115 .sp
116 116 .ne 2
117 117 .na
118 118 \fBENXIO\fR
119 119 .ad
120 120 .sp .6
121 121 .RS 4n
122 122 Ioctl command not supported or getting device soft state error.
123 123 .RE
124 124
125 125 .sp
126 126 .ne 2
127 127 .na
128 128 \fBEPERM\fR
129 129 .ad
130 130 .sp .6
131 131 .RS 4n
132 132 Process not privileged.
133 133 .RE
134 134
135 135 .sp
136 136 .ne 2
137 137 .na
138 138 \fB\fBAGPIOC_INFO\fR\fR
139 139 .ad
140 140 .sp .6
141 141 .RS 4n
142 142 Get system wide AGP or IGD hardware information. This command can be called by
143 143 any process from user or kernel context.
144 144 .sp
145 145 .in +2
146 146 .nf
147 147 The argument is a pointer to agp_info_t structure.
148 148
149 149 typedef struct _agp_info {
150 150 agp_version_t agpi_version; /* OUT: AGP version supported */
151 151 uint32_t agpi_devid; /* OUT: bridge vendor + device */
152 152 uint32_t agpi_mode; /* OUT: mode of bridge */
153 153 ulong_t agpi_aperbase; /* OUT: base of aperture */
154 154 size_t agpi_apersize; /* OUT: aperture size in MB */
155 155 uint32_t agpi_pgtotal; /* OUT: max aperture pages avail. */
156 156 uint32_t agpi_pgsystem; /* OUT: same as pg_total */
157 157 uint32_t agpi_pgused; /* OUT: no. of currently used pages */
158 158 } agp_info_t;
159 159
160 160 agpi_version The version of AGP protocol the bridge device is
161 161 compatible with, for example, major 3 and minor 0
162 162 means AGP version 3.0.
163 163
164 164 typedef struct _agp_version {
165 165 uint16_t agpv_major;
166 166 uint16_t agpv_minor;
167 167 } agp_version_t;
168 168
169 169 agpi_devid AGP bridge vendor and device ID.
170 170 agpi_mode Current AGP mode, read from AGP status register of
171 171 target device. The main bits are defined as below.
172 172 /* AGP status register bits definition */
173 173
174 174 #define AGPSTAT_RQ_MASK 0xff000000
175 175 #define AGPSTAT_SBA (0x1 << 9)
176 176 #define AGPSTAT_OVER4G (0x1 << 5)
177 177 #define AGPSTAT_FW (0x1 << 4)
178 178 #define AGPSTAT_RATE_MASK 0x7
179 179 /* AGP 3.0 only bits */
180 180 #define AGPSTAT_ARQSZ_MASK (0x7 << 13)
181 181 #define AGPSTAT_CAL_MASK (0x7 << 10)
182 182 #define AGPSTAT_GART64B (0x1 << 7)
183 183 #define AGPSTAT_MODE3 (0x1 << 3)
184 184 /* rate for 2.0 mode */
185 185 #define AGP2_RATE_1X 0x1
186 186 #define AGP2_RATE_2X 0x2
187 187 #define AGP2_RATE_4X 0x4
188 188 /* rate for 3.0 mode */
189 189 #define AGP3_RATE_4X 0x1
190 190 #define AGP3_RATE_8X 0x2
191 191
192 192 agpi_aperbase The base address of aperture in PCI memory space.
193 193 agpi_apersize The size of the aperture in megabytes.
194 194 agpi_pgtotal Represents the maximum memory
195 195 pages the system can allocate
196 196 according to aperture size and
197 197 system memory size (which may differ
198 198 from the maximum locked memory a process
199 199 can have. The latter is subject
200 200 to the memory resource limit imposed
201 201 by the resource_controls(5) for each
202 202 project(4)):
203 203
204 204 project.max-device-locked-memory
205 205
206 206 This value can be modified through system
207 207 utilities like prctl(1).
208 208
209 209 agpi_pgsystem Same as pg_total.
210 210 agpi_pgused System pages already allocated by the driver.
211 211
212 212 Return Values:
213 213
214 214 EFAULT Argument copy out error
215 215 EINVAL Command invalid
216 216 0 Success
217 217 .fi
218 218 .in -2
219 219
220 220 .RE
221 221
222 222 .sp
223 223 .ne 2
224 224 .na
225 225 \fB\fBAGPIOC_ACQUIRE\fR\fR
226 226 .ad
227 227 .sp .6
228 228 .RS 4n
229 229 Acquire control of GART. With the exception of AGPIOC_INFO, a process must
230 230 acquire GART before can it call other agpgart ioctl commands. Additionally,
231 231 only processes with GRAPHICS_ACCESS privilege may access this ioctl. In the
232 232 current agpgart implementation, GART access is exclusive, meaning that only one
233 233 process can perform GART operations at a time. To release control over GART,
234 234 call AGPIOC_RELEASE. This command can be called from user or kernel context.
235 235 .sp
236 236 The argument should be NULL.
237 237 .sp
238 238 Return values:
239 239 .sp
240 240 .ne 2
241 241 .na
242 242 \fBEBUSY\fR
243 243 .ad
244 244 .RS 9n
245 245 GART has been acquired
246 246 .RE
247 247
248 248 .sp
249 249 .ne 2
250 250 .na
251 251 \fB0\fR
252 252 .ad
253 253 .RS 9n
254 254 Success.
255 255 .RE
256 256
257 257 .RE
258 258
259 259 .sp
260 260 .ne 2
261 261 .na
262 262 \fB\fBAGPIOC_RELEASE\fR\fR
263 263 .ad
264 264 .sp .6
265 265 .RS 4n
266 266 Release GART control. If a process releases GART control, it cannot perform
267 267 additional GART operations until GART is reacquired. Note that this command
268 268 does not free allocated memory or clear GART entries. (All clear jobs are done
269 269 by direct calls or by closing the device). When a process exits without making
270 270 this ioctl, the final \fBclose\fR(2) performs this automatically. This command
271 271 can be called from user or kernel context.
272 272 .sp
273 273 The argument should be NULL.
274 274 .sp
275 275 Return values:
276 276 .sp
277 277 .ne 2
278 278 .na
279 279 \fBEPERM\fR
280 280 .ad
281 281 .RS 9n
282 282 Not owner of GART.
283 283 .RE
284 284
285 285 .sp
286 286 .ne 2
287 287 .na
288 288 \fB0\fR
289 289 .ad
290 290 .RS 9n
291 291 Success.
292 292 .RE
293 293
294 294 .RE
295 295
296 296 .sp
297 297 .ne 2
298 298 .na
299 299 \fB\fBAGPIOC_SETUP\fR\fR
300 300 .ad
301 301 .sp .6
302 302 .RS 4n
303 303 Setup AGPCMD register. An AGPCMD register resides in both the AGP master and
304 304 target devices. The AGPCMD register controls the working mode of the AGP master
305 305 and target devices. Each device must be configured using the same mode. This
306 306 command can be called from user or kernel context.
307 307 .sp
308 308 .in +2
309 309 .nf
310 310 The argument is a pointer to agp_setup_t structure:
311 311
312 312 typedef struct _agp_setup {
313 313 uint32_t agps_mode; /* IN: value to be set for AGPCMD */
314 314 } agp_setup_t;
315 315
316 316 agps_mode Specifying the mode to be set. Each bit of the value may have
317 317 a specific meaning, please refer to AGP 2.0/3.0 specification
318 318 or hardware datasheets for details.
319 319
320 320 /* AGP command register bits definition */
321 321 #define AGPCMD_RQ_MASK 0xff000000
322 322 #define AGPCMD_SBAEN (0x1 << 9)
323 323 #define AGPCMD_AGPEN (0x1 << 8)
324 324 #define AGPCMD_OVER4GEN (0x1 << 5)
325 325 #define AGPCMD_FWEN (0x1 << 4)
326 326 #define AGPCMD_RATE_MASK 0x7
327 327 /* AGP 3.0 only bits */
328 328 #define AGP3_CMD_ARQSZ_MASK (0x7 << 13)
329 329 #define AGP3_CMD_CAL_MASK (0x7 << 10)
330 330 #define AGP3_CMD_GART64BEN (0x1 << 7)
331 331 .fi
332 332 .in -2
333 333
334 334 The final values set to the AGPCMD register of the master/target devices are
335 335 decided by the agps_mode value and AGPSTAT of the master and target devices.
336 336 .sp
337 337 Return Values:
338 338 .sp
339 339 .ne 2
340 340 .na
341 341 \fBEPERM\fR
342 342 .ad
343 343 .RS 10n
344 344 Not owner of GART.
345 345 .RE
346 346
347 347 .sp
348 348 .ne 2
349 349 .na
350 350 \fBEFAULT\fR
351 351 .ad
352 352 .RS 10n
353 353 Argument copy in error.
354 354 .RE
355 355
356 356 .sp
357 357 .ne 2
358 358 .na
359 359 \fBEINVAL\fR
360 360 .ad
361 361 .RS 10n
362 362 Command invalid for non-AGP system.
363 363 .RE
364 364
365 365 .sp
366 366 .ne 2
367 367 .na
368 368 \fBEIO\fR
369 369 .ad
370 370 .RS 10n
371 371 Hardware setup error.
372 372 .RE
373 373
374 374 .sp
375 375 .ne 2
376 376 .na
377 377 \fB0\fR
378 378 .ad
379 379 .RS 10n
380 380 Success.
381 381 .RE
382 382
383 383 .RE
384 384
385 385 .sp
386 386 .ne 2
387 387 .na
388 388 \fB\fBAGPIOC_ALLOCATE\fR\fR
389 389 .ad
390 390 .sp .6
391 391 .RS 4n
392 392 Allocate system memory for graphics device. This command returns a unique ID
393 393 which can be used in subsequent operations to represent the allocated memory.
394 394 The memory is made up of discontiguous physical pages. In rare cases, special
395 395 memory types may be required. The allocated memory must be bound to the GART
396 396 table before it can be used by graphics device. Graphics applications can also
397 397 \fBmmap\fR(2) the memory to userland for data storing. Memory should be freed
398 398 when it is no longer used by calling AGPIOC_DEALLOCATE or simply by closing the
399 399 device. This command can be called from user or kernel context.
400 400 .sp
401 401 .in +2
402 402 .nf
403 403 The argument is a pointer to agp_allocate_t structure.
404 404
405 405 typedef struct _agp_allocate {
406 406 int32_t agpa_key; /* OUT:ID of allocated memory */
407 407 uint32_t agpa_pgcount;/* IN: no. of pages to be allocated */
408 408 uint32_t agpa_type;/* IN: type of memory to be allocated */
409 409 uint32_t agpa_physical; /* OUT: reserved */
410 410 } agp_allocate_t;
411 411 .fi
412 412 .in -2
413 413
414 414 .sp
415 415 .ne 2
416 416 .na
417 417 \fBagpa_key\fR
418 418 .ad
419 419 .RS 21n
420 420 Unique ID of the allocated memory.
421 421 .RE
422 422
423 423 .sp
424 424 .ne 2
425 425 .na
426 426 \fBagpa_pgcount\fR
427 427 .ad
428 428 .RS 21n
429 429 Number of pages to be allocated. The driver currently supports only 4K pages.
430 430 The value cannot exceed the agpi_pgtotal value returned by AGPIOC_INFO ioct and
431 431 is subject to the limit of project.max-device-locked-memory. If the memory
432 432 needed is larger than the resource limit but not larger than agpi_pgtotal, use
433 433 \fBprctl\fR(1) or other system utilities to change the default value of memory
434 434 resource limit beforehand.
435 435 .RE
436 436
437 437 .sp
438 438 .ne 2
439 439 .na
440 440 \fBagpa_type\fR
441 441 .ad
442 442 .RS 21n
443 443 Type of memory to be allocated. The valid value of agpa_type should be
444 444 AGP_NORMAL. It is defined as:
445 445 .sp
446 446 .in +2
447 447 .nf
448 448 #define AGP_NORMAL 0
449 449 .fi
450 450 .in -2
451 451
452 452 Above, AGP_NORMAL represents the discontiguous non-cachable physical memory
453 453 which doesn't consume kernel virtual space but can be mapped to user space by
454 454 \fBmmap\fR(2). This command may support more type values in the future.
455 455 .RE
456 456
457 457 .sp
458 458 .ne 2
459 459 .na
460 460 \fBagpa_physical\fR
461 461 .ad
462 462 .RS 21n
463 463 Reserved for special uses. In normal operations, the value is undefined.
464 464 .sp
465 465 Return Values:
466 466 .sp
467 467 .ne 2
468 468 .na
469 469 \fBEPERM\fR
470 470 .ad
471 471 .RS 10n
472 472 Not owner of GART.
473 473 .RE
474 474
475 475 .sp
476 476 .ne 2
477 477 .na
478 478 \fBEINVAL\fR
479 479 .ad
480 480 .RS 10n
481 481 Argument not valid.
482 482 .RE
483 483
484 484 .sp
485 485 .ne 2
486 486 .na
487 487 \fBEFAULT\fR
488 488 .ad
489 489 .RS 10n
490 490 Argument copy in/out error.
491 491 .RE
492 492
493 493 .sp
494 494 .ne 2
495 495 .na
496 496 \fBENOMEM\fR
497 497 .ad
498 498 .RS 10n
499 499 Memory allocation error.
500 500 .RE
501 501
502 502 .sp
503 503 .ne 2
504 504 .na
505 505 \fB0\fR
506 506 .ad
507 507 .RS 10n
508 508 Success.
509 509 .RE
510 510
511 511 .RE
512 512
513 513 .sp
514 514 .ne 2
515 515 .na
516 516 \fBAGPIOC_DEALLOCATE\fR
517 517 .ad
518 518 .RS 21n
519 519 Deallocate the memory identified by a key assigned in a previous allocation. If
520 520 the memory isn't unbound from GART, this command unbinds it automatically. The
521 521 memory should no longer be used and those still in mapping to userland cannot
522 522 be deallocated. Always call AGPIOC_DEALLOCATE explicitly (instead of
523 523 deallocating implicitly by closing the device), as the system won't carry out
524 524 the job until the last reference to the device file is dropped. This command
525 525 from user or kernel context.
526 526 .sp
527 527 The input argument is a key of type int32_t, no output argument.
528 528 .sp
529 529 Return Values:
530 530 .sp
531 531 .ne 2
532 532 .na
533 533 \fBEPERM\fR
534 534 .ad
535 535 .RS 10n
536 536 Not owner of GART.
537 537 .RE
538 538
539 539 .sp
540 540 .ne 2
541 541 .na
542 542 \fBEINVAL\fR
543 543 .ad
544 544 .RS 10n
545 545 Key not valid or memory in use.
546 546 .RE
547 547
548 548 .sp
549 549 .ne 2
550 550 .na
551 551 \fB0\fR
552 552 .ad
553 553 .RS 10n
554 554 Success.
555 555 .RE
556 556
557 557 .RE
558 558
559 559 .sp
560 560 .ne 2
561 561 .na
562 562 \fBAGPIOC_BIND\fR
563 563 .ad
564 564 .RS 21n
565 565 Bind allocated memory. This command binds the allocated memory identified
566 566 by a key to a specific offset of the GART table, which enables GART to
567 567 translate the aperture range at the offset to system memory. Each GART entry
568 568 represents one physical page. If the GART range is previously bound to other
569 569 system memory, it returns an error. Once the memory is bound, it cannot be
570 570 bound to other offsets unless it is unbound. To unbind the memory, call
571 571 AGPIOC_UNBIND or deallocate the memory. This command can be called from user or
572 572 kernel context.
573 573 .sp
574 574 .in +2
575 575 .nf
576 576 The argument is a pointer to agp_bind_t structure:
577 577
578 578 typedef struct _agp_bind {
579 579 int32_t agpb_key; /* IN: ID of memory to be bound */
580 580 uint32_t agpb_pgstart; /* IN: offset in aperture */
581 581 } agp_bind_t;
582 582 .fi
583 583 .in -2
584 584
585 585 .sp
586 586 .ne 2
587 587 .na
588 588 \fBagpb_key\fR
589 589 .ad
590 590 .RS 20n
591 591 The unique ID of the memory to be bound, which is previously allocated by
592 592 calling AGPIOC_ALLOCATE.
593 593 .RE
594 594
595 595 .sp
596 596 .ne 2
597 597 .na
598 598 \fBagpb_pgstart\fR
599 599 .ad
600 600 .RS 20n
601 601 The starting page offset to be bound in aperture space.
602 602 .RE
603 603
604 604 Return Values:
605 605 .sp
606 606 .ne 2
607 607 .na
608 608 \fBEPERM\fR
609 609 .ad
610 610 .RS 20n
611 611 Not owner of GART.
612 612 .RE
613 613
614 614 .sp
615 615 .ne 2
616 616 .na
617 617 \fBEFAULT\fR
618 618 .ad
619 619 .RS 20n
620 620 Argument copy in error.
621 621 .RE
622 622
623 623 .sp
624 624 .ne 2
625 625 .na
626 626 \fBEINVAL\fR
627 627 .ad
628 628 .RS 20n
629 629 Argument not valid.
630 630 .RE
631 631
632 632 .sp
633 633 .ne 2
634 634 .na
635 635 \fBEIO\fR
636 636 .ad
637 637 .RS 20n
638 638 Binding to the GTT table of IGD devices failed.
639 639 .RE
640 640
641 641 .sp
642 642 .ne 2
643 643 .na
644 644 \fB0\fR
645 645 .ad
646 646 .RS 20n
647 647 Success.
648 648 .RE
649 649
650 650 .RE
651 651
652 652 .sp
653 653 .ne 2
654 654 .na
655 655 \fBAGPIOC_UNBIND\fR
656 656 .ad
657 657 .RS 21n
658 658 Unbind memory identified by a key from the GART. This command clears the
659 659 corresponding entries in the GART table. Only the memory not in mapping to
660 660 userland is allowed to be unbound.
661 661 .sp
662 662 This ioctl command can be called from user or kernel context.
663 663 .sp
664 664 .in +2
665 665 .nf
666 666 The argument is a pointer to agp_unbind_t structure.
667 667
668 668 typedef struct _agp_unbind {
669 669 int32_t agpu_key; /* IN: key of memory to be unbound*/
670 670 uint32_t agpu_pri; /* Not used: for compat. with Xorg */
671 671 } agp_unbind_t;
672 672 .fi
673 673 .in -2
674 674
675 675 .sp
676 676 .ne 2
677 677 .na
678 678 \fBagpu_key\fR
679 679 .ad
680 680 .RS 20n
681 681 Unique ID of the memory to be unbound which was previously bound by calling
682 682 AGPIOC_BIND.
683 683 .RE
684 684
685 685 .sp
686 686 .ne 2
687 687 .na
688 688 \fBagpu_pri\fR
689 689 .ad
690 690 .RS 20n
691 691 Reserved for compatibility with X.org/XFree86, not used.
692 692 .RE
693 693
694 694 Return Values:
695 695 .sp
696 696 .ne 2
697 697 .na
698 698 \fBEPERM\fR
699 699 .ad
700 700 .RS 20n
701 701 Not owner of GART.
702 702 .RE
703 703
704 704 .sp
705 705 .ne 2
706 706 .na
707 707 \fBEFAULT\fR
708 708 .ad
709 709 .RS 20n
710 710 Argument copy in error.
711 711 .RE
712 712
713 713 .sp
714 714 .ne 2
715 715 .na
716 716 \fBEINVAL\fR
717 717 .ad
718 718 .RS 20n
719 719 Argument not valid or memory in use.
720 720 .RE
721 721
722 722 .sp
723 723 .ne 2
724 724 .na
725 725 \fBEIO\fR
726 726 .ad
727 727 .RS 20n
728 728 Unbinding from the GTT table of IGD devices failed.
729 729 .RE
730 730
731 731 .sp
732 732 .ne 2
733 733 .na
734 734 \fB0\fR
735 735 .ad
736 736 .RS 20n
737 737 Success
738 738 .RE
739 739
740 740 .RE
741 741
742 742 .RE
743 743
744 744 .SH EXAMPLE
745 745 .sp
746 746 .LP
747 747 Below is an sample program showing how agpgart ioctls can be used:
748 748 .sp
749 749 .in +2
750 750 .nf
751 751 #include <stdio.h>
752 752 #include <stdlib.h>
753 753 #include <unistd.h
754 754 #include <sys/ioccom.h>
755 755 #include <sys/types.h>
756 756 #include <fcntl.h>
757 757 #include <errno.h>
758 758 #include <sys/mman.h>
759 759 #include <sys/agpgart.h>
760 760
761 761 #define AGP_PAGE_SIZE 4096
762 762
763 763 int main(int argc, char *argv[])
764 764 {
765 765 int fd, ret;
766 766 agp_allocate_t alloc;
767 767 agp_bind_t bindinfo;
768 768 agp_info_t agpinfo;
769 769 agp_setup_t modesetup;
770 770 int *p = NULL;
771 771 off_t mapoff;
↓ open down ↓ |
755 lines elided |
↑ open up ↑ |
772 772 size_t maplen;
773 773
774 774 if((fd = open(AGP_DEVICE, O_RDWR))== -1) {
775 775 printf("open AGP_DEVICE error with %d\en", errno);\e
776 776 exit(-1);
777 777 }
778 778 printf("device opened\en");
779 779
780 780 ret = ioctl(fd, AGPIOC_INFO, &agpinfo);
781 781 if(ret == -1) {
782 - printf("Get info error %d\n", errno);
782 + printf("Get info error %d\en", errno);
783 783 exit(-1);
784 784 }
785 785 printf("AGPSTAT is %x\en", agpinfo.agpi_mode);
786 786 printf("APBASE is %x\en", agpinfo.agpi_aperbase);
787 787 printf("APSIZE is %dMB\en", agpinfo.agpi_apersize);
788 788 printf("pg_total is %d\en", agpinfo.agpi_pgtotal);
789 789
790 790 ret = ioctl(fd, AGPIOC_ACQUIRE);
791 791 if(ret == -1) {
792 792 printf(" Acquire GART error %d\en", errno);
793 793 exit(-1);
794 794 }
795 795
796 796 modesetup.agps_mode = agpinfo.agpi_mode;
797 797 ret = ioctl(fd, AGPIOC_SETUP, &modesetup);
798 798 if(ret == -1) {
799 799 printf("set up AGP mode error\en", errno);
800 800 exit(-1);
801 801 }
802 802
803 803 printf("Please input the number of pages you want to allocate\en");
804 804 scanf("%d", &alloc.agpa_pgcount);
805 805 alloc.agpa_type = AGP_NORMAL;
806 806 ret = ioctl(fd, AGPIOC_ALLOCATE, &alloc);
807 807 if(ret == -1) {
808 808 printf("Allocate memory error %d\en", errno);
809 809 exit(-1);
810 810 }
811 811
812 812 printf("Please input the aperture page offset to bind\en");
813 813 scanf("%d", &bindinfo.agpb_pgstart);
814 814 bindinfo.agpb_key = alloc.agpa_key;
815 815 ret = ioctl(fd, AGPIOC_BIND, &bindinfo);
816 816 if(ret == -1) {
817 817 printf("Bind error %d\en", errno);
818 818 exit(-1);
819 819 }
820 820 printf("Bind successful\en");
821 821
822 822 /*
823 823 * Now gart aperture space from (bindinfo.agpb_pgstart) to
824 824 * (bindinfo.agpb_pgstart + alloc.agpa_pgcount) can be used for
825 825 * AGP graphics transactions
826 826 */
827 827 ...
828 828
829 829 /*
830 830 * mmap can allow user processes to store graphics data
831 831 * to the aperture space
832 832 */
833 833 maplen = alloc.agpa_pgcount * AGP_PAGE_SIZE;
834 834 mapoff = bindinfo.agpb_pgstart * AGP_PAGE_SIZE;
835 835 p = (int *)mmap((caddr_t)0, maplen, (PROT_READ | PROT_WRITE),
836 836 MAP_SHARED, fd, mapoff);
837 837 if (p == MAP_FAILED) {
838 838 printf("Mmap error %d\en", errno);
839 839 exit(-1);
840 840 }
841 841 printf("Mmap successful\en");
842 842 ...
843 843
844 844 /*
845 845 * When user processes finish access to the aperture space,
846 846 * unmap the memory range
847 847 */
848 848 munmap((void *)p, maplen);
849 849 ...
850 850
851 851 /*
852 852 * After finishing AGP transactions, the resources can be freed
853 853 * step by step or simply by close device.
854 854 */
855 855 ret = ioctl(fd, AGPIOC_DEALLOCATE, alloc.agpa_key);
856 856 if(ret == -1) {
857 857 printf(" Deallocate memory error %d\en", errno);
858 858 exit(-1);
859 859 }
860 860
861 861 ret = ioctl(fd, AGPIOC_RELEASE);
862 862 if(ret == -1) {
863 863 printf(" Release GART error %d\en", errno);
864 864 exit(-1);
865 865 }
866 866
867 867 close(fd);
868 868 }
869 869 .fi
870 870 .in -2
871 871
872 872 .SH FILES
873 873 .sp
874 874 .ne 2
875 875 .na
876 876 \fB\fB/dev/agpgart\fR\fR
877 877 .ad
878 878 .sp .6
879 879 .RS 4n
880 880 Symbolic link to the pseudo agpgart device.
881 881 .RE
882 882
883 883 .sp
884 884 .ne 2
885 885 .na
886 886 \fB\fB/platform/i86pc/kernel/drv/agpgart\fR\fR
887 887 .ad
888 888 .sp .6
889 889 .RS 4n
890 890 agpgart pseudo driver.
891 891 .RE
892 892
893 893 .sp
894 894 .ne 2
895 895 .na
896 896 \fB\fB/platform/i86pc/kernel/drv/agpgart.conf\fR\fR
897 897 .ad
898 898 .sp .6
899 899 .RS 4n
900 900 Driver configuration file.
901 901 .RE
902 902
903 903 .SH ATTRIBUTES
904 904 .sp
905 905 .LP
906 906 See \fBattributes\fR(5) for descriptions of the following attributes:
907 907 .sp
908 908
909 909 .sp
910 910 .TS
911 911 box;
912 912 c | c
913 913 l | l .
914 914 ATTRIBUTE TYPE ATTRIBUTE VALUE
915 915 _
916 916 Architecture X86
917 917 _
918 918 Stability level Unstable
919 919 .TE
920 920
921 921 .SH SEE ALSO
922 922 .sp
923 923 .LP
924 924 \fBprctl\fR(1), \fBkstat\fR(1M), \fBclose\fR(2), \fBioctl\fR(2), \fBopen\fR(2),
925 925 \fBmmap\fR(2), \fBproject\fR(4), \fBprivileges\fR(5), \fBattributes\fR(5),
926 926 \fBresource_controls\fR(5)
↓ open down ↓ |
134 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX