agpgart.h 6.3 KB

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