Skip to content

nkaretnikov/device-path-rs

Repository files navigation

About

A sample UEFI program that prints device paths of removable media.

This is a Rust port of device-path, based on a post by Gil Mendes. (Note that this project uses a more recent version of uefi-rs.)

The build.py script is based on the one by Gil Mendes (also see uefi-rs/uefi-test-runner/build.py, which has more features).

Build and run

In order to test the program with removable media, you need to passthru a USB drive to QEMU.

macOS

It doesn't seem to be possible on Mojave with SIP enabled. Supposedly, you could work around this in previous macOS versions by unloading the relevant Apple kernel extension (kext). It seems the only way to do it now is to develop a codeless kext, listing devices you want to claim. But in order to load it, you would need to request a kext signing certificate (called "Developer ID Application"), which Apple doesn't give out to individuals, or disable SIP, which is a security risk. Otherwise, libusb can't claim the device when QEMU starts:

libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
libusb: error [darwin_claim_interface] interface not found

Links:

Linux

Use lsusb to identify the device:

Bus xxx Device xxx: ID xxxx:xxxx <Device>
    ^^^        ^^^     ^^^^ ^^^^
    1          2       3    4
  1. $HOSTBUS
  2. $HOSTADDR
  3. $VENDORID
  4. $PRODUCTID

Configure the environment:

$ # curl https://sh.rustup.rs -sSf | sh -s -- -y
$ rustup default nightly
$ cargo install cargo-xbuild
$ rustup component add rust-src

Build OVMF:

$ ./build-ovmf.sh

Build:

$ git submodule update --init
$ ./build.py build

Run (requires QEMU with USB support):

$ ./build.py run --ovmf-code=OVMF_CODE.fd --ovmf-vars=OVMF_VARS.fd --hostbus=$HOSTBUS --hostaddr=$HOSTADDR
$ # Or use: --vendorid=$VENDORID --productid=$PRODUCTID

Enter UEFI Shell (Boot Manager -> EFI Internal Shell) and confirm whether the program correctly identifies removable media:

Shell> map -v

Use Ctrl-C to exit QEMU.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published