pull/143/head
Andre Richter 3 years ago
parent 02c01c821b
commit b8227b7e5d
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -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<Virtual>,
phys_pages: &MemoryRegion<Physical>,
virt_region: &MemoryRegion<Virtual>,
phys_region: &MemoryRegion<Physical>,
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<Virtual>,
+ phys_pages: &MemoryRegion<Physical>,
+ virt_region: &MemoryRegion<Virtual>,
+ phys_region: &MemoryRegion<Physical>,
+ 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",

@ -165,15 +165,15 @@ impl<const AS_SIZE: usize> AddressSpace<AS_SIZE> {
/// - Does not prevent aliasing. Currently, the callers must be trusted.
pub unsafe fn kernel_map_at(
name: &'static str,
virt_pages: &MemoryRegion<Virtual>,
phys_pages: &MemoryRegion<Physical>,
virt_region: &MemoryRegion<Virtual>,
phys_region: &MemoryRegion<Physical>,
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(())
}

@ -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<Virtual>,
- phys_pages: &MemoryRegion<Physical>,
+ virt_region: &MemoryRegion<Virtual>,
+ phys_region: &MemoryRegion<Physical>,
virt_region: &MemoryRegion<Virtual>,
phys_region: &MemoryRegion<Physical>,
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(())
}

Loading…
Cancel
Save