Skip to content

Commit

Permalink
Initial review (use core::...)
Browse files Browse the repository at this point in the history
  • Loading branch information
magravel committed Jun 6, 2024
1 parent ab1129b commit 9824a45
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions AdvLoggerPkg/Crates/RustAdvancedLoggerDxe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern crate std; //allow rustdoc links to reference std (e.g. println docs belo
use core::{
ffi::c_void,
fmt::{self, Write},
ptr,
sync::atomic::{AtomicPtr, Ordering},
};
use r_efi::{
Expand Down Expand Up @@ -78,21 +79,21 @@ struct AdvancedLogger {
impl AdvancedLogger {
// creates a new AdvancedLogger
const fn new() -> Self {
AdvancedLogger { protocol: AtomicPtr::new(core::ptr::null_mut()) }
AdvancedLogger { protocol: AtomicPtr::new(ptr::null_mut()) }
}

// initialize the AdvancedLogger by acquiring a pointer to the AdvancedLogger protocol.
fn init(&self, bs: *mut BootServices) {
let boot_services = unsafe { bs.as_mut().expect("Boot Services Pointer is NULL") };
let mut ptr: *mut c_void = core::ptr::null_mut();
let mut ptr: *mut c_void = ptr::null_mut();
let status = (boot_services.locate_protocol)(
&ADVANCED_LOGGER_PROTOCOL_GUID as *const Guid as *mut Guid,
core::ptr::null_mut(),
core::ptr::addr_of_mut!(ptr),
ptr::null_mut(),
ptr::addr_of_mut!(ptr),
);
match status {
Status::SUCCESS => self.protocol.store(ptr as *mut AdvancedLoggerProtocol, Ordering::SeqCst),
_ => self.protocol.store(core::ptr::null_mut(), Ordering::SeqCst),
_ => self.protocol.store(ptr::null_mut(), Ordering::SeqCst),
}
}

Expand All @@ -106,9 +107,6 @@ impl AdvancedLogger {
}
}

unsafe impl Sync for AdvancedLogger {}
unsafe impl Send for AdvancedLogger {}

struct LogTransactor<'a> {
protocol: &'a mut AdvancedLoggerProtocol,
level: usize,
Expand Down

0 comments on commit 9824a45

Please sign in to comment.