BarryServer : Git

All the code for all my projects
// BarryServer : Git / Orion / blob / 1628fcfdfdf2978ed9ccac96ee7d13bb3dc43a01 / drivers / tty / tty_ioctl.c

// Related

Orion

Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)
/*
 * This file implements the TTY ioctl() backend.  It stores many of the settings
 * which are used throughout the rest of the TTY driver.
 */

#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <termios.h>
#include "../../vfs/vfs.h"

extern Termios tty;

extern int ttyW, ttyH;
extern int vgaWidth, vgaHeight;

int
tty_ioctl(File *file, unsigned long request, uintptr_t argp)
{
	Termios *ts;
	Winsize *ws;
	switch (request) {
	case TCGETS:
		ts = (void *) argp;
		memcpy(ts, &tty, sizeof(Termios));
		return 0;
	case TCSETS:
		ts = (void *) argp;
		memcpy(&tty, ts, sizeof(Termios));
		return 0;
	case TCGWINSZ:
		ws = (void *) argp;
		ws->rows = ttyH;
		ws->cols = ttyW;
		ws->xres = vgaWidth;
		ws->yres = vgaHeight;
		return 0;
	}
}