efi
efi copied to clipboard
Create a more ergonomic model for protocols and handles
Currently we have to call the raw UEFI code to create device handles and install protocols. Create a model that's more ergonomic and safe. For example we could have a type called Handle with methods like InstallProtocol() and UninstallProtocol(). These methods would take any type that implements a trait called Protocol. The trait will have a static field called guid() which the Handle can internally to register the protocol with UEFI.
The Handle will take ownership of all protocol instances passed to it and keep maybe dyn references to them in a vector. A Protocol implementation will be needed per protocol and will have methods on it specific to the protocol. The Handle will support querying for a protocol using the GUID. It will also uninstall all protocols it's currently holding in its Drop.
To make things more strongly typed we could find a way to have multiple different Handle types such as DeviceHandle, ImageHandle etc. In that case maybe Handle will be a trait rather than struct.