miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Toggle main menu visibility
Loading...
Searching...
No Matches
tty.h
Go to the documentation of this file.
1
// MIT License
2
//
3
// Copyright (c) 2026 Christian Spoo
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
34
35
#ifndef _MINIOS_DRIVERS_TTY_H_
36
#define _MINIOS_DRIVERS_TTY_H_
37
38
#include <
miniOS/types.h
>
39
40
#define TTY_LFLAG_ISIG 0x0001u
41
#define TTY_LFLAG_ICANON 0x0002u
42
#define TTY_LFLAG_ECHO 0x0008u
43
44
#define VINTR 0
45
#define VEOF 1
46
#define TTY_NCCS 8
47
48
#define TCGETS 0x5401UL
49
#define TCSETS 0x5402UL
50
#define TCSETSW 0x5403UL
51
#define TCSETSF 0x5404UL
52
#define TIOCSCTTY 0x540EUL
53
#define TIOCGPGRP 0x540FUL
/* get foreground process group id */
54
#define TIOCSPGRP 0x5410UL
/* set foreground process group id */
55
#define TIOCGWINSZ 0x5413UL
56
#define TIOCNOTTY 0x5422UL
57
58
struct
minios_termios
{
59
uint32_t
c_iflag
;
60
uint32_t
c_oflag
;
61
uint32_t
c_cflag
;
62
uint32_t
c_lflag
;
63
uint8_t
c_cc
[
TTY_NCCS
];
64
};
65
66
struct
minios_winsize
{
67
uint16_t
ws_row
;
68
uint16_t
ws_col
;
69
uint16_t
ws_xpixel
;
70
uint16_t
ws_ypixel
;
71
};
72
81
void
tty_init
(
void
);
82
93
void
tty_keyboard_input
(
char
c);
94
104
void
tty_inject_escape
(
const
char
*seq,
int
len
);
105
110
int
tty_has_data
(
void
);
111
124
int
tty_read
(
void
*buf,
uint32_t
len
,
int
nonblock);
125
136
int
tty_write
(
const
void
*buf,
uint32_t
len
);
137
152
int
tty_ioctl
(
uint64_t
cmd,
uint64_t
arg);
153
163
int
tty_isatty_fd
(
int
fd
);
164
166
167
#endif
/* _MINIOS_DRIVERS_TTY_H_ */
tty_init
void tty_init(void)
Sets up the canonical input ring buffer, initialises the default termios (c_lflag = ICANON|ECHO|ISIG,...
Definition
tty.c:165
TTY_NCCS
#define TTY_NCCS
Definition
tty.h:46
tty_write
int tty_write(const void *buf, uint32_t len)
Forwards each byte to vt_write_byte(), which handles ANSI/VT escape sequence parsing and VGA cell ren...
Definition
tty.c:294
tty_ioctl
int tty_ioctl(uint64_t cmd, uint64_t arg)
TCGETS: copies current termios to *arg. TCSETS/TCSETSW: copies termios from *arg into the kernel TTY ...
Definition
tty.c:304
tty_inject_escape
void tty_inject_escape(const char *seq, int len)
Definition
tty.c:181
tty_isatty_fd
int tty_isatty_fd(int fd)
Returns 1 if the fd's vfs_file entry has ftype == VFS_FILE_TYPE_CHAR and device_type == VFS_DEVICE_TT...
Definition
tty.c:364
tty_has_data
int tty_has_data(void)
Definition
tty.c:173
tty_keyboard_input
void tty_keyboard_input(char c)
In canonical mode (ICANON set): appends to the line buffer; on newline or VEOF flushes the complete l...
Definition
tty.c:189
tty_read
int tty_read(void *buf, uint32_t len, int nonblock)
In canonical mode: blocks (or returns -EAGAIN if nonblock) until a complete line is available,...
Definition
tty.c:254
minios_termios
Definition
tty.h:58
minios_termios::c_oflag
uint32_t c_oflag
Definition
tty.h:60
minios_termios::c_cc
uint8_t c_cc[TTY_NCCS]
Definition
tty.h:63
minios_termios::c_lflag
uint32_t c_lflag
Definition
tty.h:62
minios_termios::c_cflag
uint32_t c_cflag
Definition
tty.h:61
minios_termios::c_iflag
uint32_t c_iflag
Definition
tty.h:59
minios_winsize
Definition
tty.h:66
minios_winsize::ws_xpixel
uint16_t ws_xpixel
Definition
tty.h:69
minios_winsize::ws_ypixel
uint16_t ws_ypixel
Definition
tty.h:70
minios_winsize::ws_col
uint16_t ws_col
Definition
tty.h:68
minios_winsize::ws_row
uint16_t ws_row
Definition
tty.h:67
fd
int fd
Definition
syscall_fs.c:0
types.h
uint16_t
unsigned short uint16_t
Definition
types.h:31
uint32_t
unsigned int uint32_t
Definition
types.h:34
uint64_t
unsigned long int uint64_t
Definition
types.h:37
uint8_t
unsigned char uint8_t
Definition
types.h:28
len
uint32_t len
Definition
virtio_net.c:1
include
miniOS
drivers
tty.h
Generated by
1.18.0