Skip to content

PCI echo device + driver written in Rust – QEMU proof‑of‑concept for PCI bar handling, IRQ, random values.

Notifications You must be signed in to change notification settings

lfern/pci-echodev-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust PCI Echo Device for QEMU

Overview

This project is a Rust implementation of the PCI Echo Device originally developed in C by Johannes4Linux.
The goal is to replicate the device’s functionality using Rust, leveraging its safety and modern features, while integrating with QEMU as a PCI device.

Prerequisites

  • QEMU source code (matching or compatible version)
  • Build tools: clang, gcc, make, pkg-config, etc.
  • MSYS2 environment on Windows (also known as mynwin) for building QEMU and dependencies
  • Rust toolchain (install via rustup)
  • Add bindgen and clang to mingw: pacman -S mingw-w64-ucrt-x86_64-rust-bindgen mingw-w64-ucrt-x86_64-clang

Integration Steps

1. Clone QEMU source

git clone https://git.qemu.org/git/qemu.git
cd qemu

2. Prepare build environment

On Windows, you can use MSYS2 (minwin) as your build environment. For setup and compilation instructions, you may follow guides such as:
Compiling QEMU for Windows - Itayemi's Blog

3. Create wrap file for Rust subproject

Inside the subprojects directory of the QEMU source tree, create a file named pci-echodev-1-rs.wrap with the following content:

[wrap-file]
directory = pci-echodev-1-rs

# method = cargo
# patch_directory = pci-echodev-1-rs
[provide]
dependency_names = pci-echodev-1-rs

This file instructs QEMU’s build system how to include the Rust subproject as a wrapped dependency.

4. Add Rust PCI Echo Device subproject

Place the Rust implementation under pci-echodev-rs/ inside the QEMU subprojects directory and rename it to pci-echodev-1-rs.

5. Add to meson qemu files

pci_echodev_1_rs_dep = dependency('pci-echodev-1-rs', native: true)

system_ss.add(pci_echodev_1_rs_dep)

6. Build qemu

Navigate to the qemu directory and build:

./configure --enable-sdl --enable-gtk --enable-slirp # or enabled whatever you need
make

7. Run QEMU with Rust PCI Echo Device

Example command to start QEMU with the device enabled:

./qemu-system-aarch64 -device pci-echodev

Usage

Describe how to test the echo functionality, e.g., writing and reading MMIO regions to verify data echo.

Development

Regenerate qemu bindings

./gen-bindings.sh

License

Licensed under the MIT License.

References


Feel free to expand this README with build instructions, known issues, or contribution guidelines as your project evolves.

INSTALAR alguno de estos para tener bindgen

pacman -S  mingw64/mingw-w64-x86_64-clang
pacman -S  mingw-w64-x86_64-clang mingw-w64-ucrt-x86_64-rust-bindgen
pacman -S  mingw64/mingw-w64-x86_64-clang
pacman -S  mingw-w64-x86_64-clang mingw-w64-ucrt-x86_64-rust-bindgen
pacman -S mingw-w64-ucrt-x86_64-rust-bindgen mingw-w64-ucrt-x86_64-clang

Esto es para usar el rust de windows dentro de ucrt64 export PATH="/c/Users/lfern/.cargo/bin:$PATH"

Para que compile sin que los warnings sean considerados como errores. Hacerlo antes del configure export RUSTFLAGS="-Awarnings"


Chequeando paquete: mingw-w64-ucrt-x86_64-rust-bindgen ✓ Instalado Chequeando paquete: mingw-w64-ucrt-x86_64-clang ✓ Instalado

About

PCI echo device + driver written in Rust – QEMU proof‑of‑concept for PCI bar handling, IRQ, random values.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages