~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/drivers/i810/common.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/**************************************************************************
 
3
 
 
4
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
 
5
Copyright � 2002 David Dawes
 
6
 
 
7
All Rights Reserved.
 
8
 
 
9
Permission is hereby granted, free of charge, to any person obtaining a
 
10
copy of this software and associated documentation files (the
 
11
"Software"), to deal in the Software without restriction, including
 
12
without limitation the rights to use, copy, modify, merge, publish,
 
13
distribute, sub license, and/or sell copies of the Software, and to
 
14
permit persons to whom the Software is furnished to do so, subject to
 
15
the following conditions:
 
16
 
 
17
The above copyright notice and this permission notice (including the
 
18
next paragraph) shall be included in all copies or substantial portions
 
19
of the Software.
 
20
 
 
21
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
22
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
23
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 
24
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
 
25
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
26
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
27
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
28
 
 
29
**************************************************************************/
 
30
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/common.h,v 1.6 2003/02/06 04:18:04 dawes Exp $ */
 
31
 
 
32
/*
 
33
 * Authors:
 
34
 *   Keith Whitwell <keith@tungstengraphics.com>
 
35
 *   David Dawes <dawes@tungstengraphics.com>
 
36
 *
 
37
 */
 
38
 
 
39
#ifndef _INTEL_COMMON_H_
 
40
#define _INTEL_COMMON_H_
 
41
 
 
42
#ifdef __GNUC__
 
43
#define PFX __FILE__,__LINE__,__FUNCTION__
 
44
#define FUNCTION_NAME __FUNCTION__
 
45
#else
 
46
#define PFX __FILE__,__LINE__,""
 
47
#define FUNCTION_NAME ""
 
48
#endif
 
49
 
 
50
#ifdef I830DEBUG
 
51
#define MARKER() ErrorF("\n### %s:%d: >>> %s <<< ###\n\n", \
 
52
                         __FILE__, __LINE__,__FUNCTION__)
 
53
#define DPRINTF I830DPRINTF_stub
 
54
#else /* #ifdef I830DEBUG */
 
55
#define MARKER()
 
56
/* this is a real ugly hack to get the compiler to optimize the debugging statements into oblivion */
 
57
#define DPRINTF if(0) I830DPRINTF_stub
 
58
#endif /* #ifdef I830DEBUG */
 
59
 
 
60
#define KB(x) ((x) * 1024)
 
61
#define MB(x) ((x) * KB(1024))
 
62
 
 
63
/* Using usleep() makes things noticably slow. */
 
64
#if 0
 
65
#define DELAY(x) usleep(x)
 
66
#else
 
67
#define DELAY(x) do {;} while (0)
 
68
#endif
 
69
 
 
70
/* I830 hooks for the I810 driver setup/probe. */
 
71
extern const OptionInfoRec *I830BIOSAvailableOptions(int chipid, int busid);
 
72
extern void I830InitpScrn(ScrnInfoPtr pScrn);
 
73
 
 
74
/* Symbol lists shared by the i810 and i830 parts. */
 
75
extern const char *I810vgahwSymbols[];
 
76
extern const char *I810ramdacSymbols[];
 
77
extern const char *I810int10Symbols[];
 
78
extern const char *I810vbeSymbols[];
 
79
extern const char *I810ddcSymbols[];
 
80
extern const char *I810fbSymbols[];
 
81
extern const char *I810xaaSymbols[];
 
82
extern const char *I810shadowSymbols[];
 
83
 
 
84
extern void I830DPRINTF_stub(const char *filename, int line,
 
85
                             const char *function, const char *fmt, ...);
 
86
 
 
87
#ifdef _I830_H_
 
88
#define PrintErrorState I830PrintErrorState
 
89
#define WaitRingFunc I830WaitLpRing
 
90
#define RecPtr pI830
 
91
#else
 
92
#define PrintErrorState I810PrintErrorState
 
93
#define WaitRingFunc I810WaitLpRing
 
94
#define RecPtr pI810
 
95
#endif
 
96
 
 
97
/* BIOS debug macro */
 
98
#define xf86ExecX86int10_wrapper(pInt, pScrn) do {                      \
 
99
   if (I810_DEBUG & DEBUG_VERBOSE_BIOS) {                               \
 
100
      ErrorF("\n\n\n\nExecuting (ax == 0x%x) BIOS call\n", pInt->ax);   \
 
101
      ErrorF("Checking Error state before execution\n");                \
 
102
      PrintErrorState(pScrn);                                           \
 
103
   }                                                                    \
 
