line.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2001, 2002 Jeff Dike ([email protected])
  4. */
  5. #ifndef __LINE_H__
  6. #define __LINE_H__
  7. #include <linux/list.h>
  8. #include <linux/workqueue.h>
  9. #include <linux/tty.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/mutex.h>
  13. #include "chan_user.h"
  14. #include "mconsole_kern.h"
  15. /* There's only two modifiable fields in this - .mc.list and .driver */
  16. struct line_driver {
  17. const char *name;
  18. const char *device_name;
  19. const short major;
  20. const short minor_start;
  21. const short type;
  22. const short subtype;
  23. const char *read_irq_name;
  24. const char *write_irq_name;
  25. struct mc_device mc;
  26. struct tty_driver *driver;
  27. };
  28. struct line {
  29. struct tty_port port;
  30. int valid;
  31. int read_irq, write_irq;
  32. char *init_str;
  33. struct list_head chan_list;
  34. struct chan *chan_in, *chan_out;
  35. /*This lock is actually, mostly, local to*/
  36. spinlock_t lock;
  37. int throttled;
  38. /* Yes, this is a real circular buffer.
  39. * XXX: And this should become a struct kfifo!
  40. *
  41. * buffer points to a buffer allocated on demand, of length
  42. * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
  43. char *buffer;
  44. char *head;
  45. char *tail;
  46. int sigio;
  47. struct delayed_work task;
  48. const struct line_driver *driver;
  49. };
  50. extern void line_close(struct tty_struct *tty, struct file * filp);
  51. extern int line_open(struct tty_struct *tty, struct file *filp);
  52. extern int line_install(struct tty_driver *driver, struct tty_struct *tty,
  53. struct line *line);
  54. extern void line_cleanup(struct tty_struct *tty);
  55. extern void line_hangup(struct tty_struct *tty);
  56. extern int line_setup(char **conf, unsigned nlines, char **def,
  57. char *init, char *name);
  58. extern int line_write(struct tty_struct *tty, const unsigned char *buf,
  59. int len);
  60. extern unsigned int line_chars_in_buffer(struct tty_struct *tty);
  61. extern void line_flush_buffer(struct tty_struct *tty);
  62. extern void line_flush_chars(struct tty_struct *tty);
  63. extern unsigned int line_write_room(struct tty_struct *tty);
  64. extern void line_throttle(struct tty_struct *tty);
  65. extern void line_unthrottle(struct tty_struct *tty);
  66. extern char *add_xterm_umid(char *base);
  67. extern int line_setup_irq(int fd, int input, int output, struct line *line,
  68. void *data);
  69. extern void line_close_chan(struct line *line);
  70. extern int register_lines(struct line_driver *line_driver,
  71. const struct tty_operations *driver,
  72. struct line *lines, int nlines);
  73. extern int setup_one_line(struct line *lines, int n, char *init,
  74. const struct chan_opts *opts, char **error_out);
  75. extern void close_lines(struct line *lines, int nlines);
  76. extern int line_config(struct line *lines, unsigned int sizeof_lines,
  77. char *str, const struct chan_opts *opts,
  78. char **error_out);
  79. extern int line_id(char **str, int *start_out, int *end_out);
  80. extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
  81. char **error_out);
  82. extern int line_get_config(char *dev, struct line *lines,
  83. unsigned int sizeof_lines, char *str,
  84. int size, char **error_out);
  85. #endif