diff --git a/14_virtual_mem_part2_mmio_remap/README.md b/14_virtual_mem_part2_mmio_remap/README.md index 2e62c878..cb87b91c 100644 --- a/14_virtual_mem_part2_mmio_remap/README.md +++ b/14_virtual_mem_part2_mmio_remap/README.md @@ -57,8 +57,8 @@ separation, this tutorial makes a start by changing the following things: 1. Instead of bulk-`identity mapping` the whole of the board's address space, only the particular parts that are needed will be mapped. -1. For now, the `kernel binary` stays identity mapped. This will be changed in the in the coming - tutorials as it is a quite difficult and peculiar exercise to remap the kernel. +1. For now, the `kernel binary` stays identity mapped. This will be changed in the coming tutorials + as it is a quite difficult and peculiar exercise to remap the kernel. 1. Device `MMIO regions` are lazily remapped during a device driver's `init()`. 1. A dedicated region of virtual addresses that we reserve using `BSP` code and the `linker script` is used for this. @@ -162,8 +162,8 @@ use: /// Prevents mapping into the MMIO range of the tables. pub unsafe fn kernel_map_at( name: &'static str, - virt_pages: &MemoryRegion, - phys_pages: &MemoryRegion, + virt_region: &MemoryRegion, + phys_region: &MemoryRegion, attr: &AttributeFields, ) -> Result<(), &'static str>; @@ -3207,11 +3207,11 @@ diff -uNr 13_exceptions_part2_peripheral_IRQs/src/memory/mmu.rs 14_virtual_mem_p +/// - Does not prevent aliasing. Currently, the callers must be trusted. +pub unsafe fn kernel_map_at( + name: &'static str, -+ virt_pages: &MemoryRegion, -+ phys_pages: &MemoryRegion, ++ virt_region: &MemoryRegion, ++ phys_region: &MemoryRegion, + attr: &AttributeFields, +) -> Result<(), &'static str> { -+ if bsp::memory::mmu::virt_mmio_remap_region().overlaps(virt_pages) { ++ if bsp::memory::mmu::virt_mmio_remap_region().overlaps(virt_region) { + return Err("Attempt to manually map into MMIO region"); } -} @@ -3238,7 +3238,7 @@ diff -uNr 13_exceptions_part2_peripheral_IRQs/src/memory/mmu.rs 14_virtual_mem_p - } else { - (size, "Byte") - }; -+ kernel_map_at_unchecked(name, virt_pages, phys_pages, attr)?; ++ kernel_map_at_unchecked(name, virt_region, phys_region, attr)?; - let attr = match self.attribute_fields.mem_attributes { - MemAttributes::CacheableDRAM => "C", diff --git a/14_virtual_mem_part2_mmio_remap/src/memory/mmu.rs b/14_virtual_mem_part2_mmio_remap/src/memory/mmu.rs index e833dd1a..efc87a33 100644 --- a/14_virtual_mem_part2_mmio_remap/src/memory/mmu.rs +++ b/14_virtual_mem_part2_mmio_remap/src/memory/mmu.rs @@ -165,15 +165,15 @@ impl AddressSpace { /// - Does not prevent aliasing. Currently, the callers must be trusted. pub unsafe fn kernel_map_at( name: &'static str, - virt_pages: &MemoryRegion, - phys_pages: &MemoryRegion, + virt_region: &MemoryRegion, + phys_region: &MemoryRegion, attr: &AttributeFields, ) -> Result<(), &'static str> { - if bsp::memory::mmu::virt_mmio_remap_region().overlaps(virt_pages) { + if bsp::memory::mmu::virt_mmio_remap_region().overlaps(virt_region) { return Err("Attempt to manually map into MMIO region"); } - kernel_map_at_unchecked(name, virt_pages, phys_pages, attr)?; + kernel_map_at_unchecked(name, virt_region, phys_region, attr)?; Ok(()) } diff --git a/15_virtual_mem_part3_precomputed_tables/README.md b/15_virtual_mem_part3_precomputed_tables/README.md index a8d6f8f3..97188d49 100644 --- a/15_virtual_mem_part3_precomputed_tables/README.md +++ b/15_virtual_mem_part3_precomputed_tables/README.md @@ -1578,20 +1578,18 @@ diff -uNr 14_virtual_mem_part2_mmio_remap/src/memory/mmu.rs 15_virtual_mem_part3 +/// Add an entry to the mapping info record. +pub fn kernel_add_mapping_record( name: &'static str, -- virt_pages: &MemoryRegion, -- phys_pages: &MemoryRegion, -+ virt_region: &MemoryRegion, -+ phys_region: &MemoryRegion, + virt_region: &MemoryRegion, + phys_region: &MemoryRegion, attr: &AttributeFields, -) -> Result<(), &'static str> { -- if bsp::memory::mmu::virt_mmio_remap_region().overlaps(virt_pages) { +- if bsp::memory::mmu::virt_mmio_remap_region().overlaps(virt_region) { - return Err("Attempt to manually map into MMIO region"); +) { + if let Err(x) = mapping_record::kernel_add(name, virt_region, phys_region, attr) { + warn!("{}", x); } - -- kernel_map_at_unchecked(name, virt_pages, phys_pages, attr)?; +- kernel_map_at_unchecked(name, virt_region, phys_region, attr)?; - - Ok(()) }