line.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 "chan_user.h"
  13. #include "mconsole_kern.h"
  14. struct line_driver {
  15. char *name;
  16. char *device_name;
  17. char *devfs_name;
  18. short major;
  19. short minor_start;
  20. short type;
  21. short subtype;
  22. int read_irq;
  23. char *read_irq_name;
  24. int write_irq;
  25. char *write_irq_name;
  26. char *symlink_from;
  27. char *symlink_to;
  28. struct mc_device mc;
  29. };
  30. struct line {
  31. struct tty_struct *tty;
  32. char *init_str;
  33. int init_pri;
  34. struct list_head chan_list;
  35. int valid;
  36. int count;
  37. int throttled;
  38. /*This lock is actually, mostly, local to*/
  39. spinlock_t lock;
  40. /* Yes, this is a real circular buffer.
  41. * XXX: And this should become a struct kfifo!
  42. *
  43. * buffer points to a buffer allocated on demand, of length
  44. * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
  45. char *buffer;
  46. char *head;
  47. char *tail;
  48. int sigio;
  49. struct work_struct task;
  50. struct line_driver *driver;
  51. int have_irq;
  52. };
  53. #define LINE_INIT(str, d) \
  54. { init_str : str, \
  55. init_pri : INIT_STATIC, \
  56. valid : 1, \
  57. throttled : 0, \
  58. lock : SPIN_LOCK_UNLOCKED, \
  59. buffer : NULL, \
  60. head : NULL, \
  61. tail : NULL, \
  62. sigio : 0, \
  63. driver : d, \
  64. have_irq : 0 }
  65. struct lines {
  66. int num;
  67. };
  68. #define LINES_INIT(n) { num : n }
  69. extern void line_close(struct tty_struct *tty, struct file * filp);
  70. extern int line_open(struct line *lines, struct tty_struct *tty);
  71. extern int line_setup(struct line *lines, unsigned int sizeof_lines,
  72. char *init);
  73. extern int line_write(struct tty_struct *tty, const unsigned char *buf,
  74. int len);
  75. extern void line_put_char(struct tty_struct *tty, unsigned char ch);
  76. extern void line_set_termios(struct tty_struct *tty, struct termios * old);
  77. extern int line_chars_in_buffer(struct tty_struct *tty);
  78. extern void line_flush_buffer(struct tty_struct *tty);
  79. extern void line_flush_chars(struct tty_struct *tty);
  80. extern int line_write_room(struct tty_struct *tty);
  81. extern int line_ioctl(struct tty_struct *tty, struct file * file,
  82. unsigned int cmd, unsigned long arg);
  83. extern void line_throttle(struct tty_struct *tty);
  84. extern void line_unthrottle(struct tty_struct *tty);
  85. extern char *add_xterm_umid(char *base);
  86. extern int line_setup_irq(int fd, int input, int output, struct line *line,
  87. void *data);
  88. extern void line_close_chan(struct line *line);
  89. extern struct tty_driver * line_register_devfs(struct lines *set,
  90. struct line_driver *line_driver,
  91. struct tty_operations *driver,
  92. struct line *lines,
  93. int nlines);
  94. extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
  95. extern void close_lines(struct line *lines, int nlines);
  96. extern int line_config(struct line *lines, unsigned int sizeof_lines,
  97. char *str, struct chan_opts *opts);
  98. extern int line_id(char **str, int *start_out, int *end_out);
  99. extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n);
  100. extern int line_get_config(char *dev, struct line *lines,
  101. unsigned int sizeof_lines, char *str,
  102. int size, char **error_out);
  103. #endif