PageRenderTime 53ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/nx-3.5.0/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.c

#
C | 114 lines | 74 code | 18 blank | 22 comment | 5 complexity | da8c4d3e8f88d3af8cb800771b4d3e5c MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, LGPL-2.0
  1. /* $XConsortium: SlowBcopy.c /main/1 1996/05/07 17:14:10 kaleb $ */
  2. /*******************************************************************************
  3. for Alpha Linux
  4. *******************************************************************************/
  5. /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.c,v 1.6tsi Exp $ */
  6. /*
  7. * Create a dependency that should be immune from the effect of register
  8. * renaming as is commonly seen in superscalar processors. This should
  9. * insert a minimum of 100-ns delays between reads/writes at clock rates
  10. * up to 100 MHz---GGL
  11. *
  12. * Slowbcopy(char *src, char *dst, int count)
  13. *
  14. */
  15. #ifdef HAVE_XORG_CONFIG_H
  16. #include <xorg-config.h>
  17. #endif
  18. #include <X11/X.h>
  19. #include "xf86.h"
  20. #include "xf86Priv.h"
  21. #include "xf86_OSlib.h"
  22. #include "compiler.h"
  23. /* The outb() isn't needed on my machine, but who knows ... -- ost */
  24. void
  25. xf86SlowBcopy(unsigned char *src, unsigned char *dst, int len)
  26. {
  27. while(len--)
  28. {
  29. *dst++ = *src++;
  30. #if !defined(__sparc__) && \
  31. !defined(__powerpc__) && \
  32. !defined(__mips__) && \
  33. !defined(__ia64__)
  34. outb(0x80, 0x00);
  35. #endif
  36. }
  37. }
  38. #ifdef __alpha__
  39. /*
  40. * The Jensen lacks dense memory, thus we have to address the bus via
  41. * the sparse addressing scheme. Time critical code uses routines from
  42. * BUSmemcpy.c
  43. *
  44. * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
  45. */
  46. #ifdef linux
  47. unsigned long _bus_base(void);
  48. #ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */
  49. #define SPARSE (5)
  50. #else
  51. #define SPARSE (7)
  52. #endif
  53. #define isJensen() (!_bus_base())
  54. #else
  55. #define isJensen() 0
  56. #define SPARSE 0
  57. #endif
  58. void
  59. xf86SlowBCopyFromBus(unsigned char *src, unsigned char *dst, int count)
  60. {
  61. if (isJensen())
  62. {
  63. unsigned long addr;
  64. long result;
  65. addr = (unsigned long) src;
  66. while( count ){
  67. result = *(volatile int *) addr;
  68. result >>= ((addr>>SPARSE) & 3) * 8;
  69. *dst++ = (unsigned char) (0xffUL & result);
  70. addr += 1<<SPARSE;
  71. count--;
  72. outb(0x80, 0x00);
  73. }
  74. }
  75. else
  76. xf86SlowBcopy(src,dst,count);
  77. }
  78. void
  79. xf86SlowBCopyToBus(unsigned char *src, unsigned char *dst, int count)
  80. {
  81. if (isJensen())
  82. {
  83. unsigned long addr;
  84. addr = (unsigned long) dst;
  85. while(count) {
  86. *(volatile unsigned int *) addr = (unsigned short)(*src) * 0x01010101;
  87. src++;
  88. addr += 1<<SPARSE;
  89. count--;
  90. outb(0x80, 0x00);
  91. }
  92. }
  93. else
  94. xf86SlowBcopy(src,dst,count);
  95. }
  96. #endif