From 73d852f57cd66ff3e3a92d55259d4ba14acb67a0 Mon Sep 17 00:00:00 2001 From: Berkus Decker Date: Sun, 20 Jan 2019 17:43:20 +0200 Subject: [PATCH] Add memory map code from u-boot [sq] --- src/arch/aarch64/mod.rs | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/arch/aarch64/mod.rs b/src/arch/aarch64/mod.rs index fe6dd39..b3ab996 100644 --- a/src/arch/aarch64/mod.rs +++ b/src/arch/aarch64/mod.rs @@ -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 + } +}