Add memory map code from u-boot [sq]

This commit is contained in:
Berkus Decker 2019-01-20 17:43:20 +02:00
parent 1b5a1a87aa
commit 73d852f57c
1 changed files with 44 additions and 0 deletions

View File

@ -111,3 +111,47 @@ pub fn write_ttbr_tcr_mair(el: u8, base: u64, tcr: u64, attr: u64) {
asm!("isb" :::: "volatile");
}
}
struct MemMapRegion {
virt: usize,
phys: usize,
size: usize,
attr: usize,
}
impl MemMapRegion {}
// const bcm2837_mem_map: MemMapRegion[] = {
// MemMapRegion {
// virt: 0x00000000,
// phys: 0x00000000,
// size: 0x3f000000,
// attr: PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_INNER_SHARE, // mair
// },
// MemMapRegion {
// virt: 0x3f000000,
// phys: 0x3f000000,
// size: 0x01000000,
// attr: PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | PTE_BLOCK_NON_SHARE | PTE_BLOCK_PXN | PTE_BLOCK_UXN,
// }
// }
pub struct BcmHost;
impl BcmHost {
// As per https://www.raspberrypi.org/documentation/hardware/raspberrypi/peripheral_addresses.md
/// This returns the ARM-side physical address where peripherals are mapped.
pub fn get_peripheral_address() -> usize {
0x3f00_0000
}
/// This returns the size of the peripheral's space.
pub fn get_peripheral_size() -> usize {
0x0100_0000
}
/// This returns the bus address of the SDRAM.
pub fn get_sdram_address() -> usize {
0xC000_0000 // uncached
}
}