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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/kdrive/sis530/sisdraw.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
 * Id: sisdraw.h,v 1.1 1999/11/02 08:17:24 keithp Exp $
 
3
 *
 
4
 * Copyright � 1999 Keith Packard
 
5
 *
 
6
 * Permission to use, copy, modify, distribute, and sell this software and its
 
7
 * documentation for any purpose is hereby granted without fee, provided that
 
8
 * the above copyright notice appear in all copies and that both that
 
9
 * copyright notice and this permission notice appear in supporting
 
10
 * documentation, and that the name of Keith Packard not be used in
 
11
 * advertising or publicity pertaining to distribution of the software without
 
12
 * specific, written prior permission.  Keith Packard makes no
 
13
 * representations about the suitability of this software for any purpose.  It
 
14
 * is provided "as is" without express or implied warranty.
 
15
 *
 
16
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
18
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
20
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
21
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
22
 * PERFORMANCE OF THIS SOFTWARE.
 
23
 */
 
24
/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sisdraw.h,v 1.2 2000/02/23 20:30:08 dawes Exp $ */
 
25
 
 
26
#ifndef _SISDRAW_H_
 
27
#define _SISDRAW_H_
 
28
 
 
29
#define SetupSis(s)  KdScreenPriv(s); \
 
30
                    sisCardInfo(pScreenPriv); \
 
31
                    SisPtr sis = sisc->sis
 
32
 
 
33
#define SIS_CMD_BITBLT                  (0)
 
34
#define SIS_CMD_COLOR_EXPAND            (1)
 
35
#define SIS_CMD_ENH_COLOR_EXPAND        (2)
 
36
#define SIS_CMD_MULTI_SCANLINE          (3)
 
37
#define SIS_CMD_LINE                    (4)
 
38
#define SIS_CMD_TRAPEZOID               (5)
 
39
#define SIS_CMD_TRANSPARENT_BITBLT      (6)
 
40
                                         
 
41
#define SIS_CMD_SRC_SCREEN              (0 << 4)
 
42
#define SIS_CMD_SRC_CPU                 (1 << 4)
 
43
 
 
44
#define SIS_CMD_PAT_FG                  (0 << 6)
 
45
#define SIS_CMD_PAT_PATTERN             (1 << 6)
 
46
#define SIS_CMD_PAT_MONO                (2 << 6)
 
47
                                         
 
48
/* 8->15 rop */
 
49
 
 
50
#define SIS_CMD_DEC_X                   (0 << 16)
 
51
#define SIS_CMD_INC_X                   (1 << 16)
 
52
 
 
53
#define SIS_CMD_DEC_Y                   (0 << 17)
 
54
#define SIS_CMD_INC_Y                   (1 << 17)
 
55
                                         
 
56
#define SIS_CMD_RECT_CLIP_DISABLE       (0 << 18)
 
57
#define SIS_CMD_RECT_CLIP_ENABLE        (1 << 18)
 
58
 
 
59
#define SIS_CMD_OPAQUE                  (0 << 20)
 
60
#define SIS_CMD_TRANSPARENT             (1 << 20)
 
61
 
 
62
#define SIS_CMD_RECT_CLIP_MERGE         (0 << 26)
 
63
#define SIS_CMD_RECT_CLIP_DONT_MERGE    (1 << 26)
 
64
 
 
65
#define SIS_STAT_2D_IDLE                (1 << 31)
 
66
#define SIS_STAT_3D_IDLE                (1 << 30)
 
67
#define SIS_STAT_EMPTY                  (1 << 29)
 
68
#define SIS_STAT_CPU_BITBLT             (0xf << 24)
 
69
#define SIS_STAT_ENH_COLOR_EXPAND       (1 << 23)
 
70
#define SIS_STAT_AVAIL                  (0x1fff)
 
71
 
 
72
extern CARD8    sisPatRop[16];
 
73
extern CARD8    sisBltRop[16];
 
74
                                         
 
75
#define _sisSetSolidRect(sis,pix,alu,cmd) {\
 
76
    (sis)->u.general.pattern_fg = (pix); \
 
77
    (cmd) = (SIS_CMD_BITBLT | \
 
78
             SIS_CMD_SRC_SCREEN | \
 
79
             SIS_CMD_PAT_FG | \
 
80
             (sisPatRop[alu] << 8) | \
 
81
             SIS_CMD_INC_X | \
 
82
             SIS_CMD_INC_Y | \
 
83
             SIS_CMD_RECT_CLIP_DISABLE | \
 
84
             SIS_CMD_OPAQUE | \
 
85
             SIS_CMD_RECT_CLIP_DONT_MERGE); \
 
86
}
 
87
 
 
88
#define _sisClip(sis,x1,y1,x2,y2) { \
 
