AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
vt.h File Reference
#include <core/system.h>
#include <dev/tty.h>
#include <ds/ringbuf.h>
#include <ds/queue.h>
#include <aquila/kd.h>
#include <aquila/vt.h>

Go to the source code of this file.

Data Structures

struct  vt_cell
 A character cell. More...
struct  vt_display
 A display that virtual terminals are shown on. More...
struct  vt_cursor
 The cursor's state, saved by DECSC. More...
struct  vt
 A virtual terminal: its screen, its emulator's state, and its tty. More...

Macros

#define VT_COUNT   6
#define VT_BOLD   0x01
#define VT_DIM   0x02
#define VT_UNDERLINE   0x04
#define VT_BLINK   0x08
#define VT_REVERSE   0x10
#define VT_INVISIBLE   0x20
#define VT_ITALIC   0x40
#define VT_CURSOR   0x80

Functions

int vt_fb_probe (void)
 Sets up the virtual terminals on the framebuffer, if there is one the terminals can draw on, and clears the screen.
int vt_vga_probe (void)
 Says whether VGA text mode can be used.
uint32_t vt_palette (uint8_t color)
 Returns one of the 256 colours of xterm's palette: the 16 colours, a 6 x 6 x 6 cube, and 24 greys.
uint8_t vt_vga_attr (struct vt_cell cell)
 Returns the VGA text mode attribute of a cell (its colours, in VGA's order), for the VGA display and /dev/vcsa.
int vt_term_init (struct vt *vt, int rows, int cols)
 Sets a terminal's screens up, the main one and the alternate one, both cleared, and resets it.
void vt_term_reset (struct vt *vt)
 Resets a terminal (RIS, ESC c): the defaults, the tab stops every 8 columns, the main screen cleared, and the cursor at the top left.
void vt_term_write (struct vt *vt, const char *buf, size_t size)
 Takes what programs write to a terminal, and changes its screen.
void vt_input (const char *buf, size_t size)
 Gives what keys sent to the foreground terminal, as input.
void vt_switch (int id)
 Switches to another terminal, for Alt+Fn and VT_ACTIVATE.
void vt_keypress (void)
 Undoes, at a key press, the modes that a process which is gone had set on the foreground terminal: otherwise the keyboard could be left to no one.
struct vt * vt_foreground (void)
 Returns the terminal in the foreground.
void vt_scancode (int scancode)
 Takes a scancode from the keyboard, and sends what the key means to the foreground terminal, in its keyboard mode.
void vt_keyboard_reset (void)
 Forgets a prefix or a sequence that a change of mode cut in the middle.
int vt_keymap (int table, int keycode)
 Says what a key is, for KDGKBENT: programs that read key codes (K_MEDIUMRAW) use it to know what each key means.

Variables

struct vt_display vt_fb_display
struct vt_display vt_vga_display
struct dev vtdev

Macro Definition Documentation

◆ VT_BLINK

#define VT_BLINK   0x08

Definition at line 28 of file vt.h.

Referenced by sgr().

◆ VT_BOLD

#define VT_BOLD   0x01

Definition at line 25 of file vt.h.

Referenced by fb_draw(), sgr(), and vt_vga_attr().

◆ VT_COUNT

#define VT_COUNT   6

Definition at line 22 of file vt.h.

Referenced by sttydev_mux(), vcs_read(), vt_get(), vt_kd_ioctl(), vt_probe(), and vt_switch().

◆ VT_CURSOR

#define VT_CURSOR   0x80

Definition at line 32 of file vt.h.

Referenced by fb_draw(), and refresh().

◆ VT_DIM

#define VT_DIM   0x02

Definition at line 26 of file vt.h.

Referenced by fb_draw(), and sgr().

◆ VT_INVISIBLE

#define VT_INVISIBLE   0x20

Definition at line 30 of file vt.h.

Referenced by fb_draw(), sgr(), and vt_vga_attr().

◆ VT_ITALIC

#define VT_ITALIC   0x40

Definition at line 31 of file vt.h.

Referenced by sgr().

◆ VT_REVERSE

#define VT_REVERSE   0x10

Definition at line 29 of file vt.h.

Referenced by fb_draw(), refresh(), sgr(), and vt_vga_attr().

◆ VT_UNDERLINE

#define VT_UNDERLINE   0x04

Definition at line 27 of file vt.h.

Referenced by fb_draw(), and sgr().

Function Documentation

◆ vt_fb_probe()

int vt_fb_probe ( void )

Sets up the virtual terminals on the framebuffer, if there is one the terminals can draw on, and clears the screen.

Returns
0, or -ENODEV if there is no framebuffer, or not one of 16, 24 or 32 bits per pixel

Definition at line 100 of file fb.c.

References bytes_pp, vt_display::cols, fb, fbdev_primary(), FONT_H, FONT_W, memset(), NULL, pitch, vt_display::rows, vt_fb_display, and vt_fb_probe().

Referenced by vt_fb_probe(), and vt_probe().

◆ vt_foreground()

struct vt * vt_foreground ( void )

Returns the terminal in the foreground.

Returns
the terminal, or NULL before the terminals are set up

Definition at line 261 of file vt.c.

References fg, and vt_foreground().

Referenced by cursor_key(), vt_foreground(), and vt_scancode().

◆ vt_input()

void vt_input ( const char * buf,
size_t size )

Gives what keys sent to the foreground terminal, as input.

Parameters
bufwhat the keys sent
sizeits size, in bytes

Definition at line 375 of file vt.c.

References busy, fg, refresh(), vt_input(), vt_input_to(), and vt_reply().

Referenced by send(), send_byte(), send_char(), and vt_input().

◆ vt_keyboard_reset()

void vt_keyboard_reset ( void )

Forgets a prefix or a sequence that a change of mode cut in the middle.

Definition at line 198 of file keyboard.c.

References extended, skip, and vt_keyboard_reset().

Referenced by vt_check(), vt_kd_ioctl(), vt_keyboard_reset(), and vt_switch_now().

◆ vt_keymap()

int vt_keymap ( int table,
int keycode )

Says what a key is, for KDGKBENT: programs that read key codes (K_MEDIUMRAW) use it to know what each key means.

Parameters
tablethe table: none, Shift, AltGr, or both (AltGr is the same as without: the US layout has no AltGr)
keycodethe key's Linux key code
Returns
the key's meaning (K(type, value)), or K_HOLE if the key isn't in that table

Definition at line 130 of file keyboard.c.

References KEY_PAUSE, keys, SC_ALT, SC_BS, SC_CAPS, SC_CTRL, SC_ENTER, SC_ESC, SC_F1, SC_F10, SC_F11, SC_F12, SC_KP7, SC_KP_DEL, SC_KP_MUL, SC_LSHIFT, SC_NUM, SC_RSHIFT, SC_TAB, shifted, table(), and vt_keymap().

Referenced by vt_kd_ioctl(), and vt_keymap().

◆ vt_keypress()

void vt_keypress ( void )

Undoes, at a key press, the modes that a process which is gone had set on the foreground terminal: otherwise the keyboard could be left to no one.

Definition at line 363 of file vt.c.

References fg, vt_check(), and vt_keypress().

Referenced by vt_keypress(), and vt_scancode().

◆ vt_palette()

uint32_t vt_palette ( uint8_t color)

Returns one of the 256 colours of xterm's palette: the 16 colours, a 6 x 6 x 6 cube, and 24 greys.

Parameters
colorthe colour's number
Returns
the colour, as 0xRRGGBB

Definition at line 73 of file vt.c.

References ansi_colors, and vt_palette().

Referenced by color16(), fb_draw(), and vt_palette().

◆ vt_scancode()

void vt_scancode ( int scancode)

Takes a scancode from the keyboard, and sends what the key means to the foreground terminal, in its keyboard mode.

The PS/2 keyboard driver calls it from the keyboard's interrupt.

Parameters
scancodethe scancode (set 1)

Definition at line 307 of file keyboard.c.

References alt, caps, control(), ctrl, cursor_key(), e0_keycodes, editing_key(), extended, fkeys, vt::kb_mode, kernel_ctrlaltdel(), KEY_PAUSE, keypad_digits, keypad_keys, keys, vt::mode, modifier(), num, SC_BS, SC_CAPS, SC_ENTER, SC_ESC, SC_F1, SC_F10, SC_F11, SC_F12, SC_KP7, SC_KP_DEL, SC_KP_MUL, SC_LSHIFT, SC_NUM, SC_RSHIFT, SC_TAB, send(), send_byte(), send_char(), send_key(), shift, shifted, skip, vt_foreground(), vt_keypress(), vt_scancode(), and vt_switch().

Referenced by ps2kbd_probe(), and vt_scancode().

◆ vt_switch()

void vt_switch ( int id)

Switches to another terminal, for Alt+Fn and VT_ACTIVATE.

If the foreground terminal's process asked to decide (VT_PROCESS), it is asked instead, and the switch waits for its answer (VT_RELDISP).

Parameters
idthe terminal's index: 0 for /dev/tty1

Definition at line 341 of file vt.c.

References fg, vt::id, vt::mode, pending, vt_check(), VT_COUNT, vt_signal(), vt_switch(), vt_switch_now(), and vts.

Referenced by vt_kd_ioctl(), vt_scancode(), and vt_switch().

◆ vt_term_init()

int vt_term_init ( struct vt * vt,
int rows,
int cols )

Sets a terminal's screens up, the main one and the alternate one, both cleared, and resets it.

Parameters
vtthe terminal
rowsthe screen's rows
colsthe screen's columns
Returns
0, or -ENOMEM

Definition at line 420 of file term.c.

References vt::alt, vt_cell::ch, clear_screen(), vt::cols, DEFAULT_BG, DEFAULT_FG, kfree(), kmalloc(), vt::main, NULL, vt::pen, vt::rows, vt::screen, vt_term_init(), and vt_term_reset().

Referenced by vt_setup(), and vt_term_init().

◆ vt_term_reset()

void vt_term_reset ( struct vt * vt)

Resets a terminal (RIS, ESC c): the defaults, the tab stops every 8 columns, the main screen cleared, and the cursor at the top left.

Parameters
vtthe terminal

Definition at line 395 of file term.c.

References clear_screen(), vt::col, vt::last, vt::main, vt::reverse_screen, vt::row, S_GROUND, vt::screen, soft_reset(), vt::state, tab_set(), vt::utf8_left, and vt_term_reset().

Referenced by esc(), vt_term_init(), and vt_term_reset().

◆ vt_term_write()

void vt_term_write ( struct vt * vt,
const char * buf,
size_t size )

Takes what programs write to a terminal, and changes its screen.

Parameters
vtthe terminal
bufwhat was written
sizeits size, in bytes

Definition at line 957 of file term.c.

References term_char(), and vt_term_write().

Referenced by vt_kmsg(), vt_term_write(), and vt_tty_output().

◆ vt_vga_attr()

uint8_t vt_vga_attr ( struct vt_cell cell)

Returns the VGA text mode attribute of a cell (its colours, in VGA's order), for the VGA display and /dev/vcsa.

Parameters
cellthe cell
Returns
the attribute byte: the background in bits 4 to 6, the foreground in bits 0 to 3

Definition at line 122 of file vt.c.

References vt_cell::attr, vt_cell::bg, color16(), fg, vt_cell::fg, vga, VT_BOLD, VT_INVISIBLE, VT_REVERSE, and vt_vga_attr().

Referenced by vcs_read(), vga_draw(), and vt_vga_attr().

◆ vt_vga_probe()

int vt_vga_probe ( void )

Says whether VGA text mode can be used.

It always can, on a PC.

Returns
0

Definition at line 48 of file vga.c.

References vt_vga_probe().

Referenced by vt_probe(), and vt_vga_probe().

Variable Documentation

◆ vt_fb_display

struct vt_display vt_fb_display
extern

Definition at line 130 of file fb.c.

Referenced by vt_fb_probe(), and vt_probe().

◆ vt_vga_display

struct vt_display vt_vga_display
extern

Definition at line 53 of file vga.c.

Referenced by vt_probe().

◆ vtdev

struct dev vtdev
extern

Definition at line 774 of file vt.c.

Referenced by sttydev_mux(), and ttydev_mux().