servermd.h revision c2d0e2a8
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/* XXX arm is not always LE */ 134#if defined(__arm32__) || defined(__arm__) 135 136#define IMAGE_BYTE_ORDER LSBFirst 137 138# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 139# define BITMAP_BIT_ORDER MSBFirst 140# else 141# define BITMAP_BIT_ORDER LSBFirst 142# endif 143 144# if defined(XF86MONOVGA) || defined(XF86VGA16) 145# define BITMAP_SCANLINE_UNIT 8 146# endif 147 148#define GLYPHPADBYTES 4 149#define GETLEFTBITS_ALIGNMENT 1 150#define LARGE_INSTRUCTION_CACHE 151#define AVOID_MEMORY_READ 152 153#endif /* __arm32__ */ 154 155#if defined (hpux) || defined __hppa__ 156 157#define IMAGE_BYTE_ORDER MSBFirst 158#define BITMAP_BIT_ORDER MSBFirst 159#define GLYPHPADBYTES 4 /* to make fb work */ 160#define GETLEFTBITS_ALIGNMENT 1 /* PA forces longs to 4 */ 161 /* byte boundries */ 162#define AVOID_MEMORY_READ 163#define FAST_CONSTANT_OFFSET_MODE 164#define LARGE_INSTRUCTION_CACHE 165#define PLENTIFUL_REGISTERS 166 167#endif /* hpux || __hppa__ */ 168 169#if defined(__powerpc__) || defined(__ppc__) 170 171#define IMAGE_BYTE_ORDER MSBFirst 172#define BITMAP_BIT_ORDER MSBFirst 173#define GLYPHPADBYTES 4 174#define GETLEFTBITS_ALIGNMENT 1 175 176/* XXX Should this be for Lynx only? */ 177#ifdef Lynx 178#define BITMAP_SCANLINE_UNIT 8 179#endif 180 181#define LARGE_INSTRUCTION_CACHE 182#define FAST_CONSTANT_OFFSET_MODE 183#define PLENTIFUL_REGISTERS 184#define AVOID_MEMORY_READ 185 186#define FAST_MEMCPY 187 188#endif /* PowerPC */ 189 190#if defined(__sh__) 191 192#if defined(__BIG_ENDIAN__) 193# define IMAGE_BYTE_ORDER MSBFirst 194# define BITMAP_BIT_ORDER MSBFirst 195# define GLYPHPADBYTES 4 196# define GETLEFTBITS_ALIGNMENT 1 197#else 198# define IMAGE_BYTE_ORDER LSBFirst 199# define BITMAP_BIT_ORDER LSBFirst 200# define GLYPHPADBYTES 4 201# define GETLEFTBITS_ALIGNMENT 1 202#endif 203 204#define AVOID_MEMORY_READ 205#define FAST_CONSTANT_OFFSET_MODE 206#define LARGE_INSTRUCTION_CACHE 207#define PLENTIFUL_REGISTERS 208 209#endif /* SuperH */ 210 211 212#if (defined(sun) && (defined(__sparc) || defined(sparc))) || \ 213 (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \ 214 defined(__sparc__) || defined(__mc68000__) 215 216#if defined(__sparc) || defined(__sparc__) 217# if !defined(sparc) 218# define sparc 1 219# endif 220#endif 221 222#if defined(sun386) || defined(sun5) 223# define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */ 224# define BITMAP_BIT_ORDER LSBFirst 225#else 226# define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */ 227# define BITMAP_BIT_ORDER MSBFirst 228#endif 229 230#ifdef sparc 231# define AVOID_MEMORY_READ 232# define LARGE_INSTRUCTION_CACHE 233# define FAST_CONSTANT_OFFSET_MODE 234# define SHARED_IDCACHE 235#endif 236 237#ifdef mc68020 238#define FAST_UNALIGNED_READS 239#endif 240 241#define GLYPHPADBYTES 4 242#define GETLEFTBITS_ALIGNMENT 1 243 244#endif /* sun && !(i386 && SVR4) */ 245 246 247#if defined(AIXV3) 248 249#define IMAGE_BYTE_ORDER MSBFirst /* Values for the RISC/6000 */ 250#define BITMAP_BIT_ORDER MSBFirst 251#define GLYPHPADBYTES 4 252#define GETLEFTBITS_ALIGNMENT 1 253 254#define LARGE_INSTRUCTION_CACHE 255#define FAST_CONSTANT_OFFSET_MODE 256#define PLENTIFUL_REGISTERS 257#define AVOID_MEMORY_READ 258 259#define FAST_MEMCPY 260#endif /* AIXV3 */ 261 262#if defined(ibm032) || defined (ibm) 263 264#ifdef i386 265# define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */ 266#else 267# define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only*/ 268#endif 269#define BITMAP_BIT_ORDER MSBFirst 270#define GLYPHPADBYTES 1 271#define GETLEFTBITS_ALIGNMENT 4 272/* ibm pcc doesn't understand pragmas. */ 273 274#ifdef i386 275#define BITMAP_SCANLINE_UNIT 8 276#endif 277 278#endif /* ibm */ 279 280#if defined (M4310) || defined(M4315) || defined(M4317) || defined(M4319) || defined(M4330) 281 282#define IMAGE_BYTE_ORDER MSBFirst /* Values for Pegasus only */ 283#define BITMAP_BIT_ORDER MSBFirst 284#define GLYPHPADBYTES 4 285#define GETLEFTBITS_ALIGNMENT 1 286 287#define FAST_UNALIGNED_READS 288 289#endif /* tektronix */ 290 291#ifdef macII 292 293#define IMAGE_BYTE_ORDER MSBFirst /* Values for the MacII only */ 294#define BITMAP_BIT_ORDER MSBFirst 295#define GLYPHPADBYTES 4 296#define GETLEFTBITS_ALIGNMENT 1 297 298/* might want FAST_UNALIGNED_READS for frame buffers with < 1us latency */ 299 300#endif /* macII */ 301 302#if (defined(mips) || defined(__mips)) && !defined(sgi) 303 304#if defined(MIPSEL) || defined(__MIPSEL__) 305# define IMAGE_BYTE_ORDER LSBFirst /* Values for the PMAX only */ 306# define BITMAP_BIT_ORDER LSBFirst 307# define GLYPHPADBYTES 4 308# define GETLEFTBITS_ALIGNMENT 1 309#else 310# define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */ 311# define BITMAP_BIT_ORDER MSBFirst 312# define GLYPHPADBYTES 4 313# define GETLEFTBITS_ALIGNMENT 1 314#endif 315 316#define AVOID_MEMORY_READ 317#define FAST_CONSTANT_OFFSET_MODE 318#define LARGE_INSTRUCTION_CACHE 319#define PLENTIFUL_REGISTERS 320 321#endif /* mips */ 322 323#if defined(__alpha) || defined(__alpha__) || defined(__alphaCross) 324# define IMAGE_BYTE_ORDER LSBFirst /* Values for the Alpha only */ 325 326# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 327# define BITMAP_BIT_ORDER MSBFirst 328# else 329# define BITMAP_BIT_ORDER LSBFirst 330# endif 331 332# if defined(XF86MONOVGA) || defined(XF86VGA16) 333# define BITMAP_SCANLINE_UNIT 8 334# endif 335 336# define GLYPHPADBYTES 4 337# define GETLEFTBITS_ALIGNMENT 1 338# define FAST_CONSTANT_OFFSET_MODE 339# define LARGE_INSTRUCTION_CACHE 340# define PLENTIFUL_REGISTERS 341 342#endif /* alpha */ 343 344#if defined (linux) && defined (__s390__) 345 346#define IMAGE_BYTE_ORDER MSBFirst 347#define BITMAP_BIT_ORDER MSBFirst 348#define GLYPHPADBYTES 4 349#define GETLEFTBITS_ALIGNMENT 1 350 351#define BITMAP_SCANLINE_UNIT 8 352#define LARGE_INSTRUCTION_CACHE 353#define FAST_CONSTANT_OFFSET_MODE 354#define FAST_UNALIGNED_READ 355 356#define FAST_MEMCPY 357 358#endif /* linux/s390 */ 359 360#if defined (linux) && defined (__s390x__) 361 362#define IMAGE_BYTE_ORDER MSBFirst 363#define BITMAP_BIT_ORDER MSBFirst 364#define GLYPHPADBYTES 4 365#define GETLEFTBITS_ALIGNMENT 1 366 367#define BITMAP_SCANLINE_UNIT 8 368#define LARGE_INSTRUCTION_CACHE 369#define FAST_CONSTANT_OFFSET_MODE 370#define FAST_UNALIGNED_READ 371 372#define FAST_MEMCPY 373#endif /* linux/s390x */ 374 375 376#if defined(__ia64__) || defined(ia64) 377# define IMAGE_BYTE_ORDER LSBFirst 378 379# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 380# define BITMAP_BIT_ORDER MSBFirst 381# else 382# define BITMAP_BIT_ORDER LSBFirst 383# endif 384 385# if defined(XF86MONOVGA) || defined(XF86VGA16) 386# define BITMAP_SCANLINE_UNIT 8 387# endif 388 389# define GLYPHPADBYTES 4 390# define GETLEFTBITS_ALIGNMENT 1 391# define FAST_CONSTANT_OFFSET_MODE 392# define LARGE_INSTRUCTION_CACHE 393# define PLENTIFUL_REGISTERS 394 395#endif /* ia64 */ 396 397#if defined(__amd64__) || defined(amd64) || defined(__amd64) 398# define IMAGE_BYTE_ORDER LSBFirst 399 400# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 401# define BITMAP_BIT_ORDER MSBFirst 402# else 403# define BITMAP_BIT_ORDER LSBFirst 404# endif 405 406# if defined(XF86MONOVGA) || defined(XF86VGA16) 407# define BITMAP_SCANLINE_UNIT 8 408# endif 409 410# define GLYPHPADBYTES 4 411# define GETLEFTBITS_ALIGNMENT 1 412# define LARGE_INSTRUCTION_CACHE 413# define FAST_CONSTANT_OFFSET_MODE 414/* ???? */ 415# define FAST_UNALIGNED_READS 416#endif /* AMD64 */ 417 418#ifdef stellar 419 420#define IMAGE_BYTE_ORDER MSBFirst /* Values for the stellar only*/ 421#define BITMAP_BIT_ORDER MSBFirst 422#define GLYPHPADBYTES 4 423#define GETLEFTBITS_ALIGNMENT 4 424#define IMAGE_BUFSIZE (64*1024) 425/* 426 * Use SysV random number generator. 427 */ 428#define random rand 429 430#endif /* stellar */ 431 432#ifdef luna 433 434#define IMAGE_BYTE_ORDER MSBFirst /* Values for the OMRON only*/ 435#define BITMAP_BIT_ORDER MSBFirst 436#define GLYPHPADBYTES 4 437#define GETLEFTBITS_ALIGNMENT 1 438 439#ifndef mc68000 440#define FAST_CONSTANT_OFFSET_MODE 441#define AVOID_MEMORY_READ 442#define LARGE_INSTRUCTION_CACHE 443#define PLENTIFUL_REGISTERS 444#endif 445 446#endif /* luna */ 447 448#if (defined(SVR4) && defined(i386)) || \ 449 defined(__alpha__) || defined(__alpha) || \ 450 defined(__i386__) || defined(__i386) || \ 451 defined(__QNX__) || \ 452 defined(__s390x__) || defined(__s390__) 453 454#ifndef IMAGE_BYTE_ORDER 455#define IMAGE_BYTE_ORDER LSBFirst 456#endif 457 458#ifndef BITMAP_BIT_ORDER 459# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) 460# define BITMAP_BIT_ORDER MSBFirst 461# else 462# define BITMAP_BIT_ORDER LSBFirst 463# endif 464#endif 465 466#ifndef BITMAP_SCANLINE_UNIT 467# if defined(XF86MONOVGA) || defined(XF86VGA16) 468# define BITMAP_SCANLINE_UNIT 8 469# endif 470#endif 471 472#ifndef GLYPHPADBYTES 473#define GLYPHPADBYTES 4 474#endif 475 476#define GETLEFTBITS_ALIGNMENT 1 477#define AVOID_MEMORY_READ 478#ifdef XSVGA 479#define AVOID_GLYPHBLT 480#define FAST_CONSTANT_OFFSET_MODE 481#define FAST_MEMCPY 482#define NO_ONE_RECT 483#endif 484 485#endif /* SVR4 / BSD / i386 */ 486 487#if defined (linux) && defined (__mc68000__) 488 489#define IMAGE_BYTE_ORDER MSBFirst 490#define BITMAP_BIT_ORDER MSBFirst 491#define FAST_UNALIGNED_READS 492#define GLYPHPADBYTES 4 493#define GETLEFTBITS_ALIGNMENT 1 494 495#endif /* linux/m68k */ 496 497#ifdef sgi 498 499#define IMAGE_BYTE_ORDER MSBFirst 500#define BITMAP_BIT_ORDER MSBFirst 501#define GLYPHPADBYTES 4 502#define GETLEFTBITS_ALIGNMENT 1 503#define AVOID_MEMORY_READ 504#define FAST_CONSTANT_OFFSET_MODE 505#define LARGE_INSTRUCTION_CACHE 506#define PLENTIFUL_REGISTERS 507 508#endif 509 510/* linux on the Compaq Itsy */ 511#if defined(linux) && defined(__arm__) 512#define IMAGE_BYTE_ORDER LSBFirst 513#define BITMAP_BIT_ORDER LSBFirst 514#define GLYPHPADBYTES 4 515#define GETLEFTBITS_ALIGNMENT 1 516#endif 517 518/* linux on IBM S/390 */ 519#if defined (linux) && defined (__s390__) 520#define IMAGE_BYTE_ORDER MSBFirst 521#define BITMAP_BIT_ORDER MSBFirst 522#define GLYPHPADBYTES 4 523#define GETLEFTBITS_ALIGNMENT 1 524#endif /* linux/s390 */ 525 526/* size of buffer to use with GetImage, measured in bytes. There's obviously 527 * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives 528 * you) used and the number of times the ddx routine has to be called. 529 */ 530#ifndef IMAGE_BUFSIZE 531#define IMAGE_BUFSIZE (64*1024) 532#endif 533 534/* pad scanline to a longword */ 535#ifndef BITMAP_SCANLINE_UNIT 536#define BITMAP_SCANLINE_UNIT 32 537#endif 538 539#ifndef BITMAP_SCANLINE_PAD 540#define BITMAP_SCANLINE_PAD 32 541#define LOG2_BITMAP_PAD 5 542#define LOG2_BYTES_PER_SCANLINE_PAD 2 543#endif 544 545/* 546 * This returns the number of padding units, for depth d and width w. 547 * For bitmaps this can be calculated with the macros above. 548 * Other depths require either grovelling over the formats field of the 549 * screenInfo or hardwired constants. 550 */ 551 552typedef struct _PaddingInfo { 553 int padRoundUp; /* pixels per pad unit - 1 */ 554 int padPixelsLog2; /* log 2 (pixels per pad unit) */ 555 int padBytesLog2; /* log 2 (bytes per pad unit) */ 556 int notPower2; /* bitsPerPixel not a power of 2 */ 557 int bytesPerPixel; /* only set when notPower2 is TRUE */ 558 int bitsPerPixel; /* bits per pixel */ 559} PaddingInfo; 560extern PaddingInfo PixmapWidthPaddingInfo[]; 561 562/* The only portable way to get the bpp from the depth is to look it up */ 563#define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel) 564 565#define PixmapWidthInPadUnits(w, d) \ 566 (PixmapWidthPaddingInfo[d].notPower2 ? \ 567 (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \ 568 PixmapWidthPaddingInfo[d].bytesPerPixel) >> \ 569 PixmapWidthPaddingInfo[d].padBytesLog2) : \ 570 ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \ 571 PixmapWidthPaddingInfo[d].padPixelsLog2)) 572 573/* 574 * Return the number of bytes to which a scanline of the given 575 * depth and width will be padded. 576 */ 577#define PixmapBytePad(w, d) \ 578 (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2) 579 580#define BitmapBytePad(w) \ 581 (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD) 582 583#define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d) 584#define PixmapBytePadProto(w, d) PixmapBytePad(w, d) 585#define BitmapBytePadProto(w) BitmapBytePad(w) 586 587#endif /* SERVERMD_H */ 588