2 /****************************************************************************
3 * Copyright (C) 2003-2006 by XGI Technology, Taiwan.
5 * All Rights Reserved. *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation on the rights to use, copy, modify, merge,
11 * publish, distribute, sublicense, and/or sell copies of the Software,
12 * and to permit persons to whom the Software is furnished to do so,
13 * subject to the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial
17 * portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NON-INFRINGEMENT. IN NO EVENT SHALL XGI AND/OR
23 * ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 ***************************************************************************/
34 #define XGI_MAJOR_VERSION 0
35 #define XGI_MINOR_VERSION 7
36 #define XGI_PATCHLEVEL 5
38 #define XGI_DRV_VERSION "0.7.5"
41 #define XGI_DRV_NAME "xgi"
45 * xgi reserved major device number, Set this to 0 to
46 * request dynamic major number allocation.
49 #define XGI_DEV_MAJOR 0
52 #ifndef XGI_MAX_DEVICES
53 #define XGI_MAX_DEVICES 1
57 /* #define XGI_DEBUG */
59 #ifndef PCI_VENDOR_ID_XGI
61 #define PCI_VENDOR_ID_XGI 0x1023
63 #define PCI_VENDOR_ID_XGI 0x18CA
67 #ifndef PCI_DEVICE_ID_XP5
68 #define PCI_DEVICE_ID_XP5 0x2200
71 #ifndef PCI_DEVICE_ID_XG47
72 #define PCI_DEVICE_ID_XG47 0x0047
75 /* Macros to make printk easier */
76 #define XGI_ERROR(fmt, arg...) \
77 printk(KERN_ERR "[" XGI_DRV_NAME ":%s] *ERROR* " fmt, __FUNCTION__, ##arg)
79 #define XGI_MEM_ERROR(area, fmt, arg...) \
80 printk(KERN_ERR "[" XGI_DRV_NAME ":%s] *ERROR* " fmt, __FUNCTION__, ##arg)
82 /* #define XGI_DEBUG */
85 #define XGI_INFO(fmt, arg...) \
86 printk(KERN_ALERT "[" XGI_DRV_NAME ":%s] " fmt, __FUNCTION__, ##arg)
87 /* printk(KERN_INFO "[" XGI_DRV_NAME ":%s] " fmt, __FUNCTION__, ##arg) */
89 #define XGI_INFO(fmt, arg...) do { } while (0)
92 /* device name length; must be atleast 8 */
93 #define XGI_DEVICE_NAME_LENGTH 40
95 /* need a fake device number for control device; just to flag it for msgs */
96 #define XGI_CONTROL_DEVICE_NUMBER 100
109 /* physical characteristics */
110 struct xgi_aperture mmio;
111 struct xgi_aperture fb;
112 struct xgi_aperture pcie;
113 struct xgi_screen_info scrn_info;
114 struct xgi_sarea_info sarea_info;
116 /* look up table parameters */
118 unsigned int lutPageSize;
119 unsigned int lutPageOrder;
121 unsigned int sdfbPageSize;
128 /* keep track of any pending bottom halfes */
129 struct tasklet_struct tasklet;
131 spinlock_t info_lock;
133 struct semaphore info_sem;
134 struct semaphore fb_sem;
135 struct semaphore pcie_sem;
138 struct xgi_ioctl_post_vbios {
146 PCIE_3D should not begin with 1,
147 2D alloc pcie memory will use owner 1.
149 PCIE_3D = 11, /*vetex buf */
150 PCIE_3D_CMDLIST = 12,
151 PCIE_3D_SCRATCHPAD = 13,
152 PCIE_3D_TEXTURE = 14,
153 PCIE_INVALID = 0x7fffffff
157 struct list_head list;
158 enum xgi_mem_location location;
159 unsigned long bus_addr;
167 #define XGI_FLAG_OPEN 0x0001
168 #define XGI_FLAG_NEEDS_POSTING 0x0002
169 #define XGI_FLAG_WAS_POSTED 0x0004
170 #define XGI_FLAG_CONTROL 0x0010
171 #define XGI_FLAG_MAP_REGS_EARLY 0x0200
173 /* mmap(2) offsets */
175 #define IS_IO_OFFSET(info, offset, length) \
176 (((offset) >= (info)->mmio.base) \
177 && (((offset) + (length)) <= (info)->mmio.base + (info)->mmio.size))
179 /* Jong 06/14/2006 */
180 /* (info)->fb.base is a base address for physical (bus) address space */
181 /* what's the definition of offest? on physical (bus) address space or HW address space */
182 /* Jong 06/15/2006; use HW address space */
183 #define IS_FB_OFFSET(info, offset, length) \
185 && (((offset) + (length)) <= (info)->fb.size))
187 #define IS_FB_OFFSET(info, offset, length) \
188 (((offset) >= (info)->fb.base) \
189 && (((offset) + (length)) <= (info)->fb.base + (info)->fb.size))
192 #define IS_PCIE_OFFSET(info, offset, length) \
193 (((offset) >= (info)->pcie.base) \
194 && (((offset) + (length)) <= (info)->pcie.base + (info)->pcie.size))
196 extern int xgi_fb_heap_init(struct xgi_info * info);
197 extern void xgi_fb_heap_cleanup(struct xgi_info * info);
199 extern void xgi_fb_alloc(struct xgi_info * info, struct xgi_mem_alloc * alloc,
201 extern void xgi_fb_free(struct xgi_info * info, unsigned long offset);
202 extern void xgi_mem_collect(struct xgi_info * info, unsigned int *pcnt);
204 extern int xgi_pcie_heap_init(struct xgi_info * info);
205 extern void xgi_pcie_heap_cleanup(struct xgi_info * info);
207 extern void xgi_pcie_alloc(struct xgi_info * info,
208 struct xgi_mem_alloc * alloc, pid_t pid);
209 extern void xgi_pcie_free(struct xgi_info * info, unsigned long offset);
210 extern void xgi_pcie_heap_check(void);
211 extern struct xgi_pcie_block *xgi_find_pcie_block(struct xgi_info * info,
212 unsigned long address);
213 extern void *xgi_find_pcie_virt(struct xgi_info * info, unsigned long address);
215 extern void xgi_test_rwinkernel(struct xgi_info * info, unsigned long address);