Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions doc/riscv/xen-console.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ skinparam participantPadding 20
skinparam boxPadding 10

actor "User" as user
participant "dom0\nhvc0 tty\n(drivers/tty/hvc/hvc_xen.c)" as hvc0
participant "dom0\nxl console\n(tools/xl)" as xlc
participant "dom0\nxenconsoled\n(tools/console/daemon/io.c)" as xcd
participant "Xen\nhypervisor\n(xen/common/)" as xen
participant "domU\nLinux hvc0\n(drivers/tty/hvc/hvc_xen.c)" as domu
Expand Down Expand Up @@ -51,14 +53,39 @@ end note

== Console Input (user types a character) ==

user -> xcd : keystroke on pty master
note over user, xen
INPUT path uses handle_tty_read(), NOT handle_tty_write().
(handle_tty_write is the reverse: guest output → pty master.)
end note

user -> xen : keystroke in QEMU serial\n(Xen owns the physical UART)
xen -> xen : serial_rx() → __serial_rx()\nserial_rx_ring[prod++] = c\nsend_global_virq(VIRQ_CONSOLE)\n(xen/drivers/char/console.c)
xen -> hvc0 : VIRQ_CONSOLE event channel\n(notify hardware domain)
hvc0 -> xen : HYPERVISOR_console_io(CONSOLEIO_read)
xen --> hvc0 : drain serial_rx_ring → char\n(do_console_io, console.c)

note over hvc0
char surfaces on dom0 hvc0 tty (/dev/hvc0)
end note

hvc0 -> xlc : char readable on /dev/hvc0\n(xl console's stdin)

note over xlc
operator runs `xl console <domU>`; it reads the
char from stdin (hvc0) and writes it to the
pty SLAVE (/dev/pts/N, path from xenstore
/local/domain/<domid>/console/tty).
end note

xlc -> xcd : write char to pty slave (/dev/pts/N)\n→ becomes readable on master_fd

note over xcd
handle_tty_write()
tools/console/daemon/io.c
poll() returns POLLIN on master_fd
→ handle_tty_read()
tools/console/daemon/io.c:1019
end note

xcd -> xcd : write char to in[] ring\nintf->in[in_prod++ & mask] = char\nxen_mb()
xcd -> xcd : read(master_fd, msg)\nwrite char to in[] ring\nintf->in[in_prod++ & mask] = char\nxen_wmb()\nintf->in_prod = prod
xcd -> xen : xenevtchn_notify(local_port)\n[SBI ecall → evtchn_send()]

note over xen
Expand Down
Loading