Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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_H |
| 28 | #define _AGP_H 1 |
| 29 | |
| 30 | #include <linux/agp_backend.h> |
| 31 | |
| 32 | #define AGPIOC_BASE 'A' |
| 33 | #define AGPIOC_INFO _IOR (AGPIOC_BASE, 0, struct agp_info*) |
| 34 | #define AGPIOC_ACQUIRE _IO (AGPIOC_BASE, 1) |
| 35 | #define AGPIOC_RELEASE _IO (AGPIOC_BASE, 2) |
| 36 | #define AGPIOC_SETUP _IOW (AGPIOC_BASE, 3, struct agp_setup*) |
| 37 | #define AGPIOC_RESERVE _IOW (AGPIOC_BASE, 4, struct agp_region*) |
| 38 | #define AGPIOC_PROTECT _IOW (AGPIOC_BASE, 5, struct agp_region*) |
| 39 | #define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 6, struct agp_allocate*) |
| 40 | #define AGPIOC_DEALLOCATE _IOW (AGPIOC_BASE, 7, int) |
| 41 | #define AGPIOC_BIND _IOW (AGPIOC_BASE, 8, struct agp_bind*) |
| 42 | #define AGPIOC_UNBIND _IOW (AGPIOC_BASE, 9, struct agp_unbind*) |
| 43 | |
| 44 | #define AGP_DEVICE "/dev/agpgart" |
| 45 | |
| 46 | #ifndef TRUE |
| 47 | #define TRUE 1 |
| 48 | #endif |
| 49 | |
| 50 | #ifndef FALSE |
| 51 | #define FALSE 0 |
| 52 | #endif |
| 53 | |
| 54 | #ifndef __KERNEL__ |
| 55 | #include <linux/types.h> |
| 56 | #include <asm/types.h> |
| 57 | |
| 58 | struct agp_version { |
| 59 | __u16 major; |
| 60 | __u16 minor; |
| 61 | }; |
| 62 | |
| 63 | typedef struct _agp_info { |
| 64 | struct agp_version version; /* version of the driver */ |
| 65 | __u32 bridge_id; /* bridge vendor/device */ |
| 66 | __u32 agp_mode; /* mode info of bridge */ |
| 67 | unsigned long aper_base;/* base of aperture */ |
| 68 | size_t aper_size; /* size of aperture */ |
| 69 | size_t pg_total; /* max pages (swap + system) */ |
| 70 | size_t pg_system; /* max pages (system) */ |
| 71 | size_t pg_used; /* current pages used */ |
| 72 | } agp_info; |
| 73 | |
| 74 | typedef struct _agp_setup { |
| 75 | __u32 agp_mode; /* mode info of bridge */ |
| 76 | } agp_setup; |
| 77 | |
| 78 | /* |
| 79 | * The "prot" down below needs still a "sleep" flag somehow ... |
| 80 | */ |
| 81 | typedef struct _agp_segment { |
| 82 | off_t pg_start; /* starting page to populate */ |
| 83 | size_t pg_count; /* number of pages */ |
| 84 | int prot; /* prot flags for mmap */ |
| 85 | } agp_segment; |
| 86 | |
| 87 | typedef struct _agp_region { |
| 88 | pid_t pid; /* pid of process */ |
| 89 | size_t seg_count; /* number of segments */ |
| 90 | struct _agp_segment *seg_list; |
| 91 | } agp_region; |
| 92 | |
| 93 | typedef struct _agp_allocate { |
| 94 | int key; /* tag of allocation */ |
| 95 | size_t pg_count; /* number of pages */ |
| 96 | __u32 type; /* 0 == normal, other devspec */ |
| 97 | __u32 physical; /* device specific (some devices |
| 98 | * need a phys address of the |
| 99 | * actual page behind the gatt |
| 100 | * table) */ |
| 101 | } agp_allocate; |
| 102 | |
| 103 | typedef struct _agp_bind { |
| 104 | int key; /* tag of allocation */ |
| 105 | off_t pg_start; /* starting page to populate */ |
| 106 | } agp_bind; |
| 107 | |
| 108 | typedef struct _agp_unbind { |
| 109 | int key; /* tag of allocation */ |
| 110 | __u32 priority; /* priority for paging out */ |
| 111 | } agp_unbind; |
| 112 | |
| 113 | #else /* __KERNEL__ */ |
akpm@osdl.org | 1686782 | 2006-01-13 15:51:02 -0800 | [diff] [blame] | 114 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | #define AGPGART_MINOR 175 |
| 117 | |
| 118 | struct agp_info { |
| 119 | struct agp_version version; /* version of the driver */ |
| 120 | u32 bridge_id; /* bridge vendor/device */ |
| 121 | u32 agp_mode; /* mode info of bridge */ |
| 122 | unsigned long aper_base;/* base of aperture */ |
| 123 | size_t aper_size; /* size of aperture */ |
| 124 | size_t pg_total; /* max pages (swap + system) */ |
| 125 | size_t pg_system; /* max pages (system) */ |
| 126 | size_t pg_used; /* current pages used */ |
| 127 | }; |
| 128 | |
| 129 | struct agp_setup { |
| 130 | u32 agp_mode; /* mode info of bridge */ |
| 131 | }; |
| 132 | |
| 133 | /* |
| 134 | * The "prot" down below needs still a "sleep" flag somehow ... |
| 135 | */ |
| 136 | struct agp_segment { |
| 137 | off_t pg_start; /* starting page to populate */ |
| 138 | size_t pg_count; /* number of pages */ |
| 139 | int prot; /* prot flags for mmap */ |
| 140 | }; |
| 141 | |
| 142 | struct agp_segment_priv { |
| 143 | off_t pg_start; |
| 144 | size_t pg_count; |
| 145 | pgprot_t prot; |
| 146 | }; |
| 147 | |
| 148 | struct agp_region { |
| 149 | pid_t pid; /* pid of process */ |
| 150 | size_t seg_count; /* number of segments */ |
| 151 | struct agp_segment *seg_list; |
| 152 | }; |
| 153 | |
| 154 | struct agp_allocate { |
| 155 | int key; /* tag of allocation */ |
| 156 | size_t pg_count; /* number of pages */ |
| 157 | u32 type; /* 0 == normal, other devspec */ |
| 158 | u32 physical; /* device specific (some devices |
| 159 | * need a phys address of the |
| 160 | * actual page behind the gatt |
| 161 | * table) */ |
| 162 | }; |
| 163 | |
| 164 | struct agp_bind { |
| 165 | int key; /* tag of allocation */ |
| 166 | off_t pg_start; /* starting page to populate */ |
| 167 | }; |
| 168 | |
| 169 | struct agp_unbind { |
| 170 | int key; /* tag of allocation */ |
| 171 | u32 priority; /* priority for paging out */ |
| 172 | }; |
| 173 | |
| 174 | struct agp_client { |
| 175 | struct agp_client *next; |
| 176 | struct agp_client *prev; |
| 177 | pid_t pid; |
| 178 | int num_segments; |
| 179 | struct agp_segment_priv **segments; |
| 180 | }; |
| 181 | |
| 182 | struct agp_controller { |
| 183 | struct agp_controller *next; |
| 184 | struct agp_controller *prev; |
| 185 | pid_t pid; |
| 186 | int num_clients; |
| 187 | struct agp_memory *pool; |
| 188 | struct agp_client *clients; |
| 189 | }; |
| 190 | |
| 191 | #define AGP_FF_ALLOW_CLIENT 0 |
| 192 | #define AGP_FF_ALLOW_CONTROLLER 1 |
| 193 | #define AGP_FF_IS_CLIENT 2 |
| 194 | #define AGP_FF_IS_CONTROLLER 3 |
| 195 | #define AGP_FF_IS_VALID 4 |
| 196 | |
| 197 | struct agp_file_private { |
| 198 | struct agp_file_private *next; |
| 199 | struct agp_file_private *prev; |
| 200 | pid_t my_pid; |
| 201 | long access_flags; /* long req'd for set_bit --RR */ |
| 202 | }; |
| 203 | |
| 204 | struct agp_front_data { |
akpm@osdl.org | 1686782 | 2006-01-13 15:51:02 -0800 | [diff] [blame] | 205 | struct mutex agp_mutex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | struct agp_controller *current_controller; |
| 207 | struct agp_controller *controllers; |
| 208 | struct agp_file_private *file_priv_list; |
| 209 | u8 used_by_controller; |
| 210 | u8 backend_acquired; |
| 211 | }; |
| 212 | |
| 213 | #endif /* __KERNEL__ */ |
| 214 | |
| 215 | #endif /* _AGP_H */ |