TinyEMU Data Flow Interactive source-guided map

How bytes move through TinyEMU

This overview follows a VM from config file to running guest: config bytes become machine parameters, files become RAM and devices, guest CPU accesses route through the physical memory map, and VirtIO queues bridge guest descriptors to host-backed console, disk, network, filesystem, input, and display services.

End-to-end pipelineThe main data structures and callbacks that connect host resources to the guest.
CLI and config`main()` parses options, loads JSON, and resolves relative files.
Machine params`VirtMachineParams` accumulates memory, files, drives, net, fs, display, and input.
Machine initThe selected `VirtMachineClass` registers RAM, MMIO devices, IRQs, and boot payloads.
Run loop`select()` polls host fds, refreshes UI, then executes a bounded CPU slice.
Guest I/OMMIO writes notify VirtIO queues; host callbacks complete descriptors and raise IRQs.
CLI argv
  -> VirtMachineParams
  -> RISCVMachine / PC machine
  -> PhysMemoryMap ranges
  -> CPU interpreter
  -> target_* memory helpers
  -> device read/write callbacks
  -> VirtIO queue callbacks
  -> host block/net/fs/console/display/input
Layer responsibilitiesEach layer owns one translation in the flow.

Startup Config to parameters

`virt_machine_parse_config()` turns JSON keys into typed fields. `config_additional_file_load()` then loads BIOS, kernel, initrd, and VGA BIOS blobs before device construction.

Machine Parameters to topology

`riscv_machine_init()` allocates the CPU, maps RAM, installs CLINT/PLIC/HTIF MMIO callbacks, creates VirtIO devices, and copies boot payloads into RAM.

CPU Virtual to physical

`get_phys_addr()` performs privilege and page-table translation. Slow read/write paths populate TLB entries for RAM and call device callbacks for MMIO.

VirtIO Descriptors to host work

Guest drivers write queue addresses and notify registers. `queue_notify()` walks available descriptors, calls the device handler, then `virtio_consume_desc()` writes used-ring entries and raises an IRQ.