drivers/tty/hvc/hvsi.c
Source file repositories/reference/linux-study-clean/drivers/tty/hvc/hvsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/hvc/hvsi.c- Extension
.c- Size
- 30273 bytes
- Lines
- 1225
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/console.hlinux/ctype.hlinux/delay.hlinux/init.hlinux/interrupt.hlinux/module.hlinux/major.hlinux/kernel.hlinux/of_irq.hlinux/spinlock.hlinux/sysrq.hlinux/tty.hlinux/tty_flip.hasm/hvcall.hasm/hvconsole.hlinux/uaccess.hasm/vio.hasm/param.hasm/hvsi.h
Detected Declarations
struct hvsi_structenum HVSI_PROTOCOL_STATEfunction is_consolefunction is_openfunction print_statefunction __set_statefunction set_statefunction len_packetfunction is_headerfunction got_packetfunction compact_inbuffunction dump_hexfunction dump_packetfunction hvsi_readfunction hvsi_recv_controlfunction hvsi_recv_responsefunction hvsi_version_respondfunction hvsi_recv_queryfunction hvsi_insert_charsfunction TTY_THRESHOLD_THROTTLEfunction handshakingfunction hvsi_send_overflowfunction hvsi_interruptfunction poll_for_statefunction wait_for_statefunction hvsi_queryfunction hvsi_get_mctrlfunction hvsi_set_mctrlfunction hvsi_drain_inputfunction hvsi_handshakefunction hvsi_handshakerfunction hvsi_put_charsfunction hvsi_close_protocolfunction hvsi_openfunction hvsi_flush_outputfunction hvsi_closefunction hvsi_hangupfunction hvsi_pushfunction hvsi_write_workerfunction hvsi_write_roomfunction hvsi_chars_in_bufferfunction hvsi_writefunction bufferfunction hvsi_throttlefunction hvsi_unthrottlefunction hvsi_tiocmgetfunction hvsi_tiocmsetfunction hvsi_init
Annotated Snippet
device_initcall(hvsi_init);
/***** console (not tty) code: *****/
static void hvsi_console_print(struct console *console, const char *buf,
unsigned int count)
{
struct hvsi_struct *hp = &hvsi_ports[console->index];
char c[HVSI_MAX_OUTGOING_DATA] __ALIGNED__;
unsigned int i = 0, n = 0;
int ret, donecr = 0;
mb();
if (!is_open(hp))
return;
/*
* ugh, we have to translate LF -> CRLF ourselves, in place.
* copied from hvc_console.c:
*/
while (count > 0 || i > 0) {
if (count > 0 && i < sizeof(c)) {
if (buf[n] == '\n' && !donecr) {
c[i++] = '\r';
donecr = 1;
} else {
c[i++] = buf[n++];
donecr = 0;
--count;
}
} else {
ret = hvsi_put_chars(hp, c, i);
if (ret < 0)
i = 0;
i -= ret;
}
}
}
static struct tty_driver *hvsi_console_device(struct console *console,
int *index)
{
*index = console->index;
return hvsi_driver;
}
static int __init hvsi_console_setup(struct console *console, char *options)
{
struct hvsi_struct *hp;
int ret;
if (console->index < 0 || console->index >= hvsi_count)
return -EINVAL;
hp = &hvsi_ports[console->index];
/* give the FSP a chance to change the baud rate when we re-open */
hvsi_close_protocol(hp);
ret = hvsi_handshake(hp);
if (ret < 0)
return ret;
ret = hvsi_get_mctrl(hp);
if (ret < 0)
return ret;
ret = hvsi_set_mctrl(hp, hp->mctrl | TIOCM_DTR);
if (ret < 0)
return ret;
hp->flags |= HVSI_CONSOLE;
return 0;
}
static struct console hvsi_console = {
.name = "hvsi",
.write = hvsi_console_print,
.device = hvsi_console_device,
.setup = hvsi_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
};
static int __init hvsi_console_init(void)
{
struct device_node *vty;
hvsi_wait = poll_for_state; /* no irqs yet; must poll */
Annotation
- Immediate include surface: `linux/console.h`, `linux/ctype.h`, `linux/delay.h`, `linux/init.h`, `linux/interrupt.h`, `linux/module.h`, `linux/major.h`, `linux/kernel.h`.
- Detected declarations: `struct hvsi_struct`, `enum HVSI_PROTOCOL_STATE`, `function is_console`, `function is_open`, `function print_state`, `function __set_state`, `function set_state`, `function len_packet`, `function is_header`, `function got_packet`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.