Skip to content
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

Merged
merged 3 commits into from Nov 2, 2020

Conversation

CalebLBaker
Copy link
Contributor

#70

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
@@ -23,9 +23,15 @@ pub struct MemoryMapTag {
impl MemoryMapTag {
/// Return an iterator over all AVAILABLE marked memory areas.
pub fn memory_areas(&self) -> MemoryAreaIter {
Copy link
Member

@IsaacWoods IsaacWoods Nov 2, 2020

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.

Copy link
Contributor Author

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.

#[derive(Clone, Debug)]
pub struct MemoryAreaIter<'a> {
pub struct AllMemoryAreaIter<'a> {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@IsaacWoods IsaacWoods left a comment

Choose a reason for hiding this comment

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

Great, thank you!

@IsaacWoods IsaacWoods merged commit c05546a into rust-osdev:master Nov 2, 2020
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants