drivers/tty/hvc/hvc_xen.c
Source file repositories/reference/linux-study-clean/drivers/tty/hvc/hvc_xen.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/hvc/hvc_xen.c- Extension
.c- Size
- 18267 bytes
- Lines
- 795
- Domain
- Driver Families
- Bucket
- drivers/tty
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/console.hlinux/delay.hlinux/err.hlinux/irq.hlinux/init.hlinux/types.hlinux/list.hlinux/serial_core.hasm/io.hasm/xen/hypervisor.hxen/xen.hxen/interface/xen.hxen/hvm.hxen/grant_table.hxen/page.hxen/events.hxen/interface/io/console.hxen/interface/sched.hxen/hvc-console.hxen/xenbus.hhvc_console.h
Detected Declarations
struct xencons_infofunction parse_xen_console_iofunction list_for_each_entryfunction xenbus_devid_to_vtermnofunction notify_daemonfunction __write_consolefunction domU_write_consolefunction domU_read_consolefunction dom0_read_consolefunction dom0_write_consolefunction xen_hvm_console_initfunction xencons_info_pv_initfunction xen_pv_console_initfunction xen_initial_domain_console_initfunction xen_console_update_evtchnfunction xen_console_resumefunction xencons_disconnect_backendfunction xencons_freefunction xen_console_removefunction xencons_removefunction xencons_connect_backendfunction xencons_probefunction xencons_resumefunction xencons_backend_changedfunction xen_hvc_initfunction xen_cons_initfunction xen_hvm_early_writefunction xen_hvm_early_writefunction xenboot_write_consolefunction xen_raw_console_writefunction xen_raw_printkfunction xenboot_earlycon_writefunction xenboot_earlycon_setupmodule init xen_hvc_init
Annotated Snippet
device_initcall(xen_hvc_init);
static int __init xen_cons_init(void)
{
const struct hv_ops *ops;
xen_console_io = opt_console_io >= 0 ? opt_console_io :
xen_initial_domain();
if (!xen_domain())
return 0;
if (xen_console_io)
ops = &dom0_hvc_ops;
else {
int r;
ops = &domU_hvc_ops;
if (xen_hvm_domain())
r = xen_hvm_console_init();
else
r = xen_pv_console_init();
if (r < 0)
return r;
}
hvc_instantiate(HVC_COOKIE, 0, ops);
return 0;
}
console_initcall(xen_cons_init);
#ifdef CONFIG_X86
static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len)
{
if (xen_cpuid_base())
outsb(0xe9, str, len);
}
#else
static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len) { }
#endif
#ifdef CONFIG_EARLY_PRINTK
static int __init xenboot_console_setup(struct console *console, char *string)
{
static struct xencons_info xenboot;
if (xen_initial_domain() || !xen_pv_domain())
return 0;
return xencons_info_pv_init(&xenboot, 0);
}
static void xenboot_write_console(struct console *console, const char *string,
unsigned len)
{
unsigned int linelen, off = 0;
const char *pos;
if (dom0_write_console(0, string, len) >= 0)
return;
if (!xen_pv_domain()) {
xen_hvm_early_write(0, string, len);
return;
}
if (domU_write_console(0, "(early) ", 8) < 0)
return;
while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
linelen = pos-string+off;
if (off + linelen > len)
break;
domU_write_console(0, string+off, linelen);
domU_write_console(0, "\r\n", 2);
off += linelen + 1;
}
if (off < len)
domU_write_console(0, string+off, len-off);
}
struct console xenboot_console = {
.name = "xenboot",
.write = xenboot_write_console,
.setup = xenboot_console_setup,
.flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
.index = -1,
};
#endif /* CONFIG_EARLY_PRINTK */
void xen_raw_console_write(const char *str)
Annotation
- Immediate include surface: `linux/console.h`, `linux/delay.h`, `linux/err.h`, `linux/irq.h`, `linux/init.h`, `linux/types.h`, `linux/list.h`, `linux/serial_core.h`.
- Detected declarations: `struct xencons_info`, `function parse_xen_console_io`, `function list_for_each_entry`, `function xenbus_devid_to_vtermno`, `function notify_daemon`, `function __write_console`, `function domU_write_console`, `function domU_read_console`, `function dom0_read_console`, `function dom0_write_console`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.