Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_TTY_BUFFER_H
0003 #define _LINUX_TTY_BUFFER_H
0004 
0005 #include <linux/atomic.h>
0006 #include <linux/llist.h>
0007 #include <linux/mutex.h>
0008 #include <linux/workqueue.h>
0009 
0010 struct tty_buffer {
0011     union {
0012         struct tty_buffer *next;
0013         struct llist_node free;
0014     };
0015     int used;
0016     int size;
0017     int commit;
0018     int lookahead;      /* Lazy update on recv, can become less than "read" */
0019     int read;
0020     int flags;
0021     /* Data points here */
0022     unsigned long data[];
0023 };
0024 
0025 /* Values for .flags field of tty_buffer */
0026 #define TTYB_NORMAL 1   /* buffer has no flags buffer */
0027 
0028 static inline unsigned char *char_buf_ptr(struct tty_buffer *b, int ofs)
0029 {
0030     return ((unsigned char *)b->data) + ofs;
0031 }
0032 
0033 static inline char *flag_buf_ptr(struct tty_buffer *b, int ofs)
0034 {
0035     return (char *)char_buf_ptr(b, ofs) + b->size;
0036 }
0037 
0038 struct tty_bufhead {
0039     struct tty_buffer *head;    /* Queue head */
0040     struct work_struct work;
0041     struct mutex       lock;
0042     atomic_t       priority;
0043     struct tty_buffer sentinel;
0044     struct llist_head free;     /* Free queue head */
0045     atomic_t       mem_used;    /* In-use buffers excluding free list */
0046     int        mem_limit;
0047     struct tty_buffer *tail;    /* Active buffer */
0048 };
0049 
0050 /*
0051  * When a break, frame error, or parity error happens, these codes are
0052  * stuffed into the flags buffer.
0053  */
0054 #define TTY_NORMAL  0
0055 #define TTY_BREAK   1
0056 #define TTY_FRAME   2
0057 #define TTY_PARITY  3
0058 #define TTY_OVERRUN 4
0059 
0060 #endif