diff --git a/crates/efi/src/boot.rs b/crates/efi/src/boot.rs index 9b52da0..253cbcc 100644 --- a/crates/efi/src/boot.rs +++ b/crates/efi/src/boot.rs @@ -109,7 +109,7 @@ impl BootServices { } pub fn locate_protocol(&self) -> Result<&'static mut T, Status> { - let guid = ::guid(); + let guid = &::GUID; let mut proto_ptr: *mut c_void = core::ptr::null_mut(); match Status::from_num(unsafe { diff --git a/crates/efi/src/proto/gop.rs b/crates/efi/src/proto/gop.rs index ccf6777..9fc4c8a 100644 --- a/crates/efi/src/proto/gop.rs +++ b/crates/efi/src/proto/gop.rs @@ -2,13 +2,6 @@ use crate::{Status, Guid}; use crate::proto::Protocol; use core::ffi::c_void; -const GRAPHICS_OUTPUT_PROTOCOL_GUID: Guid = Guid { - data1: 0x9042a9de, - data2: 0x23dc, - data3: 0x4a38, - data4: [0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a] -}; - #[repr(C)] pub struct Mode { pub max_mode: u32, @@ -62,9 +55,12 @@ pub struct ModeIterator<'a> { } impl Protocol for GraphicsOutputProtocol { - fn guid() -> &'static Guid { - return &GRAPHICS_OUTPUT_PROTOCOL_GUID; - } + const GUID: Guid = Guid { + data1: 0x9042a9de, + data2: 0x23dc, + data3: 0x4a38, + data4: [0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a] + }; } impl GraphicsOutputProtocol { diff --git a/crates/efi/src/proto/mod.rs b/crates/efi/src/proto/mod.rs index 61cc1c0..b97e269 100644 --- a/crates/efi/src/proto/mod.rs +++ b/crates/efi/src/proto/mod.rs @@ -3,7 +3,8 @@ pub mod stip; pub mod gop; pub trait Protocol { - fn guid() -> &'static super::Guid; + const GUID: super::Guid; + //fn guid() -> &'static super::Guid; } pub use stop::SimpleTextOutputProtocol; diff --git a/crates/efi/src/proto/stip.rs b/crates/efi/src/proto/stip.rs index 959f11f..0fda514 100644 --- a/crates/efi/src/proto/stip.rs +++ b/crates/efi/src/proto/stip.rs @@ -1,5 +1,4 @@ -use crate::{Status, Guid, Event, system_table}; -use core::ffi::c_void; +use crate::{Status, Guid, Protocol, Event, system_table}; #[repr(C)] #[derive(Debug)] @@ -15,6 +14,15 @@ pub struct SimpleTextInputProtocol { wait_for_key: Event } +impl Protocol for SimpleTextInputProtocol { + const GUID: Guid = Guid { + data1: 0x387477c1, + data2: 0x69c7, + data3: 0x11d2, + data4: [0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b] + }; +} + impl SimpleTextInputProtocol { pub fn reset(&mut self, extended_verification: bool) -> Result<(), Status> { return Status::from_num(unsafe { @@ -23,7 +31,7 @@ impl SimpleTextInputProtocol { } pub fn read_key_blocking(&mut self) -> Result { - let res = system_table().boot_services.wait_for_event(self.wait_for_key)?; + system_table().boot_services.wait_for_event(self.wait_for_key)?; loop { let res = self.read_key_stroke(); match res { diff --git a/crates/efi/src/proto/stop.rs b/crates/efi/src/proto/stop.rs index 52615fe..ffeac80 100644 --- a/crates/efi/src/proto/stop.rs +++ b/crates/efi/src/proto/stop.rs @@ -1,25 +1,21 @@ -use crate::{Status, Guid}; +use crate::{Status, Guid, Protocol}; use core::ffi::c_void; use core::fmt; -const SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID: Guid = Guid { - data1: 0x387477c2, - data2: 0x69c7, - data3: 0x11d2, - data4: [0x82, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b] -}; - #[repr(C)] pub struct SimpleTextOutputProtocol { fn_reset: *mut c_void, fn_output_string: unsafe fn(&SimpleTextOutputProtocol, s: *const i16) -> u64 } -impl super::Protocol for SimpleTextOutputProtocol { - fn guid() -> &'static Guid { - return &SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID; - } +impl Protocol for SimpleTextOutputProtocol { + const GUID: Guid = Guid { + data1: 0x387477c2, + data2: 0x69c7, + data3: 0x11d2, + data4: [0x82, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b] + }; } impl SimpleTextOutputProtocol {