21#define TIOCGWINSZ 0x5413
72 memcopy(priv->input_buffer + priv->line_buff_tail, &input->code,
75 priv->line_buff_tail =
76 (priv->line_buff_tail +
sizeof(
uint16_t)) & (1024 - 1);
87 for (
int i = 0; i < VOXIA_TTY_MAX_COUNT; i++) {
136 size_t bytes_read = 0;
138 while (bytes_read <
len) {
141 int empty = (priv->
head == priv->
tail);
151 thr->in_kernel_sleep =
true;
162 while (bytes_read < len && priv->
head != priv->
tail) {
164 priv->
head = (priv->
head + 1) & (1024 - 1);
170 return (
int)bytes_read;
187 (priv->tail - priv->head) & (VOXIA_TTY_INPUT_BUFFER_SIZE - 1);
188 size_t available = VOXIA_TTY_INPUT_BUFFER_SIZE - 1 -
used;
192 auto tail = priv->tail;
193 size_t first_chunk = VOXIA_TTY_INPUT_BUFFER_SIZE -
tail;
195 if (
len <= first_chunk) {
200 (
uint8_t*)buf + first_chunk,
len - first_chunk);
203 priv->tail = (
tail +
len) & (VOXIA_TTY_INPUT_BUFFER_SIZE - 1);
217 vxnamei(path_name->c_str, curr_dentry);
223 (*curr_dentry)->vnode =
vnode;
225 (*curr_dentry)->vnode->permission = 660;
228 (*curr_dentry)->vnode->device.major = dev->major;
229 (*curr_dentry)->vnode->device.minor = dev->minor;
230 (*curr_dentry)->vnode->mountedhere = dev;
234 (*curr_dentry)->vnode->vnode_private = priv;
242 priv->line_buff_tail = 0;
243 priv->line_buff_head = 0;
265 if (!priv || !priv->dirty)
271 while (priv->head != priv->tail) {
279 for (
int i = 0; i < clen; i++) {
280 seq[i] = priv->input_buffer[temp_head];
281 temp_head = (temp_head + 1) &
282 (VOXIA_TTY_INPUT_BUFFER_SIZE - 1);
283 if (temp_head == priv->tail && i < clen - 1) {
291 (
int)priv->cursory, 0xFFFFFF,
294 priv->cursorx +=
width;
295 if (priv->cursorx >= priv->cols) {
298 if (priv->cursory >= priv->rows)
301 priv->head = temp_head;
307 (priv->head + 1) & (VOXIA_TTY_INPUT_BUFFER_SIZE - 1);
312 if (priv->cursory >= priv->rows)
315 }
else if (c ==
'\r') {
318 }
else if (c ==
'\b') {
319 if (priv->cursorx > 0) {
321 putc(
' ', (
int)priv->cursorx,
322 (
int)priv->cursory, 0xFFFFFF, 0x000000);
325 putc((
char)c, (
int)priv->cursorx, (
int)priv->cursory,
329 if (priv->cursorx >= priv->cols) {
332 if (priv->cursory >= priv->rows)
static void do_scroll(void)
void console_set_pos(int x, int y)
each_core_data * get_current_core_data(void)
struct dentry * dentry_ptr
struct vnode * vnode_ptr_t
int vxnamei(const char *path, dentry_ptr *out)
Resolves a file path to a directory entry (dentry).
cdev_ptr_t create_dev(void *ops, uint32_t major)
uint32_t screen_cols(void)
int utf8_char_len(uint8_t c)
uint32_t screen_rows(void)
uint32_t vxGetWidth(void)
uint32_t vxGetHeight(void)
void putc(char c, int col, int row, uint32_t fg, uint32_t bg)
void clear_screen(uint32_t color)
void putc_utf8(const char *s, int col, int row, uint32_t fg, uint32_t bg)
void serial2_printf(const char *fmt,...)
void * kalloc(size_t size)
int notify_register(char *name, struct notifier *n)
#define LOG2_INFO(mod, fmt,...)
void spin_acquire(spinlock_t *lock)
void spin_release(spinlock_t *lock)
char * itoa(int64_t value, int base)
void memset(void *ptr, int value, size_t num)
void memcopy(void *dest, void *src, size_t size)
void str_release(kstring str)
kstring str_concat(kstring s, const char *suffix)
kstring str(const char *str)
char input_buffer[VOXIA_TTY_INPUT_BUFFER_SIZE]
void tty_check_and_flush()
dentry_ptr get_active_tty_dentry()
static int __current_tty_active
static void configure_tty(int tty)
dentry_ptr get_tty_dentry(int tty)
static vops_file_t * __tty_ops
static long char_write(vnode_t *vnode, void *buf, size_t len, size_t offset)
static int char_ioctl(vnode_t *vnode, uint32_t req, void *arg)
void change_active_tty(int tty)
static dentry_ptr __tty_dentry[VOXIA_TTY_MAX_COUNT]
static void tty_input_handler(uint32_t event, void *data, void *ctx)
static int char_read(vnode_t *vnode, void *buf, size_t len, size_t offset)
vnode_t * create_and_attach_vnode()