line.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. char *init_str;
  32. int init_pri;
  33. struct list_head chan_list;
  34. int valid;
  35. int count;
  36. /*This lock is actually, mostly, local to*/
  37. spinlock_t lock;
  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 work_struct task;
  48. struct line_driver *driver;
  49. int have_irq;
  50. };
  51. #define LINE_INIT(str, d) \
  52. { init_str : str, \
  53. init_pri : INIT_STATIC, \
  54. chan_list : { }, \
  55. valid : 1, \
  56. buffer : NULL, \
  57. head : NULL, \
  58. tail : NULL, \
  59. sigio : 0, \
  60. driver : d, \
  61. have_irq : 0 }
  62. struct lines {
  63. int num;
  64. };
  65. #define LINES_INIT(n) { num : n }
  66. extern void line_close(struct tty_struct *tty, struct file * filp);
  67. extern int line_open(struct line *lines, struct tty_struct *tty,
  68. struct chan_opts *opts);
  69. extern int line_setup(struct line *lines, unsigned int sizeof_lines, char *init,
  70. int all_allowed);
  71. extern int line_write(struct tty_struct *tty, const unsigned char *buf, int len);
  72. extern void line_put_char(struct tty_struct *tty, unsigned char ch);
  73. extern void line_set_termios(struct tty_struct *tty, struct termios * old);
  74. extern int line_chars_in_buffer(struct tty_struct *tty);
  75. extern void line_flush_buffer(struct tty_struct *tty);
  76. extern void line_flush_chars(struct tty_struct *tty);
  77. extern int line_write_room(struct tty_struct *tty);
  78. extern int line_ioctl(struct tty_struct *tty, struct file * file,
  79. unsigned int cmd, unsigned long arg);
  80. extern char *add_xterm_umid(char *base);
  81. extern int line_setup_irq(int fd, int input, int output, struct tty_struct *tty);
  82. extern void line_close_chan(struct line *line);
  83. extern void line_disable(struct tty_struct *tty, int current_irq);
  84. extern struct tty_driver * line_register_devfs(struct lines *set,
  85. struct line_driver *line_driver,
  86. struct tty_operations *driver,
  87. struct line *lines,
  88. int nlines);
  89. extern void lines_init(struct line *lines, int nlines);
  90. extern void close_lines(struct line *lines, int nlines);
  91. extern int line_config(struct line *lines, unsigned int sizeof_lines, char *str);
  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, unsigned int sizeof_lines, char *str,
  95. int size, char **error_out);
  96. #endif