STRUCT CONSW(9)
β¨ NAME β¨
struct consw β the callback squad for consoles π
(this is from the struct consw(9) page in the Kernel API Manual, bestie)
πΈ SYNOPSIS πΈ
struct consw {
struct module *owner;
const char *(*con_startup)(void);
void (*con_init)(struct vc_data *vc, bool init);
void (*con_deinit)(struct vc_data *vc);
void (*con_clear)(struct vc_data *vc, unsigned int y, unsigned int
x, unsigned int count);
void (*con_putc)(struct vc_data *vc, u16 ca, unsigned int y,
unsigned int x);
void (*con_putcs)(struct vc_data *vc, const u16 *s, unsigned int
count, unsigned int ypos, unsigned int xpos);
void (*con_cursor)(struct vc_data *vc, bool enable);
bool (*con_scroll)(struct vc_data *vc, unsigned int top, unsigned
int bottom, enum con_scroll dir, unsigned int lines);
bool (*con_switch)(struct vc_data *vc);
bool (*con_blank)(struct vc_data *vc, enum vesa_blank_mode blank,
bool mode_switch);
int (*con_font_set)(struct vc_data *vc, const struct console_font
*font, unsigned int vpitch, unsigned int flags);
int (*con_font_get)(struct vc_data *vc, struct console_font *font,
unsigned int vpitch);
int (*con_font_default)(struct vc_data *vc, struct console_font
*font, const char *name);
int (*con_resize)(struct vc_data *vc, unsigned int width, unsigned
int height, bool from_user);
void (*con_set_palette)(struct vc_data *vc, const unsigned char
*table);
void (*con_scrolldelta)(struct vc_data *vc, int lines);
bool (*con_set_origin)(struct vc_data *vc);
void (*con_save_screen)(struct vc_data *vc);
u8 (*con_build_attr)(struct vc_data *vc, u8 color, enum vc_intensity
intensity, bool blink, bool underline, bool reverse, bool italic);
void (*con_invert_region)(struct vc_data *vc, u16 *p, int count);
};
π Members π
Okay so this struct is literally just a big bundle of function pointers, and each one is a lil vibe check the console layer does on your driver. Let's go through every single one, no skips, no cap π₯
ownerβ the module we grab references on when this console is in use, iykyk π«Άcon_startupβ sets up the console and returns its name (likeVGA,EGA, ...). Name reveal moment β¨con_initβ initializes the console on vc. Theinitflag istruefor the very first call on this vc β so yes, it's giving "first time? bestie" energy πcon_deinitβ deinitializes the console from vc. It's the goodbye hug πcon_clearβ erasescountcharacters at[x, y]on vc. Heads up:count >= 1, always πcon_putcβ emits one character with attributescato[x, y]on vc. Optional β if you don't have it,con_putcsgets called instead π¦con_putcsβ emitscountcharacters with attributessto[x, y]on vc. The group-chat version ofcon_putcfr fr π¬con_cursorβ enables/disables the cursor depending onenable. Blinking or not, that's the question πcon_scrollβ moves lines fromtoptobottomin directiondir, bylines. Returnstrueif no generic handling should be done. It's invoked bycsi_Mand by printing to the console. Return-value girlies, this one's for you π₯con_switchβ the notifier that a console switch happened; it's supposed to returntrueif a redraw is needed. Basically "do I need to redo my makeup" πcon_blankβ blanks/unblanks the console. The target mode comes in throughblank.mode_switchis set if we're changing from/to text/graphics. The hook is supposed to returntrueif a redraw is needed πcon_font_setβ sets console vc's font to font with heightvpitch.flagscan beKD_FONT_FLAG_DONT_RECALC. (Optional)con_font_getβ fetches the current font on vc of heightvpitchinto font. (Optional) πcon_font_defaultβ sets the default font on vc.namecan beNULLor a font name to search for. font can be filled back. (Optional)con_resizeβ resizes the vc console towidthxheight.from_useristruewhen this change comes from user space. Glow-up incoming β¨con_set_paletteβ sets the palette of the console vc to table. (Optional) Aesthetic customization, we love to see it πcon_scrolldeltaβ the contents of the console should be scrolled bylines. Invoked by the user. (Optional)con_set_originβ sets the origin (seevc_data::vc_origin) of the vc. If it's not provided, or it returnsfalse, the origin is set tovc->vc_screenbuf. (Optional) π§con_save_screenβ saves screen content intovc->vc_screenbuf. Called, for example, upon entering graphics. (Optional) Screenshot before the graphics era πcon_build_attrβ builds attributes based oncolor,intensity, and other parameters. The result is used for both normal and erase characters. (Optional) πcon_invert_regionβ inverts a region of lengthcounton vc starting atp. (Optional) Uno reverse card π
π SEE ALSO π
Go read these next, bestie, they're all in the same friend group:
- Kernel file
./include/linux/console.h enum cons_flags(9)struct nbcon_state(9)enum nbcon_prio(9)struct nbcon_context(9)struct nbcon_write_context(9)struct console(9)console_srcu_read_flags(9)console_srcu_write_flags(9)for_each_console_srcu(9)for_each_console(9)
Okay that's the whole page, nothing skipped, I promise π«Ά this one lives in./include/linuxand the manual page itself is dated October 2026 βstruct consw(9), periodt π stay slaying those callbacks β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms