Fork me on GitHub

root/include/fiwix/tty.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * fiwix/include/fiwix/tty.h
   3  *
   4  * Copyright 2018-2021, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #ifndef _FIWIX_TTY_H
   9 #define _FIWIX_TTY_H
  10 
  11 #include <fiwix/termios.h>
  12 #include <fiwix/fs.h>
  13 #include <fiwix/console.h>
  14 #include <fiwix/serial.h>
  15 
  16 #define NR_TTYS         NR_VCONSOLES + NR_SERIAL
  17 
  18 #define CBSIZE          32      /* number of characters in cblock */
  19 #define NR_CB_QUEUE     8       /* number of cblocks per queue */
  20 #define CB_POOL_SIZE    128     /* number of cblocks in the central pool */
  21 
  22 #define TAB_SIZE        8
  23 #define MAX_TAB_COLS    132     /* maximum number of tab stops */
  24 
  25 #define LAST_CHAR(q)    ((q)->tail ? (q)->tail->data[(q)->tail->end_off - 1] : NULL)
  26 
  27 struct clist {
  28         unsigned short int count;
  29         unsigned short int cb_num;
  30         struct cblock *head;
  31         struct cblock *tail;
  32 };
  33 
  34 struct cblock {
  35         unsigned short int start_off;
  36         unsigned short int end_off;
  37         unsigned char data[CBSIZE];
  38         struct cblock *prev;
  39         struct cblock *next;
  40 };
  41 
  42 struct kbd_state {
  43         char mode;
  44 };
  45 
  46 struct tty {
  47         __dev_t dev;
  48         struct clist read_q;
  49         struct clist cooked_q;
  50         struct clist write_q;
  51         short int count;
  52         struct termios termios;
  53         struct winsize winsize;
  54         struct kbd_state kbd;
  55         __pid_t pid, pgid, sid;
  56         unsigned char lnext;
  57         void *driver_data;
  58         int canon_data;
  59         char tab_stop[132];
  60         int column;
  61 
  62         /* formerly tty driver operations */
  63         void (*stop)(struct tty *);
  64         void (*start)(struct tty *);
  65         void (*deltab)(struct tty *);
  66         void (*reset)(struct tty *);
  67         void (*input)(struct tty *);
  68         void (*output)(struct tty *);
  69         int (*open)(struct tty *);
  70         int (*close)(struct tty *);
  71         void (*set_termios)(struct tty *);
  72 };
  73 extern struct tty tty_table[];
  74 
  75 int register_tty(__dev_t);
  76 struct tty * get_tty(__dev_t);
  77 void disassociate_ctty(struct tty *);
  78 void termios_reset(struct tty *);
  79 void do_cook(struct tty *);
  80 int tty_putchar(struct tty *, unsigned char);
  81 int tty_open(struct inode *, struct fd *);
  82 int tty_close(struct inode *, struct fd *);
  83 int tty_read(struct inode *, struct fd *, char *, __size_t);
  84 int tty_write(struct inode *, struct fd *, const char *, __size_t);
  85 int tty_ioctl(struct inode *, int cmd, unsigned long int);
  86 int tty_lseek(struct inode *, __off_t);
  87 int tty_select(struct inode *, int);
  88 void tty_init(void);
  89 
  90 int tty_queue_putchar(struct tty *, struct clist *, unsigned char);
  91 int tty_queue_unputchar(struct clist *);
  92 unsigned char tty_queue_getchar(struct clist *);
  93 void tty_queue_flush(struct clist *);
  94 int tty_queue_room(struct clist *q);
  95 void tty_queue_init(void);
  96 
  97 int vt_ioctl(struct tty *, int, unsigned long int);
  98 
  99 #endif /* _FIWIX_TTY_H */

/* [previous][next][first][last][top][bottom][index][help] */