104
   xf86ExecX86int10(pInt);                                              \
 
105
   if(I810_DEBUG & DEBUG_VERBOSE_BIOS) {                                \
 
106
      ErrorF("Checking Error state after execution\n");                 \
 
107
      usleep(50000);                                                    \
 
108
      PrintErrorState(pScrn);                                           \
 
109
   }                                                                    \
 
110
} while (0)
 
111
 
 
112
#define OUT_RING(n) do {                                                \
 
113
   if (I810_DEBUG & DEBUG_VERBOSE_RING)                                 \
 
114
      ErrorF( "OUT_RING %x: %x, (mask %x)\n", outring, n, ringmask);    \
 
115
   *(volatile unsigned int *)(virt + outring) = n;                      \
 
116
   outring += 4;                                                        \
 
117
   outring &= ringmask;                                                 \
 
118
} while (0)
 
119
 
 
120
#if 1
 
121
#define ADVANCE_LP_RING() do {                                          \
 
122
   RecPtr->LpRing.tail = outring;                                       \
 
123
   if (outring & 0x07)                                                  \
 
124
      ErrorF("ADVANCE_LP_RING: "                                        \
 
125
             "outring (0x%x) isn't on a QWord boundary", outring);      \
 
126
   OUTREG(LP_RING + RING_TAIL, outring);                                \
 
127
} while (0)
 
128
#else
 
129
#define ADVANCE_LP_RING() {                                             \
 
130
   RecPtr->LpRing.tail = outring;                                       \
 
131
   if (outring & 0x07)                                                  \
 
132
      ErrorF("ADVANCE_LP_RING: "                                        \
 
133
             "outring (0x%x) isn't on a QWord boundary", outring);      \
 
134
   ErrorF("head is %d, tail is %d [%d]\n", INREG(LP_RING + RING_HEAD), INREG(LP_RING + RING_TAIL), outring); \
 
135
   OUTREG(LP_RING + RING_TAIL, outring);                                \
 
136
   ErrorF("head is %d, tail is %d [%d]\n", INREG(LP_RING + RING_HEAD), INREG(LP_RING + RING_TAIL), outring); \
 
137
}
 
138
#endif
 
139
 
 
140
/*
 
141
 * XXX Note: the head/tail masks are different for 810 and i830.
 
142
 * If the i810 always sets the higher bits to 0, then this shouldn't be
 
143
 * a problem.  Check this!
 
144
 */
 
145
#define DO_RING_IDLE() do {                                             \
 
146
   int _head;                                                           \
 
147
   int _tail;                                                           \
 
148
   do {                                                                 \
 
149
      _head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;              \
 
150
      _tail = INREG(LP_RING + RING_TAIL) & I830_TAIL_MASK;              \
 
151
      DELAY(10);                                                        \
 
152
   } while (_head != _tail);                                            \
 
153
} while( 0)
 
154
 
 
155
/*
 
156
 * This is for debugging a potential problem writing the tail pointer
 
157
 * close to the end of the ring buffer.
 
158
 */
 
159
#ifndef AVOID_TAIL_END
 
160
#define AVOID_TAIL_END 0
 
161
#endif
 
162
#ifndef AVOID_SIZE
 
163
#define AVOID_SIZE 64
 
164
#endif
 
165
 
 
166
#if AVOID_TAIL_END
 
167
 
 
168
#define BEGIN_LP_RING(n)                                                \
 
169
   unsigned int outring, ringmask;                                      \
 
170
   volatile unsigned char *virt;                                        \
 
171
   unsigned int needed;                                                 \
 
172
   if ((n) & 1)                                                         \
 
173
      ErrorF("BEGIN_LP_RING called with odd argument: %d\n", n);        \
 
174
   if ((n) > 2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC))                       \
 
175
      DO_RING_IDLE();                                                   \
 
176
   needed = (n) * 4;                                                    \
 
177
   if ((RecPtr->LpRing.tail > RecPtr->LpRing.tail_mask - AVOID_SIZE) || \
 
178
       (RecPtr->LpRing.tail + needed) >                                 \
 
179
        RecPtr->LpRing.tail_mask - AVOID_SIZE) {                        \
 
180
      needed += RecPtr->LpRing.tail_mask + 1 - RecPtr->LpRing.tail;     \
 
181
      ErrorF("BEGIN_LP_RING: skipping last 64 bytes of "                \
 
182
             "ring (%d vs %d)\n", needed, (n) * 4);                     \
 
183
   }                                                                    \
 
