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;
114 /* look up table parameters */
116 unsigned int lutPageSize;
117 unsigned int lutPageOrder;
119 unsigned int sdfbPageSize;
126 /* keep track of any pending bottom halfes */
127 struct tasklet_struct tasklet;
129 spinlock_t info_lock;
131 struct semaphore info_sem;
132 struct semaphore fb_sem;
133 struct semaphore pcie_sem;
136 struct xgi_ioctl_post_vbios {
144 PCIE_3D should not begin with 1,
145 2D alloc pcie memory will use owner 1.
147 PCIE_3D = 11, /*vetex buf */
148 PCIE_3D_CMDLIST = 12,
149 PCIE_3D_SCRATCHPAD = 13,
150 PCIE_3D_TEXTURE = 14,
151 PCIE_INVALID = 0x7fffffff
155 struct list_head list;
156 enum xgi_mem_location location;
157 unsigned long bus_addr;
165 #define XGI_FLAG_OPEN 0x0001
166 #define XGI_FLAG_NEEDS_POSTING 0x0002
167 #define XGI_FLAG_WAS_POSTED 0x0004
168 #define XGI_FLAG_CONTROL 0x0010
169 #define XGI_FLAG_MAP_REGS_EARLY 0x0200
171 /* mmap(2) offsets */
173 #define IS_IO_OFFSET(info, offset, length) \
174 (((offset) >= (info)->mmio.base) \
175 && (((offset) + (length)) <= (info)->mmio.base + (info)->mmio.size))
177 /* Jong 06/14/2006 */
178 /* (info)->fb.base is a base address for physical (bus) address space */
179 /* what's the definition of offest? on physical (bus) address space or HW address space */
180 /* Jong 06/15/2006; use HW address space */
181 #define IS_FB_OFFSET(info, offset, length) \
183 && (((offset) + (length)) <= (info)->fb.size))
185 #define IS_FB_OFFSET(info, offset, length) \
186 (((offset) >= (info)->fb.base) \
187 && (((offset) + (length)) <= (info)->fb.base + (info)->fb.size))
190 #define IS_PCIE_OFFSET(info, offset, length) \
191 (((offset) >= (info)->pcie.base) \
192 && (((offset) + (length)) <= (info)->pcie.base + (info)->pcie.size))
194 extern int xgi_fb_heap_init(struct xgi_info * info);
195 extern void xgi_fb_heap_cleanup(struct xgi_info * info);
197 extern void xgi_fb_alloc(struct xgi_info * info, struct xgi_mem_alloc * alloc,
199 extern void xgi_fb_free(struct xgi_info * info, unsigned long offset);
200 extern void xgi_mem_collect(struct xgi_info * info, unsigned int *pcnt);
202 extern int xgi_pcie_heap_init(struct xgi_info * info);
203 extern void xgi_pcie_heap_cleanup(struct xgi_info * info);
205 extern void xgi_pcie_alloc(struct xgi_info * info,
206 struct xgi_mem_alloc * alloc, pid_t pid);
207 extern void xgi_pcie_free(struct xgi_info * info, unsigned long offset);
208 extern struct xgi_pcie_block *xgi_find_pcie_block(struct xgi_info * info,
209 unsigned long address);
210 extern void *xgi_find_pcie_virt(struct xgi_info * info, unsigned long address);
212 extern void xgi_test_rwinkernel(struct xgi_info * info, unsigned long address);