rio_linux.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *  rio_linux.h
  3.  *
  4.  *  Copyright (C) 1998,1999,2000 R.E.Wolff@BitWizard.nl
  5.  *
  6.  *      This program is free software; you can redistribute it and/or modify
  7.  *      it under the terms of the GNU General Public License as published by
  8.  *      the Free Software Foundation; either version 2 of the License, or
  9.  *      (at your option) any later version.
  10.  *
  11.  *      This program is distributed in the hope that it will be useful,
  12.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *      GNU General Public License for more details.
  15.  *
  16.  *      You should have received a copy of the GNU General Public License
  17.  *      along with this program; if not, write to the Free Software
  18.  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  *  RIO serial driver.
  21.  *
  22.  *  Version 1.0 -- July, 1999. 
  23.  * 
  24.  */
  25. #include <linux/config.h>
  26. #define RIO_NBOARDS        4
  27. #define RIO_PORTSPERBOARD 128
  28. #define RIO_NPORTS        (RIO_NBOARDS * RIO_PORTSPERBOARD)
  29. #define MODEM_SUPPORT
  30. #ifdef __KERNEL__
  31. #define RIO_MAGIC 0x12345678
  32. struct vpd_prom {
  33.   unsigned short id;
  34.   char hwrev;
  35.   char hwass;
  36.   int uniqid;
  37.   char myear;
  38.   char mweek;
  39.   char hw_feature[5];
  40.   char oem_id;
  41.   char identifier[16];
  42. };
  43. #define RIO_DEBUG_ALL           0xffffffff
  44. #define O_OTHER(tty)    
  45.       ((O_OLCUC(tty))  ||
  46.       (O_ONLCR(tty))   ||
  47.       (O_OCRNL(tty))   ||
  48.       (O_ONOCR(tty))   ||
  49.       (O_ONLRET(tty))  ||
  50.       (O_OFILL(tty))   ||
  51.       (O_OFDEL(tty))   ||
  52.       (O_NLDLY(tty))   ||
  53.       (O_CRDLY(tty))   ||
  54.       (O_TABDLY(tty))  ||
  55.       (O_BSDLY(tty))   ||
  56.       (O_VTDLY(tty))   ||
  57.       (O_FFDLY(tty)))
  58. /* Same for input. */
  59. #define I_OTHER(tty)    
  60.       ((I_INLCR(tty))  ||
  61.       (I_IGNCR(tty))   ||
  62.       (I_ICRNL(tty))   ||
  63.       (I_IUCLC(tty))   ||
  64.       (L_ISIG(tty)))
  65. #endif /* __KERNEL__ */
  66. #define RIO_BOARD_INTR_LOCK  1
  67. #ifndef RIOCTL_MISC_MINOR 
  68. /* Allow others to gather this into "major.h" or something like that */
  69. #define RIOCTL_MISC_MINOR    169
  70. #endif
  71. void rio_dec_mod_count (void);
  72. void rio_inc_mod_count (void);
  73. /* Allow us to debug "in the field" without requiring clients to
  74.    recompile.... */
  75. #if 1
  76. #define rio_spin_lock_irqsave(sem, flags) do { 
  77. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlockirqsave: %p %s:%dn", 
  78.                                 sem, __FILE__, __LINE__);
  79. spin_lock_irqsave(sem, flags);
  80. } while (0)
  81. #define rio_spin_unlock_irqrestore(sem, flags) do { 
  82. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlockirqrestore: %p %s:%dn",
  83.                                 sem, __FILE__, __LINE__);
  84. spin_unlock_irqrestore(sem, flags);
  85. } while (0)
  86. #define rio_spin_lock(sem) do { 
  87. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlock: %p %s:%dn",
  88.                                 sem, __FILE__, __LINE__);
  89. spin_lock(sem);
  90. } while (0)
  91. #define rio_spin_unlock(sem) do { 
  92. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlock: %p %s:%dn",
  93.                                 sem, __FILE__, __LINE__);
  94. spin_unlock(sem);
  95. } while (0)
  96. #else
  97. #define rio_spin_lock_irqsave(sem, flags) 
  98.             spin_lock_irqsave(sem, flags)
  99. #define rio_spin_unlock_irqrestore(sem, flags) 
  100.             spin_unlock_irqrestore(sem, flags)
  101. #define rio_spin_lock(sem) 
  102.             spin_lock(sem) 
  103. #define rio_spin_unlock(sem) 
  104.             spin_unlock(sem) 
  105. #endif
  106. #ifdef CONFIG_RIO_OLDPCI
  107. static inline void *rio_memcpy_toio (void *dummy, void *dest, void *source, int n)
  108. {
  109.   char *dst = dest;
  110.   char *src = source;
  111.   while (n--) {
  112.     writeb (*src++, dst++);
  113.     (void) readb (dummy);
  114.   }
  115.   return dest;
  116. }
  117. static inline void *rio_memcpy_fromio (void *dest, void *source, int n)
  118. {
  119.   char *dst = dest;
  120.   char *src = source;
  121.   while (n--) 
  122.     *dst++ = readb (src++);
  123.   return dest;
  124. }
  125. #else
  126. #define rio_memcpy_toio(dummy,dest,source,n)   memcpy_toio(dest, source, n)
  127. #define rio_memcpy_fromio                      memcpy_fromio
  128. #endif
  129. #define DEBUG 1
  130. /* 
  131.    This driver can spew a whole lot of debugging output at you. If you
  132.    need maximum performance, you should disable the DEBUG define. To
  133.    aid in debugging in the field, I'm leaving the compile-time debug
  134.    features enabled, and disable them "runtime". That allows me to
  135.    instruct people with problems to enable debugging without requiring
  136.    them to recompile... 
  137. */
  138. #ifdef DEBUG
  139. #define rio_dprintk(f, str...) do { if (rio_debug & f) printk (str);} while (0)
  140. #define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %sn", __FUNCTION__)
  141. #define func_exit()  rio_dprintk (RIO_DEBUG_FLOW, "rio: exit  %sn", __FUNCTION__)
  142. #define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)n",  
  143. __FUNCTION__, port->line)
  144. #else
  145. #define rio_dprintk(f, str...) /* nothing */
  146. #define func_enter()
  147. #define func_exit()
  148. #define func_enter2()
  149. #endif