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

