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.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
27 #ifndef _AGP_BACKEND_H
28 #define _AGP_BACKEND_H 1
38 #define AGPGART_VERSION_MAJOR 0
39 #define AGPGART_VERSION_MINOR 99
87 typedef struct _agp_version {
92 typedef struct _agp_kern_info {
94 struct pci_dev *device;
95 enum chipset_type chipset;
99 int max_memory; /* In pages */
101 int cant_use_aperture;
102 unsigned long page_mask;
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.
118 typedef struct _agp_memory {
120 struct _agp_memory *next;
121 struct _agp_memory *prev;
123 int num_scratch_pages;
124 unsigned long *memory;
132 #define AGP_NORMAL_MEMORY 0
134 extern void agp_free_memory(agp_memory *);
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
145 * It takes an agp_memory pointer as an argument.
149 extern agp_memory *agp_allocate_memory(size_t, u32);
152 * agp_allocate_memory :
154 * This function allocates a group of pages of
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.
163 * It returns NULL whenever memory is unavailable.
167 extern int agp_copy_info(agp_kern_info *);
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.
176 * It takes an agp_kern_info pointer as an
177 * argument. The caller should insure that
178 * this pointer is valid.
182 extern int agp_bind_memory(agp_memory *, off_t);
187 * This function binds an agp_memory structure
188 * into the graphics aperture translation table.
190 * It takes an agp_memory pointer and an offset into
191 * the graphics aperture translation table as arguments
193 * It returns -EINVAL if the pointer == NULL.
194 * It returns -EBUSY if the area of the table
195 * requested is already in use.
199 extern int agp_unbind_memory(agp_memory *);
202 * agp_unbind_memory :
204 * This function removes an agp_memory structure
205 * from the graphics aperture translation table.
207 * It takes an agp_memory pointer as an argument.
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
216 extern void agp_enable(u32);
221 * This function initializes the agp point-to-point
224 * It takes an agp mode register as an argument
228 extern int agp_backend_acquire(void);
231 * agp_backend_acquire :
233 * This Function attempts to acquire the agp
236 * returns -EBUSY if agp is in use,
237 * returns 0 if the caller owns the agp backend
240 extern void agp_backend_release(void);
243 * agp_backend_release :
245 * This Function releases the lock on the agp
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.)
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 *);
261 int (*acquire)(void);
262 void (*release)(void);
263 int (*copy_info)(agp_kern_info *);
266 extern const drm_agp_t *drm_agp_p;
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.
274 #endif /* _AGP_BACKEND_H */