-
Notifications
You must be signed in to change notification settings - Fork 737
Allow custom implementations of DebugWriter #4382
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to do something like this, but I get the sense that what is in debug.rs right now is more based on what worked rather than something meant to be extensible.
I think we should create the trait, but having extract() as a member function doesn't make much sense. Probably flush() should be there instead.
The existing struct should be called DebugWriterRingBuffer
or something.
kernel/src/debug.rs
Outdated
@@ -303,22 +303,36 @@ pub struct DebugWriter { | |||
count: Cell<usize>, | |||
} | |||
|
|||
pub trait DebugWriterTrait: Write + IoWrite { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub trait DebugWriterTrait: Write + IoWrite { | |
pub trait DebugWriter: Write + IoWrite { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the draft implementation is a somewhat dirty WA intended to keep all the existing implementation as is while also allowing custom one. Ideally the empty trait functions should not be there as they are only required by specific implementations. If we are in agreement we want this, I can look into cleaner implementation when I have some free cycles...
597f65a
to
5d3ad86
Compare
Pull Request Overview
Fixes #4302
Add a trait for debug writer, so the downstream code can implement it's own, not depending on UART backend.
Testing Strategy
Tested on QEMU and local simulated RiscV platform with both UART based and non-UART implentations.
Tested debug buffer overflow on buffered implementation
TODO or Help Wanted
Would be nice to test with some implementation using
console_ordered
as it has some "intrusive" calls to the debug apiDocumentation Updated
Inline documentation added in
debug.rs
Formatting
make prepush
.