xref: /onnv-gate/usr/src/uts/common/sys/agpgart.h (revision 11260:eb8c6f2097e8)
10Sstevel@tonic-gate /*
2*11260SMiao.Chen@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
30Sstevel@tonic-gate  * Use is subject to license terms.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate 
60Sstevel@tonic-gate /*
70Sstevel@tonic-gate  * Copyright (c) 2000 Doug Rabson
8*11260SMiao.Chen@Sun.COM  * Copyright (c) 2009, Intel Corporation.
90Sstevel@tonic-gate  * All rights reserved.
100Sstevel@tonic-gate  *
110Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
120Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
130Sstevel@tonic-gate  * are met:
140Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
150Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
160Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
170Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
180Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
210Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
220Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
230Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
240Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
250Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
260Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
270Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
280Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
290Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
300Sstevel@tonic-gate  * SUCH DAMAGE.
310Sstevel@tonic-gate  *
320Sstevel@tonic-gate  */
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifndef	_SYS_AGPGART_H
350Sstevel@tonic-gate #define	_SYS_AGPGART_H
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef __cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #define	AGP_NORMAL	0	/* mapped to user land, no cache */
420Sstevel@tonic-gate 
430Sstevel@tonic-gate typedef struct _agp_version {
440Sstevel@tonic-gate 	uint16_t	agpv_major;
450Sstevel@tonic-gate 	uint16_t	agpv_minor;
460Sstevel@tonic-gate } agp_version_t;
470Sstevel@tonic-gate 
480Sstevel@tonic-gate 
490Sstevel@tonic-gate typedef struct	_agp_info {
500Sstevel@tonic-gate 	agp_version_t	agpi_version;
510Sstevel@tonic-gate 	uint32_t	agpi_devid;	/* bridge vendor + device */
520Sstevel@tonic-gate 	uint32_t	agpi_mode;	/* mode of brdige */
530Sstevel@tonic-gate 	ulong_t		agpi_aperbase;	/* base of aperture */
540Sstevel@tonic-gate 	size_t		agpi_apersize;	/* aperture range size */
550Sstevel@tonic-gate 	uint32_t	agpi_pgtotal;	/* max number of pages in aperture */
560Sstevel@tonic-gate 	uint32_t	agpi_pgsystem;	/* same as pg_total */
570Sstevel@tonic-gate 	uint32_t	agpi_pgused;	/* NUMBER of currently used pages */
580Sstevel@tonic-gate } agp_info_t;
590Sstevel@tonic-gate 
600Sstevel@tonic-gate typedef struct _agp_setup {
610Sstevel@tonic-gate 	uint32_t	agps_mode;
620Sstevel@tonic-gate } agp_setup_t;
630Sstevel@tonic-gate 
640Sstevel@tonic-gate typedef struct _agp_allocate {
650Sstevel@tonic-gate 	int32_t		agpa_key;
660Sstevel@tonic-gate 	uint32_t	agpa_pgcount;
670Sstevel@tonic-gate 	uint32_t	agpa_type;
680Sstevel@tonic-gate 	uint32_t	agpa_physical;	/* for i810 only, private */
690Sstevel@tonic-gate } agp_allocate_t;
700Sstevel@tonic-gate 
71*11260SMiao.Chen@Sun.COM typedef struct _agp_bind_pages {
72*11260SMiao.Chen@Sun.COM 	uint32_t	agpb_pgstart;
73*11260SMiao.Chen@Sun.COM 	pfn_t		*agpb_pages;
74*11260SMiao.Chen@Sun.COM 	unsigned long 	agpb_pgcount;
75*11260SMiao.Chen@Sun.COM } agp_bind_pages_t;
76*11260SMiao.Chen@Sun.COM 
77*11260SMiao.Chen@Sun.COM typedef struct _agp_unbind_pages {
78*11260SMiao.Chen@Sun.COM 	uint32_t	agpb_pgstart;
79*11260SMiao.Chen@Sun.COM 	unsigned long	agpb_pgcount;
80*11260SMiao.Chen@Sun.COM 	uint32_t	agpb_type;
81*11260SMiao.Chen@Sun.COM } agp_unbind_pages_t;
82*11260SMiao.Chen@Sun.COM 
830Sstevel@tonic-gate typedef struct _agp_bind {
840Sstevel@tonic-gate 	int32_t		agpb_key;
850Sstevel@tonic-gate 	uint32_t	agpb_pgstart;
860Sstevel@tonic-gate } agp_bind_t;
870Sstevel@tonic-gate 
880Sstevel@tonic-gate typedef struct _agp_unbind {
890Sstevel@tonic-gate 	int32_t		agpu_key;
900Sstevel@tonic-gate 	uint32_t	agpu_pri;	/* no use in solaris */
910Sstevel@tonic-gate } agp_unbind_t;
920Sstevel@tonic-gate 
930Sstevel@tonic-gate #define	AGPIOC_BASE		'G'
940Sstevel@tonic-gate #define	AGPIOC_INFO		_IOR(AGPIOC_BASE, 0, 100)
950Sstevel@tonic-gate #define	AGPIOC_ACQUIRE		_IO(AGPIOC_BASE, 1)
960Sstevel@tonic-gate #define	AGPIOC_RELEASE		_IO(AGPIOC_BASE, 2)
970Sstevel@tonic-gate #define	AGPIOC_SETUP		_IOW(AGPIOC_BASE, 3, agp_setup_t)
980Sstevel@tonic-gate #define	AGPIOC_ALLOCATE		_IOWR(AGPIOC_BASE, 4, agp_allocate_t)
990Sstevel@tonic-gate #define	AGPIOC_DEALLOCATE	_IOW(AGPIOC_BASE, 5, int)
1000Sstevel@tonic-gate #define	AGPIOC_BIND		_IOW(AGPIOC_BASE, 6, agp_bind_t)
1010Sstevel@tonic-gate #define	AGPIOC_UNBIND		_IOW(AGPIOC_BASE, 7, agp_unbind_t)
1022820Skz151634 #define	AGPIOC_IOREMAP		_IO(AGPIOC_BASE, 8)
1032820Skz151634 #define	AGPIOC_IOREMAP_FREE	_IO(AGPIOC_BASE, 9)
1042820Skz151634 #define	AGPIOC_READ		_IO(AGPIOC_BASE, 10)
1052820Skz151634 #define	AGPIOC_WRITE		_IO(AGPIOC_BASE, 11)
106*11260SMiao.Chen@Sun.COM #define	AGPIOC_FLUSHCHIPSET	_IO(AGPIOC_BASE, 12)
107*11260SMiao.Chen@Sun.COM #define	AGPIOC_PAGES_BIND	_IOW(AGPIOC_BASE, 13, agp_bind_pages_t)
108*11260SMiao.Chen@Sun.COM #define	AGPIOC_PAGES_UNBIND	_IOW(AGPIOC_BASE, 14, agp_unbind_pages_t)
109*11260SMiao.Chen@Sun.COM #define	AGPIOC_PAGES_REBIND	_IO(AGPIOC_BASE, 15)
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate /* AGP status register bits definition */
1120Sstevel@tonic-gate #define	AGPSTAT_RQ_MASK		0xff000000	/* target only */
1130Sstevel@tonic-gate #define	AGPSTAT_SBA		(0x1 << 9)	/* always 1 for 3.0 */
1140Sstevel@tonic-gate #define	AGPSTAT_OVER4G		(0x1 << 5)
1150Sstevel@tonic-gate #define	AGPSTAT_FW		(0x1 << 4)
1160Sstevel@tonic-gate #define	AGPSTAT_RATE_MASK	0x7
1170Sstevel@tonic-gate /* rate for 2.0 mode */
1180Sstevel@tonic-gate #define	AGP2_RATE_1X		0x1
1190Sstevel@tonic-gate #define	AGP2_RATE_2X		0x2
1200Sstevel@tonic-gate #define	AGP2_RATE_4X		0x4
1210Sstevel@tonic-gate /* AGP 3.0 only bits */
1220Sstevel@tonic-gate #define	AGPSTAT_ARQSZ_MASK	(0x7 << 13)	/* target only */
1230Sstevel@tonic-gate #define	AGPSTAT_CAL_MASK	(0x7 << 10)
1240Sstevel@tonic-gate #define	AGPSTAT_GART64B		(0x1 << 7)	/* target only */
1250Sstevel@tonic-gate #define	AGPSTAT_MODE3		(0x1 << 3)
1260Sstevel@tonic-gate /* Rate for 3.0 mode */
1270Sstevel@tonic-gate #define	AGP3_RATE_4X		0x1
1280Sstevel@tonic-gate #define	AGP3_RATE_8X		0x2
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate /* AGP command register bits definition */
1310Sstevel@tonic-gate #define	AGPCMD_RQ_MASK		0xff000000	/* master only */
1320Sstevel@tonic-gate #define	AGPCMD_SBAEN		(0x1 << 9)	/* must be 1 for 3.0 */
1330Sstevel@tonic-gate #define	AGPCMD_AGPEN		(0x1 << 8)
1340Sstevel@tonic-gate #define	AGPCMD_OVER4GEN		(0x1 << 5)
1350Sstevel@tonic-gate #define	AGPCMD_FWEN		(0x1 << 4)
1360Sstevel@tonic-gate #define	AGPCMD_RATE_MASK	0x7
1370Sstevel@tonic-gate /* AGP 3.0 only bits */
1380Sstevel@tonic-gate #define	AGP3_CMD_ARQSZ_MASK	(0x7 << 13)	/* master only */
1390Sstevel@tonic-gate #define	AGP3_CMD_CAL_MASK	(0x7 << 10)	/* target only */
1400Sstevel@tonic-gate #define	AGP3_CMD_GART64BEN	(0x1 << 7)	/* target only */
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate #define	AGP_DEVICE	"/dev/agpgart"
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate #ifdef __cplusplus
1450Sstevel@tonic-gate }
1460Sstevel@tonic-gate #endif
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate #endif /* _SYS_AGPGART_H */
149