line.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  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 one modifiable field in this - .mc.list */
  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. };
  29. struct line {
  30. struct tty_struct *tty;
  31. spinlock_t count_lock;
  32. int valid;
  33. char *init_str;
  34. int init_pri;
  35. struct list_head chan_list;
  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. int have_irq;
  51. };
  52. #define LINE_INIT(str, d) \
  53. { .count_lock = SPIN_LOCK_UNLOCKED, \
  54. .init_str = str, \
  55. .init_pri = INIT_STATIC, \
  56. .valid = 1, \
  57. .lock = SPIN_LOCK_UNLOCKED, \
  58. .driver = d }
  59. extern void line_close(struct tty_struct *tty, struct file * filp);
  60. extern int line_open(struct line *lines, struct tty_struct *tty);
  61. extern int line_setup(struct line *lines, unsigned int sizeof_lines,
  62. char *init, char **error_out);
  63. extern int line_write(struct tty_struct *tty, const unsigned char *buf,
  64. int len);
  65. extern void line_put_char(struct tty_struct *tty, unsigned char ch);
  66. extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
  67. extern int line_chars_in_buffer(struct tty_struct *tty);
  68. extern void line_flush_buffer(struct tty_struct *tty);
  69. extern void line_flush_chars(struct tty_struct *tty);
  70. extern int line_write_room(struct tty_struct *tty);
  71. extern int line_ioctl(struct tty_struct *tty, struct file * file,
  72. unsigned int cmd, unsigned long arg);
  73. extern void line_throttle(struct tty_struct *tty);
  74. extern void line_unthrottle(struct tty_struct *tty);
  75. extern char *add_xterm_umid(char *base);
  76. extern int line_setup_irq(int fd, int input, int output, struct line *line,
  77. void *data);
  78. extern void line_close_chan(struct line *line);
  79. extern struct tty_driver *register_lines(struct line_driver *line_driver,
  80. const struct tty_operations *driver,
  81. struct line *lines, int nlines);
  82. extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
  83. extern void close_lines(struct line *lines, int nlines);
  84. extern int line_config(struct line *lines, unsigned int sizeof_lines,
  85. char *str, const struct chan_opts *opts,
  86. char **error_out);
  87. extern int line_id(char **str, int *start_out, int *end_out);
  88. extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
  89. char **error_out);
  90. extern int line_get_config(char *dev, struct line *lines,
  91. unsigned int sizeof_lines, char *str,
  92. int size, char **error_out);
  93. #endif