184
   if (RecPtr->LpRing.space < needed)                                   \
 
185
      WaitRingFunc(pScrn, needed, 0);                                   \
 
186
   RecPtr->LpRing.space -= needed;                                      \
 
187
   outring = RecPtr->LpRing.tail;                                       \
 
188
   ringmask = RecPtr->LpRing.tail_mask;                                 \
 
189
   virt = RecPtr->LpRing.virtual_start;                                 \
 
190
   while (needed > (n) * 4) {                                           \
 
191
      ErrorF("BEGIN_LP_RING: putting MI_NOOP at 0x%x (remaining %d)\n", \
 
192
             outring, needed - (n) * 4);                                \
 
193
      OUT_RING(MI_NOOP);                                                \
 
194
      needed -= 4;                                                      \
 
195
   }                                                                    \
 
196
   if (I810_DEBUG & DEBUG_VERBOSE_RING)                                 \
 
197
      ErrorF( "BEGIN_LP_RING %d in %s\n", n, FUNCTION_NAME);
 
198
 
 
199
#else /* AVOID_TAIL_END */
 
200
 
 
201
#define BEGIN_LP_RING(n)                                                \
 
202
   unsigned int outring, ringmask;                                      \
 
203
   volatile unsigned char *virt;                                        \
 
204
   unsigned int needed;                                                 \
 
205
   if ((n) & 1)                                                         \
 
206
      ErrorF("BEGIN_LP_RING called with odd argument: %d\n", n);        \
 
207
   if ((n) > 2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC))                       \
 
208
      DO_RING_IDLE();                                                   \
 
209
   needed = (n) * 4;                                                    \
 
210
   if (RecPtr->LpRing.space < needed)                                   \
 
211
      WaitRingFunc(pScrn, needed, 0);                                   \
 
212
   RecPtr->LpRing.space -= needed;                                      \
 
213
   outring = RecPtr->LpRing.tail;                                       \
 
214
   ringmask = RecPtr->LpRing.tail_mask;                                 \
 
215
   virt = RecPtr->LpRing.virtual_start;                                 \
 
216
   if (I810_DEBUG & DEBUG_VERBOSE_RING)                                 \
 
217
      ErrorF( "BEGIN_LP_RING %d in %s\n", n, FUNCTION_NAME);
 
218
 
 
219
#endif /* AVOID_TAIL_END */
 
220
 
 
221
 
 
222
/* Memory mapped register access macros */
 
223
#define INREG8(addr)        *(volatile CARD8  *)(RecPtr->MMIOBase + (addr))
 
224
#define INREG16(addr)       *(volatile CARD16 *)(RecPtr->MMIOBase + (addr))
 
225
#define INREG(addr)         *(volatile CARD32 *)(RecPtr->MMIOBase + (addr))
 
226
 
 
227
#define OUTREG8(addr, val) do {                                         \
 
228
   *(volatile CARD8 *)(RecPtr->MMIOBase  + (addr)) = (val);             \
 
229
   if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) {                               \
 
230
      ErrorF("OUTREG8(0x%x, 0x%x) in %s\n", addr, val, FUNCTION_NAME);  \
 
231
   }                                                                    \
 
232
} while (0)
 
233
 
 
234
#define OUTREG16(addr, val) do {                                        \
 
235
   *(volatile CARD16 *)(RecPtr->MMIOBase + (addr)) = (val);             \
 
236
   if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) {                               \
 
237
      ErrorF("OUTREG16(0x%x, 0x%x) in %s\n", addr, val, FUNCTION_NAME); \
 
238
   }                                                                    \
 
239
} while (0)
 
240
 
 
241
#define OUTREG(addr, val) do {                                          \
 
242
   *(volatile CARD32 *)(RecPtr->MMIOBase + (addr)) = (val);             \
 
243
   if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) {                               \
 
244
      ErrorF("OUTREG(0x%x, 0x%x) in %s\n", addr, val, FUNCTION_NAME);   \
 
245
   }                                                                    \
 
246
} while (0)
 
247
 
 
248
/* To remove all debugging, make sure I810_DEBUG is defined as a
 
249
 * preprocessor symbol, and equal to zero.
 
250
 */
 
