Giter Club home page Giter Club logo

rust-hypervisor-firmware's Introduction

Simple rust uefi core firmware

This project is an experiment and should not be used production workloads.

Building

  1. Install rust (https://www.rust-lang.org/)

  2. Intall xbuild

cargo install cargo-xbuild
  1. Compile the code
cargo xbuild --release --target target.json
  1. The result will be in:

target/target/release/payload-efi

  1. Compiler grub (option)

Download grub

https://github.com/rhboot/grub2.git 

Build grub

../configure --prefix /home/luxy/local --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-platform=efi --enable-boot-time --enable-mm-debug --enable-cache-stats 

Install grub

sudo losetup -f -P clear-31380-kvm.img 
sudo mount /dev/loop1p1 /mnt/clear-kvm-img/ 
sudo ./grub-install --efi-directory /mnt/clear-kvm-img --target x86_64-efi 

Running

  1. check out https://github.com/jyao1/edk2/tree/minovmf

  2. build MinOvmf64FwPkg.

   build -p MinOvmf64FwPkg\MinOvmf64RustFwPkg.dsc -a IA32 -a X64 -t CLANGPDB

The image is Build\MinOvmf64Fw\DEBUG_CLANGPDB\fv\OVMF64RUSTFW.fd.

  1. install qemu (https://www.qemu.org/)

  2. download image. (https://download.clearlinux.org/releases/31380/clear/clear-31380-kvm.img.xz)

  3. run qemu

qemu-system-x86_64.exe -machine q35,smm=on -smp 4 -serial mon:stdio -drive if=pflash,format=raw,unit=0,file=OVMF64RUSTFW.fd -drive if=none,id=virtio-disk0,file=clear-31380-kvm.img -device virtio-blk-pci,drive=virtio-disk0,disable-legacy=on,disable-modern=off  -vnc 0.0.0.0:1 -m 1g --enable-kvm 
  1. Then a uefi shell command prompt is shown in the command window. It supports some simple commands, such as memmap.
EFI\BOOT\BOOTX64.efi
  1. It will boot to grub.

Add kernel information:

linux (hd0,gpt1)/EFI/org.clearlinux/kernel-org.clearlinux.kvm.5.3.7-396 root=PARTUUID=492838b1-9d22-484a-a59f-fdd6f18d188c quiet console=hvc0 console=tty0 console=ttyS0,115200n8 cryptomgr.notests init=/usr/lib/systemd/systemd-bootchart initcall_debug no_timer_check noreplace-smp page_alloc.shuffle=1 rootfstype=ext4,btrfs,xfs tsc=reliable rw 

Then

boot
  1. It will boot to kernel. You can see the last debug message is exit_boot_service.

Boot Flow

The payload-efi can be treated as a UEFI payload.

The EDKII SEC loads payload-efi as UEFI core.

Then the payload-efi loads the EDKII UEFI shell.

TODO

  • implement more feature required by UEFI specification.
  • remove the EDKII SEC dependency.

rust-hypervisor-firmware's People

Contributors

josephlr avatar jyao1 avatar rbradford avatar thenewwazoo avatar

Forkers

xiaoyuxlu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.