STRUCT KGDB_IO(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct kgdb_io(9) ✨

Okay bestie, so this is a page from the Kernel API Manual β€” yes, the Linux kernel one β€” and it's all about struct kgdb_io, which lowkey describes the interface for an I/O driver to talk with KGDB. That's it, that's the whole vibe: it's the contract, the group chat rules, the "here's what you gotta bring to the party" list for anyone who wants their I/O driver to hang out with the kernel debugger. πŸŽ€


🌸 NAME 🌸

struct kgdb_io β€” Describe the interface for an I/O driver to talk with KGDB.

Like, literally that. This struct is the handshake. Your driver on one side, KGDB on the other, and this is the friendship bracelet that makes it official. 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

struct kgdb_io {
    const char              *name;
    int (*read_char) (void);
    void (*write_char) (u8);
    void (*flush) (void);
    int (*init) (void);
    void (*deinit) (void);
    void (*pre_exception) (void);
    void (*post_exception) (void);
    struct console          *cons;
 };

Look at her. Nine members, all function pointers except the name and the console. Every single field is load-bearing, no cap. πŸ’…


πŸ‘‘ Members πŸ‘‘

So here's the full roster β€” every field, what it does, and why it's the main character of its own little moment:

  • name β€” Name of the I/O driver. Just the name, bestie. Identification. It's giving "hello my name is" sticker energy. 🏷️
  • read_char β€” Pointer to a function that will return one char. One. Char. That's the whole job description. πŸ”€
  • write_char β€” Pointer to a function that will write one char. See above, but the other direction. Symmetry, we love to see it. ✍️
  • flush β€” Pointer to a function that will flush any pending writes. Because sometimes things are just sitting in a buffer being lazy and you gotta nudge them out the door. πŸšͺ
  • init β€” Pointer to a function that will initialize the device. First-day-of-school vibes, except for your hardware. ⭐
  • deinit β€” Pointer to a function that will deinit the device. Implication alert 🚨 β€” this implies that this I/O driver is temporary and expects to be replaced. Called when an I/O driver is replaced or explicitly unregistered. So like, don't get too attached, she knows she's a guest. 😭
  • pre_exception β€” Pointer to a function that will do any prep work for the I/O driver. Warm-up stretches before the big moment. 🧚
  • post_exception β€” Pointer to a function that will do any cleanup work for the I/O driver. Aftermath duty, the "okay let's put the chairs back" of it all. 🧹
  • cons β€” valid if the I/O device is a console; else NULL. That's the rule. Console driver? Cool, pop it in. Not a console? NULL and move along. πŸ™ˆ
Ngl, every one of these is a pointer to a function except name and cons β€” so if you're filling this out, don't try to jam a plain value in where a callback belongs. The compiler will not be nice about it. πŸ’€

🌈 SEE ALSO 🌈

The full bestie tag-along list β€” and yes, we're naming every single one, because nobody gets left out of the group chat:

Kernel file ./include/linux/kgdb.h plus kgdb_skipexception(9), kgdb_breakpoint(9), kgdb_arch_init(9), kgdb_arch_exit(9), pt_regs_to_gdb_regs(9), sleeping_thread_to_gdb_regs(9), gdb_regs_to_pt_regs(9), kgdb_arch_handle_exception(9), kgdb_arch_handle_qxfer_pkt(9), kgdb_call_nmi_hook(9), kgdb_roundup_cpus(9), kgdb_arch_set_pc(9), kgdb_arch_late(9), and struct kgdb_arch(9).

That's fourteen (9) pages and a struct, ikyk. Go read them, they're all part of the same little family. πŸ”₯


Okay that's the whole page!! πŸ’– It lives under ./include/linux, and this edition is dated October 2026 β€” so mark your calendar, future girlies, this is the version we're rocking with. Byeee, go write your driver, you're gonna slay. πŸŒΈπŸ¦‹πŸ’œ

πŸ“¦ where this page comes from