mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
tty: tty abstraction initial implementation
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#define DEV_MAJOR_NULL 1
|
||||
#define DEV_MAJOR_FULL 2
|
||||
#define DEV_MAJOR_ZERO 3
|
||||
#define DEV_MAJOR_CONSOLE 4
|
||||
#define DEV_MAJOR_TTY 4
|
||||
#define DEV_MAJOR_FB 5
|
||||
#define DEV_MAJOR_KEYBOARD 6
|
||||
#define DEV_MAJOR_BLOCK 7
|
||||
@@ -17,6 +17,7 @@
|
||||
#define DEV_MAJOR_URANDOM 9
|
||||
#define DEV_MAJOR_NET 10
|
||||
#define DEV_MAJOR_MOUSE 11
|
||||
#define DEV_MAJOR_CONSOLE 12
|
||||
|
||||
typedef struct {
|
||||
int (*open)(int minor, int flags);
|
||||
@@ -29,6 +30,7 @@ typedef struct {
|
||||
int (*isatty)(int minor);
|
||||
int (*ioctl)(int minor, unsigned long request, void *arg, int *result);
|
||||
int (*maxseek)(int minor, size_t *max);
|
||||
void (*inactive)(int minor);
|
||||
} devops_t;
|
||||
|
||||
typedef struct devnode_t {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef _TTY_H
|
||||
#define _TTY_H
|
||||
|
||||
#include <mutex.h>
|
||||
#include <termios.h>
|
||||
#include <kernel/poll.h>
|
||||
#include <ringbuffer.h>
|
||||
|
||||
#define DEVICE_BUFFER_SIZE 512
|
||||
#define READ_BUFFER_SIZE 4096
|
||||
|
||||
typedef void (*ttydevicewritefn_t)(char *str, size_t size);
|
||||
|
||||
typedef struct {
|
||||
pollheader_t pollheader;
|
||||
char *name;
|
||||
ringbuffer_t readbuffer;
|
||||
mutex_t readmutex;
|
||||
mutex_t writemutex;
|
||||
termios_t termios;
|
||||
char *devicebuffer;
|
||||
int devicepos;
|
||||
ttydevicewritefn_t writetodevice;
|
||||
int minor;
|
||||
winsize_t winsize;
|
||||
} tty_t;
|
||||
|
||||
void tty_init();
|
||||
tty_t *tty_create(char *name, ttydevicewritefn_t fn);
|
||||
void tty_destroy(char *name, tty_t *tty);
|
||||
void tty_process(tty_t *tty, char c);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user