89
    (sis)->u.general.clip_left = (x1); \
 
90
    (sis)->u.general.clip_top = (y1); \
 
91
    (sis)->u.general.clip_right = (x2); \
 
92
    (sis)->u.general.clip_bottom = (y2); \
 
93
}
 
94
 
 
95
#define _sisRect(sis,x,y,w,h,cmd) { \
 
96
    (sis)->u.general.dst_x = (x); \
 
97
    (sis)->u.general.dst_y = (y); \
 
98
    (sis)->u.general.rect_width = (w); \
 
99
    (sis)->u.general.rect_height = (h); \
 
100
    (sis)->u.general.command = (cmd); \
 
101
}
 
102
 
 
103
#define _sisSetTransparentPlaneBlt(sis, alu, fg, cmd) { \
 
104
    (sis)->u.general.src_fg = (fg); \
 
105
    (cmd) = (SIS_CMD_ENH_COLOR_EXPAND | \
 
106
             SIS_CMD_SRC_CPU | \
 
107
             SIS_CMD_PAT_FG | \
 
108
             (sisBltRop[alu] << 8) | \
 
109
             SIS_CMD_INC_X | \
 
110
             SIS_CMD_INC_Y | \
 
111
             SIS_CMD_RECT_CLIP_DISABLE | \
 
112
             SIS_CMD_TRANSPARENT | \
 
113
             SIS_CMD_RECT_CLIP_DONT_MERGE); \
 
114
}
 
115
 
 
116
#define _sisSetOpaquePlaneBlt(sis, alu, fg, bg, cmd) { \
 
117
    (sis)->u.general.src_fg = (fg); \
 
118
    (sis)->u.general.src_bg = (bg); \
 
119
    (cmd) = (SIS_CMD_ENH_COLOR_EXPAND | \
 
120
             SIS_CMD_SRC_CPU | \
 
121
             SIS_CMD_PAT_FG | \
 
122
             (sisBltRop[alu] << 8) | \
 
123
             SIS_CMD_INC_X | \
 
124
             SIS_CMD_INC_Y | \
 
125
             SIS_CMD_RECT_CLIP_DISABLE | \
 
126
             SIS_CMD_OPAQUE | \
 
127
             SIS_CMD_RECT_CLIP_DONT_MERGE); \
 
128
}
 
129
 
 
130
#define _sisPlaneBlt(sis,x,y,w,h,cmd) _sisSolidRect(sis,x,y,w,h,cmd)
 
131
 
 
132
#define _sisSetBlt(sis,alu,cmd) { \
 
133
    (sis)->u.general.src_base = (sis)->u.general.dst_base; \
 
134
    (sis)->u.general.src_pitch = (sis)->u.general.dst_pitch; \
 
135
    (cmd) = (SIS_CMD_RECT_CLIP_DONT_MERGE |\
 
136
             (sisBltRop[alu] << 8) |\
 
137
             SIS_CMD_PAT_FG |\
 
138
             SIS_CMD_SRC_SCREEN |\
 
139
             SIS_CMD_BITBLT); \
 
140
}
 
141
 
 
142
#define _sisBlt(sis,sx,sy,dx,dy,w,h,cmd) { \
 
143
    (sis)->u.general.src_x = (sx); \
 
144
    (sis)->u.general.src_y = (sy); \
 
145
    (sis)->u.general.dst_x = (dx); \
 
146
    (sis)->u.general.dst_y = (dy); \
 
147
    (sis)->u.general.rect_width = (w); \
 
148
    (sis)->u.general.rect_height = (h); \
 
149
    (sis)->u.general.command = (cmd); \
 
150
}
 
151
                
 
152
#define SIS_IE  (SIS_STAT_2D_IDLE|SIS_STAT_EMPTY)
 
153
 
 
154
#define _sisWaitIdleEmpty(sis) \
 
155
    while (((sis)->u.general.status & SIS_IE) != SIS_IE)
 
156
 
 
157
/*
 
158
 * Ok, so the Sis530 is broken -- it expects bitmaps to come MSB bit order,
 
159
 * but it's willing to take them in LSB byte order.  These macros
 
160
 * flip bits around without flipping bytes.  Instead of using a table
 
161
 * and burning memory bandwidth, do them in place with the CPU.
 
162
 */
 
163
 
 
164
/* The MIPS compiler automatically places these constants in registers */
 
165
#define SisInvertBits32(v) { \
 
166
    v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
 
167
    v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
 
168
    v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
 
169
}
 
170
 
 
171
#define SisInvertBits16(v) { \
 
172
    v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
 
173
    v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
 
174
    v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
 
175
}
 
176
 
 
177
#define SisInvertBits8(v) { \
 
178
    v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
 
179
    v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
 
180
    v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
 
181
}
 
182
 
 
183
#endif