servermd.h revision 05b261ec
1/*********************************************************** 2 3Copyright 1987, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in this Software without prior written authorization from The Open Group. 24 25 26Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 27 28 All Rights Reserved 29 30Permission to use, copy, modify, and distribute this software and its 31documentation for any purpose and without fee is hereby granted, 32provided that the above copyright notice appear in all copies and that 33both that copyright notice and this permission notice appear in 34supporting documentation, and that the name of Digital not be 35used in advertising or publicity pertaining to distribution of the 36software without specific, written prior permission. 37 38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 44SOFTWARE. 45 46******************************************************************/ 47 48#ifndef SERVERMD_H 49#define SERVERMD_H 1 50 51/* 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. 64 * 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. 76 * 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: 82 * 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. 91 * 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). 98 * 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 106 * 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 115 * defined for MIPS. 116 * SHARED_IDCACHE - 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. 121 */ 122 123#ifdef vax 124 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 130 131#endif /* vax */ 132 133#ifdef __arm32__ 134 135#define IMAGE_BYTE_ORDER LSBFirst 136 137# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 138# define BITMAP_BIT_ORDER MSBFirst 139# else 140# define BITMAP_BIT_ORDER LSBFirst 141# endif 142 143# if defined(XF86MONOVGA) || defined(XF86VGA16) 144# define BITMAP_SCANLINE_UNIT 8 145# endif 146 147#define GLYPHPADBYTES 4 148#define GETLEFTBITS_ALIGNMENT 1 149#define LARGE_INSTRUCTION_CACHE 150#define AVOID_MEMORY_READ 151 152#endif /* __arm32__ */ 153 154#if defined (hpux) || defined __hppa__ 155 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 */ 160 /* byte boundries */ 161#define AVOID_MEMORY_READ 162#define FAST_CONSTANT_OFFSET_MODE 163#define LARGE_INSTRUCTION_CACHE 164#define PLENTIFUL_REGISTERS 165 166#endif /* hpux || __hppa__ */ 167 168#if defined(__powerpc__) || defined(__ppc__) 169 170#define IMAGE_BYTE_ORDER MSBFirst 171#define BITMAP_BIT_ORDER MSBFirst 172#define GLYPHPADBYTES 4 173#define GETLEFTBITS_ALIGNMENT 1 174 175/* XXX Should this be for Lynx only? */ 176#ifdef Lynx 177#define BITMAP_SCANLINE_UNIT 8 178#endif 179 180#define LARGE_INSTRUCTION_CACHE 181#define FAST_CONSTANT_OFFSET_MODE 182#define PLENTIFUL_REGISTERS 183#define AVOID_MEMORY_READ 184 185#define FAST_MEMCPY 186 187#endif /* PowerPC */ 188 189#if defined(__sh__) 190 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 196#else 197# define IMAGE_BYTE_ORDER LSBFirst 198# define BITMAP_BIT_ORDER LSBFirst 199# define GLYPHPADBYTES 4 200# define GETLEFTBITS_ALIGNMENT 1 201#endif 202 203#define AVOID_MEMORY_READ 204#define FAST_CONSTANT_OFFSET_MODE 205#define LARGE_INSTRUCTION_CACHE 206#define PLENTIFUL_REGISTERS 207 208#endif /* SuperH */ 209 210 211#if (defined(sun) && (defined(__sparc) || defined(sparc))) || \ 212 (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \ 213 defined(__sparc__) || defined(__mc68000__) 214 215#if defined(__sparc) || defined(__sparc__) 216# if !defined(sparc) 217# define sparc 1 218# endif 219#endif 220 221#if defined(sun386) || defined(sun5) 222# define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */ 223# define BITMAP_BIT_ORDER LSBFirst 224#else 225# define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */ 226# define BITMAP_BIT_ORDER MSBFirst 227#endif 228 229#ifdef sparc 230# define AVOID_MEMORY_READ 231# define LARGE_INSTRUCTION_CACHE 232# define FAST_CONSTANT_OFFSET_MODE 233# define SHARED_IDCACHE 234#endif 235 236#ifdef mc68020 237#define FAST_UNALIGNED_READS 238#endif 239 240#define GLYPHPADBYTES 4 241#define GETLEFTBITS_ALIGNMENT 1 242 243#endif /* sun && !(i386 && SVR4) */ 244 245 246#if defined(AIXV3) 247 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 252 253#define LARGE_INSTRUCTION_CACHE 254#define FAST_CONSTANT_OFFSET_MODE 255#define PLENTIFUL_REGISTERS 256#define AVOID_MEMORY_READ 257 258#define FAST_MEMCPY 259#endif /* AIXV3 */ 260 261#if defined(ibm032) || defined (ibm) 262 263#ifdef i386 264# define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */ 265#else 266# define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only*/ 267#endif 268#define BITMAP_BIT_ORDER MSBFirst 269#define GLYPHPADBYTES 1 270#define GETLEFTBITS_ALIGNMENT 4 271/* ibm pcc doesn't understand pragmas. */ 272 273#ifdef i386 274#define BITMAP_SCANLINE_UNIT 8 275#endif 276 277#endif /* ibm */ 278 279#if defined (M4310) || defined(M4315) || defined(M4317) || defined(M4319) || defined(M4330) 280 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 285 286#define FAST_UNALIGNED_READS 287 288#endif /* tektronix */ 289 290#ifdef macII 291 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 296 297/* might want FAST_UNALIGNED_READS for frame buffers with < 1us latency */ 298 299#endif /* macII */ 300 301#if (defined(mips) || defined(__mips)) && !defined(sgi) 302 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 308#else 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 313#endif 314 315#define AVOID_MEMORY_READ 316#define FAST_CONSTANT_OFFSET_MODE 317#define LARGE_INSTRUCTION_CACHE 318#define PLENTIFUL_REGISTERS 319 320#endif /* mips */ 321 322#if defined(__alpha) || defined(__alpha__) || defined(__alphaCross) 323# define IMAGE_BYTE_ORDER LSBFirst /* Values for the Alpha only */ 324 325# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 326# define BITMAP_BIT_ORDER MSBFirst 327# else 328# define BITMAP_BIT_ORDER LSBFirst 329# endif 330 331# if defined(XF86MONOVGA) || defined(XF86VGA16) 332# define BITMAP_SCANLINE_UNIT 8 333# endif 334 335# define GLYPHPADBYTES 4 336# define GETLEFTBITS_ALIGNMENT 1 337# define FAST_CONSTANT_OFFSET_MODE 338# define LARGE_INSTRUCTION_CACHE 339# define PLENTIFUL_REGISTERS 340 341#endif /* alpha */ 342 343#if defined (linux) && defined (__s390__) 344 345#define IMAGE_BYTE_ORDER MSBFirst 346#define BITMAP_BIT_ORDER MSBFirst 347#define GLYPHPADBYTES 4 348#define GETLEFTBITS_ALIGNMENT 1 349 350#define BITMAP_SCANLINE_UNIT 8 351#define LARGE_INSTRUCTION_CACHE 352#define FAST_CONSTANT_OFFSET_MODE 353#define FAST_UNALIGNED_READ 354 355#define FAST_MEMCPY 356 357#endif /* linux/s390 */ 358 359#if defined (linux) && defined (__s390x__) 360 361#define IMAGE_BYTE_ORDER MSBFirst 362#define BITMAP_BIT_ORDER MSBFirst 363#define GLYPHPADBYTES 4 364#define GETLEFTBITS_ALIGNMENT 1 365 366#define BITMAP_SCANLINE_UNIT 8 367#define LARGE_INSTRUCTION_CACHE 368#define FAST_CONSTANT_OFFSET_MODE 369#define FAST_UNALIGNED_READ 370 371#define FAST_MEMCPY 372#endif /* linux/s390x */ 373 374 375#if defined(__ia64__) || defined(ia64) 376# define IMAGE_BYTE_ORDER LSBFirst 377 378# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 379# define BITMAP_BIT_ORDER MSBFirst 380# else 381# define BITMAP_BIT_ORDER LSBFirst 382# endif 383 384# if defined(XF86MONOVGA) || defined(XF86VGA16) 385# define BITMAP_SCANLINE_UNIT 8 386# endif 387 388# define GLYPHPADBYTES 4 389# define GETLEFTBITS_ALIGNMENT 1 390# define FAST_CONSTANT_OFFSET_MODE 391# define LARGE_INSTRUCTION_CACHE 392# define PLENTIFUL_REGISTERS 393 394#endif /* ia64 */ 395 396#if defined(__amd64__) || defined(amd64) || defined(__amd64) 397# define IMAGE_BYTE_ORDER LSBFirst 398 399# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 400# define BITMAP_BIT_ORDER MSBFirst 401# else 402# define BITMAP_BIT_ORDER LSBFirst 403# endif 404 405# if defined(XF86MONOVGA) || defined(XF86VGA16) 406# define BITMAP_SCANLINE_UNIT 8 407# endif 408 409# define GLYPHPADBYTES 4 410# define GETLEFTBITS_ALIGNMENT 1 411# define LARGE_INSTRUCTION_CACHE 412# define FAST_CONSTANT_OFFSET_MODE 413/* ???? */ 414# define FAST_UNALIGNED_READS 415#endif /* AMD64 */ 416 417#ifdef stellar 418 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) 424/* 425 * Use SysV random number generator. 426 */ 427#define random rand 428 429#endif /* stellar */ 430 431#ifdef luna 432 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 437 438#ifndef mc68000 439#define FAST_CONSTANT_OFFSET_MODE 440#define AVOID_MEMORY_READ 441#define LARGE_INSTRUCTION_CACHE 442#define PLENTIFUL_REGISTERS 443#endif 444 445#endif /* luna */ 446 447#if (defined(SVR4) && defined(i386)) || \ 448 defined(__alpha__) || defined(__alpha) || \ 449 defined(__i386__) || defined(__i386) || \ 450 defined(__QNX__) || \ 451 defined(__s390x__) || defined(__s390__) 452 453#ifndef IMAGE_BYTE_ORDER 454#define IMAGE_BYTE_ORDER LSBFirst 455#endif 456 457#ifndef BITMAP_BIT_ORDER 458# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 459# define BITMAP_BIT_ORDER MSBFirst 460# else 461# define BITMAP_BIT_ORDER LSBFirst 462# endif 463#endif 464 465#ifndef BITMAP_SCANLINE_UNIT 466# if defined(XF86MONOVGA) || defined(XF86VGA16) 467# define BITMAP_SCANLINE_UNIT 8 468# endif 469#endif 470 471#ifndef GLYPHPADBYTES 472#define GLYPHPADBYTES 4 473#endif 474 475#define GETLEFTBITS_ALIGNMENT 1 476#define AVOID_MEMORY_READ 477#ifdef XSVGA 478#define AVOID_GLYPHBLT 479#define FAST_CONSTANT_OFFSET_MODE 480#define FAST_MEMCPY 481#define NO_ONE_RECT 482#endif 483 484#endif /* SVR4 / BSD / i386 */ 485 486#if defined (linux) && defined (__mc68000__) 487 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 493 494#endif /* linux/m68k */ 495 496#ifdef sgi 497 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 506 507#endif 508 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 515#endif 516 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 */ 524 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. 528 */ 529#ifndef IMAGE_BUFSIZE 530#define IMAGE_BUFSIZE (64*1024) 531#endif 532 533/* pad scanline to a longword */ 534#ifndef BITMAP_SCANLINE_UNIT 535#define BITMAP_SCANLINE_UNIT 32 536#endif 537 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 542#endif 543 544/* 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. 549 */ 550 551typedef 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 */ 558} PaddingInfo; 559extern PaddingInfo PixmapWidthPaddingInfo[]; 560 561/* The only portable way to get the bpp from the depth is to look it up */ 562#define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel) 563 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)) 571 572/* 573 * Return the number of bytes to which a scanline of the given 574 * depth and width will be padded. 575 */ 576#define PixmapBytePad(w, d) \ 577 (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2) 578 579#define BitmapBytePad(w) \ 580 (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD) 581 582#define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d) 583#define PixmapBytePadProto(w, d) PixmapBytePad(w, d) 584#define BitmapBytePadProto(w) BitmapBytePad(w) 585 586#endif /* SERVERMD_H */ 587