xref: /OK3568_Linux_fs/kernel/include/linux/agp_backend.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * AGPGART backend specific includes. Not for userspace consumption.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (C) 2004 Silicon Graphics, Inc.
5*4882a593Smuzhiyun  * Copyright (C) 2002-2003 Dave Jones
6*4882a593Smuzhiyun  * Copyright (C) 1999 Jeff Hartmann
7*4882a593Smuzhiyun  * Copyright (C) 1999 Precision Insight, Inc.
8*4882a593Smuzhiyun  * Copyright (C) 1999 Xi Graphics, Inc.
9*4882a593Smuzhiyun  *
10*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
11*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
12*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
13*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
15*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * The above copyright notice and this permission notice shall be included
18*4882a593Smuzhiyun  * in all copies or substantial portions of the Software.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21*4882a593Smuzhiyun  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23*4882a593Smuzhiyun  * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
24*4882a593Smuzhiyun  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25*4882a593Smuzhiyun  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
26*4882a593Smuzhiyun  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27*4882a593Smuzhiyun  *
28*4882a593Smuzhiyun  */
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #ifndef _AGP_BACKEND_H
31*4882a593Smuzhiyun #define _AGP_BACKEND_H 1
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #include <linux/list.h>
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun enum chipset_type {
36*4882a593Smuzhiyun 	NOT_SUPPORTED,
37*4882a593Smuzhiyun 	SUPPORTED,
38*4882a593Smuzhiyun };
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun struct agp_version {
41*4882a593Smuzhiyun 	u16 major;
42*4882a593Smuzhiyun 	u16 minor;
43*4882a593Smuzhiyun };
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun struct agp_kern_info {
46*4882a593Smuzhiyun 	struct agp_version version;
47*4882a593Smuzhiyun 	struct pci_dev *device;
48*4882a593Smuzhiyun 	enum chipset_type chipset;
49*4882a593Smuzhiyun 	unsigned long mode;
50*4882a593Smuzhiyun 	unsigned long aper_base;
51*4882a593Smuzhiyun 	size_t aper_size;
52*4882a593Smuzhiyun 	int max_memory;		/* In pages */
53*4882a593Smuzhiyun 	int current_memory;
54*4882a593Smuzhiyun 	bool cant_use_aperture;
55*4882a593Smuzhiyun 	unsigned long page_mask;
56*4882a593Smuzhiyun 	const struct vm_operations_struct *vm_ops;
57*4882a593Smuzhiyun };
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun /*
60*4882a593Smuzhiyun  * The agp_memory structure has information about the block of agp memory
61*4882a593Smuzhiyun  * allocated.  A caller may manipulate the next and prev pointers to link
62*4882a593Smuzhiyun  * each allocated item into a list.  These pointers are ignored by the backend.
63*4882a593Smuzhiyun  * Everything else should never be written to, but the caller may read any of
64*4882a593Smuzhiyun  * the items to determine the status of this block of agp memory.
65*4882a593Smuzhiyun  */
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun struct agp_bridge_data;
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun struct agp_memory {
70*4882a593Smuzhiyun 	struct agp_memory *next;
71*4882a593Smuzhiyun 	struct agp_memory *prev;
72*4882a593Smuzhiyun 	struct agp_bridge_data *bridge;
73*4882a593Smuzhiyun 	struct page **pages;
74*4882a593Smuzhiyun 	size_t page_count;
75*4882a593Smuzhiyun 	int key;
76*4882a593Smuzhiyun 	int num_scratch_pages;
77*4882a593Smuzhiyun 	off_t pg_start;
78*4882a593Smuzhiyun 	u32 type;
79*4882a593Smuzhiyun 	u32 physical;
80*4882a593Smuzhiyun 	bool is_bound;
81*4882a593Smuzhiyun 	bool is_flushed;
82*4882a593Smuzhiyun 	/* list of agp_memory mapped to the aperture */
83*4882a593Smuzhiyun 	struct list_head mapped_list;
84*4882a593Smuzhiyun 	/* DMA-mapped addresses */
85*4882a593Smuzhiyun 	struct scatterlist *sg_list;
86*4882a593Smuzhiyun 	int num_sg;
87*4882a593Smuzhiyun };
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun #define AGP_NORMAL_MEMORY 0
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun #define AGP_USER_TYPES (1 << 16)
92*4882a593Smuzhiyun #define AGP_USER_MEMORY (AGP_USER_TYPES)
93*4882a593Smuzhiyun #define AGP_USER_CACHED_MEMORY (AGP_USER_TYPES + 1)
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun extern struct agp_bridge_data *agp_bridge;
96*4882a593Smuzhiyun extern struct list_head agp_bridges;
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun extern struct agp_bridge_data *(*agp_find_bridge)(struct pci_dev *);
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun extern void agp_free_memory(struct agp_memory *);
101*4882a593Smuzhiyun extern struct agp_memory *agp_allocate_memory(struct agp_bridge_data *, size_t, u32);
102*4882a593Smuzhiyun extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *);
103*4882a593Smuzhiyun extern int agp_bind_memory(struct agp_memory *, off_t);
104*4882a593Smuzhiyun extern int agp_unbind_memory(struct agp_memory *);
105*4882a593Smuzhiyun extern void agp_enable(struct agp_bridge_data *, u32);
106*4882a593Smuzhiyun extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *);
107*4882a593Smuzhiyun extern void agp_backend_release(struct agp_bridge_data *);
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun #endif				/* _AGP_BACKEND_H */
110