vbos/include/kernel/tty.h
Michael Shaw 1d1dad34ce boot: fix crash on early memory allocations
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
2026-08-11 18:29:51 -04:00

56 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _TTY_H_
#define _TTY_H_
#include <kernel/device.h>
#include <kernel/proc.h>
#include <lib/ringbuf.h>
#define NCCS 20
typedef u32 tcflag_t;
typedef char cc_t;
struct termios {
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t c_cc[NCCS];
};
struct tty_serial_ops {
void (*serial_putchar)(struct tty *tty, char c);
char (*serial_getchar)(struct tty *tty);
};
struct tty {
dev_t dev;
void *priv;
struct tty_serial_ops serial_ops;
struct ringbuf *input_buf;
struct ringbuf *output_buf;
pid_t fg_proc;
};
struct tty *tty_create(const char *name, void *priv);
void tty_putchar(struct tty *tty, char c);
char tty_getchar(struct tty *tty);
void tty_write(struct tty *tty, const char *s);
void arch_serial_write(struct tty *tty, char c);
char arch_serial_read(struct tty *tty);
void tty_send_dsr(struct tty *tty);
void tty_set_origin_mode(struct tty *tty);
void tty_clear_screen(struct tty *tty);
void tty_set_cursor_pos(struct tty *tty, int x, int y);
void tty_get_cursor_pos(struct tty *tty, int *row, int *col);
void tty_get_size(struct tty *tty, int *rows, int *cols);
void tty_setlf(struct tty *tty);
struct tty *tty_tee_create(const char *name);
void tty_tee_add(struct tty *tee, struct tty *child);
void tty_tee_remove(struct tty *tee, struct tty *child);
#endif /* _TTY_H_ */