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.
- 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
git clone https://git.qemu.org/git/qemu.git
cd qemu
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
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.
Place the Rust implementation under pci-echodev-rs/
inside the QEMU subprojects directory and rename it to pci-echodev-1-rs.
pci_echodev_1_rs_dep = dependency('pci-echodev-1-rs', native: true)
system_ss.add(pci_echodev_1_rs_dep)
Navigate to the qemu directory and build:
./configure --enable-sdl --enable-gtk --enable-slirp # or enabled whatever you need
make
Example command to start QEMU with the device enabled:
./qemu-system-aarch64 -device pci-echodev
Describe how to test the echo functionality, e.g., writing and reading MMIO regions to verify data echo.
./gen-bindings.sh
Licensed under the MIT License.
- Original pci-echodev project
- QEMU PCI Device Development
- Rust FFI and Integration
- Compiling QEMU for Windows
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