i2os.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*******************************************************************************
  2. *
  3. * (c) 1999 by Computone Corporation
  4. *
  5. ********************************************************************************
  6. *
  7. *
  8. * PACKAGE: Linux tty Device Driver for IntelliPort II family of multiport
  9. * serial I/O controllers.
  10. *
  11. * DESCRIPTION: Defines, definitions and includes which are heavily dependent
  12. * on O/S, host, compiler, etc. This file is tailored for:
  13. * Linux v2.0.0 and later
  14. * Gnu gcc c2.7.2
  15. * 80x86 architecture
  16. *
  17. *******************************************************************************/
  18. #ifndef I2OS_H /* To prevent multiple includes */
  19. #define I2OS_H 1
  20. //-------------------------------------------------
  21. // Required Includes
  22. //-------------------------------------------------
  23. #include "ip2types.h"
  24. #include <asm/io.h> /* For inb, etc */
  25. //------------------------------------
  26. // Defines for I/O instructions:
  27. //------------------------------------
  28. #define INB(port) inb(port)
  29. #define OUTB(port,value) outb((value),(port))
  30. #define INW(port) inw(port)
  31. #define OUTW(port,value) outw((value),(port))
  32. #define OUTSW(port,addr,count) outsw((port),(addr),(((count)+1)/2))
  33. #define OUTSB(port,addr,count) outsb((port),(addr),(((count)+1))&-2)
  34. #define INSW(port,addr,count) insw((port),(addr),(((count)+1)/2))
  35. #define INSB(port,addr,count) insb((port),(addr),(((count)+1))&-2)
  36. //--------------------------------------------
  37. // Interrupt control
  38. //--------------------------------------------
  39. #define LOCK_INIT(a) rwlock_init(a)
  40. #define SAVE_AND_DISABLE_INTS(a,b) { \
  41. /* printk("get_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
  42. spin_lock_irqsave(a,b); \
  43. }
  44. #define RESTORE_INTS(a,b) { \
  45. /* printk("rel_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
  46. spin_unlock_irqrestore(a,b); \
  47. }
  48. #define READ_LOCK_IRQSAVE(a,b) { \
  49. /* printk("get_read_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
  50. read_lock_irqsave(a,b); \
  51. }
  52. #define READ_UNLOCK_IRQRESTORE(a,b) { \
  53. /* printk("rel_read_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
  54. read_unlock_irqrestore(a,b); \
  55. }
  56. #define WRITE_LOCK_IRQSAVE(a,b) { \
  57. /* printk("get_write_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
  58. write_lock_irqsave(a,b); \
  59. }
  60. #define WRITE_UNLOCK_IRQRESTORE(a,b) { \
  61. /* printk("rel_write_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
  62. write_unlock_irqrestore(a,b); \
  63. }
  64. //------------------------------------------------------------------------------
  65. // Hardware-delay loop
  66. //
  67. // Probably used in only one place (see i2ellis.c) but this helps keep things
  68. // together. Note we have unwound the IN instructions. On machines with a
  69. // reasonable cache, the eight instructions (1 byte each) should fit in cache
  70. // nicely, and on un-cached machines, the code-fetch would tend not to dominate.
  71. // Note that cx is shifted so that "count" still reflects the total number of
  72. // iterations assuming no unwinding.
  73. //------------------------------------------------------------------------------
  74. //#define DELAY1MS(port,count,label)
  75. //------------------------------------------------------------------------------
  76. // Macros to switch to a new stack, saving stack pointers, and to restore the
  77. // old stack (Used, for example, in i2lib.c) "heap" is the address of some
  78. // buffer which will become the new stack (working down from highest address).
  79. // The two words at the two lowest addresses in this stack are for storing the
  80. // SS and SP.
  81. //------------------------------------------------------------------------------
  82. //#define TO_NEW_STACK(heap,size)
  83. //#define TO_OLD_STACK(heap)
  84. //------------------------------------------------------------------------------
  85. // Macros to save the original IRQ vectors and masks, and to patch in new ones.
  86. //------------------------------------------------------------------------------
  87. //#define SAVE_IRQ_MASKS(dest)
  88. //#define WRITE_IRQ_MASKS(src)
  89. //#define SAVE_IRQ_VECTOR(value,dest)
  90. //#define WRITE_IRQ_VECTOR(value,src)
  91. //------------------------------------------------------------------------------
  92. // Macro to copy data from one far pointer to another.
  93. //------------------------------------------------------------------------------
  94. #define I2_MOVE_DATA(fpSource,fpDest,count) memmove(fpDest,fpSource,count);
  95. //------------------------------------------------------------------------------
  96. // Macros to issue eoi's to host interrupt control (IBM AT 8259-style).
  97. //------------------------------------------------------------------------------
  98. //#define MASTER_EOI
  99. //#define SLAVE_EOI
  100. #endif /* I2OS_H */