251
#if 1
 
252
#define I810_DEBUG 0
 
253
#endif
 
254
#ifndef I810_DEBUG
 
255
#warning "Debugging enabled - expect reduced performance"
 
256
extern int I810_DEBUG;
 
257
#endif
 
258
 
 
259
#define DEBUG_VERBOSE_ACCEL  0x1
 
260
#define DEBUG_VERBOSE_SYNC   0x2
 
261
#define DEBUG_VERBOSE_VGA    0x4
 
262
#define DEBUG_VERBOSE_RING   0x8
 
263
#define DEBUG_VERBOSE_OUTREG 0x10
 
264
#define DEBUG_VERBOSE_MEMORY 0x20
 
265
#define DEBUG_VERBOSE_CURSOR 0x40
 
266
#define DEBUG_ALWAYS_SYNC    0x80
 
267
#define DEBUG_VERBOSE_DRI    0x100
 
268
#define DEBUG_VERBOSE_BIOS   0x200
 
269
 
 
270
/* Size of the mmio region.
 
271
 */
 
272
#define I810_REG_SIZE 0x80000
 
273
 
 
274
#ifndef PCI_CHIP_I810
 
275
#define PCI_CHIP_I810              0x7121
 
276
#define PCI_CHIP_I810_DC100        0x7123
 
277
#define PCI_CHIP_I810_E            0x7125
 
278
#define PCI_CHIP_I815              0x1132
 
279
#define PCI_CHIP_I810_BRIDGE       0x7120
 
280
#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
 
281
#define PCI_CHIP_I810_E_BRIDGE     0x7124
 
282
#define PCI_CHIP_I815_BRIDGE       0x1130
 
283
#endif
 
284
 
 
285
#ifndef PCI_CHIP_I855_GM
 
286
#define PCI_CHIP_I855_GM           0x3582
 
287
#define PCI_CHIP_I855_GM_BRIDGE    0x3580
 
288
#endif
 
289
 
 
290
#ifndef PCI_CHIP_I865_G
 
291
#define PCI_CHIP_I865_G            0x2572
 
292
#define PCI_CHIP_I865_G_BRIDGE     0x2570
 
293
#endif
 
294
 
 
295
#define IS_I810(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I810 ||    \
 
296
                        pI810->PciInfo->chipType == PCI_CHIP_I810_DC100 || \
 
297
                        pI810->PciInfo->chipType == PCI_CHIP_I810_E)
 
298
#define IS_I815(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I815)
 
299
#define IS_I830(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I830_M)
 
300
#define IS_845G(pI810) (pI810->PciInfo->chipType == PCI_CHIP_845_G)
 
301
#define IS_I85X(pI810)  (pI810->PciInfo->chipType == PCI_CHIP_I855_GM)
 
302
#define IS_I865G(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I865_G)
 
303
 
 
304
#define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810))
 
305
 
 
306
#define GTT_PAGE_SIZE                   KB(4)
 
307
#define ROUND_TO(x, y)                  (((x) + (y) - 1) / (y) * (y))
 
308
#define ROUND_DOWN_TO(x, y)             ((x) / (y) * (y))
 
309
#define ROUND_TO_PAGE(x)                ROUND_TO((x), GTT_PAGE_SIZE)
 
310
#define ROUND_TO_MB(x)                  ROUND_TO((x), MB(1))
 
311
#define PRIMARY_RINGBUFFER_SIZE         KB(128)
 
312
#define MIN_SCRATCH_BUFFER_SIZE         KB(16)
 
313
#define MAX_SCRATCH_BUFFER_SIZE         KB(64)
 
314
#define HWCURSOR_SIZE                   GTT_PAGE_SIZE
 
315
#define OVERLAY_SIZE                    GTT_PAGE_SIZE
 
316
 
 
317
/* Use a 64x64 HW cursor */
 
318
#define I810_CURSOR_X                   64
 
319
#define I810_CURSOR_Y                   I810_CURSOR_X
 
320
 
 
321
/* XXX Need to check if these are reasonable. */
 
322
#define MAX_DISPLAY_PITCH               2048
 
323
#define MAX_DISPLAY_HEIGHT              2048
 
324
 
 
325
#define PIPE_NAME(n)                    ('A' + (n))
 
326
 
 
327
#endif /* _INTEL_COMMON_H_ */