1 /***********************************************************
3 Copyright 1987, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
26 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
30 Permission to use, copy, modify, and distribute this software and its
31 documentation for any purpose and without fee is hereby granted,
32 provided that the above copyright notice appear in all copies and that
33 both that copyright notice and this permission notice appear in
34 supporting documentation, and that the name of Digital not be
35 used in advertising or publicity pertaining to distribution of the
36 software without specific, written prior permission.
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 ******************************************************************/
52 * Machine dependent values:
53 * GLYPHPADBYTES should be chosen with consideration for the space-time
54 * trade-off. Padding to 0 bytes means that there is no wasted space
55 * in the font bitmaps (both on disk and in memory), but that access of
56 * the bitmaps will cause odd-address memory references. Padding to
57 * 2 bytes would ensure even address memory references and would
58 * be suitable for a 68010-class machine, but at the expense of wasted
59 * space in the font bitmaps. Padding to 4 bytes would be good
60 * for real 32 bit machines, etc. Be sure that you tell the font
61 * compiler what kind of padding you want because its defines are
62 * kept separate from this. See server/include/font.h for how
63 * GLYPHPADBYTES is used.
65 * Along with this, you should choose an appropriate value for
66 * GETLEFTBITS_ALIGNMENT, which is used in ddx/mfb/maskbits.h. This
67 * constant choses what kind of memory references are guarenteed during
68 * font access; either 1, 2 or 4, for byte, word or longword access,
69 * respectively. For instance, if you have decided to to have
70 * GLYPHPADBYTES == 4, then it is pointless for you to have a
71 * GETLEFTBITS_ALIGNMENT > 1, because the padding of the fonts has already
72 * guarenteed you that your fonts are longword aligned. On the other
73 * hand, even if you have chosen GLYPHPADBYTES == 1 to save space, you may
74 * also decide that the computing involved in aligning the pointer is more
75 * costly than an odd-address access; you choose GETLEFTBITS_ALIGNMENT == 1.
77 * Next, choose the tuning parameters which are appropriate for your
78 * hardware; these modify the behaviour of the raw frame buffer code
79 * in ddx/mfb and ddx/cfb. Defining these incorrectly will not cause
80 * the server to run incorrectly, but defining these correctly will
81 * cause some noticeable speed improvements:
83 * AVOID_MEMORY_READ - (8-bit cfb only)
84 * When stippling pixels on the screen (polytext and pushpixels),
85 * don't read long words from the display and mask in the
86 * appropriate values. Rather, perform multiple byte/short/long
87 * writes as appropriate. This option uses many more instructions
88 * but runs much faster when the destination is much slower than
89 * the CPU and at least 1 level of write buffer is availible (2
90 * is much better). Defined currently for SPARC and MIPS.
92 * FAST_CONSTANT_OFFSET_MODE - (cfb and mfb)
93 * This define is used on machines which have no auto-increment
94 * addressing mode, but do have an effectively free constant-offset
95 * addressing mode. Currently defined for MIPS and SPARC, even though
96 * I remember the cg6 as performing better without it (cg3 definitely
97 * performs better with it).
99 * LARGE_INSTRUCTION_CACHE -
100 * This define increases the number of times some loops are
101 * unrolled. On 68020 machines (with 256 bytes of i-cache),
102 * this define will slow execution down as instructions miss
103 * the cache frequently. On machines with real i-caches, this
104 * reduces loop overhead, causing a slight performance improvement.
105 * Currently defined for MIPS and SPARC
107 * FAST_UNALIGNED_READS -
108 * For machines with more memory bandwidth than CPU, this
109 * define uses unaligned reads for 8-bit BitBLT instead of doing
110 * aligned reads and combining the results with shifts and
111 * logical-ors. Currently defined for 68020 and vax.
112 * PLENTIFUL_REGISTERS -
113 * For machines with > 20 registers. Currently used for
114 * unrolling the text painting code a bit more. Currently
117 * For non-Harvard RISC machines, those which share the same
118 * CPU memory bus for instructions and data. This unrolls some
119 * solid fill loops which are otherwise best left rolled up.
120 * Currently defined for SPARC.
125 #define IMAGE_BYTE_ORDER LSBFirst /* Values for the VAX only */
126 #define BITMAP_BIT_ORDER LSBFirst
127 #define GLYPHPADBYTES 1
128 #define GETLEFTBITS_ALIGNMENT 4
129 #define FAST_UNALIGNED_READS
135 #define IMAGE_BYTE_ORDER LSBFirst
137 # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
138 # define BITMAP_BIT_ORDER MSBFirst
140 # define BITMAP_BIT_ORDER LSBFirst
143 # if defined(XF86MONOVGA) || defined(XF86VGA16)
144 # define BITMAP_SCANLINE_UNIT 8
147 #define GLYPHPADBYTES 4
148 #define GETLEFTBITS_ALIGNMENT 1
149 #define LARGE_INSTRUCTION_CACHE
150 #define AVOID_MEMORY_READ
152 #endif /* __arm32__ */
154 #if defined (hpux) || defined __hppa__
156 #define IMAGE_BYTE_ORDER MSBFirst
157 #define BITMAP_BIT_ORDER MSBFirst
158 #define GLYPHPADBYTES 4 /* to make fb work */
159 #define GETLEFTBITS_ALIGNMENT 1 /* PA forces longs to 4 */
161 #define AVOID_MEMORY_READ
162 #define FAST_CONSTANT_OFFSET_MODE
163 #define LARGE_INSTRUCTION_CACHE
164 #define PLENTIFUL_REGISTERS
166 #endif /* hpux || __hppa__ */
168 #if defined(__powerpc__) || defined(__ppc__)
170 #define IMAGE_BYTE_ORDER MSBFirst
171 #define BITMAP_BIT_ORDER MSBFirst
172 #define GLYPHPADBYTES 4
173 #define GETLEFTBITS_ALIGNMENT 1
175 /* XXX Should this be for Lynx only? */
177 #define BITMAP_SCANLINE_UNIT 8
180 #define LARGE_INSTRUCTION_CACHE
181 #define FAST_CONSTANT_OFFSET_MODE
182 #define PLENTIFUL_REGISTERS
183 #define AVOID_MEMORY_READ
191 #if defined(__BIG_ENDIAN__)
192 # define IMAGE_BYTE_ORDER MSBFirst
193 # define BITMAP_BIT_ORDER MSBFirst
194 # define GLYPHPADBYTES 4
195 # define GETLEFTBITS_ALIGNMENT 1
197 # define IMAGE_BYTE_ORDER LSBFirst
198 # define BITMAP_BIT_ORDER LSBFirst
199 # define GLYPHPADBYTES 4
200 # define GETLEFTBITS_ALIGNMENT 1
203 #define AVOID_MEMORY_READ
204 #define FAST_CONSTANT_OFFSET_MODE
205 #define LARGE_INSTRUCTION_CACHE
206 #define PLENTIFUL_REGISTERS
211 #if (defined(sun) && (defined(__sparc) || defined(sparc))) || \
212 (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
213 defined(__sparc__) || defined(__mc68000__)
215 #if defined(__sparc) || defined(__sparc__)
221 #if defined(sun386) || defined(sun5)
222 # define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */
223 # define BITMAP_BIT_ORDER LSBFirst
225 # define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */
226 # define BITMAP_BIT_ORDER MSBFirst
230 # define AVOID_MEMORY_READ
231 # define LARGE_INSTRUCTION_CACHE
232 # define FAST_CONSTANT_OFFSET_MODE
233 # define SHARED_IDCACHE
237 #define FAST_UNALIGNED_READS
240 #define GLYPHPADBYTES 4
241 #define GETLEFTBITS_ALIGNMENT 1
243 #endif /* sun && !(i386 && SVR4) */
248 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the RISC/6000 */
249 #define BITMAP_BIT_ORDER MSBFirst
250 #define GLYPHPADBYTES 4
251 #define GETLEFTBITS_ALIGNMENT 1
253 #define LARGE_INSTRUCTION_CACHE
254 #define FAST_CONSTANT_OFFSET_MODE
255 #define PLENTIFUL_REGISTERS
256 #define AVOID_MEMORY_READ
261 #if defined(ibm032) || defined (ibm)
264 # define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */
266 # define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only*/
268 #define BITMAP_BIT_ORDER MSBFirst
269 #define GLYPHPADBYTES 1
270 #define GETLEFTBITS_ALIGNMENT 4
271 /* ibm pcc doesn't understand pragmas. */
274 #define BITMAP_SCANLINE_UNIT 8
279 #if defined (M4310) || defined(M4315) || defined(M4317) || defined(M4319) || defined(M4330)
281 #define IMAGE_BYTE_ORDER MSBFirst /* Values for Pegasus only */
282 #define BITMAP_BIT_ORDER MSBFirst
283 #define GLYPHPADBYTES 4
284 #define GETLEFTBITS_ALIGNMENT 1
286 #define FAST_UNALIGNED_READS
288 #endif /* tektronix */
292 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the MacII only */
293 #define BITMAP_BIT_ORDER MSBFirst
294 #define GLYPHPADBYTES 4
295 #define GETLEFTBITS_ALIGNMENT 1
297 /* might want FAST_UNALIGNED_READS for frame buffers with < 1us latency */
301 #if (defined(mips) || defined(__mips)) && !defined(sgi)
303 #if defined(MIPSEL) || defined(__MIPSEL__)
304 # define IMAGE_BYTE_ORDER LSBFirst /* Values for the PMAX only */
305 # define BITMAP_BIT_ORDER LSBFirst
306 # define GLYPHPADBYTES 4
307 # define GETLEFTBITS_ALIGNMENT 1
309 # define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */
310 # define BITMAP_BIT_ORDER MSBFirst
311 # define GLYPHPADBYTES 4
312 # define GETLEFTBITS_ALIGNMENT 1
315 #define AVOID_MEMORY_READ
316 #define FAST_CONSTANT_OFFSET_MODE
317 #define LARGE_INSTRUCTION_CACHE
318 #define PLENTIFUL_REGISTERS
322 #if defined(__alpha) || defined(__alpha__) || defined(__alphaCross)
323 # define IMAGE_BYTE_ORDER LSBFirst /* Values for the Alpha only */
325 # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
326 # define BITMAP_BIT_ORDER MSBFirst
328 # define BITMAP_BIT_ORDER LSBFirst
331 # if defined(XF86MONOVGA) || defined(XF86VGA16)
332 # define BITMAP_SCANLINE_UNIT 8
335 # define GLYPHPADBYTES 4
336 # define GETLEFTBITS_ALIGNMENT 1
337 # define FAST_CONSTANT_OFFSET_MODE
338 # define LARGE_INSTRUCTION_CACHE
339 # define PLENTIFUL_REGISTERS
343 #if defined (linux) && defined (__s390__)
345 #define IMAGE_BYTE_ORDER MSBFirst
346 #define BITMAP_BIT_ORDER MSBFirst
347 #define GLYPHPADBYTES 4
348 #define GETLEFTBITS_ALIGNMENT 1
350 #define BITMAP_SCANLINE_UNIT 8
351 #define LARGE_INSTRUCTION_CACHE
352 #define FAST_CONSTANT_OFFSET_MODE
353 #define FAST_UNALIGNED_READ
357 #endif /* linux/s390 */
359 #if defined (linux) && defined (__s390x__)
361 #define IMAGE_BYTE_ORDER MSBFirst
362 #define BITMAP_BIT_ORDER MSBFirst
363 #define GLYPHPADBYTES 4
364 #define GETLEFTBITS_ALIGNMENT 1
366 #define BITMAP_SCANLINE_UNIT 8
367 #define LARGE_INSTRUCTION_CACHE
368 #define FAST_CONSTANT_OFFSET_MODE
369 #define FAST_UNALIGNED_READ
372 #endif /* linux/s390x */
375 #if defined(__ia64__) || defined(ia64)
376 # define IMAGE_BYTE_ORDER LSBFirst
378 # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
379 # define BITMAP_BIT_ORDER MSBFirst
381 # define BITMAP_BIT_ORDER LSBFirst
384 # if defined(XF86MONOVGA) || defined(XF86VGA16)
385 # define BITMAP_SCANLINE_UNIT 8
388 # define GLYPHPADBYTES 4
389 # define GETLEFTBITS_ALIGNMENT 1
390 # define FAST_CONSTANT_OFFSET_MODE
391 # define LARGE_INSTRUCTION_CACHE
392 # define PLENTIFUL_REGISTERS
396 #if defined(__amd64__) || defined(amd64) || defined(__amd64)
397 # define IMAGE_BYTE_ORDER LSBFirst
399 # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
400 # define BITMAP_BIT_ORDER MSBFirst
402 # define BITMAP_BIT_ORDER LSBFirst
405 # if defined(XF86MONOVGA) || defined(XF86VGA16)
406 # define BITMAP_SCANLINE_UNIT 8
409 # define GLYPHPADBYTES 4
410 # define GETLEFTBITS_ALIGNMENT 1
411 # define LARGE_INSTRUCTION_CACHE
412 # define FAST_CONSTANT_OFFSET_MODE
414 # define FAST_UNALIGNED_READS
419 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the stellar only*/
420 #define BITMAP_BIT_ORDER MSBFirst
421 #define GLYPHPADBYTES 4
422 #define GETLEFTBITS_ALIGNMENT 4
423 #define IMAGE_BUFSIZE (64*1024)
425 * Use SysV random number generator.
433 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the OMRON only*/
434 #define BITMAP_BIT_ORDER MSBFirst
435 #define GLYPHPADBYTES 4
436 #define GETLEFTBITS_ALIGNMENT 1
439 #define FAST_CONSTANT_OFFSET_MODE
440 #define AVOID_MEMORY_READ
441 #define LARGE_INSTRUCTION_CACHE
442 #define PLENTIFUL_REGISTERS
447 #if (defined(SVR4) && defined(i386)) || \
448 defined(__alpha__) || defined(__alpha) || \
449 defined(__i386__) || defined(__i386) || \
450 defined(__QNX__) || \
451 defined(__s390x__) || defined(__s390__)
453 #ifndef IMAGE_BYTE_ORDER
454 #define IMAGE_BYTE_ORDER LSBFirst
457 #ifndef BITMAP_BIT_ORDER
458 # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
459 # define BITMAP_BIT_ORDER MSBFirst
461 # define BITMAP_BIT_ORDER LSBFirst
465 #ifndef BITMAP_SCANLINE_UNIT
466 # if defined(XF86MONOVGA) || defined(XF86VGA16)
467 # define BITMAP_SCANLINE_UNIT 8
471 #ifndef GLYPHPADBYTES
472 #define GLYPHPADBYTES 4
475 #define GETLEFTBITS_ALIGNMENT 1
476 #define AVOID_MEMORY_READ
478 #define AVOID_GLYPHBLT
479 #define FAST_CONSTANT_OFFSET_MODE
484 #endif /* SVR4 / BSD / i386 */
486 #if defined (linux) && defined (__mc68000__)
488 #define IMAGE_BYTE_ORDER MSBFirst
489 #define BITMAP_BIT_ORDER MSBFirst
490 #define FAST_UNALIGNED_READS
491 #define GLYPHPADBYTES 4
492 #define GETLEFTBITS_ALIGNMENT 1
494 #endif /* linux/m68k */
498 #define IMAGE_BYTE_ORDER MSBFirst
499 #define BITMAP_BIT_ORDER MSBFirst
500 #define GLYPHPADBYTES 4
501 #define GETLEFTBITS_ALIGNMENT 1
502 #define AVOID_MEMORY_READ
503 #define FAST_CONSTANT_OFFSET_MODE
504 #define LARGE_INSTRUCTION_CACHE
505 #define PLENTIFUL_REGISTERS
509 /* linux on the Compaq Itsy */
510 #if defined(linux) && defined(__arm__)
511 #define IMAGE_BYTE_ORDER LSBFirst
512 #define BITMAP_BIT_ORDER LSBFirst
513 #define GLYPHPADBYTES 4
514 #define GETLEFTBITS_ALIGNMENT 1
517 /* linux on IBM S/390 */
518 #if defined (linux) && defined (__s390__)
519 #define IMAGE_BYTE_ORDER MSBFirst
520 #define BITMAP_BIT_ORDER MSBFirst
521 #define GLYPHPADBYTES 4
522 #define GETLEFTBITS_ALIGNMENT 1
523 #endif /* linux/s390 */
525 /* size of buffer to use with GetImage, measured in bytes. There's obviously
526 * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
527 * you) used and the number of times the ddx routine has to be called.
529 #ifndef IMAGE_BUFSIZE
530 #define IMAGE_BUFSIZE (64*1024)
533 /* pad scanline to a longword */
534 #ifndef BITMAP_SCANLINE_UNIT
535 #define BITMAP_SCANLINE_UNIT 32
538 #ifndef BITMAP_SCANLINE_PAD
539 #define BITMAP_SCANLINE_PAD 32
540 #define LOG2_BITMAP_PAD 5
541 #define LOG2_BYTES_PER_SCANLINE_PAD 2
545 * This returns the number of padding units, for depth d and width w.
546 * For bitmaps this can be calculated with the macros above.
547 * Other depths require either grovelling over the formats field of the
548 * screenInfo or hardwired constants.
551 typedef struct _PaddingInfo
{
552 int padRoundUp
; /* pixels per pad unit - 1 */
553 int padPixelsLog2
; /* log 2 (pixels per pad unit) */
554 int padBytesLog2
; /* log 2 (bytes per pad unit) */
555 int notPower2
; /* bitsPerPixel not a power of 2 */
556 int bytesPerPixel
; /* only set when notPower2 is TRUE */
557 int bitsPerPixel
; /* bits per pixel */
559 extern PaddingInfo PixmapWidthPaddingInfo
[];
561 /* The only portable way to get the bpp from the depth is to look it up */
562 #define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel)
564 #define PixmapWidthInPadUnits(w, d) \
565 (PixmapWidthPaddingInfo[d].notPower2 ? \
566 (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \
567 PixmapWidthPaddingInfo[d].bytesPerPixel) >> \
568 PixmapWidthPaddingInfo[d].padBytesLog2) : \
569 ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \
570 PixmapWidthPaddingInfo[d].padPixelsLog2))
573 * Return the number of bytes to which a scanline of the given
574 * depth and width will be padded.
576 #define PixmapBytePad(w, d) \
577 (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2)
579 #define BitmapBytePad(w) \
580 (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD)
582 #define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d)
583 #define PixmapBytePadProto(w, d) PixmapBytePad(w, d)
584 #define BitmapBytePadProto(w) BitmapBytePad(w)
586 #endif /* SERVERMD_H */