line.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. .lock = SPIN_LOCK_UNLOCKED, \
  58. .driver = d }
  59. struct lines {
  60. int num;
  61. };
  62. #define LINES_INIT(n) { .num = n }
  63. extern void line_close(struct tty_struct *tty, struct file * filp);
  64. extern int line_open(struct line *lines, struct tty_struct *tty);
  65. extern int line_setup(struct line *lines, unsigned int sizeof_lines,
  66. char *init);
  67. extern int line_write(struct tty_struct *tty, const unsigned char *buf,
  68. int len);
  69. extern void line_put_char(struct tty_struct *tty, unsigned char ch);
  70. extern void line_set_termios(struct tty_struct *tty, struct termios * old);
  71. extern int line_chars_in_buffer(struct tty_struct *tty);
  72. extern void line_flush_buffer(struct tty_struct *tty);
  73. extern void line_flush_chars(struct tty_struct *tty);
  74. extern int line_write_room(struct tty_struct *tty);
  75. extern int line_ioctl(struct tty_struct *tty, struct file * file,
  76. unsigned int cmd, unsigned long arg);
  77. extern void line_throttle(struct tty_struct *tty);
  78. extern void line_unthrottle(struct tty_struct *tty);
  79. extern char *add_xterm_umid(char *base);
  80. extern int line_setup_irq(int fd, int input, int output, struct line *line,
  81. void *data);
  82. extern void line_close_chan(struct line *line);
  83. extern struct tty_driver * line_register_devfs(struct lines *set,
  84. struct line_driver *line_driver,
  85. struct tty_operations *driver,
  86. struct line *lines,
  87. int nlines);
  88. extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
  89. extern void close_lines(struct line *lines, int nlines);
  90. extern int line_config(struct line *lines, unsigned int sizeof_lines,
  91. char *str, struct chan_opts *opts);
  92. extern int line_id(char **str, int *start_out, int *end_out);
  93. extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n);
  94. extern int line_get_config(char *dev, struct line *lines,
  95. unsigned int sizeof_lines, char *str,
  96. int size, char **error_out);
  97. #endif