New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to non-available memory areas #71
Conversation
Add a function to the MemoryMapTag struct to access all memory regions
Replace semi-colon with comma; My C++ experience must be infecting my Rust code
src/memory_map.rs
Outdated
@@ -23,9 +23,15 @@ pub struct MemoryMapTag { | |||
impl MemoryMapTag { | |||
/// Return an iterator over all AVAILABLE marked memory areas. | |||
pub fn memory_areas(&self) -> MemoryAreaIter { |
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 wonder if, rather than having two iteratory types, this could return impl Iterator<Item = &MemoryArea>
(maybe you'll need a lifetime idk) and then the body could be self.all_memory_areas().filter(|entry| entry.typ == 1)
? I think that'd be cleaner, if it works.
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.
That would be cleaner and it does work. Initially I was worried that filter wouldn't work without the standard library (I'm using this crate for work on an OS kernel where I don't have the standard library and I'm new to working without the standard library, so I haven't yet figured out what is part of the standard library vs what is part of core), so I chose to avoid using filter initially. On further investigation, it seems to work fine, so I will update my pull request to make use of fileter.
src/memory_map.rs
Outdated
#[derive(Clone, Debug)] | ||
pub struct MemoryAreaIter<'a> { | ||
pub struct AllMemoryAreaIter<'a> { |
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.
EFIMemoryMap
also could use an iterator over all memory areas.
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.
It looks to me like EFIMemoryMapTag already iterates over all memory areas.
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.
Great, thank you!
#70