blob: f6778eceb8f4058bbc932d9ead806968e2a27b6e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * AGPGART module version 0.99
3 * Copyright (C) 1999 Jeff Hartmann
4 * Copyright (C) 1999 Precision Insight, Inc.
5 * Copyright (C) 1999 Xi Graphics, Inc.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 */
26
27#ifndef _AGP_H
28#define _AGP_H 1
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#define AGPIOC_BASE 'A'
31#define AGPIOC_INFO _IOR (AGPIOC_BASE, 0, struct agp_info*)
32#define AGPIOC_ACQUIRE _IO (AGPIOC_BASE, 1)
33#define AGPIOC_RELEASE _IO (AGPIOC_BASE, 2)
34#define AGPIOC_SETUP _IOW (AGPIOC_BASE, 3, struct agp_setup*)
35#define AGPIOC_RESERVE _IOW (AGPIOC_BASE, 4, struct agp_region*)
36#define AGPIOC_PROTECT _IOW (AGPIOC_BASE, 5, struct agp_region*)
37#define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 6, struct agp_allocate*)
38#define AGPIOC_DEALLOCATE _IOW (AGPIOC_BASE, 7, int)
39#define AGPIOC_BIND _IOW (AGPIOC_BASE, 8, struct agp_bind*)
40#define AGPIOC_UNBIND _IOW (AGPIOC_BASE, 9, struct agp_unbind*)
Dave Airliea13af4b2007-10-29 15:14:03 +100041#define AGPIOC_CHIPSET_FLUSH _IO (AGPIOC_BASE, 10)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43#define AGP_DEVICE "/dev/agpgart"
44
45#ifndef TRUE
46#define TRUE 1
47#endif
48
49#ifndef FALSE
50#define FALSE 0
51#endif
52
53#ifndef __KERNEL__
54#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56struct agp_version {
57 __u16 major;
58 __u16 minor;
59};
60
61typedef struct _agp_info {
62 struct agp_version version; /* version of the driver */
63 __u32 bridge_id; /* bridge vendor/device */
64 __u32 agp_mode; /* mode info of bridge */
65 unsigned long aper_base;/* base of aperture */
66 size_t aper_size; /* size of aperture */
67 size_t pg_total; /* max pages (swap + system) */
68 size_t pg_system; /* max pages (system) */
69 size_t pg_used; /* current pages used */
70} agp_info;
71
72typedef struct _agp_setup {
73 __u32 agp_mode; /* mode info of bridge */
74} agp_setup;
75
76/*
77 * The "prot" down below needs still a "sleep" flag somehow ...
78 */
79typedef struct _agp_segment {
Arnd Bergmann85efde62009-02-26 00:51:39 +010080 __kernel_off_t pg_start; /* starting page to populate */
81 __kernel_size_t pg_count; /* number of pages */
82 int prot; /* prot flags for mmap */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083} agp_segment;
84
85typedef struct _agp_region {
Arnd Bergmann85efde62009-02-26 00:51:39 +010086 __kernel_pid_t pid; /* pid of process */
87 __kernel_size_t seg_count; /* number of segments */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 struct _agp_segment *seg_list;
89} agp_region;
90
91typedef struct _agp_allocate {
92 int key; /* tag of allocation */
Arnd Bergmann85efde62009-02-26 00:51:39 +010093 __kernel_size_t pg_count;/* number of pages */
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 __u32 type; /* 0 == normal, other devspec */
95 __u32 physical; /* device specific (some devices
96 * need a phys address of the
97 * actual page behind the gatt
98 * table) */
99} agp_allocate;
100
101typedef struct _agp_bind {
102 int key; /* tag of allocation */
Arnd Bergmann85efde62009-02-26 00:51:39 +0100103 __kernel_off_t pg_start;/* starting page to populate */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104} agp_bind;
105
106typedef struct _agp_unbind {
107 int key; /* tag of allocation */
108 __u32 priority; /* priority for paging out */
109} agp_unbind;
110
111#else /* __KERNEL__ */
akpm@osdl.org16867822006-01-13 15:51:02 -0800112#include <linux/mutex.h>
David Woodhouse72b97602006-04-25 13:58:23 +0100113#include <linux/agp_backend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115#define AGPGART_MINOR 175
116
117struct agp_info {
118 struct agp_version version; /* version of the driver */
119 u32 bridge_id; /* bridge vendor/device */
120 u32 agp_mode; /* mode info of bridge */
121 unsigned long aper_base;/* base of aperture */
122 size_t aper_size; /* size of aperture */
123 size_t pg_total; /* max pages (swap + system) */
124 size_t pg_system; /* max pages (system) */
125 size_t pg_used; /* current pages used */
126};
127
128struct agp_setup {
129 u32 agp_mode; /* mode info of bridge */
130};
131
132/*
133 * The "prot" down below needs still a "sleep" flag somehow ...
134 */
135struct agp_segment {
136 off_t pg_start; /* starting page to populate */
137 size_t pg_count; /* number of pages */
138 int prot; /* prot flags for mmap */
139};
140
141struct agp_segment_priv {
142 off_t pg_start;
143 size_t pg_count;
144 pgprot_t prot;
145};
146
147struct agp_region {
148 pid_t pid; /* pid of process */
149 size_t seg_count; /* number of segments */
150 struct agp_segment *seg_list;
151};
152
153struct agp_allocate {
154 int key; /* tag of allocation */
155 size_t pg_count; /* number of pages */
156 u32 type; /* 0 == normal, other devspec */
157 u32 physical; /* device specific (some devices
158 * need a phys address of the
159 * actual page behind the gatt
160 * table) */
161};
162
163struct agp_bind {
164 int key; /* tag of allocation */
165 off_t pg_start; /* starting page to populate */
166};
167
168struct agp_unbind {
169 int key; /* tag of allocation */
170 u32 priority; /* priority for paging out */
171};
172
173struct agp_client {
174 struct agp_client *next;
175 struct agp_client *prev;
176 pid_t pid;
177 int num_segments;
178 struct agp_segment_priv **segments;
179};
180
181struct agp_controller {
182 struct agp_controller *next;
183 struct agp_controller *prev;
184 pid_t pid;
185 int num_clients;
186 struct agp_memory *pool;
187 struct agp_client *clients;
188};
189
190#define AGP_FF_ALLOW_CLIENT 0
191#define AGP_FF_ALLOW_CONTROLLER 1
192#define AGP_FF_IS_CLIENT 2
193#define AGP_FF_IS_CONTROLLER 3
194#define AGP_FF_IS_VALID 4
195
196struct agp_file_private {
197 struct agp_file_private *next;
198 struct agp_file_private *prev;
199 pid_t my_pid;
Al Viro64b33612007-10-14 19:35:20 +0100200 unsigned long access_flags; /* long req'd for set_bit --RR */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201};
202
203struct agp_front_data {
akpm@osdl.org16867822006-01-13 15:51:02 -0800204 struct mutex agp_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 struct agp_controller *current_controller;
206 struct agp_controller *controllers;
207 struct agp_file_private *file_priv_list;
Dave Airlie9516b032008-06-19 10:42:17 +1000208 bool used_by_controller;
209 bool backend_acquired;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210};
211
212#endif /* __KERNEL__ */
213
214#endif /* _AGP_H */