-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move memory discovery to the Architecture trait
Memory discovery (finding how much we have, where etc...) shouldn't be hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait so that each platform can do its thing (riscv/arm => device tree, x86 => multiboot info or e820). Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>` method in the Architecture trait. But oh boy no... Currently a method that returns an impl Trait is not possible (rustc 1.59.0-nightly). In the future, this should be possible, see: rust-lang/rust#63066 Meanwhile, this is what I came up with. Since I can't return an impl Trait but I can pass one as parameter, I have a `for_all_memory_regions` method that creates the iterator and then calls the closure with that parameter. Code that uses that is a bit more ugly and less clear than if I could have returned an impl Trait, but it should do for now. This MUST be fixed when the above issue is resolved. Also the type signatures are a bit *complex*, this is due to my vicious fight with the rust borrow-checking-and-mighty-type-checking gods of Rust. Last but not least, a quote from the great: Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre -- Garnier
- Loading branch information
Showing
5 changed files
with
118 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters