tty.h

来自「别人的根据linux0.11改的一个小的操作系统」· C头文件 代码 · 共 54 行

H
54
字号
/* 
 * tty.h
 *
 */
#ifndef	_TTY_H
#define _TTY_H
/*************************************************
 *queue
 *used for console read and write
 ************************************************/
#define MAX_CHAR	64         /* Max buffer count is 64. */
struct _queue{
	char data[MAX_CHAR];       /* Queue data area. */
	char head;                 /* Head pointer,point to the queue first element. */
	char tail;                 /* Tail pointer,point to the queue last element. */
};
#define	EMPTY(q)	(((q).head%MAX_CHAR)==((q).tail%MAX_CHAR))
#define FULL(q)		((((q).tail%MAX_CHAR)-((q).head%MAX_CHAR))==MAX_CHAR)
void put_queue(struct _queue *,char);   /* Write a element into the queue. */
char get_queue(struct _queue *);        /* Read a element from the queue. */

/************************************************
 *terminal flags
 *mark the flags whether be seted...
 ***********************************************/
struct _termflags{
	unsigned char f_echo;
};
/************************************************
 *tty structure
 *
 ***********************************************/
struct _tty_struct{
	struct _termflags flags;
	struct _queue raw;
	struct _queue final;
	void (*write)();
};

struct _tty_struct tty[3];

void tty_init();
void con_read(struct _tty_struct *);
void con_write(struct _tty_struct *);

void con_init();
void drv_init();

extern void kb_interrupt();                 /* Keyboard interrupt routine. */
void do_kb_interrupt(char);                 /* Keyboard interrupt will call this routine. */
void do_tty_interrupt(struct _tty_struct *);/* Process tty. */

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?