home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mint095b.zoo / doc / device.doc < prev    next >
Text File  |  1992-07-28  |  5KB  |  161 lines

  1. Here are some notes on writing device drivers; before reading
  2. them, you should familiarize yourself with the information in
  3. "filesys.doc", especially the material on device drivers.
  4.  
  5. Serial Port Device Drivers
  6.  
  7. Serial port device drivers should recognize the
  8. following ioctl calls:
  9. (here "f" is always a FILEPTR referring to an open
  10. file on the device)
  11.  
  12.  
  13. ioctl(f, TIOCIBAUD, long *r):
  14.  
  15. Set input speed. "r" is a pointer to a 32 bit value, and is both an
  16. input and output parameter. If *r is > 0, it represents the value
  17. to which the serial port's input speed should be set. This value
  18. is a long word representation of the speed in bits per second,
  19. e.g. to set 9600 bits per second *r should be 9600L.
  20. If *r is 0, it indicates that DTR should be dropped.
  21. If *r is < 0, the call is an inquiry call only.
  22.  
  23. On return, *r is set to the value of the input speed before the
  24. ioctl call was made. If, for some reason, this value is unknown,
  25. *r is set to -1L.
  26.  
  27. Returns:
  28. 0 on success
  29. ERANGE if the requested input speed is not available. In this case,
  30. the input speed has not been changed, and is still returned in *r.
  31.  
  32.  
  33.  
  34. ioctl(f, TIOCOBAUD, long *r):
  35.  
  36. Set output speed. "r" is a pointer to a 32 bit value, and is both an
  37. input and output parameter. If *r is > 0, it represents the value
  38. to which the serial port's output speed should be set. This value
  39. is a long word representation of the speed in bits per second,
  40. e.g. to set 9600 bits per second *r should be 9600L.
  41. If *r is 0, it indicates that the device should be hung up, i.e.
  42. that DTR should no longer be asserted.
  43. If *r is < 0, no change is to be made to the output speed.
  44.  
  45. On return, *r is set to the value of the output speed before the
  46. ioctl call was made. If, for some reason, this value is unknown,
  47. *r is set to -1L.
  48.  
  49. Returns:
  50. 0 on success
  51. ERANGE if the requested output speed is not available. In this case,
  52. the input speed has not been changed, and is still returned in *r.
  53.  
  54. Note: For many devices both the input and output speeds must always be
  55. the same. For such devices, TIOCIBAUD and TIOCOBAUD may affect both
  56. input and output speed.
  57.  
  58.  
  59.  
  60. ioctl(f, TIOCSBRK, dummy):
  61.  
  62. Causes a BREAK condition to be set on the output line.
  63. Returns:
  64. 0 on success
  65. EINVFN if the serial port cannot send BREAK
  66.  
  67.  
  68.  
  69. ioctl(f, TIOCCBRK, dummy)
  70.  
  71. Causes any existing BREAK condition to be cleared.
  72. Returns:
  73. 0 on success
  74. EINVFN if the serial port cannot send BREAK
  75.  
  76.  
  77.  
  78. ioctl(f, TIOCGFLAGS, short *flags)
  79.  
  80. Get the terminal control flags bits. 16 bit flag word
  81. pointed to by "flags" is set to reflect the current
  82. terminal state, as follows:
  83.  
  84. TF_STOPBITS    0x0003
  85. The two low order bits describe the stop bits:
  86. 0x0000    illegal -- attempts to set this value are
  87.     ignored
  88. 0x0001    1 stop bit
  89. 0x0002    1.5 stop bits
  90. 0x0003    2 stop bits
  91.  
  92. TF_CHARBITS    0x000C
  93. The next two bits describe the number of bits
  94. transmitted per character:
  95. 0x0000    8 bits per character
  96. 0x0004    7 bits per character
  97. 0x0008    6 bits per character
  98. 0x000C    5 bits per character
  99.  
  100. The final nybble contains miscellaneous flags:
  101. T_TANDEM    0x1000        ^S/^Q flow control active
  102. T_RTSCTS    0x2000        RTS/CTS flow control active
  103. T_EVENP        0x4000        even parity enabled
  104. T_ODDP        0x8000        odd parity enabled
  105.     (note: T_EVENPAR and T_ODDPAR are mutually exclusive)
  106.  
  107. All other bits are reserved, and should be set to 0.
  108.  
  109. Returns:
  110. 0 on success
  111.  
  112.  
  113.  
  114. ioctl(f, TIOCSFLAGS, short *flags)
  115.  
  116. Set the terminal control flags (see the description
  117. of TIOCGFLAGS for details) based on the values in the
  118. word pointed to by "flags".
  119.  
  120. Returns:
  121. 0 on success
  122. ERANGE if an illegal or unsupported combination of flags
  123.  is detected.
  124.  
  125.  
  126. INTERFACE WITH EXISTING TIOCSETP/TIOCGETP CALLS:
  127.  
  128. The MiNT kernel will automatically make appropriate
  129. TIOCIBAUD, TIOCOBAUD, TIOCGFLAGS, and TIOCSFLAGS calls
  130. whenever a TIOCSETP or TIOCGETP Fcntl is made on a
  131. terminal. The kernel will convert a Unix style baud
  132. specification into a MiNT style one, as follows:
  133.  
  134. value of sg_ispeed or         value sent to
  135.      sg_ospeed                 driver
  136. #define B0     0            0L
  137. #define B50    1           50L
  138. #define B75    2           75L
  139. #define B110   3          110L
  140. #define B134   4          134L
  141. #define B150   5          150L
  142. #define B200   6          200L
  143. #define B300   7          300L
  144. #define B600   8          600L
  145. #define B1200  9         1200L
  146. #define B1800  10         1800L
  147. #define B2400  11         2400L
  148. #define B4800  12         4800L
  149. #define B9600  13         9600L
  150. #define B19200 14        19200L
  151. #define B38400 15        38400L (*)
  152.  
  153. anything else               -1L
  154.  
  155.  
  156. (*) 38400 baud is not supported by the built
  157. in device drivers, but may be by external drivers
  158.  
  159. If a speed other than those listed above is desired, the
  160. TIOCIBAUD and/or TIOCOBAUD Fcntls should be used directly.
  161.