Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions core/patina_internal_depex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const GUID_SIZE: usize = mem::size_of::<r_efi::efi::Guid>();
/// The initial size of the dependency expression stack in bytes
const DEPEX_STACK_SIZE_INCREMENT: usize = 0x100;

const EVAL_REPORT: &str = "patina_internal_depex.report"; // override semantic, takes effect only before `EVAL`
Comment thread
yangrongwei marked this conversation as resolved.
Outdated
const EVAL: &str = "patina_internal_depex";

/// A UEFI dependency expression (DEPEX) opcode
#[derive(Debug, Clone, PartialEq)]
pub enum Opcode {
Expand Down Expand Up @@ -154,8 +157,19 @@ impl From<&[Opcode]> for Depex {
impl Depex {
/// Evaluates a DEPEX expression.
pub fn eval(&mut self, protocols: &[efi::Guid]) -> bool {
self.eval_with(protocols, false)
}

/// Evaluates a DEPEX expression using the overridden log target.
pub fn eval_with_report(&mut self, protocols: &[efi::Guid]) -> bool {
self.eval_with(protocols, true)
}

/// Evaluates a DEPEX expression. Supports overriding the log target.
fn eval_with(&mut self, protocols: &[efi::Guid], use_report_log: bool) -> bool {
let report = if use_report_log { EVAL_REPORT } else { EVAL };
let mut stack = Vec::with_capacity(DEPEX_STACK_SIZE_INCREMENT);
log::debug!("Depex:");
log::debug!(target: report, "Depex:");
Comment thread
yangrongwei marked this conversation as resolved.
Outdated
for (index, opcode) in self.expression.iter_mut().enumerate() {
match opcode {
Opcode::Before(_) | Opcode::After(_) => {
Expand Down Expand Up @@ -205,7 +219,7 @@ impl Depex {
}
stack.push(false);
}
log::debug!(
log::debug!(target: report,
" {opcode:x?} => {:?}, stack ->{:?}",
stack.last(),
stack.iter().rev().collect::<Vec<_>>()
Expand Down Expand Up @@ -242,23 +256,23 @@ impl Depex {
}
Opcode::True => {
stack.push(true);
log::debug!(
log::debug!(target: report,
" {opcode:x?} => {:?}, stack ->{:?}",
stack.last(),
stack.iter().rev().collect::<Vec<_>>()
);
}
Opcode::False => {
stack.push(false);
log::debug!(
log::debug!(target: report,
" {opcode:x?} => {:?}, stack ->{:?}",
stack.last(),
stack.iter().rev().collect::<Vec<_>>()
);
}
Opcode::End => {
let operator = stack.pop().unwrap_or(false);
log::debug!(
log::debug!(target: report,
" {opcode:x?} => final result: {:?}, final stack ->{:?}",
operator,
stack.iter().rev().collect::<Vec<_>>()
Expand Down
21 changes: 21 additions & 0 deletions patina_dxe_core/src/pi_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,27 @@ impl<P: PlatformInfo> PiDispatcher<P> {
guid_fmt!(driver.file_name)
);
}

if log::log_enabled!(target: "patina_internal_depex.report", log::Level::Debug) {
log::warn!("Begin Detail Report:");
for driver in &mut self.dispatcher_context.lock().pending_drivers {
Comment thread
yangrongwei marked this conversation as resolved.
Outdated
log::warn!(
"Driver {} ({:?}) found but not dispatched.",
driver.name.as_deref().unwrap_or("Unnamed"),
guid_fmt!(driver.file_name)
);

match &mut driver.depex {
Some(depex) => {
depex.eval_with_report(&PROTOCOL_DB.registered_protocols());
Comment thread
yangrongwei marked this conversation as resolved.
Outdated
}
Comment thread
yangrongwei marked this conversation as resolved.
Outdated
_ => {
log::warn!(target: "patina_internal_depex.report", " No Depex");
}
}
}
log::warn!("End Detail Report.");
}
Comment thread
yangrongwei marked this conversation as resolved.
Outdated
}
Comment on lines +117 to 136

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The messages in this "detailed report" should be at info level or higher. I think debug level.

The normal case of a driver not dispatched is already covered by warn above. This is debug information.


/// Initializes the dispatcher by registering for FV protocol installation events.
Expand Down
Loading