tty_driver.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_TTY_DRIVER_H
  3. #define _LINUX_TTY_DRIVER_H
  4. #include <linux/export.h>
  5. #include <linux/fs.h>
  6. #include <linux/kref.h>
  7. #include <linux/list.h>
  8. #include <linux/cdev.h>
  9. #include <linux/uaccess.h>
  10. #include <linux/termios.h>
  11. #include <linux/seq_file.h>
  12. #include <linux/android_kabi.h>
  13. struct tty_struct;
  14. struct tty_driver;
  15. struct serial_icounter_struct;
  16. struct serial_struct;
  17. /**
  18. * struct tty_operations -- interface between driver and tty
  19. *
  20. * @lookup: ``struct tty_struct *()(struct tty_driver *self, struct file *,
  21. * int idx)``
  22. *
  23. * Return the tty device corresponding to @idx, %NULL if there is not
  24. * one currently in use and an %ERR_PTR value on error. Called under
  25. * %tty_mutex (for now!)
  26. *
  27. * Optional method. Default behaviour is to use the @self->ttys array.
  28. *
  29. * @install: ``int ()(struct tty_driver *self, struct tty_struct *tty)``
  30. *
  31. * Install a new @tty into the @self's internal tables. Used in
  32. * conjunction with @lookup and @remove methods.
  33. *
  34. * Optional method. Default behaviour is to use the @self->ttys array.
  35. *
  36. * @remove: ``void ()(struct tty_driver *self, struct tty_struct *tty)``
  37. *
  38. * Remove a closed @tty from the @self's internal tables. Used in
  39. * conjunction with @lookup and @remove methods.
  40. *
  41. * Optional method. Default behaviour is to use the @self->ttys array.
  42. *
  43. * @open: ``int ()(struct tty_struct *tty, struct file *)``
  44. *
  45. * This routine is called when a particular @tty device is opened. This
  46. * routine is mandatory; if this routine is not filled in, the attempted
  47. * open will fail with %ENODEV.
  48. *
  49. * Required method. Called with tty lock held. May sleep.
  50. *
  51. * @close: ``void ()(struct tty_struct *tty, struct file *)``
  52. *
  53. * This routine is called when a particular @tty device is closed. At the
  54. * point of return from this call the driver must make no further ldisc
  55. * calls of any kind.
  56. *
  57. * Remark: called even if the corresponding @open() failed.
  58. *
  59. * Required method. Called with tty lock held. May sleep.
  60. *
  61. * @shutdown: ``void ()(struct tty_struct *tty)``
  62. *
  63. * This routine is called under the tty lock when a particular @tty device
  64. * is closed for the last time. It executes before the @tty resources
  65. * are freed so may execute while another function holds a @tty kref.
  66. *
  67. * @cleanup: ``void ()(struct tty_struct *tty)``
  68. *
  69. * This routine is called asynchronously when a particular @tty device
  70. * is closed for the last time freeing up the resources. This is
  71. * actually the second part of shutdown for routines that might sleep.
  72. *
  73. * @write: ``int ()(struct tty_struct *tty, const unsigned char *buf,
  74. * int count)``
  75. *
  76. * This routine is called by the kernel to write a series (@count) of
  77. * characters (@buf) to the @tty device. The characters may come from
  78. * user space or kernel space. This routine will return the
  79. * number of characters actually accepted for writing.
  80. *
  81. * May occur in parallel in special cases. Because this includes panic
  82. * paths drivers generally shouldn't try and do clever locking here.
  83. *
  84. * Optional: Required for writable devices. May not sleep.
  85. *
  86. * @put_char: ``int ()(struct tty_struct *tty, unsigned char ch)``
  87. *
  88. * This routine is called by the kernel to write a single character @ch to
  89. * the @tty device. If the kernel uses this routine, it must call the
  90. * @flush_chars() routine (if defined) when it is done stuffing characters
  91. * into the driver. If there is no room in the queue, the character is
  92. * ignored.
  93. *
  94. * Optional: Kernel will use the @write method if not provided. Do not
  95. * call this function directly, call tty_put_char().
  96. *
  97. * @flush_chars: ``void ()(struct tty_struct *tty)``
  98. *
  99. * This routine is called by the kernel after it has written a
  100. * series of characters to the tty device using @put_char().
  101. *
  102. * Optional. Do not call this function directly, call
  103. * tty_driver_flush_chars().
  104. *
  105. * @write_room: ``unsigned int ()(struct tty_struct *tty)``
  106. *
  107. * This routine returns the numbers of characters the @tty driver
  108. * will accept for queuing to be written. This number is subject
  109. * to change as output buffers get emptied, or if the output flow
  110. * control is acted.
  111. *
  112. * The ldisc is responsible for being intelligent about multi-threading of
  113. * write_room/write calls
  114. *
  115. * Required if @write method is provided else not needed. Do not call this
  116. * function directly, call tty_write_room()
  117. *
  118. * @chars_in_buffer: ``unsigned int ()(struct tty_struct *tty)``
  119. *
  120. * This routine returns the number of characters in the device private
  121. * output queue. Used in tty_wait_until_sent() and for poll()
  122. * implementation.
  123. *
  124. * Optional: if not provided, it is assumed there is no queue on the
  125. * device. Do not call this function directly, call tty_chars_in_buffer().
  126. *
  127. * @ioctl: ``int ()(struct tty_struct *tty, unsigned int cmd,
  128. * unsigned long arg)``
  129. *
  130. * This routine allows the @tty driver to implement device-specific
  131. * ioctls. If the ioctl number passed in @cmd is not recognized by the
  132. * driver, it should return %ENOIOCTLCMD.
  133. *
  134. * Optional.
  135. *
  136. * @compat_ioctl: ``long ()(struct tty_struct *tty, unsigned int cmd,
  137. * unsigned long arg)``
  138. *
  139. * Implement ioctl processing for 32 bit process on 64 bit system.
  140. *
  141. * Optional.
  142. *
  143. * @set_termios: ``void ()(struct tty_struct *tty, const struct ktermios *old)``
  144. *
  145. * This routine allows the @tty driver to be notified when device's
  146. * termios settings have changed. New settings are in @tty->termios.
  147. * Previous settings are passed in the @old argument.
  148. *
  149. * The API is defined such that the driver should return the actual modes
  150. * selected. This means that the driver is responsible for modifying any
  151. * bits in @tty->termios it cannot fulfill to indicate the actual modes
  152. * being used.
  153. *
  154. * Optional. Called under the @tty->termios_rwsem. May sleep.
  155. *
  156. * @set_ldisc: ``void ()(struct tty_struct *tty)``
  157. *
  158. * This routine allows the @tty driver to be notified when the device's
  159. * line discipline is being changed. At the point this is done the
  160. * discipline is not yet usable.
  161. *
  162. * Optional. Called under the @tty->ldisc_sem and @tty->termios_rwsem.
  163. *
  164. * @throttle: ``void ()(struct tty_struct *tty)``
  165. *
  166. * This routine notifies the @tty driver that input buffers for the line
  167. * discipline are close to full, and it should somehow signal that no more
  168. * characters should be sent to the @tty.
  169. *
  170. * Serialization including with @unthrottle() is the job of the ldisc
  171. * layer.
  172. *
  173. * Optional: Always invoke via tty_throttle_safe(). Called under the
  174. * @tty->termios_rwsem.
  175. *
  176. * @unthrottle: ``void ()(struct tty_struct *tty)``
  177. *
  178. * This routine notifies the @tty driver that it should signal that
  179. * characters can now be sent to the @tty without fear of overrunning the
  180. * input buffers of the line disciplines.
  181. *
  182. * Optional. Always invoke via tty_unthrottle(). Called under the
  183. * @tty->termios_rwsem.
  184. *
  185. * @stop: ``void ()(struct tty_struct *tty)``
  186. *
  187. * This routine notifies the @tty driver that it should stop outputting
  188. * characters to the tty device.
  189. *
  190. * Called with @tty->flow.lock held. Serialized with @start() method.
  191. *
  192. * Optional. Always invoke via stop_tty().
  193. *
  194. * @start: ``void ()(struct tty_struct *tty)``
  195. *
  196. * This routine notifies the @tty driver that it resumed sending
  197. * characters to the @tty device.
  198. *
  199. * Called with @tty->flow.lock held. Serialized with stop() method.
  200. *
  201. * Optional. Always invoke via start_tty().
  202. *
  203. * @hangup: ``void ()(struct tty_struct *tty)``
  204. *
  205. * This routine notifies the @tty driver that it should hang up the @tty
  206. * device.
  207. *
  208. * Optional. Called with tty lock held.
  209. *
  210. * @break_ctl: ``int ()(struct tty_struct *tty, int state)``
  211. *
  212. * This optional routine requests the @tty driver to turn on or off BREAK
  213. * status on the RS-232 port. If @state is -1, then the BREAK status
  214. * should be turned on; if @state is 0, then BREAK should be turned off.
  215. *
  216. * If this routine is implemented, the high-level tty driver will handle
  217. * the following ioctls: %TCSBRK, %TCSBRKP, %TIOCSBRK, %TIOCCBRK.
  218. *
  219. * If the driver sets %TTY_DRIVER_HARDWARE_BREAK in tty_alloc_driver(),
  220. * then the interface will also be called with actual times and the
  221. * hardware is expected to do the delay work itself. 0 and -1 are still
  222. * used for on/off.
  223. *
  224. * Optional: Required for %TCSBRK/%BRKP/etc. handling. May sleep.
  225. *
  226. * @flush_buffer: ``void ()(struct tty_struct *tty)``
  227. *
  228. * This routine discards device private output buffer. Invoked on close,
  229. * hangup, to implement %TCOFLUSH ioctl and similar.
  230. *
  231. * Optional: if not provided, it is assumed there is no queue on the
  232. * device. Do not call this function directly, call
  233. * tty_driver_flush_buffer().
  234. *
  235. * @wait_until_sent: ``void ()(struct tty_struct *tty, int timeout)``
  236. *
  237. * This routine waits until the device has written out all of the
  238. * characters in its transmitter FIFO. Or until @timeout (in jiffies) is
  239. * reached.
  240. *
  241. * Optional: If not provided, the device is assumed to have no FIFO.
  242. * Usually correct to invoke via tty_wait_until_sent(). May sleep.
  243. *
  244. * @send_xchar: ``void ()(struct tty_struct *tty, char ch)``
  245. *
  246. * This routine is used to send a high-priority XON/XOFF character (@ch)
  247. * to the @tty device.
  248. *
  249. * Optional: If not provided, then the @write method is called under
  250. * the @tty->atomic_write_lock to keep it serialized with the ldisc.
  251. *
  252. * @tiocmget: ``int ()(struct tty_struct *tty)``
  253. *
  254. * This routine is used to obtain the modem status bits from the @tty
  255. * driver.
  256. *
  257. * Optional: If not provided, then %ENOTTY is returned from the %TIOCMGET
  258. * ioctl. Do not call this function directly, call tty_tiocmget().
  259. *
  260. * @tiocmset: ``int ()(struct tty_struct *tty,
  261. * unsigned int set, unsigned int clear)``
  262. *
  263. * This routine is used to set the modem status bits to the @tty driver.
  264. * First, @clear bits should be cleared, then @set bits set.
  265. *
  266. * Optional: If not provided, then %ENOTTY is returned from the %TIOCMSET
  267. * ioctl. Do not call this function directly, call tty_tiocmset().
  268. *
  269. * @resize: ``int ()(struct tty_struct *tty, struct winsize *ws)``
  270. *
  271. * Called when a termios request is issued which changes the requested
  272. * terminal geometry to @ws.
  273. *
  274. * Optional: the default action is to update the termios structure
  275. * without error. This is usually the correct behaviour. Drivers should
  276. * not force errors here if they are not resizable objects (e.g. a serial
  277. * line). See tty_do_resize() if you need to wrap the standard method
  278. * in your own logic -- the usual case.
  279. *
  280. * @get_icount: ``int ()(struct tty_struct *tty,
  281. * struct serial_icounter *icount)``
  282. *
  283. * Called when the @tty device receives a %TIOCGICOUNT ioctl. Passed a
  284. * kernel structure @icount to complete.
  285. *
  286. * Optional: called only if provided, otherwise %ENOTTY will be returned.
  287. *
  288. * @get_serial: ``int ()(struct tty_struct *tty, struct serial_struct *p)``
  289. *
  290. * Called when the @tty device receives a %TIOCGSERIAL ioctl. Passed a
  291. * kernel structure @p (&struct serial_struct) to complete.
  292. *
  293. * Optional: called only if provided, otherwise %ENOTTY will be returned.
  294. * Do not call this function directly, call tty_tiocgserial().
  295. *
  296. * @set_serial: ``int ()(struct tty_struct *tty, struct serial_struct *p)``
  297. *
  298. * Called when the @tty device receives a %TIOCSSERIAL ioctl. Passed a
  299. * kernel structure @p (&struct serial_struct) to set the values from.
  300. *
  301. * Optional: called only if provided, otherwise %ENOTTY will be returned.
  302. * Do not call this function directly, call tty_tiocsserial().
  303. *
  304. * @show_fdinfo: ``void ()(struct tty_struct *tty, struct seq_file *m)``
  305. *
  306. * Called when the @tty device file descriptor receives a fdinfo request
  307. * from VFS (to show in /proc/<pid>/fdinfo/). @m should be filled with
  308. * information.
  309. *
  310. * Optional: called only if provided, otherwise nothing is written to @m.
  311. * Do not call this function directly, call tty_show_fdinfo().
  312. *
  313. * @poll_init: ``int ()(struct tty_driver *driver, int line, char *options)``
  314. *
  315. * kgdboc support (Documentation/dev-tools/kgdb.rst). This routine is
  316. * called to initialize the HW for later use by calling @poll_get_char or
  317. * @poll_put_char.
  318. *
  319. * Optional: called only if provided, otherwise skipped as a non-polling
  320. * driver.
  321. *
  322. * @poll_get_char: ``int ()(struct tty_driver *driver, int line)``
  323. *
  324. * kgdboc support (see @poll_init). @driver should read a character from a
  325. * tty identified by @line and return it.
  326. *
  327. * Optional: called only if @poll_init provided.
  328. *
  329. * @poll_put_char: ``void ()(struct tty_driver *driver, int line, char ch)``
  330. *
  331. * kgdboc support (see @poll_init). @driver should write character @ch to
  332. * a tty identified by @line.
  333. *
  334. * Optional: called only if @poll_init provided.
  335. *
  336. * @proc_show: ``int ()(struct seq_file *m, void *driver)``
  337. *
  338. * Driver @driver (cast to &struct tty_driver) can show additional info in
  339. * /proc/tty/driver/<driver_name>. It is enough to fill in the information
  340. * into @m.
  341. *
  342. * Optional: called only if provided, otherwise no /proc entry created.
  343. *
  344. * This structure defines the interface between the low-level tty driver and
  345. * the tty routines. These routines can be defined. Unless noted otherwise,
  346. * they are optional, and can be filled in with a %NULL pointer.
  347. */
  348. struct tty_operations {
  349. struct tty_struct * (*lookup)(struct tty_driver *driver,
  350. struct file *filp, int idx);
  351. int (*install)(struct tty_driver *driver, struct tty_struct *tty);
  352. void (*remove)(struct tty_driver *driver, struct tty_struct *tty);
  353. int (*open)(struct tty_struct * tty, struct file * filp);
  354. void (*close)(struct tty_struct * tty, struct file * filp);
  355. void (*shutdown)(struct tty_struct *tty);
  356. void (*cleanup)(struct tty_struct *tty);
  357. int (*write)(struct tty_struct * tty,
  358. const unsigned char *buf, int count);
  359. int (*put_char)(struct tty_struct *tty, unsigned char ch);
  360. void (*flush_chars)(struct tty_struct *tty);
  361. unsigned int (*write_room)(struct tty_struct *tty);
  362. unsigned int (*chars_in_buffer)(struct tty_struct *tty);
  363. int (*ioctl)(struct tty_struct *tty,
  364. unsigned int cmd, unsigned long arg);
  365. long (*compat_ioctl)(struct tty_struct *tty,
  366. unsigned int cmd, unsigned long arg);
  367. void (*set_termios)(struct tty_struct *tty, const struct ktermios *old);
  368. void (*throttle)(struct tty_struct * tty);
  369. void (*unthrottle)(struct tty_struct * tty);
  370. void (*stop)(struct tty_struct *tty);
  371. void (*start)(struct tty_struct *tty);
  372. void (*hangup)(struct tty_struct *tty);
  373. int (*break_ctl)(struct tty_struct *tty, int state);
  374. void (*flush_buffer)(struct tty_struct *tty);
  375. void (*set_ldisc)(struct tty_struct *tty);
  376. void (*wait_until_sent)(struct tty_struct *tty, int timeout);
  377. void (*send_xchar)(struct tty_struct *tty, char ch);
  378. int (*tiocmget)(struct tty_struct *tty);
  379. int (*tiocmset)(struct tty_struct *tty,
  380. unsigned int set, unsigned int clear);
  381. int (*resize)(struct tty_struct *tty, struct winsize *ws);
  382. int (*get_icount)(struct tty_struct *tty,
  383. struct serial_icounter_struct *icount);
  384. int (*get_serial)(struct tty_struct *tty, struct serial_struct *p);
  385. int (*set_serial)(struct tty_struct *tty, struct serial_struct *p);
  386. void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m);
  387. #ifdef CONFIG_CONSOLE_POLL
  388. int (*poll_init)(struct tty_driver *driver, int line, char *options);
  389. int (*poll_get_char)(struct tty_driver *driver, int line);
  390. void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
  391. #endif
  392. int (*proc_show)(struct seq_file *m, void *driver);
  393. ANDROID_KABI_RESERVE(1);
  394. ANDROID_KABI_RESERVE(2);
  395. } __randomize_layout;
  396. /**
  397. * struct tty_driver -- driver for TTY devices
  398. *
  399. * @kref: reference counting. Reaching zero frees all the internals and the
  400. * driver.
  401. * @cdevs: allocated/registered character /dev devices
  402. * @owner: modules owning this driver. Used drivers cannot be rmmod'ed.
  403. * Automatically set by tty_alloc_driver().
  404. * @driver_name: name of the driver used in /proc/tty
  405. * @name: used for constructing /dev node name
  406. * @name_base: used as a number base for constructing /dev node name
  407. * @major: major /dev device number (zero for autoassignment)
  408. * @minor_start: the first minor /dev device number
  409. * @num: number of devices allocated
  410. * @type: type of tty driver (%TTY_DRIVER_TYPE_)
  411. * @subtype: subtype of tty driver (%SYSTEM_TYPE_, %PTY_TYPE_, %SERIAL_TYPE_)
  412. * @init_termios: termios to set to each tty initially (e.g. %tty_std_termios)
  413. * @flags: tty driver flags (%TTY_DRIVER_)
  414. * @proc_entry: proc fs entry, used internally
  415. * @other: driver of the linked tty; only used for the PTY driver
  416. * @ttys: array of active &struct tty_struct, set by tty_standard_install()
  417. * @ports: array of &struct tty_port; can be set during initialization by
  418. * tty_port_link_device() and similar
  419. * @termios: storage for termios at each TTY close for the next open
  420. * @driver_state: pointer to driver's arbitrary data
  421. * @ops: driver hooks for TTYs. Set them using tty_set_operations(). Use &struct
  422. * tty_port helpers in them as much as possible.
  423. * @tty_drivers: used internally to link tty_drivers together
  424. *
  425. * The usual handling of &struct tty_driver is to allocate it by
  426. * tty_alloc_driver(), set up all the necessary members, and register it by
  427. * tty_register_driver(). At last, the driver is torn down by calling
  428. * tty_unregister_driver() followed by tty_driver_kref_put().
  429. *
  430. * The fields required to be set before calling tty_register_driver() include
  431. * @driver_name, @name, @type, @subtype, @init_termios, and @ops.
  432. */
  433. struct tty_driver {
  434. struct kref kref;
  435. struct cdev **cdevs;
  436. struct module *owner;
  437. const char *driver_name;
  438. const char *name;
  439. int name_base;
  440. int major;
  441. int minor_start;
  442. unsigned int num;
  443. short type;
  444. short subtype;
  445. struct ktermios init_termios;
  446. unsigned long flags;
  447. struct proc_dir_entry *proc_entry;
  448. struct tty_driver *other;
  449. /*
  450. * Pointer to the tty data structures
  451. */
  452. struct tty_struct **ttys;
  453. struct tty_port **ports;
  454. struct ktermios **termios;
  455. void *driver_state;
  456. /*
  457. * Driver methods
  458. */
  459. const struct tty_operations *ops;
  460. struct list_head tty_drivers;
  461. ANDROID_KABI_RESERVE(1);
  462. ANDROID_KABI_RESERVE(2);
  463. } __randomize_layout;
  464. extern struct list_head tty_drivers;
  465. struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner,
  466. unsigned long flags);
  467. struct tty_driver *tty_find_polling_driver(char *name, int *line);
  468. void tty_driver_kref_put(struct tty_driver *driver);
  469. /* Use TTY_DRIVER_* flags below */
  470. #define tty_alloc_driver(lines, flags) \
  471. __tty_alloc_driver(lines, THIS_MODULE, flags)
  472. static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
  473. {
  474. kref_get(&d->kref);
  475. return d;
  476. }
  477. static inline void tty_set_operations(struct tty_driver *driver,
  478. const struct tty_operations *op)
  479. {
  480. driver->ops = op;
  481. }
  482. /**
  483. * DOC: TTY Driver Flags
  484. *
  485. * TTY_DRIVER_RESET_TERMIOS
  486. * Requests the tty layer to reset the termios setting when the last
  487. * process has closed the device. Used for PTYs, in particular.
  488. *
  489. * TTY_DRIVER_REAL_RAW
  490. * Indicates that the driver will guarantee not to set any special
  491. * character handling flags if this is set for the tty:
  492. *
  493. * ``(IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || !INPCK)``
  494. *
  495. * That is, if there is no reason for the driver to
  496. * send notifications of parity and break characters up to the line
  497. * driver, it won't do so. This allows the line driver to optimize for
  498. * this case if this flag is set. (Note that there is also a promise, if
  499. * the above case is true, not to signal overruns, either.)
  500. *
  501. * TTY_DRIVER_DYNAMIC_DEV
  502. * The individual tty devices need to be registered with a call to
  503. * tty_register_device() when the device is found in the system and
  504. * unregistered with a call to tty_unregister_device() so the devices will
  505. * be show up properly in sysfs. If not set, all &tty_driver.num entries
  506. * will be created by the tty core in sysfs when tty_register_driver() is
  507. * called. This is to be used by drivers that have tty devices that can
  508. * appear and disappear while the main tty driver is registered with the
  509. * tty core.
  510. *
  511. * TTY_DRIVER_DEVPTS_MEM
  512. * Don't use the standard arrays (&tty_driver.ttys and
  513. * &tty_driver.termios), instead use dynamic memory keyed through the
  514. * devpts filesystem. This is only applicable to the PTY driver.
  515. *
  516. * TTY_DRIVER_HARDWARE_BREAK
  517. * Hardware handles break signals. Pass the requested timeout to the
  518. * &tty_operations.break_ctl instead of using a simple on/off interface.
  519. *
  520. * TTY_DRIVER_DYNAMIC_ALLOC
  521. * Do not allocate structures which are needed per line for this driver
  522. * (&tty_driver.ports) as it would waste memory. The driver will take
  523. * care. This is only applicable to the PTY driver.
  524. *
  525. * TTY_DRIVER_UNNUMBERED_NODE
  526. * Do not create numbered ``/dev`` nodes. For example, create
  527. * ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a
  528. * driver for a single tty device is being allocated.
  529. */
  530. #define TTY_DRIVER_INSTALLED 0x0001
  531. #define TTY_DRIVER_RESET_TERMIOS 0x0002
  532. #define TTY_DRIVER_REAL_RAW 0x0004
  533. #define TTY_DRIVER_DYNAMIC_DEV 0x0008
  534. #define TTY_DRIVER_DEVPTS_MEM 0x0010
  535. #define TTY_DRIVER_HARDWARE_BREAK 0x0020
  536. #define TTY_DRIVER_DYNAMIC_ALLOC 0x0040
  537. #define TTY_DRIVER_UNNUMBERED_NODE 0x0080
  538. /* tty driver types */
  539. #define TTY_DRIVER_TYPE_SYSTEM 0x0001
  540. #define TTY_DRIVER_TYPE_CONSOLE 0x0002
  541. #define TTY_DRIVER_TYPE_SERIAL 0x0003
  542. #define TTY_DRIVER_TYPE_PTY 0x0004
  543. #define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */
  544. #define TTY_DRIVER_TYPE_SYSCONS 0x0006
  545. /* system subtypes (magic, used by tty_io.c) */
  546. #define SYSTEM_TYPE_TTY 0x0001
  547. #define SYSTEM_TYPE_CONSOLE 0x0002
  548. #define SYSTEM_TYPE_SYSCONS 0x0003
  549. #define SYSTEM_TYPE_SYSPTMX 0x0004
  550. /* pty subtypes (magic, used by tty_io.c) */
  551. #define PTY_TYPE_MASTER 0x0001
  552. #define PTY_TYPE_SLAVE 0x0002
  553. /* serial subtype definitions */
  554. #define SERIAL_TYPE_NORMAL 1
  555. int tty_register_driver(struct tty_driver *driver);
  556. void tty_unregister_driver(struct tty_driver *driver);
  557. struct device *tty_register_device(struct tty_driver *driver, unsigned index,
  558. struct device *dev);
  559. struct device *tty_register_device_attr(struct tty_driver *driver,
  560. unsigned index, struct device *device, void *drvdata,
  561. const struct attribute_group **attr_grp);
  562. void tty_unregister_device(struct tty_driver *driver, unsigned index);
  563. #ifdef CONFIG_PROC_FS
  564. void proc_tty_register_driver(struct tty_driver *);
  565. void proc_tty_unregister_driver(struct tty_driver *);
  566. #else
  567. static inline void proc_tty_register_driver(struct tty_driver *d) {}
  568. static inline void proc_tty_unregister_driver(struct tty_driver *d) {}
  569. #endif
  570. #endif /* #ifdef _LINUX_TTY_DRIVER_H */