Annotation of MiNT/doc/modem.doc, revision 1.1.1.1

1.1       root        1: Here are some notes on writing device drivers; before reading
                      2: 
                      3: them, you should familiarize yourself with the information in
                      4: 
                      5: "filesys.doc", especially the material on device drivers.
                      6: 
                      7: 
                      8: 
                      9: Serial Port Device Drivers
                     10: 
                     11: 
                     12: 
                     13: Serial port device drivers should recognize the
                     14: 
                     15: following ioctl calls:
                     16: 
                     17: (here "f" is always a FILEPTR referring to an open
                     18: 
                     19: file on the device)
                     20: 
                     21: 
                     22: 
                     23: 
                     24: 
                     25: ioctl(f, TIOCIBAUD, long *r):
                     26: 
                     27: 
                     28: 
                     29: Set input speed. "r" is a pointer to a 32 bit value, and is both an
                     30: 
                     31: input and output parameter. If *r is > 0, it represents the value
                     32: 
                     33: to which the serial port's input speed should be set. This value
                     34: 
                     35: is a long word representation of the speed in bits per second,
                     36: 
                     37: e.g. to set 9600 bits per second *r should be 9600L.
                     38: 
                     39: If *r is 0, it indicates that DTR should be dropped.
                     40: 
                     41: If *r is < 0, the call is an inquiry call only.
                     42: 
                     43: 
                     44: 
                     45: On return, *r is set to the value of the input speed before the
                     46: 
                     47: ioctl call was made. If, for some reason, this value is unknown,
                     48: 
                     49: *r is set to -1L.
                     50: 
                     51: 
                     52: 
                     53: Returns:
                     54: 
                     55: 0 on success
                     56: 
                     57: ERANGE if the requested input speed is not available. In this case,
                     58: 
                     59: the next lowest legal input speed available is returned in *r.
                     60: 
                     61: 
                     62: 
                     63: 
                     64: 
                     65: 
                     66: 
                     67: ioctl(f, TIOCOBAUD, long *r):
                     68: 
                     69: 
                     70: 
                     71: Set output speed. "r" is a pointer to a 32 bit value, and is both an
                     72: 
                     73: input and output parameter. If *r is > 0, it represents the value
                     74: 
                     75: to which the serial port's output speed should be set. This value
                     76: 
                     77: is a long word representation of the speed in bits per second,
                     78: 
                     79: e.g. to set 9600 bits per second *r should be 9600L.
                     80: 
                     81: If *r is 0, it indicates that the device should be hung up, i.e.
                     82: 
                     83: that DTR should no longer be asserted.
                     84: 
                     85: If *r is < 0, no change is to be made to the output speed.
                     86: 
                     87: 
                     88: 
                     89: On return, *r is set to the value of the output speed before the
                     90: 
                     91: ioctl call was made. If, for some reason, this value is unknown,
                     92: 
                     93: *r is set to -1L.
                     94: 
                     95: 
                     96: 
                     97: Returns:
                     98: 
                     99: 0 on success
                    100: 
                    101: ERANGE if the requested output speed is not available. In this case,
                    102: 
                    103: the next lowest legal output speed available is returned in *r.
                    104: 
                    105: 
                    106: 
                    107: Note: For many devices both the input and output speeds must always be
                    108: 
                    109: the same. For such devices, TIOCIBAUD and TIOCOBAUD may affect both
                    110: 
                    111: input and output speed.
                    112: 
                    113: 
                    114: 
                    115: 
                    116: 
                    117: 
                    118: 
                    119: ioctl(f, TIOCSBRK, dummy):
                    120: 
                    121: 
                    122: 
                    123: Causes a BREAK condition to be set on the output line.
                    124: 
                    125: Returns:
                    126: 
                    127: 0 on success
                    128: 
                    129: EINVFN if the serial port cannot send BREAK
                    130: 
                    131: 
                    132: 
                    133: 
                    134: 
                    135: 
                    136: 
                    137: ioctl(f, TIOCCBRK, dummy)
                    138: 
                    139: 
                    140: 
                    141: Causes any existing BREAK condition to be cleared.
                    142: 
                    143: Returns:
                    144: 
                    145: 0 on success
                    146: 
                    147: EINVFN if the serial port cannot send BREAK
                    148: 
                    149: 
                    150: 
                    151: 
                    152: 
                    153: 
                    154: 
                    155: ioctl(f, TIOCGFLAGS, short *flags)
                    156: 
                    157: 
                    158: 
                    159: Get the terminal control flags bits. 16 bit flag word
                    160: 
                    161: pointed to by "flags" is set to reflect the current
                    162: 
                    163: terminal state, as follows:
                    164: 
                    165: 
                    166: 
                    167: TF_STOPBITS    0x0003
                    168: 
                    169: The two low order bits describe the stop bits:
                    170: 
                    171: 0x0000 illegal -- attempts to set this value are
                    172: 
                    173:        ignored
                    174: 
                    175: 0x0001 1 stop bit
                    176: 
                    177: 0x0002 1.5 stop bits
                    178: 
                    179: 0x0003 2 stop bits
                    180: 
                    181: 
                    182: 
                    183: TF_CHARBITS    0x000C
                    184: 
                    185: The next two bits describe the number of bits
                    186: 
                    187: transmitted per character:
                    188: 
                    189: 0x0000 8 bits per character
                    190: 
                    191: 0x0004 7 bits per character
                    192: 
                    193: 0x0008 6 bits per character
                    194: 
                    195: 0x000C 5 bits per character
                    196: 
                    197: 
                    198: 
                    199: The final nybble contains miscellaneous flags:
                    200: 
                    201: T_TANDEM       0x1000          ^S/^Q flow control active
                    202: 
                    203: T_RTSCTS       0x2000          RTS/CTS flow control active
                    204: 
                    205: T_EVENP                0x4000          even parity enabled
                    206: 
                    207: T_ODDP         0x8000          odd parity enabled
                    208: 
                    209:        (note: T_EVENPAR and T_ODDPAR are mutually exclusive)
                    210: 
                    211: 
                    212: 
                    213: All other bits are reserved, and should be set to 0.
                    214: 
                    215: 
                    216: 
                    217: Returns:
                    218: 
                    219: 0 on success
                    220: 
                    221: 
                    222: 
                    223: 
                    224: 
                    225: 
                    226: 
                    227: ioctl(f, TIOCSFLAGS, short *flags)
                    228: 
                    229: 
                    230: 
                    231: Set the terminal control flags (see the description
                    232: 
                    233: of TIOCGFLAGS for details) based on the values in the
                    234: 
                    235: word pointed to by "flags".
                    236: 
                    237: 
                    238: 
                    239: Returns:
                    240: 
                    241: 0 on success
                    242: 
                    243: ERANGE if an illegal or unsupported combination of flags
                    244: 
                    245:  is detected.
                    246: 
                    247: 
                    248: 
                    249: 
                    250: 
                    251: INTERFACE WITH EXISTING TIOCSETP/TIOCGETP CALLS:
                    252: 
                    253: 
                    254: 
                    255: The MiNT kernel will automatically make appropriate
                    256: 
                    257: TIOCIBAUD, TIOCOBAUD, TIOCGFLAGS, and TIOCSFLAGS calls
                    258: 
                    259: whenever a TIOCSETP or TIOCGETP Fcntl is made on a
                    260: 
                    261: terminal. The kernel will convert a Unix style baud
                    262: 
                    263: specification into a MiNT style one, as follows:
                    264: 
                    265: 
                    266: 
                    267: value of sg_ispeed or       value sent to
                    268: 
                    269:      sg_ospeed                  driver
                    270: 
                    271: #define B0     0                   0L
                    272: 
                    273: #define B50    1                  50L
                    274: 
                    275: #define B75    2                  75L
                    276: 
                    277: #define B110   3                 110L
                    278: 
                    279: #define B134   4                 134L
                    280: 
                    281: #define B150   5                 150L
                    282: 
                    283: #define B200   6                 200L
                    284: 
                    285: #define B300   7                 300L
                    286: 
                    287: #define B600   8                 600L
                    288: 
                    289: #define B1200  9                1200L
                    290: 
                    291: #define B1800  10               1800L
                    292: 
                    293: #define B2400  11               2400L
                    294: 
                    295: #define B4800  12               4800L
                    296: 
                    297: #define B9600  13               9600L
                    298: 
                    299: #define B19200 14              19200L
                    300: 
                    301: #define B38400 15              38400L (*)
                    302: 
                    303: 
                    304: 
                    305: anything else                     -1L
                    306: 
                    307: 
                    308: 
                    309: 
                    310: 
                    311: (*) 38400 baud is not supported by the built
                    312: 
                    313: in device drivers, but may be by external drivers
                    314: 
                    315: 
                    316: 
                    317: If a speed other than those listed above is desired, the
                    318: 
                    319: TIOCIBAUD and/or TIOCOBAUD Fcntls should be used directly.
                    320: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.