tree: b9c5ca9a93ce134b96e9716bcaf4d97900d2a815 [path history] [tgz]
  1. drivers/
  2. fidl/
  3. tests/
  4. tools/
  5. README.md
src/qemu_edu/README.md

QEMU edu driver sample

This sample project contains a Fuchsia driver for the QEMU edu device, a virtual PCI device built into the Fuchsia emulator (based on QEMU) that computes factorial values. The driver interacts with the device hardware using the fuchsia.hardware.pci protocol, and exposes a custom FIDL protocol (fuchsia.hardware.qemuedu) for other components to consume.

Building

To build the qemu_edu driver and related components, run the following command:

tools/bazel build --config=fuchsia_x64 //src/qemu_edu/driver:pkg
tools/bazel build --config=fuchsia_x64 //src/qemu_edu/test:pkg
tools/bazel build --config=fuchsia_x64 //src/qemu_edu/tools:pkg

Running

Use the following commands to load the driver and run the command line tool on a target device:

  1. Load the qemu_edu driver component:

    tools/bazel run --config=fuchsia_x64 //src/qemu_edu/driver:pkg.component
    
  2. Run the eductl tools component:

    tools/bazel run --config=fuchsia_x64 //src/qemu_edu/tools:pkg.component
    
  3. Open the device log viewer:

    tools/ffx log --filter qemu_edu --filter eductl
    

You should see the factorial requested by the tools component and processed by the driver component.

[qemu-edu,driver][I]: [fuchsia-codelab/qemu_edu/qemu_edu.cc:232] Replying with factorial=479001600
[][I] Factorial(12) = 479001600

Testing

Use the following command to run the system test component for the qemu_edu driver on a target device:

tools/bazel run --config=fuchsia_x64 //src/qemu_edu/test:pkg.component

You should see the test cases execute and pass:

Running test 'fuchsia-pkg://bazel.test.pkg.system.test.component/qemu_edu_system_test#meta/qemu_edu_system_test.cm'
[RUNNING]   main
[stdout - main]
Running main() from gmock_main.cc
[==========] Running 2 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 2 tests from QemuEduSystemTest
[ RUN      ] QemuEduSystemTest.LivenessCheck
[       OK ] QemuEduSystemTest.LivenessCheck (4 ms)
[ RUN      ] QemuEduSystemTest.ComputeFactorial
[       OK ] QemuEduSystemTest.ComputeFactorial (4 ms)
[----------] 2 tests from QemuEduSystemTest (9 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 1 test suite ran. (9 ms total)
[  PASSED  ] 2 tests.
[PASSED]    main

Source layout

  • driver/ — Source code of the qemu_edu PCI device driver.
  • fidl/ — FIDL library definition for fuchsia.hardware.qemuedu.
  • test/ — System test component that exercises the qemu_edu driver.
  • tools/ — Command line tool (eductl) that interacts with the qemu_edu driver.