Skip to content

Commit 5d35b33

Browse files
committed
uefi-raw: bool: use Boolean in raw signatures
Several raw declarations used u8 where the specifications spell the field or parameter as BOOLEAN. Use the crate Boolean wrapper so the raw signature carries the same meaning. Spec: https://uefi.org/specs/UEFI/2.11/ Refs: 8.3.3, 12.5.1, and 17.1.3. TCG: https://uefi.org/specifications Ref: TCG EFI Protocol, 6.5.2 GetEventLog. Assisted-by: Codex:GPT-5.5
1 parent 1641c40 commit 5d35b33

5 files changed

Lines changed: 24 additions & 16 deletions

File tree

uefi-raw/src/protocol/console.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ pub struct SimplePointerMode {
184184
pub resolution_x: u64,
185185
pub resolution_y: u64,
186186
pub resolution_z: u64,
187-
pub left_button: u8,
188-
pub right_button: u8,
187+
pub left_button: Boolean,
188+
pub right_button: Boolean,
189189
}
190190

191191
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]

uefi-raw/src/protocol/tcg/v2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! [TPM]: https://en.wikipedia.org/wiki/Trusted_Platform_Module
1414
1515
use super::EventType;
16-
use crate::{Guid, PhysicalAddress, Status, guid};
16+
use crate::{Boolean, Guid, PhysicalAddress, Status, guid};
1717
use bitflags::bitflags;
1818
use core::ffi::c_void;
1919

@@ -151,7 +151,7 @@ pub struct Tcg2Protocol {
151151
event_log_format: Tcg2EventLogFormat,
152152
event_log_location: *mut PhysicalAddress,
153153
event_log_last_entry: *mut PhysicalAddress,
154-
event_log_truncated: *mut u8,
154+
event_log_truncated: *mut Boolean,
155155
) -> Status,
156156

157157
pub hash_log_extend_event: unsafe extern "efiapi" fn(

uefi-raw/src/protocol/usb/host_controller.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ pub struct Usb2HostControllerProtocol {
111111
this: *const Self,
112112
max_speed: *mut Speed,
113113
port_number: *mut u8,
114+
// [`Boolean::TRUE`] if the controller supports 64-bit memory
115+
// addressing, [`Boolean::false`] otherwise.
116+
//
117+
// Effectively this is treated like a [`Boolean`] but the spec types it
118+
// as `u8`.
114119
is_64_bit_capable: *mut u8,
115120
) -> Status,
116121
pub reset: unsafe extern "efiapi" fn(this: *mut Self, attributes: ResetAttributes) -> Status,

uefi-raw/src/table/runtime.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ pub struct RuntimeServices {
2121
pub get_time:
2222
unsafe extern "efiapi" fn(time: *mut Time, capabilities: *mut TimeCapabilities) -> Status,
2323
pub set_time: unsafe extern "efiapi" fn(time: *const Time) -> Status,
24-
pub get_wakeup_time:
25-
unsafe extern "efiapi" fn(enabled: *mut u8, pending: *mut u8, time: *mut Time) -> Status,
26-
pub set_wakeup_time: unsafe extern "efiapi" fn(enable: u8, time: *const Time) -> Status,
24+
pub get_wakeup_time: unsafe extern "efiapi" fn(
25+
enabled: *mut Boolean,
26+
pending: *mut Boolean,
27+
time: *mut Time,
28+
) -> Status,
29+
pub set_wakeup_time: unsafe extern "efiapi" fn(enable: Boolean, time: *const Time) -> Status,
2730
pub set_virtual_address_map: unsafe extern "efiapi" fn(
2831
map_size: usize,
2932
desc_size: usize,

uefi/src/proto/tcg/v2.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use core::fmt::{self, Debug, Formatter};
2121
use core::marker::PhantomData;
2222
use core::{ptr, slice};
2323
use ptr_meta::Pointee;
24+
use uefi_raw::Boolean;
2425
use uefi_raw::protocol::tcg::v2::{Tcg2EventHeader as EventHeader, Tcg2Protocol};
2526

2627
#[cfg(feature = "alloc")]
@@ -568,7 +569,7 @@ impl Tcg {
568569
pub fn get_event_log_v1(&mut self) -> Result<v1::EventLog<'_>> {
569570
let mut location = 0;
570571
let mut last_entry = 0;
571-
let mut truncated = 0;
572+
let mut truncated = Boolean::default();
572573

573574
let status = unsafe {
574575
(self.0.get_event_log)(
@@ -581,10 +582,12 @@ impl Tcg {
581582
};
582583

583584
if status.is_success() {
584-
let is_truncated = truncated != 0;
585-
586585
let log = unsafe {
587-
v1::EventLog::new(location as *const u8, last_entry as *const u8, is_truncated)
586+
v1::EventLog::new(
587+
location as *const u8,
588+
last_entry as *const u8,
589+
truncated.into(),
590+
)
588591
};
589592

590593
Ok(log)
@@ -597,8 +600,7 @@ impl Tcg {
597600
pub fn get_event_log_v2(&mut self) -> Result<EventLog<'_>> {
598601
let mut location = 0;
599602
let mut last_entry = 0;
600-
let mut truncated = 0;
601-
603+
let mut truncated = Boolean::default();
602604
let status = unsafe {
603605
(self.0.get_event_log)(
604606
&mut self.0,
@@ -610,13 +612,11 @@ impl Tcg {
610612
};
611613

612614
if status.is_success() {
613-
let is_truncated = truncated != 0;
614-
615615
let log = EventLog {
616616
_lifetime: PhantomData,
617617
location: location as *const u8,
618618
last_entry: last_entry as *const u8,
619-
is_truncated,
619+
is_truncated: truncated.into(),
620620
};
621621

622622
Ok(log)

0 commit comments

Comments
 (0)