Skip to content

TTY

Defined in: src/drivers/tty/tty.ts:65

One terminal, i.e. struct tty_struct.

new TTY(driver, index): TTY

Defined in: src/drivers/tty/tty.ts:77

TTYDriver

number

Which line of the driver this is, i.e. tty->index

TTY

optional device?: Device<unknown>

Defined in: src/drivers/tty/tty.ts:72

The device in sysfs, only set while the tty is registered


readonly driver: TTYDriver

Defined in: src/drivers/tty/tty.ts:78


optional foreground?: Process

Defined in: src/drivers/tty/tty.ts:75

What the terminal is in front of, i.e. tty->pgrp.


readonly index: number

Defined in: src/drivers/tty/tty.ts:80

Which line of the driver this is, i.e. tty->index


readonly ldisc: LineDiscipline

Defined in: src/drivers/tty/tty.ts:67

The line discipline, i.e. tty->ldisc. Only N_TTY exists.


protected readonly read_wait: Set<() => void>

Defined in: src/drivers/tty/tty.ts:117

Whatever is waiting for input to arrive, i.e. tty->read_wait


termios: Termios

Defined in: src/drivers/tty/tty.ts:69

get available(): number

Defined in: src/drivers/tty/tty.ts:112

Bytes that have been read from the terminal and are waiting to be handed over

number


get dev_t(): object

Defined in: src/drivers/tty/tty.ts:91

object

major: number

minor: number


get name(): string

Defined in: src/drivers/tty/tty.ts:87

What this line is called, e.g. ttyS0 for line 0 of a driver named ttyS.

string


get winsize(): WinSize

Defined in: src/drivers/tty/tty.ts:99

How big the terminal is. Terminals that can’t say are 80x24, the same default Linux uses.

WinSize

set winsize(size): void

Defined in: src/drivers/tty/tty.ts:107

Tell the terminal how big it is, i.e. TIOCSWINSZ. A driver that knows its own size keeps reporting that, since it is the one that can tell.

WinSize

void

protected attrs(): Record<string, DeviceAttribute>

Defined in: src/drivers/tty/tty.ts:185

The attributes the tty’s device gets in sysfs

Record<string, DeviceAttribute>


close(): void

Defined in: src/drivers/tty/tty.ts:153

Stop using the terminal

void


open(): void

Defined in: src/drivers/tty/tty.ts:148

Start using the terminal, i.e. the open half of tty_operations

void


receive(data): void

Defined in: src/drivers/tty/tty.ts:143

Take bytes from the terminal. Call this from whatever is driving the tty when the user types something.

string | Uint8Array<ArrayBufferLike>

void


register(name?): void

Defined in: src/drivers/tty/tty.ts:201

Add the tty to sysfs and /dev, i.e. tty_register_device.

string = ...

Overrides the name worked out from the driver, which is how /dev/tty and /dev/console get theirs

void


set_termios(termios): void

Defined in: src/drivers/tty/tty.ts:178

Change the line settings, i.e. TCSETS

Partial<Termios>

void


signal(signal): boolean

Defined in: src/drivers/tty/tty.ts:161

Signal whatever the terminal is in front of, like what __isig and TIOCSWINSZ do.

Signal

boolean

whether there was anything to signal


unregister(): void

Defined in: src/drivers/tty/tty.ts:209

void


wait_read(waiter): () => void

Defined in: src/drivers/tty/tty.ts:125

Wait for input to arrive, i.e. add_wait_queue(&tty->read_wait, ...). There is nothing to block on here, so a waiter is called once there is something to read and reads it then, the way a woken task would.

() => void

a function that stops waiting, i.e. remove_wait_queue

() => void


wake_read(): void

Defined in: src/drivers/tty/tty.ts:135

Let whatever is waiting know there is input to be read, i.e. wake_up_interruptible_poll(&tty->read_wait, EPOLLIN). The line discipline is what decides when that is, since only it knows whether a line is finished.

void


write(data): void

Defined in: src/drivers/tty/tty.ts:168

Send bytes to the terminal, after output processing

Uint8Array

void


write_raw(data): void

Defined in: src/drivers/tty/tty.ts:173

Send bytes to the terminal without output processing, e.g. for echoing

Uint8Array

void