STRUCT CONSW(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 (like VGA, EGA, ...). Name reveal moment ✨
  • con_init β€” initializes the console on vc. The init flag is true for 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 β€” erases count characters at [x, y] on vc. Heads up: count >= 1, always πŸ’…
  • con_putc β€” emits one character with attributes ca to [x, y] on vc. Optional β€” if you don't have it, con_putcs gets called instead πŸ¦‹
  • con_putcs β€” emits count characters with attributes s to [x, y] on vc. The group-chat version of con_putc fr fr πŸ’¬
  • con_cursor β€” enables/disables the cursor depending on enable. Blinking or not, that's the question πŸ‘€
  • con_scroll β€” moves lines from top to bottom in direction dir, by lines. Returns true if no generic handling should be done. It's invoked by csi_M and 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 return true if a redraw is needed. Basically "do I need to redo my makeup" πŸ’„
  • con_blank β€” blanks/unblanks the console. The target mode comes in through blank. mode_switch is set if we're changing from/to text/graphics. The hook is supposed to return true if a redraw is needed πŸ‘‘
  • con_font_set β€” sets console vc's font to font with height vpitch. flags can be KD_FONT_FLAG_DONT_RECALC. (Optional)
  • con_font_get β€” fetches the current font on vc of height vpitch into font. (Optional) πŸŽ€
  • con_font_default β€” sets the default font on vc. name can be NULL or a font name to search for. font can be filled back. (Optional)
  • con_resize β€” resizes the vc console to width x height. from_user is true when 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 by lines. Invoked by the user. (Optional)
  • con_set_origin β€” sets the origin (see vc_data::vc_origin) of the vc. If it's not provided, or it returns false, the origin is set to vc->vc_screenbuf. (Optional) 🧚
  • con_save_screen β€” saves screen content into vc->vc_screenbuf. Called, for example, upon entering graphics. (Optional) Screenshot before the graphics era πŸ’€
  • con_build_attr β€” builds attributes based on color, intensity, and other parameters. The result is used for both normal and erase characters. (Optional) πŸ“
  • con_invert_region β€” inverts a region of length count on vc starting at p. (Optional) Uno reverse card πŸƒ

πŸ‘‘ SEE ALSO πŸ‘‘

Go read these next, bestie, they're all in the same friend group:


Okay that's the whole page, nothing skipped, I promise 🫢 this one lives in ./include/linux and the manual page itself is dated October 2026 β€” struct consw(9), periodt πŸ’– stay slaying those callbacks ✨
πŸ“¦ where this page comes from