xref: /OK3568_Linux_fs/kernel/include/linux/agpgart.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * AGPGART module version 0.99
3*4882a593Smuzhiyun  * Copyright (C) 1999 Jeff Hartmann
4*4882a593Smuzhiyun  * Copyright (C) 1999 Precision Insight, Inc.
5*4882a593Smuzhiyun  * Copyright (C) 1999 Xi Graphics, Inc.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
8*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
9*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
10*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
12*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  * The above copyright notice and this permission notice shall be included
15*4882a593Smuzhiyun  * in all copies or substantial portions of the Software.
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18*4882a593Smuzhiyun  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20*4882a593Smuzhiyun  * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
21*4882a593Smuzhiyun  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22*4882a593Smuzhiyun  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23*4882a593Smuzhiyun  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  */
26*4882a593Smuzhiyun #ifndef _AGP_H
27*4882a593Smuzhiyun #define _AGP_H 1
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #include <linux/mutex.h>
30*4882a593Smuzhiyun #include <linux/agp_backend.h>
31*4882a593Smuzhiyun #include <uapi/linux/agpgart.h>
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun struct agp_info {
34*4882a593Smuzhiyun 	struct agp_version version;	/* version of the driver        */
35*4882a593Smuzhiyun 	u32 bridge_id;		/* bridge vendor/device         */
36*4882a593Smuzhiyun 	u32 agp_mode;		/* mode info of bridge          */
37*4882a593Smuzhiyun 	unsigned long aper_base;/* base of aperture             */
38*4882a593Smuzhiyun 	size_t aper_size;	/* size of aperture             */
39*4882a593Smuzhiyun 	size_t pg_total;	/* max pages (swap + system)    */
40*4882a593Smuzhiyun 	size_t pg_system;	/* max pages (system)           */
41*4882a593Smuzhiyun 	size_t pg_used;		/* current pages used           */
42*4882a593Smuzhiyun };
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun struct agp_setup {
45*4882a593Smuzhiyun 	u32 agp_mode;		/* mode info of bridge          */
46*4882a593Smuzhiyun };
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun /*
49*4882a593Smuzhiyun  * The "prot" down below needs still a "sleep" flag somehow ...
50*4882a593Smuzhiyun  */
51*4882a593Smuzhiyun struct agp_segment {
52*4882a593Smuzhiyun 	off_t pg_start;		/* starting page to populate    */
53*4882a593Smuzhiyun 	size_t pg_count;	/* number of pages              */
54*4882a593Smuzhiyun 	int prot;		/* prot flags for mmap          */
55*4882a593Smuzhiyun };
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun struct agp_segment_priv {
58*4882a593Smuzhiyun 	off_t pg_start;
59*4882a593Smuzhiyun 	size_t pg_count;
60*4882a593Smuzhiyun 	pgprot_t prot;
61*4882a593Smuzhiyun };
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun struct agp_region {
64*4882a593Smuzhiyun 	pid_t pid;		/* pid of process               */
65*4882a593Smuzhiyun 	size_t seg_count;	/* number of segments           */
66*4882a593Smuzhiyun 	struct agp_segment *seg_list;
67*4882a593Smuzhiyun };
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun struct agp_allocate {
70*4882a593Smuzhiyun 	int key;		/* tag of allocation            */
71*4882a593Smuzhiyun 	size_t pg_count;	/* number of pages              */
72*4882a593Smuzhiyun 	u32 type;		/* 0 == normal, other devspec   */
73*4882a593Smuzhiyun 	u32 physical;           /* device specific (some devices
74*4882a593Smuzhiyun 				 * need a phys address of the
75*4882a593Smuzhiyun 				 * actual page behind the gatt
76*4882a593Smuzhiyun 				 * table)                        */
77*4882a593Smuzhiyun };
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun struct agp_bind {
80*4882a593Smuzhiyun 	int key;		/* tag of allocation            */
81*4882a593Smuzhiyun 	off_t pg_start;		/* starting page to populate    */
82*4882a593Smuzhiyun };
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun struct agp_unbind {
85*4882a593Smuzhiyun 	int key;		/* tag of allocation            */
86*4882a593Smuzhiyun 	u32 priority;		/* priority for paging out      */
87*4882a593Smuzhiyun };
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun struct agp_client {
90*4882a593Smuzhiyun 	struct agp_client *next;
91*4882a593Smuzhiyun 	struct agp_client *prev;
92*4882a593Smuzhiyun 	pid_t pid;
93*4882a593Smuzhiyun 	int num_segments;
94*4882a593Smuzhiyun 	struct agp_segment_priv **segments;
95*4882a593Smuzhiyun };
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun struct agp_controller {
98*4882a593Smuzhiyun 	struct agp_controller *next;
99*4882a593Smuzhiyun 	struct agp_controller *prev;
100*4882a593Smuzhiyun 	pid_t pid;
101*4882a593Smuzhiyun 	int num_clients;
102*4882a593Smuzhiyun 	struct agp_memory *pool;
103*4882a593Smuzhiyun 	struct agp_client *clients;
104*4882a593Smuzhiyun };
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun #define AGP_FF_ALLOW_CLIENT		0
107*4882a593Smuzhiyun #define AGP_FF_ALLOW_CONTROLLER 	1
108*4882a593Smuzhiyun #define AGP_FF_IS_CLIENT		2
109*4882a593Smuzhiyun #define AGP_FF_IS_CONTROLLER		3
110*4882a593Smuzhiyun #define AGP_FF_IS_VALID 		4
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun struct agp_file_private {
113*4882a593Smuzhiyun 	struct agp_file_private *next;
114*4882a593Smuzhiyun 	struct agp_file_private *prev;
115*4882a593Smuzhiyun 	pid_t my_pid;
116*4882a593Smuzhiyun 	unsigned long access_flags;	/* long req'd for set_bit --RR */
117*4882a593Smuzhiyun };
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun struct agp_front_data {
120*4882a593Smuzhiyun 	struct mutex agp_mutex;
121*4882a593Smuzhiyun 	struct agp_controller *current_controller;
122*4882a593Smuzhiyun 	struct agp_controller *controllers;
123*4882a593Smuzhiyun 	struct agp_file_private *file_priv_list;
124*4882a593Smuzhiyun 	bool used_by_controller;
125*4882a593Smuzhiyun 	bool backend_acquired;
126*4882a593Smuzhiyun };
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun #endif				/* _AGP_H */
129