added a lot of printk output to ease writing of emulator
[linux-2.4.21-pre4.git] / include / linux / agp_backend.h
1 /*
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_BACKEND_H
28 #define _AGP_BACKEND_H 1
29
30 #ifndef TRUE
31 #define TRUE 1
32 #endif
33
34 #ifndef FALSE
35 #define FALSE 0
36 #endif
37
38 #define AGPGART_VERSION_MAJOR 0
39 #define AGPGART_VERSION_MINOR 99
40
41 enum chipset_type {
42         NOT_SUPPORTED,
43         INTEL_GENERIC,
44         INTEL_LX,
45         INTEL_BX,
46         INTEL_GX,
47         INTEL_I810,
48         INTEL_I815,
49         INTEL_I820,
50         INTEL_I830_M,
51         INTEL_I845_G,
52         INTEL_I840,
53         INTEL_I845,
54         INTEL_I850,
55         INTEL_I860,
56         VIA_GENERIC,
57         VIA_VP3,
58         VIA_MVP3,
59         VIA_MVP4,
60         VIA_APOLLO_PRO,
61         VIA_APOLLO_KX133,
62         VIA_APOLLO_KT133,
63         VIA_APOLLO_P4X400,
64         VIA_APOLLO_KT400,
65         SIS_GENERIC,
66         AMD_GENERIC,
67         AMD_IRONGATE,
68         AMD_761,
69         AMD_762,
70         AMD_8151,
71         ALI_M1541,
72         ALI_M1621,
73         ALI_M1631,
74         ALI_M1632,
75         ALI_M1641,
76         ALI_M1644,
77         ALI_M1647,
78         ALI_M1651,
79         ALI_M1671,
80         ALI_GENERIC,
81         SVWRKS_HE,
82         SVWRKS_LE,
83         SVWRKS_GENERIC,
84         HP_ZX1,
85 };
86
87 typedef struct _agp_version {
88         u16 major;
89         u16 minor;
90 } agp_version;
91
92 typedef struct _agp_kern_info {
93         agp_version version;
94         struct pci_dev *device;
95         enum chipset_type chipset;
96         unsigned long mode;
97         off_t aper_base;
98         size_t aper_size;
99         int max_memory;         /* In pages */
100         int current_memory;
101         int cant_use_aperture;
102         unsigned long page_mask;
103 } agp_kern_info;
104
105 /* 
106  * The agp_memory structure has information
107  * about the block of agp memory allocated.
108  * A caller may manipulate the next and prev
109  * pointers to link each allocated item into
110  * a list.  These pointers are ignored by the 
111  * backend.  Everything else should never be
112  * written to, but the caller may read any of
113  * the items to detrimine the status of this
114  * block of agp memory.
115  * 
116  */
117
118 typedef struct _agp_memory {
119         int key;
120         struct _agp_memory *next;
121         struct _agp_memory *prev;
122         size_t page_count;
123         int num_scratch_pages;
124         unsigned long *memory;
125         off_t pg_start;
126         u32 type;
127         u32 physical;
128         u8 is_bound;
129         u8 is_flushed;
130 } agp_memory;
131
132 #define AGP_NORMAL_MEMORY 0
133
134 extern void agp_free_memory(agp_memory *);
135
136 /*
137  * agp_free_memory :
138  * 
139  * This function frees memory associated with
140  * an agp_memory pointer.  It is the only function
141  * that can be called when the backend is not owned
142  * by the caller.  (So it can free memory on client
143  * death.)
144  * 
145  * It takes an agp_memory pointer as an argument.
146  * 
147  */
148
149 extern agp_memory *agp_allocate_memory(size_t, u32);
150
151 /*
152  * agp_allocate_memory :
153  * 
154  * This function allocates a group of pages of
155  * a certain type.
156  * 
157  * It takes a size_t argument of the number of pages, and
158  * an u32 argument of the type of memory to be allocated.  
159  * Every agp bridge device will allow you to allocate 
160  * AGP_NORMAL_MEMORY which maps to physical ram.  Any other
161  * type is device dependant.
162  * 
163  * It returns NULL whenever memory is unavailable.
164  * 
165  */
166
167 extern int agp_copy_info(agp_kern_info *);
168
169 /*
170  * agp_copy_info :
171  * 
172  * This function copies information about the
173  * agp bridge device and the state of the agp
174  * backend into an agp_kern_info pointer.
175  * 
176  * It takes an agp_kern_info pointer as an
177  * argument.  The caller should insure that
178  * this pointer is valid.
179  * 
180  */
181
182 extern int agp_bind_memory(agp_memory *, off_t);
183
184 /*
185  * agp_bind_memory :
186  * 
187  * This function binds an agp_memory structure
188  * into the graphics aperture translation table.
189  * 
190  * It takes an agp_memory pointer and an offset into
191  * the graphics aperture translation table as arguments
192  * 
193  * It returns -EINVAL if the pointer == NULL.
194  * It returns -EBUSY if the area of the table
195  * requested is already in use.
196  * 
197  */
198
199 extern int agp_unbind_memory(agp_memory *);
200
201 /* 
202  * agp_unbind_memory :
203  * 
204  * This function removes an agp_memory structure
205  * from the graphics aperture translation table.
206  * 
207  * It takes an agp_memory pointer as an argument.
208  * 
209  * It returns -EINVAL if this piece of agp_memory
210  * is not currently bound to the graphics aperture
211  * translation table or if the agp_memory 
212  * pointer == NULL
213  * 
214  */
215
216 extern void agp_enable(u32);
217
218 /* 
219  * agp_enable :
220  * 
221  * This function initializes the agp point-to-point
222  * connection.
223  * 
224  * It takes an agp mode register as an argument
225  * 
226  */
227
228 extern int agp_backend_acquire(void);
229
230 /*
231  * agp_backend_acquire :
232  * 
233  * This Function attempts to acquire the agp
234  * backend.
235  * 
236  * returns -EBUSY if agp is in use,
237  * returns 0 if the caller owns the agp backend
238  */
239
240 extern void agp_backend_release(void);
241
242 /*
243  * agp_backend_release :
244  * 
245  * This Function releases the lock on the agp
246  * backend.
247  * 
248  * The caller must insure that the graphics
249  * aperture translation table is read for use
250  * by another entity.  (Ensure that all memory
251  * it bound is unbound.)
252  * 
253  */
254
255 typedef struct {
256         void       (*free_memory)(agp_memory *);
257         agp_memory *(*allocate_memory)(size_t, u32);
258         int        (*bind_memory)(agp_memory *, off_t);
259         int        (*unbind_memory)(agp_memory *);
260         void       (*enable)(u32);
261         int        (*acquire)(void);
262         void       (*release)(void);
263         int        (*copy_info)(agp_kern_info *);
264 } drm_agp_t;
265
266 extern const drm_agp_t *drm_agp_p;
267
268 /*
269  * Interface between drm and agp code.  When agp initializes, it makes
270  * the above structure available via inter_module_register(), drm might
271  * use it.  Keith Owens <kaos@ocs.com.au> 28 Oct 2000.
272  */
273
274 #endif                          /* _AGP_BACKEND_H */