uefi-rs icon indicating copy to clipboard operation
uefi-rs copied to clipboard

Use an automated parser to generate EFI service VMTs

Open stevefan1999-personal opened this issue 3 years ago • 2 comments

We could always parse the tables from EDK2, i.e. here: https://github.com/tianocore/edk2/blob/f1567720b13a578ffa54716119f826df622babcd/MdePkg/Include/Uefi/UefiSpec.h

We are certainly not going to immunant/c2rust cause it does not have enough information without pulling the entire EDK2 I think, so I say we could use a C parser in Rust. I'm investigating vickenty/lang-c for this.

The generate will generate a 1-1 correspondence C-to-Rust unsafe method (because having unsafe function pointer at struct level isn't enough, there's no UFCS for example IIRC).

Once the generator is done, the current handwritten helper impls will be moved to a wrapped extension trait that you could import.

Rust compiler should be able to smartly deflate the VMT and directly transform the supposed virtual trait call into the equivalent raw EFI function pointer call as you usually do.

stevefan1999-personal avatar Oct 29 '20 02:10 stevefan1999-personal

This is quite an undertaking, but would definitely boost our progress of porting the whole UEFI API significantly!

GabrielMajeri avatar Oct 30 '20 19:10 GabrielMajeri

@stevefan1999-personal I would like to know if this if you have been able to investigate on this? I raised the same kind of issue with #195 and would like to give a shot to bindgen on EDK2 unless you are already working on something similar :).

hussein-aitlahcen avatar Jan 26 '21 15:01 hussein-aitlahcen