Skip to content

patina_adv_logger: Refactor core logic from component logic#1323

Open
cfernald wants to merge 1 commit intoOpenDevicePartnership:mainfrom
cfernald:adv_log_min
Open

patina_adv_logger: Refactor core logic from component logic#1323
cfernald wants to merge 1 commit intoOpenDevicePartnership:mainfrom
cfernald:adv_log_min

Conversation

@cfernald
Copy link
Contributor

Description

Currently the adv logger crate exposes all of the component and integration test, etc. by default. However, for consumers wanting to log to the advanced from more minimal environments, this is not ideal. This commit refactors this base support to be the minimal core logic, and then a component feature on top used by DXE.

Base: Exposes the core logger logic, and nothing else. Does no use alloc.

Component: Exposes the component, protocol, and integrations test logic.

To achieve this, this refactors the write and reader into separate modules and simplifies to use a read-only and write-only paradigm to simplify the wrapper logic.

With this change, consumers can use patina_adv_logger without default features to get a minimal advanced logger implementation.

Issue #1318

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

  • Q35 w/ integration tests
  • Unit tests

Integration Instructions

N/A

Currently the adv logger crate exposes all of the component and integration
test, etc. by default. However, for consumers wanting to log to the advanced
from more minimal environments, this is not ideal. This commit refactors
this base support to be the minimal core logic, and then a component feature
on top used by DXE.

Base: Exposes the core logger logic, and nothing else. Does no use alloc.

Component: Exposes the component, protocol, and integrations test logic.

To achieve this, this refactors the write and reader into separate modules
and simplifies to use a read-only and write-only paradigm to simplify the
wrapper logic.

With this change, consumers can use patina_adv_logger without default features
to get a minimal advanced logger implementation.
@github-actions github-actions bot added the impact:non-functional Does not have a functional impact label Feb 17, 2026
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 89.18919% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
components/patina_adv_logger/src/writer.rs 84.06% 11 Missing ⚠️
components/patina_adv_logger/src/reader.rs 91.80% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@@ -0,0 +1,310 @@
//! UEFI Advanced Logger Reader Support
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the use case for the reader? Tools/tests? In FW, other than tools and the FileLogger, we only ever write, right?

Copy link
Contributor Author

@cfernald cfernald Feb 17, 2026

Choose a reason for hiding this comment

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

There are two use cases at the moment. The integration test, which uses it to verify the log! and protocol logs are both making it to the memory log, and the parser which is available in the std build, and is used to build the executable parser in this crate.

The reason I'm exposing it is basically as you mentioned, giving the option for object level parsing in external consumers, but it seems appropriate to expose IMO.

pub mod logger;

#[cfg(feature = "reader")]
pub mod reader;
Copy link
Collaborator

Choose a reason for hiding this comment

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

cargo doc --no-default-features fails:

error[E0432]: unresolved import `crate::reader`                                                                   
  --> components\patina_adv_logger\src\parser.rs:11:12
   |
11 | use crate::reader::AdvancedLogReader;
   |            ^^^^^^ could not find `reader` in the crate root
   |
note: found an item that was configured out
  --> components\patina_adv_logger\src\lib.rs:19:9
   |
18 | #[cfg(feature = "reader")]
   |       ------------------ the item is gated behind the `reader` feature
19 | pub mod reader;
   |         ^^^^^^

error[E0432]: unresolved import `alloc`
  --> components\patina_adv_logger\src\parser.rs:12:5
   |
12 | use alloc::format;
   |     ^^^^^ help: a similar path exists: `std::alloc`

The parser module depends on reader::AdvancedLogReader but reader is gated here behind the reader feature. This fails without the reader feature being enabled. You can change how you like, but this should run successfully.

pub struct AdvLoggerInfoV5 {
/// Signature 'ALOG'
signature: u32,
pub signature: u32,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have not fully read through the PR but does every field really need to be public versus pub(crate)?

buffer
}

#[allow(dead_code)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this really considered dead code given it is in the tests module and called by tests?


const TEST_DATA_SIZE: usize = 128;

fn create_buffer_v5(timer_frequency: u64, hw_port_disabled: bool) -> Box<[u8]> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

create_buffer_v5() and create_buffer_v6() exist in both reader.rs and writer.rs. Can a common test module share code for both?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:non-functional Does not have a functional impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants