-
Notifications
You must be signed in to change notification settings - Fork 1
Map the other devices automatically #98
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2f8b40b
[!][update] remove `Device::rtc` and rtc.rs
Alignof 70c5516
[!][update] remove `Device::sdhci` and sdhci.rs
Alignof a1204ac
[!][update] remove an unused method `MmioDevice::memmap`
Alignof 6ff6aac
[!][add] add `MmioDevice::name`
Alignof afa8d28
[add] newly define `OtherMmioDevice`
Alignof 5c06a11
[add] add `create_page_table_for_other_devices`
Alignof 09ec8ac
[!][add] add `other_mmio_devices` to `Devices`
Alignof 01bf3d9
[update] remove `initrd` from `Devices`
Alignof b8d644c
[add] add `split_memory_maps`
Alignof fc1f2dd
[add] add `MemoryMap::flags`
Alignof cee034f
[add] add `MemoryMap::flags_as_array`
Alignof 2fccdc9
Merge pull request #97 from Alignof/fix/creating_page_table
Alignof File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,17 +4,18 @@ | |
| //! It has a single fixed-frequency monotonic time counter (MTIME) register and a time compare register (MTIMECMP) for each HART connected to the MTIMER device. | ||
| //! A MTIMER device not connected to any HART should only have a MTIME register and no MTIMECMP registers. | ||
|
|
||
| use super::{MmioDevice, PTE_FLAGS_FOR_DEVICE}; | ||
| use crate::memmap::{ | ||
| GuestPhysicalAddress, HostPhysicalAddress, MemoryMap, page_table::constants::PAGE_SIZE, | ||
| }; | ||
| use super::MmioDevice; | ||
| use crate::memmap::HostPhysicalAddress; | ||
|
|
||
| use alloc::string::{String, ToString}; | ||
| use alloc::vec::Vec; | ||
| use fdt::{Fdt, standard_nodes::MemoryRegion}; | ||
|
|
||
| /// MTIMER: Machine level TIMER device | ||
| #[derive(Debug)] | ||
| pub struct Mtimer { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| /// Device tree name | ||
| name: String, | ||
| /// Memory maps for memory mapped register. | ||
| register_map_regions: Vec<MemoryRegion>, | ||
| } | ||
|
|
@@ -30,32 +31,12 @@ impl MmioDevice for Mtimer { | |
| Self::create_page_table(root_page_table_addr, ®ister_map_regions, clint_node.name); | ||
|
|
||
| Some(Mtimer { | ||
| name: clint_node.name.to_string(), | ||
| register_map_regions, | ||
| }) | ||
| } | ||
|
|
||
| fn memmap(&self) -> Vec<MemoryMap> { | ||
| self.register_map_regions | ||
| .clone() | ||
| .into_iter() | ||
| .map(|region| { | ||
| let mut size = region.size.unwrap(); | ||
| let mut virt_start = GuestPhysicalAddress(region.starting_address as usize); | ||
| let mut phys_start = HostPhysicalAddress(region.starting_address as usize); | ||
|
|
||
| // change memory map region if region size is less than the page size. | ||
| if phys_start % PAGE_SIZE != 0 && size < PAGE_SIZE { | ||
| size = PAGE_SIZE; | ||
| virt_start = virt_start - (virt_start % PAGE_SIZE); | ||
| phys_start = phys_start - (phys_start % PAGE_SIZE); | ||
| } | ||
|
|
||
| MemoryMap::new( | ||
| virt_start..virt_start + size, | ||
| phys_start..phys_start + size, | ||
| &PTE_FLAGS_FOR_DEVICE, | ||
| ) | ||
| }) | ||
| .collect() | ||
| fn name(&self) -> &str { | ||
| &self.name | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this boolean expression can be simplified