servermd.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /***********************************************************
  2. Copyright 1987, 1998 The Open Group
  3. Permission to use, copy, modify, distribute, and sell this software and its
  4. documentation for any purpose is hereby granted without fee, provided that
  5. the above copyright notice appear in all copies and that both that
  6. copyright notice and this permission notice appear in supporting
  7. documentation.
  8. The above copyright notice and this permission notice shall be included in
  9. all copies or substantial portions of the Software.
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  14. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. Except as contained in this notice, the name of The Open Group shall not be
  17. used in advertising or otherwise to promote the sale, use or other dealings
  18. in this Software without prior written authorization from The Open Group.
  19. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  20. All Rights Reserved
  21. Permission to use, copy, modify, and distribute this software and its
  22. documentation for any purpose and without fee is hereby granted,
  23. provided that the above copyright notice appear in all copies and that
  24. both that copyright notice and this permission notice appear in
  25. supporting documentation, and that the name of Digital not be
  26. used in advertising or publicity pertaining to distribution of the
  27. software without specific, written prior permission.
  28. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  29. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  30. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  31. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  32. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  33. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  34. SOFTWARE.
  35. ******************************************************************/
  36. #ifndef SERVERMD_H
  37. #define SERVERMD_H 1
  38. /*
  39. * Machine dependent values:
  40. * GLYPHPADBYTES should be chosen with consideration for the space-time
  41. * trade-off. Padding to 0 bytes means that there is no wasted space
  42. * in the font bitmaps (both on disk and in memory), but that access of
  43. * the bitmaps will cause odd-address memory references. Padding to
  44. * 2 bytes would ensure even address memory references and would
  45. * be suitable for a 68010-class machine, but at the expense of wasted
  46. * space in the font bitmaps. Padding to 4 bytes would be good
  47. * for real 32 bit machines, etc. Be sure that you tell the font
  48. * compiler what kind of padding you want because its defines are
  49. * kept separate from this. See server/include/font.h for how
  50. * GLYPHPADBYTES is used.
  51. *
  52. * Along with this, you should choose an appropriate value for
  53. * GETLEFTBITS_ALIGNMENT, which is used in ddx/mfb/maskbits.h. This
  54. * constant choses what kind of memory references are guarenteed during
  55. * font access; either 1, 2 or 4, for byte, word or longword access,
  56. * respectively. For instance, if you have decided to to have
  57. * GLYPHPADBYTES == 4, then it is pointless for you to have a
  58. * GETLEFTBITS_ALIGNMENT > 1, because the padding of the fonts has already
  59. * guarenteed you that your fonts are longword aligned. On the other
  60. * hand, even if you have chosen GLYPHPADBYTES == 1 to save space, you may
  61. * also decide that the computing involved in aligning the pointer is more
  62. * costly than an odd-address access; you choose GETLEFTBITS_ALIGNMENT == 1.
  63. *
  64. * Next, choose the tuning parameters which are appropriate for your
  65. * hardware; these modify the behaviour of the raw frame buffer code
  66. * in ddx/mfb and ddx/cfb. Defining these incorrectly will not cause
  67. * the server to run incorrectly, but defining these correctly will
  68. * cause some noticeable speed improvements:
  69. *
  70. * AVOID_MEMORY_READ - (8-bit cfb only)
  71. * When stippling pixels on the screen (polytext and pushpixels),
  72. * don't read long words from the display and mask in the
  73. * appropriate values. Rather, perform multiple byte/short/long
  74. * writes as appropriate. This option uses many more instructions
  75. * but runs much faster when the destination is much slower than
  76. * the CPU and at least 1 level of write buffer is availible (2
  77. * is much better). Defined currently for SPARC and MIPS.
  78. *
  79. * FAST_CONSTANT_OFFSET_MODE - (cfb and mfb)
  80. * This define is used on machines which have no auto-increment
  81. * addressing mode, but do have an effectively free constant-offset
  82. * addressing mode. Currently defined for MIPS and SPARC, even though
  83. * I remember the cg6 as performing better without it (cg3 definitely
  84. * performs better with it).
  85. *
  86. * LARGE_INSTRUCTION_CACHE -
  87. * This define increases the number of times some loops are
  88. * unrolled. On 68020 machines (with 256 bytes of i-cache),
  89. * this define will slow execution down as instructions miss
  90. * the cache frequently. On machines with real i-caches, this
  91. * reduces loop overhead, causing a slight performance improvement.
  92. * Currently defined for MIPS and SPARC
  93. *
  94. * FAST_UNALIGNED_READS -
  95. * For machines with more memory bandwidth than CPU, this
  96. * define uses unaligned reads for 8-bit BitBLT instead of doing
  97. * aligned reads and combining the results with shifts and
  98. * logical-ors. Currently defined for 68020 and vax.
  99. * PLENTIFUL_REGISTERS -
  100. * For machines with > 20 registers. Currently used for
  101. * unrolling the text painting code a bit more. Currently
  102. * defined for MIPS.
  103. * SHARED_IDCACHE -
  104. * For non-Harvard RISC machines, those which share the same
  105. * CPU memory bus for instructions and data. This unrolls some
  106. * solid fill loops which are otherwise best left rolled up.
  107. * Currently defined for SPARC.
  108. */
  109. #ifdef __arm32__
  110. #define IMAGE_BYTE_ORDER LSBFirst
  111. # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
  112. # define BITMAP_BIT_ORDER MSBFirst
  113. # else
  114. # define BITMAP_BIT_ORDER LSBFirst
  115. # endif
  116. # if defined(XF86MONOVGA) || defined(XF86VGA16)
  117. # define BITMAP_SCANLINE_UNIT 8
  118. # endif
  119. #define GLYPHPADBYTES 4
  120. #define GETLEFTBITS_ALIGNMENT 1
  121. #define LARGE_INSTRUCTION_CACHE
  122. #define AVOID_MEMORY_READ
  123. #endif /* __arm32__ */
  124. #if defined(__powerpc__) || defined(__ppc__)
  125. #define IMAGE_BYTE_ORDER MSBFirst
  126. #define BITMAP_BIT_ORDER MSBFirst
  127. #define GLYPHPADBYTES 4
  128. #define GETLEFTBITS_ALIGNMENT 1
  129. /* XXX Should this be for Lynx only? */
  130. #define LARGE_INSTRUCTION_CACHE
  131. #define FAST_CONSTANT_OFFSET_MODE
  132. #define PLENTIFUL_REGISTERS
  133. #define AVOID_MEMORY_READ
  134. #define FAST_MEMCPY
  135. #endif /* PowerPC */
  136. #if defined(__sh__)
  137. #if defined(__BIG_ENDIAN__)
  138. # define IMAGE_BYTE_ORDER MSBFirst
  139. # define BITMAP_BIT_ORDER MSBFirst
  140. # define GLYPHPADBYTES 4
  141. # define GETLEFTBITS_ALIGNMENT 1
  142. #else
  143. # define IMAGE_BYTE_ORDER LSBFirst
  144. # define BITMAP_BIT_ORDER LSBFirst
  145. # define GLYPHPADBYTES 4
  146. # define GETLEFTBITS_ALIGNMENT 1
  147. #endif
  148. #define AVOID_MEMORY_READ
  149. #define FAST_CONSTANT_OFFSET_MODE
  150. #define LARGE_INSTRUCTION_CACHE
  151. #define PLENTIFUL_REGISTERS
  152. #endif /* SuperH */
  153. #if (defined(sun) && (defined(__sparc) || defined(sparc))) || \
  154. (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
  155. defined(__sparc__) || defined(__mc68000__)
  156. #if defined(__sparc) || defined(__sparc__)
  157. # if !defined(sparc)
  158. # define sparc 1
  159. # endif
  160. #endif
  161. #if defined(sun386) || defined(sun5)
  162. # define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */
  163. # define BITMAP_BIT_ORDER LSBFirst
  164. #else
  165. # define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */
  166. # define BITMAP_BIT_ORDER MSBFirst
  167. #endif
  168. #ifdef sparc
  169. # define AVOID_MEMORY_READ
  170. # define LARGE_INSTRUCTION_CACHE
  171. # define FAST_CONSTANT_OFFSET_MODE
  172. # define SHARED_IDCACHE
  173. #endif
  174. #ifdef mc68020
  175. #define FAST_UNALIGNED_READS
  176. #endif
  177. #define GLYPHPADBYTES 4
  178. #define GETLEFTBITS_ALIGNMENT 1
  179. #endif /* sun */
  180. #if defined(ibm032) || defined (ibm)
  181. #ifdef i386
  182. # define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */
  183. #else
  184. # define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only*/
  185. #endif
  186. #define BITMAP_BIT_ORDER MSBFirst
  187. #define GLYPHPADBYTES 1
  188. #define GETLEFTBITS_ALIGNMENT 4
  189. /* ibm pcc doesn't understand pragmas. */
  190. #ifdef i386
  191. #define BITMAP_SCANLINE_UNIT 8
  192. #endif
  193. #endif /* ibm */
  194. #if (defined(mips) || defined(__mips)) && !defined(sgi)
  195. #if defined(MIPSEL) || defined(__MIPSEL__)
  196. # define IMAGE_BYTE_ORDER LSBFirst /* Values for the PMAX only */
  197. # define BITMAP_BIT_ORDER LSBFirst
  198. # define GLYPHPADBYTES 4
  199. # define GETLEFTBITS_ALIGNMENT 1
  200. #else
  201. # define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */
  202. # define BITMAP_BIT_ORDER MSBFirst
  203. # define GLYPHPADBYTES 4
  204. # define GETLEFTBITS_ALIGNMENT 1
  205. #endif
  206. #define AVOID_MEMORY_READ
  207. #define FAST_CONSTANT_OFFSET_MODE
  208. #define LARGE_INSTRUCTION_CACHE
  209. #define PLENTIFUL_REGISTERS
  210. #endif /* mips */
  211. #if defined(__amd64__) || defined(amd64) || defined(__amd64)
  212. # define IMAGE_BYTE_ORDER LSBFirst
  213. # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
  214. # define BITMAP_BIT_ORDER MSBFirst
  215. # else
  216. # define BITMAP_BIT_ORDER LSBFirst
  217. # endif
  218. # if defined(XF86MONOVGA) || defined(XF86VGA16)
  219. # define BITMAP_SCANLINE_UNIT 8
  220. # endif
  221. # define GLYPHPADBYTES 4
  222. # define GETLEFTBITS_ALIGNMENT 1
  223. # define LARGE_INSTRUCTION_CACHE
  224. # define FAST_CONSTANT_OFFSET_MODE
  225. /* ???? */
  226. # define FAST_UNALIGNED_READS
  227. #endif /* AMD64 */
  228. #if defined(__alpha__) || defined(__alpha) || \
  229. defined(__i386__) || defined(__i386) || \
  230. defined(__UNIXOS2__) || \
  231. defined(__OS2ELF__) || \
  232. defined(__QNX__) || \
  233. defined(__s390x__) || defined(__s390__)
  234. #ifndef IMAGE_BYTE_ORDER
  235. #define IMAGE_BYTE_ORDER LSBFirst
  236. #endif
  237. #ifndef BITMAP_BIT_ORDER
  238. # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
  239. # define BITMAP_BIT_ORDER MSBFirst
  240. # else
  241. # define BITMAP_BIT_ORDER LSBFirst
  242. # endif
  243. #endif
  244. #ifndef BITMAP_SCANLINE_UNIT
  245. # if defined(XF86MONOVGA) || defined(XF86VGA16)
  246. # define BITMAP_SCANLINE_UNIT 8
  247. # endif
  248. #endif
  249. #ifndef GLYPHPADBYTES
  250. #define GLYPHPADBYTES 4
  251. #endif
  252. #define GETLEFTBITS_ALIGNMENT 1
  253. #define AVOID_MEMORY_READ
  254. #endif /* BSD / i386 */
  255. #if defined (linux) && defined (__mc68000__)
  256. #define IMAGE_BYTE_ORDER MSBFirst
  257. #define BITMAP_BIT_ORDER MSBFirst
  258. #define FAST_UNALIGNED_READS
  259. #define GLYPHPADBYTES 4
  260. #define GETLEFTBITS_ALIGNMENT 1
  261. #endif /* linux/m68k */
  262. /* linux on the Compaq Itsy */
  263. #if defined(linux) && defined(__arm__)
  264. #define IMAGE_BYTE_ORDER LSBFirst
  265. #define BITMAP_BIT_ORDER LSBFirst
  266. #define GLYPHPADBYTES 4
  267. #define GETLEFTBITS_ALIGNMENT 1
  268. #endif
  269. /* size of buffer to use with GetImage, measured in bytes. There's obviously
  270. * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
  271. * you) used and the number of times the ddx routine has to be called.
  272. */
  273. #ifndef IMAGE_BUFSIZE
  274. #define IMAGE_BUFSIZE (64*1024)
  275. #endif
  276. /* pad scanline to a longword */
  277. #ifndef BITMAP_SCANLINE_UNIT
  278. #define BITMAP_SCANLINE_UNIT 32
  279. #endif
  280. #ifndef BITMAP_SCANLINE_PAD
  281. #define BITMAP_SCANLINE_PAD 32
  282. #define LOG2_BITMAP_PAD 5
  283. #define LOG2_BYTES_PER_SCANLINE_PAD 2
  284. #endif
  285. /*
  286. * This returns the number of padding units, for depth d and width w.
  287. * For bitmaps this can be calculated with the macros above.
  288. * Other depths require either grovelling over the formats field of the
  289. * screenInfo or hardwired constants.
  290. */
  291. typedef struct _PaddingInfo {
  292. int padRoundUp; /* pixels per pad unit - 1 */
  293. int padPixelsLog2; /* log 2 (pixels per pad unit) */
  294. int padBytesLog2; /* log 2 (bytes per pad unit) */
  295. int notPower2; /* bitsPerPixel not a power of 2 */
  296. int bytesPerPixel; /* only set when notPower2 is TRUE */
  297. int bitsPerPixel; /* bits per pixel */
  298. } PaddingInfo;
  299. extern PaddingInfo PixmapWidthPaddingInfo[];
  300. /* The only portable way to get the bpp from the depth is to look it up */
  301. #define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel)
  302. #define PixmapWidthInPadUnits(w, d) \
  303. (PixmapWidthPaddingInfo[d].notPower2 ? \
  304. (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \
  305. PixmapWidthPaddingInfo[d].bytesPerPixel) >> \
  306. PixmapWidthPaddingInfo[d].padBytesLog2) : \
  307. ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \
  308. PixmapWidthPaddingInfo[d].padPixelsLog2))
  309. /*
  310. * Return the number of bytes to which a scanline of the given
  311. * depth and width will be padded.
  312. */
  313. #define PixmapBytePad(w, d) \
  314. (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2)
  315. #define BitmapBytePad(w) \
  316. (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD)
  317. #define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d)
  318. #define PixmapBytePadProto(w, d) PixmapBytePad(w, d)
  319. #define BitmapBytePadProto(w) BitmapBytePad(w)
  320. #endif /* SERVERMD_H */