17c478bd9Sstevel@tonic-gate /* 2*0035d21cSmiao chen - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* 77c478bd9Sstevel@tonic-gate * Copyright (c) 2000 Doug Rabson 8*0035d21cSmiao chen - Sun Microsystems - Beijing China * Copyright (c) 2009, Intel Corporation. 97c478bd9Sstevel@tonic-gate * All rights reserved. 107c478bd9Sstevel@tonic-gate * 117c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 127c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions 137c478bd9Sstevel@tonic-gate * are met: 147c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 157c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 167c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 177c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 187c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 217c478bd9Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 227c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 237c478bd9Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 247c478bd9Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 257c478bd9Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 267c478bd9Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 277c478bd9Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 287c478bd9Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 297c478bd9Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 307c478bd9Sstevel@tonic-gate * SUCH DAMAGE. 317c478bd9Sstevel@tonic-gate * 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifndef _SYS_AGPGART_H 357c478bd9Sstevel@tonic-gate #define _SYS_AGPGART_H 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #define AGP_NORMAL 0 /* mapped to user land, no cache */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate typedef struct _agp_version { 447c478bd9Sstevel@tonic-gate uint16_t agpv_major; 457c478bd9Sstevel@tonic-gate uint16_t agpv_minor; 467c478bd9Sstevel@tonic-gate } agp_version_t; 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate typedef struct _agp_info { 507c478bd9Sstevel@tonic-gate agp_version_t agpi_version; 517c478bd9Sstevel@tonic-gate uint32_t agpi_devid; /* bridge vendor + device */ 527c478bd9Sstevel@tonic-gate uint32_t agpi_mode; /* mode of brdige */ 537c478bd9Sstevel@tonic-gate ulong_t agpi_aperbase; /* base of aperture */ 547c478bd9Sstevel@tonic-gate size_t agpi_apersize; /* aperture range size */ 557c478bd9Sstevel@tonic-gate uint32_t agpi_pgtotal; /* max number of pages in aperture */ 567c478bd9Sstevel@tonic-gate uint32_t agpi_pgsystem; /* same as pg_total */ 577c478bd9Sstevel@tonic-gate uint32_t agpi_pgused; /* NUMBER of currently used pages */ 587c478bd9Sstevel@tonic-gate } agp_info_t; 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate typedef struct _agp_setup { 617c478bd9Sstevel@tonic-gate uint32_t agps_mode; 627c478bd9Sstevel@tonic-gate } agp_setup_t; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate typedef struct _agp_allocate { 657c478bd9Sstevel@tonic-gate int32_t agpa_key; 667c478bd9Sstevel@tonic-gate uint32_t agpa_pgcount; 677c478bd9Sstevel@tonic-gate uint32_t agpa_type; 687c478bd9Sstevel@tonic-gate uint32_t agpa_physical; /* for i810 only, private */ 697c478bd9Sstevel@tonic-gate } agp_allocate_t; 707c478bd9Sstevel@tonic-gate 71*0035d21cSmiao chen - Sun Microsystems - Beijing China typedef struct _agp_bind_pages { 72*0035d21cSmiao chen - Sun Microsystems - Beijing China uint32_t agpb_pgstart; 73*0035d21cSmiao chen - Sun Microsystems - Beijing China pfn_t *agpb_pages; 74*0035d21cSmiao chen - Sun Microsystems - Beijing China unsigned long agpb_pgcount; 75*0035d21cSmiao chen - Sun Microsystems - Beijing China } agp_bind_pages_t; 76*0035d21cSmiao chen - Sun Microsystems - Beijing China 77*0035d21cSmiao chen - Sun Microsystems - Beijing China typedef struct _agp_unbind_pages { 78*0035d21cSmiao chen - Sun Microsystems - Beijing China uint32_t agpb_pgstart; 79*0035d21cSmiao chen - Sun Microsystems - Beijing China unsigned long agpb_pgcount; 80*0035d21cSmiao chen - Sun Microsystems - Beijing China uint32_t agpb_type; 81*0035d21cSmiao chen - Sun Microsystems - Beijing China } agp_unbind_pages_t; 82*0035d21cSmiao chen - Sun Microsystems - Beijing China 837c478bd9Sstevel@tonic-gate typedef struct _agp_bind { 847c478bd9Sstevel@tonic-gate int32_t agpb_key; 857c478bd9Sstevel@tonic-gate uint32_t agpb_pgstart; 867c478bd9Sstevel@tonic-gate } agp_bind_t; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate typedef struct _agp_unbind { 897c478bd9Sstevel@tonic-gate int32_t agpu_key; 907c478bd9Sstevel@tonic-gate uint32_t agpu_pri; /* no use in solaris */ 917c478bd9Sstevel@tonic-gate } agp_unbind_t; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate #define AGPIOC_BASE 'G' 947c478bd9Sstevel@tonic-gate #define AGPIOC_INFO _IOR(AGPIOC_BASE, 0, 100) 957c478bd9Sstevel@tonic-gate #define AGPIOC_ACQUIRE _IO(AGPIOC_BASE, 1) 967c478bd9Sstevel@tonic-gate #define AGPIOC_RELEASE _IO(AGPIOC_BASE, 2) 977c478bd9Sstevel@tonic-gate #define AGPIOC_SETUP _IOW(AGPIOC_BASE, 3, agp_setup_t) 987c478bd9Sstevel@tonic-gate #define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 4, agp_allocate_t) 997c478bd9Sstevel@tonic-gate #define AGPIOC_DEALLOCATE _IOW(AGPIOC_BASE, 5, int) 1007c478bd9Sstevel@tonic-gate #define AGPIOC_BIND _IOW(AGPIOC_BASE, 6, agp_bind_t) 1017c478bd9Sstevel@tonic-gate #define AGPIOC_UNBIND _IOW(AGPIOC_BASE, 7, agp_unbind_t) 10260405de4Skz151634 #define AGPIOC_IOREMAP _IO(AGPIOC_BASE, 8) 10360405de4Skz151634 #define AGPIOC_IOREMAP_FREE _IO(AGPIOC_BASE, 9) 10460405de4Skz151634 #define AGPIOC_READ _IO(AGPIOC_BASE, 10) 10560405de4Skz151634 #define AGPIOC_WRITE _IO(AGPIOC_BASE, 11) 106*0035d21cSmiao chen - Sun Microsystems - Beijing China #define AGPIOC_FLUSHCHIPSET _IO(AGPIOC_BASE, 12) 107*0035d21cSmiao chen - Sun Microsystems - Beijing China #define AGPIOC_PAGES_BIND _IOW(AGPIOC_BASE, 13, agp_bind_pages_t) 108*0035d21cSmiao chen - Sun Microsystems - Beijing China #define AGPIOC_PAGES_UNBIND _IOW(AGPIOC_BASE, 14, agp_unbind_pages_t) 109*0035d21cSmiao chen - Sun Microsystems - Beijing China #define AGPIOC_PAGES_REBIND _IO(AGPIOC_BASE, 15) 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* AGP status register bits definition */ 1127c478bd9Sstevel@tonic-gate #define AGPSTAT_RQ_MASK 0xff000000 /* target only */ 1137c478bd9Sstevel@tonic-gate #define AGPSTAT_SBA (0x1 << 9) /* always 1 for 3.0 */ 1147c478bd9Sstevel@tonic-gate #define AGPSTAT_OVER4G (0x1 << 5) 1157c478bd9Sstevel@tonic-gate #define AGPSTAT_FW (0x1 << 4) 1167c478bd9Sstevel@tonic-gate #define AGPSTAT_RATE_MASK 0x7 1177c478bd9Sstevel@tonic-gate /* rate for 2.0 mode */ 1187c478bd9Sstevel@tonic-gate #define AGP2_RATE_1X 0x1 1197c478bd9Sstevel@tonic-gate #define AGP2_RATE_2X 0x2 1207c478bd9Sstevel@tonic-gate #define AGP2_RATE_4X 0x4 1217c478bd9Sstevel@tonic-gate /* AGP 3.0 only bits */ 1227c478bd9Sstevel@tonic-gate #define AGPSTAT_ARQSZ_MASK (0x7 << 13) /* target only */ 1237c478bd9Sstevel@tonic-gate #define AGPSTAT_CAL_MASK (0x7 << 10) 1247c478bd9Sstevel@tonic-gate #define AGPSTAT_GART64B (0x1 << 7) /* target only */ 1257c478bd9Sstevel@tonic-gate #define AGPSTAT_MODE3 (0x1 << 3) 1267c478bd9Sstevel@tonic-gate /* Rate for 3.0 mode */ 1277c478bd9Sstevel@tonic-gate #define AGP3_RATE_4X 0x1 1287c478bd9Sstevel@tonic-gate #define AGP3_RATE_8X 0x2 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate /* AGP command register bits definition */ 1317c478bd9Sstevel@tonic-gate #define AGPCMD_RQ_MASK 0xff000000 /* master only */ 1327c478bd9Sstevel@tonic-gate #define AGPCMD_SBAEN (0x1 << 9) /* must be 1 for 3.0 */ 1337c478bd9Sstevel@tonic-gate #define AGPCMD_AGPEN (0x1 << 8) 1347c478bd9Sstevel@tonic-gate #define AGPCMD_OVER4GEN (0x1 << 5) 1357c478bd9Sstevel@tonic-gate #define AGPCMD_FWEN (0x1 << 4) 1367c478bd9Sstevel@tonic-gate #define AGPCMD_RATE_MASK 0x7 1377c478bd9Sstevel@tonic-gate /* AGP 3.0 only bits */ 1387c478bd9Sstevel@tonic-gate #define AGP3_CMD_ARQSZ_MASK (0x7 << 13) /* master only */ 1397c478bd9Sstevel@tonic-gate #define AGP3_CMD_CAL_MASK (0x7 << 10) /* target only */ 1407c478bd9Sstevel@tonic-gate #define AGP3_CMD_GART64BEN (0x1 << 7) /* target only */ 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate #define AGP_DEVICE "/dev/agpgart" 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1457c478bd9Sstevel@tonic-gate } 1467c478bd9Sstevel@tonic-gate #endif 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #endif /* _SYS_AGPGART_H */ 149