line.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
  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 int read_irq;
  24. const char *read_irq_name;
  25. const int write_irq;
  26. const char *write_irq_name;
  27. struct mc_device mc;
  28. struct tty_driver *driver;
  29. };
  30. struct line {
  31. struct tty_port port;
  32. int valid;
  33. char *init_str;
  34. struct list_head chan_list;
  35. struct chan *chan_in, *chan_out;
  36. /*This lock is actually, mostly, local to*/
  37. spinlock_t lock;
  38. int throttled;
  39. /* Yes, this is a real circular buffer.
  40. * XXX: And this should become a struct kfifo!
  41. *
  42. * buffer points to a buffer allocated on demand, of length
  43. * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
  44. char *buffer;
  45. char *head;
  46. char *tail;
  47. int sigio;
  48. struct delayed_work task;
  49. const struct line_driver *driver;
  50. };
  51. extern void line_close(struct tty_struct *tty, struct file * filp);
  52. extern int line_open(struct tty_struct *tty, struct file *filp);
  53. extern int line_install(struct tty_driver *driver, struct tty_struct *tty,
  54. struct line *line);
  55. extern void line_cleanup(struct tty_struct *tty);
  56. extern void line_hangup(struct tty_struct *tty);
  57. extern int line_setup(char **conf, unsigned nlines, char **def,
  58. char *init, char *name);
  59. extern int line_write(struct tty_struct *tty, const unsigned char *buf,
  60. int len);
  61. extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
  62. extern int line_chars_in_buffer(struct tty_struct *tty);
  63. extern void line_flush_buffer(struct tty_struct *tty);
  64. extern void line_flush_chars(struct tty_struct *tty);
  65. extern int line_write_room(struct tty_struct *tty);
  66. extern void line_throttle(struct tty_struct *tty);
  67. extern void line_unthrottle(struct tty_struct *tty);
  68. extern char *add_xterm_umid(char *base);
  69. extern int line_setup_irq(int fd, int input, int output, struct line *line,
  70. void *data);
  71. extern void line_close_chan(struct line *line);
  72. extern int register_lines(struct line_driver *line_driver,
  73. const struct tty_operations *driver,
  74. struct line *lines, int nlines);
  75. extern int setup_one_line(struct line *lines, int n, char *init,
  76. const struct chan_opts *opts, char **error_out);
  77. extern void close_lines(struct line *lines, int nlines);
  78. extern int line_config(struct line *lines, unsigned int sizeof_lines,
  79. char *str, const struct chan_opts *opts,
  80. char **error_out);
  81. extern int line_id(char **str, int *start_out, int *end_out);
  82. extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
  83. char **error_out);
  84. extern int line_get_config(char *dev, struct line *lines,
  85. unsigned int sizeof_lines, char *str,
  86. int size, char **error_out);
  87. #endif