cd64io.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef __CD64IO_H__
  2. #define __CD64IO_H__
  3. #ifdef CD64_USE_LIBIEEE1284
  4. #include <ieee1284.h>
  5. int cd64_open_ieee1284(struct cd64_t *cd64);
  6. int cd64_close_ieee1284(struct cd64_t *cd64);
  7. int cd64_xfer_ieee1284(struct cd64_t *cd64, uint8_t *wr, uint8_t *rd, int delayms);
  8. #endif
  9. #ifdef CD64_USE_PPDEV
  10. #ifndef __linux__
  11. #error ppdev can only be used on Linux
  12. #endif
  13. #include <sys/ioctl.h>
  14. #include <linux/parport.h>
  15. #include <linux/ppdev.h>
  16. int cd64_open_ppdev(struct cd64_t *cd64);
  17. int cd64_close_ppdev(struct cd64_t *cd64);
  18. int cd64_xfer_ppdev(struct cd64_t *cd64, uint8_t *wr, uint8_t *rd, int delayms);
  19. #endif
  20. #ifdef CD64_USE_PORTDEV
  21. #ifndef __linux__
  22. #error portdev can only be used on Linux
  23. #endif
  24. int cd64_open_portdev(struct cd64_t *cd64);
  25. int cd64_close_portdev(struct cd64_t *cd64);
  26. int cd64_xfer_portdev(struct cd64_t *cd64, uint8_t *wr, uint8_t *rd, int delayms);
  27. #endif
  28. #ifdef CD64_USE_RAWIO
  29. /* #define REALLY_SLOW_IO */
  30. #if defined __linux__ && (defined __i386__ || defined __x86_64__)
  31. #include <sys/io.h>
  32. #endif
  33. #ifdef __OpenBSD__
  34. #include <sys/types.h>
  35. #include <machine/sysarch.h>
  36. #include <i386/pio.h>
  37. /* pio.h defines several I/O functions & macros, including the macros inb() and
  38. * outb(). This shows that using a bit of inline assembly is not such a bad idea
  39. * at all. */
  40. #undef inb
  41. #define inb(port) __inb(port)
  42. #undef outb
  43. #define outb(data, port) __outb(port, data)
  44. #endif
  45. #ifdef __FreeBSD__
  46. #include <fcntl.h>
  47. #include <machine/cpufunc.h>
  48. /* Almost the same story as under OpenBSD. cpufunc.h defines the macros inb()
  49. * and outb(). We redefine them. Be sure _POSIX_SOURCE is not defined before
  50. * including <machine/cpufunc.h>. */
  51. #undef inb
  52. #define inb(port) inbv(port)
  53. #undef outb
  54. #define outb(data, port) outbv(port, data)
  55. #endif
  56. #ifdef __BEOS__
  57. #include <fcntl.h>
  58. #endif
  59. #ifdef _MSC_VER
  60. #include <conio.h> /* inp() & outp() */
  61. #pragma warning(push)
  62. #pragma warning(disable: 4820) /* 'bytes' bytes padding added after construct 'member_name' */
  63. #include <io.h> /* access() */
  64. #pragma warning(pop)
  65. #define F_OK 0
  66. #endif
  67. #ifdef __MSDOS__
  68. #include <pc.h> /* inportb() & outportb() */
  69. #endif
  70. #if defined _WIN32 || defined __CYGWIN__
  71. #ifdef _MSC_VER
  72. #pragma warning(push)
  73. #pragma warning(disable: 4255) /* 'function' : no function prototype given: converting '()' to '(void)' */
  74. #pragma warning(disable: 4668) /* 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives' */
  75. #pragma warning(disable: 4820) /* 'bytes' bytes padding added after construct 'member_name' */
  76. #endif
  77. #include <windows.h> /* defines _WIN32 (checks for */
  78. #ifdef _MSC_VER /* __CYGWIN__ must come first) */
  79. #pragma warning(pop)
  80. #endif
  81. #endif /* _WIN32 || __CYGWIN__ */
  82. int cd64_open_rawio(struct cd64_t *cd64);
  83. int cd64_close_rawio(struct cd64_t *cd64);
  84. int cd64_xfer_rawio(struct cd64_t *cd64, uint8_t *wr, uint8_t *rd, int delayms);
  85. #endif
  86. #if defined _WIN32 && !defined __CYGWIN__
  87. /* milliseconds */
  88. #ifdef _MSC_VER
  89. #pragma warning(push)
  90. #pragma warning(disable: 4255) /* 'function' : no function prototype given: converting '()' to '(void)' */
  91. #pragma warning(disable: 4668) /* 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives' */
  92. #pragma warning(disable: 4820) /* 'bytes' bytes padding added after construct 'member_name' */
  93. #endif
  94. #include <windows.h>
  95. #ifdef _MSC_VER
  96. #pragma warning(pop)
  97. #endif
  98. #define MSLEEP(x) Sleep(x)
  99. #elif defined __MSDOS__
  100. /* milliseconds */
  101. #include <dos.h>
  102. #define MSLEEP(x) delay(x)
  103. #elif defined __BEOS__
  104. /* microseconds */
  105. #include <OS.h>
  106. #define MSLEEP(x) snooze((x) * 1000)
  107. #else /* UNIX & Cygwin */
  108. /* microseconds */
  109. #include <unistd.h>
  110. #define MSLEEP(x) usleep((x) * 1000)
  111. #endif
  112. #if defined __STDC_VERSION && __STDC_VERSION >= 19990L && !defined DEBUG
  113. /* If DEBUG is defined the keyword inline is not recognised (syntax error). */
  114. #define INLINE inline
  115. #elif defined _MSC_VER
  116. /* Visual C++ doesn't allow inline in C source code */
  117. #define INLINE __inline
  118. #else
  119. #define INLINE
  120. #endif
  121. #endif