AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
tty.c File Reference

The terminal devices' numbers: which driver each one is. More...

#include <core/system.h>
#include <core/module.h>
#include <dev/ttydev.h>
#include <fs/posix.h>
#include <sys/sched.h>
#include <dev/tty.h>
#include <dev/vt.h>
#include <fs/vfs.h>

Go to the source code of this file.

Functions

struct dev * sttydev_mux (struct devid *dd)
 Picks the driver of a terminal of major 4, by its minor: the virtual terminals' for minors up to VT_COUNT, the UARTs' for 64 and up.
static int ctty_open (struct file *file)
 Opens /dev/tty: the file is made the controlling terminal's device instead.
struct dev * ttydev_mux (struct devid *dd)
 Picks the driver of a terminal device of major 5, by its minor.
int ttydev_probe ()
 Registers the terminal devices, majors 4 and 5.

Variables

static struct dev cttydev
struct dev sttydev
struct dev ttydev

Detailed Description

The terminal devices' numbers: which driver each one is.

Major 4 is the terminals themselves: /dev/tty0 to /dev/tty6, the virtual terminals (minor 0 is the one in the foreground), and /dev/ttyS0 and up, the UARTs (minors 64 and up). Major 5 is the special ones: /dev/tty (the process's controlling terminal), /dev/console and /dev/ptmx. These are Linux's numbers.

Definition in file tty.c.

Function Documentation

◆ ctty_open()

int ctty_open ( struct file * file)
static

Opens /dev/tty: the file is made the controlling terminal's device instead.

Fails with ENXIO if the process has no controlling terminal.

Definition at line 45 of file tty.c.

References ctty_open(), curproc, kdev_file_open(), vnode::ref, vfs_close(), tty::vnode, and VNODE_DEV.

Referenced by ctty_open().

◆ sttydev_mux()

struct dev * sttydev_mux ( struct devid * dd)

Picks the driver of a terminal of major 4, by its minor: the virtual terminals' for minors up to VT_COUNT, the UARTs' for 64 and up.

Parameters
ddthe device's number
Returns
its driver, or NULL if the kernel has none for it

Definition at line 27 of file tty.c.

References devid::minor, NULL, sttydev_mux(), VT_COUNT, and vtdev.

Referenced by sttydev_mux().

◆ ttydev_mux()

struct dev * ttydev_mux ( struct devid * dd)

Picks the driver of a terminal device of major 5, by its minor.

Parameters
ddthe device's number
Returns
its driver, or NULL if the kernel has none for it

Definition at line 81 of file tty.c.

References cttydev, devid::minor, NULL, ptmdev, ttydev_mux(), and vtdev.

Referenced by ttydev_mux().

◆ ttydev_probe()

int ttydev_probe ( )

Registers the terminal devices, majors 4 and 5.

Returns
0

Definition at line 109 of file tty.c.

References kdev_chrdev_register(), sttydev, ttydev, and ttydev_probe().

Referenced by ttydev_probe().

Variable Documentation

◆ cttydev

struct dev cttydev
static
Initial value:
= {
.name = "ctty",
.fops = {
.open = ctty_open,
},
}
static int ctty_open(struct file *file)
Opens /dev/tty: the file is made the controlling terminal's device instead.
Definition tty.c:45

Definition at line 68 of file tty.c.

Referenced by ttydev_mux().

◆ sttydev

struct dev sttydev
Initial value:
= {
.name = "sttydev",
.mux = sttydev_mux,
}
struct dev * sttydev_mux(struct devid *dd)
Picks the driver of a terminal of major 4, by its minor: the virtual terminals' for minors up to VT_C...
Definition tty.c:27

Definition at line 116 of file tty.c.

Referenced by ttydev_probe().

◆ ttydev

struct dev ttydev
Initial value:
= {
.name = "ttydev",
.mux = ttydev_mux,
}
struct dev * ttydev_mux(struct devid *dd)
Picks the driver of a terminal device of major 5, by its minor.
Definition tty.c:81

Definition at line 121 of file tty.c.

Referenced by ttydev_probe().