xref: /gfx-drm/usr/src/uts/common/sys/agpgart.h (revision 3db4bae9)
1 /*
2  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2000 Doug Rabson
8  * Copyright (c) 2009, Intel Corporation.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef	_SYS_AGPGART_H
35 #define	_SYS_AGPGART_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #define	AGP_NORMAL	0	/* mapped to user land, no cache */
42 
43 typedef struct _agp_version {
44 	uint16_t	agpv_major;
45 	uint16_t	agpv_minor;
46 } agp_version_t;
47 
48 
49 typedef struct	_agp_info {
50 	agp_version_t	agpi_version;
51 	uint32_t	agpi_devid;	/* bridge vendor + device */
52 	uint32_t	agpi_mode;	/* mode of brdige */
53 	ulong_t		agpi_aperbase;	/* base of aperture */
54 	size_t		agpi_apersize;	/* aperture range size */
55 	uint32_t	agpi_pgtotal;	/* max number of pages in aperture */
56 	uint32_t	agpi_pgsystem;	/* same as pg_total */
57 	uint32_t	agpi_pgused;	/* NUMBER of currently used pages */
58 } agp_info_t;
59 
60 typedef struct _agp_setup {
61 	uint32_t	agps_mode;
62 } agp_setup_t;
63 
64 typedef struct _agp_allocate {
65 	int32_t		agpa_key;
66 	uint32_t	agpa_pgcount;
67 	uint32_t	agpa_type;
68 	uint32_t	agpa_physical;	/* for i810 only, private */
69 } agp_allocate_t;
70 
71 typedef struct _agp_bind_pages {
72 	uint32_t	agpb_pgstart;
73 	uint32_t 	agpb_pgcount;
74 	pfn_t		*agpb_pages;
75 	uint32_t	agpb_type;	/* AGP_USER_MEMORY */
76 } agp_bind_pages_t;
77 
78 typedef struct _agp_unbind_pages {
79 	uint32_t	agpu_pgstart;
80 	uint32_t	agpu_pgcount;
81 	pfn_t		agpu_scratch;
82 	uint32_t	agpu_flags;
83 } agp_unbind_pages_t;
84 
85 typedef struct _agp_bind {
86 	int32_t		agpb_key;
87 	uint32_t	agpb_pgstart;
88 } agp_bind_t;
89 
90 typedef struct _agp_unbind {
91 	int32_t		agpu_key;
92 	uint32_t	agpu_pri;	/* no use in solaris */
93 } agp_unbind_t;
94 
95 typedef struct _agp_rw_gtt {
96 	uint32_t	agprw_pgstart;
97 	uint32_t	agprw_pgcount;
98 	void		*agprw_addr;	/* buffer */
99 	uint32_t	agprw_flags;	/* 0:read, 1:write */
100 } agp_rw_gtt_t;
101 
102 #define	AGPIOC_BASE		'G'
103 #define	AGPIOC_INFO		_IOR(AGPIOC_BASE, 0, 100)
104 #define	AGPIOC_ACQUIRE		_IO(AGPIOC_BASE, 1)
105 #define	AGPIOC_RELEASE		_IO(AGPIOC_BASE, 2)
106 #define	AGPIOC_SETUP		_IOW(AGPIOC_BASE, 3, agp_setup_t)
107 #define	AGPIOC_ALLOCATE		_IOWR(AGPIOC_BASE, 4, agp_allocate_t)
108 #define	AGPIOC_DEALLOCATE	_IOW(AGPIOC_BASE, 5, int)
109 #define	AGPIOC_BIND		_IOW(AGPIOC_BASE, 6, agp_bind_t)
110 #define	AGPIOC_UNBIND		_IOW(AGPIOC_BASE, 7, agp_unbind_t)
111 #define	AGPIOC_IOREMAP		_IO(AGPIOC_BASE, 8)
112 #define	AGPIOC_IOREMAP_FREE	_IO(AGPIOC_BASE, 9)
113 #define	AGPIOC_READ		_IO(AGPIOC_BASE, 10)
114 #define	AGPIOC_WRITE		_IO(AGPIOC_BASE, 11)
115 #define	AGPIOC_FLUSHCHIPSET	_IO(AGPIOC_BASE, 12)
116 #define	AGPIOC_PAGES_BIND	_IOW(AGPIOC_BASE, 13, agp_bind_pages_t)
117 #define	AGPIOC_PAGES_UNBIND	_IOW(AGPIOC_BASE, 14, agp_unbind_pages_t)
118 #define	AGPIOC_RW_GTT		_IOW(AGPIOC_BASE, 15, agp_rw_gtt_t)
119 
120 /* AGP bind pages type values */
121 #define	AGP_USER_TYPES (1 << 16)
122 #define	AGP_USER_MEMORY (AGP_USER_TYPES)
123 #define	AGP_USER_CACHED_MEMORY (AGP_USER_TYPES + 1)
124 
125 /* AGP status register bits definition */
126 #define	AGPSTAT_RQ_MASK		0xff000000	/* target only */
127 #define	AGPSTAT_SBA		(0x1 << 9)	/* always 1 for 3.0 */
128 #define	AGPSTAT_OVER4G		(0x1 << 5)
129 #define	AGPSTAT_FW		(0x1 << 4)
130 #define	AGPSTAT_RATE_MASK	0x7
131 /* rate for 2.0 mode */
132 #define	AGP2_RATE_1X		0x1
133 #define	AGP2_RATE_2X		0x2
134 #define	AGP2_RATE_4X		0x4
135 /* AGP 3.0 only bits */
136 #define	AGPSTAT_ARQSZ_MASK	(0x7 << 13)	/* target only */
137 #define	AGPSTAT_CAL_MASK	(0x7 << 10)
138 #define	AGPSTAT_GART64B		(0x1 << 7)	/* target only */
139 #define	AGPSTAT_MODE3		(0x1 << 3)
140 /* Rate for 3.0 mode */
141 #define	AGP3_RATE_4X		0x1
142 #define	AGP3_RATE_8X		0x2
143 
144 /* AGP command register bits definition */
145 #define	AGPCMD_RQ_MASK		0xff000000	/* master only */
146 #define	AGPCMD_SBAEN		(0x1 << 9)	/* must be 1 for 3.0 */
147 #define	AGPCMD_AGPEN		(0x1 << 8)
148 #define	AGPCMD_OVER4GEN		(0x1 << 5)
149 #define	AGPCMD_FWEN		(0x1 << 4)
150 #define	AGPCMD_RATE_MASK	0x7
151 /* AGP 3.0 only bits */
152 #define	AGP3_CMD_ARQSZ_MASK	(0x7 << 13)	/* master only */
153 #define	AGP3_CMD_CAL_MASK	(0x7 << 10)	/* target only */
154 #define	AGP3_CMD_GART64BEN	(0x1 << 7)	/* target only */
155 
156 #define	AGP_DEVICE	"/dev/agpgart"
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif /* _SYS_AGPGART_H */
163