diff --git a/firmware/application/m4_startup.cpp b/firmware/application/m4_startup.cpp index 5a705bff..6dc74b4b 100644 --- a/firmware/application/m4_startup.cpp +++ b/firmware/application/m4_startup.cpp @@ -32,14 +32,14 @@ * I suppose I could force M4MEMMAP to an invalid memory reason which would * cause an exception and effectively halt the M4. But that feels gross. */ -void m4_init(const portapack::spi_flash::region_t from, void* const to) { +void m4_init(const portapack::spi_flash::region_t from, const portapack::memory::region_t to) { /* Initialize M4 code RAM */ - std::memcpy(to, from.base_address(), from.size); + std::memcpy(reinterpret_cast(to.base()), from.base(), from.size); /* M4 core is assumed to be sleeping with interrupts off, so we can mess * with its address space and RAM without concern. */ - LPC_CREG->M4MEMMAP = reinterpret_cast(to); + LPC_CREG->M4MEMMAP = to.base(); /* Reset M4 core */ LPC_RGU->RESET_CTRL[0] = (1 << 13); diff --git a/firmware/application/m4_startup.hpp b/firmware/application/m4_startup.hpp index b4763156..16758d90 100644 --- a/firmware/application/m4_startup.hpp +++ b/firmware/application/m4_startup.hpp @@ -24,8 +24,9 @@ #include +#include "memory_map.hpp" #include "spi_image.hpp" -void m4_init(const portapack::spi_flash::region_t from, void* const to); +void m4_init(const portapack::spi_flash::region_t from, const portapack::memory::region_t to); #endif/*__M4_STARTUP_H__*/ diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index aaa26e5f..815ca249 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -247,7 +247,7 @@ int main(void) { ui::Painter painter; EventDispatcher event_dispatcher { &system_view, painter, context }; - m4_init(portapack::spi_flash::baseband, portapack::spi_flash::m4_text_ram_base); + m4_init(portapack::spi_flash::baseband, portapack::memory::map::m4_code); controls_init(); lcd_frame_sync_configure(); diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 8b730049..2b2f9830 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -151,7 +151,7 @@ HackRFFirmwareView::HackRFFirmwareView(NavigationView& nav) { button_yes.on_select = [&nav](Button&){ shutdown(); - m4_init(spi_flash::hackrf, reinterpret_cast(0x10000000)); + m4_init(spi_flash::hackrf, memory::map::m4_code_hackrf); while(true) { __WFE(); diff --git a/firmware/common/portapack_shared_memory.cpp b/firmware/common/portapack_shared_memory.cpp index bf02da4f..4d4e913c 100644 --- a/firmware/common/portapack_shared_memory.cpp +++ b/firmware/common/portapack_shared_memory.cpp @@ -21,4 +21,13 @@ #include "portapack_shared_memory.hpp" -SharedMemory& shared_memory = *reinterpret_cast(0x10088000); +#include "memory_map.hpp" + +SharedMemory& shared_memory = *reinterpret_cast( + portapack::memory::map::shared_memory.base() +); + +static_assert( + sizeof(SharedMemory) <= portapack::memory::map::shared_memory.size(), + "SharedMemory is too large" +); diff --git a/firmware/common/spi_image.hpp b/firmware/common/spi_image.hpp index e693d3e9..3b8105ec 100644 --- a/firmware/common/spi_image.hpp +++ b/firmware/common/spi_image.hpp @@ -25,7 +25,7 @@ #include #include -#include "hal.h" +#include "memory_map.hpp" namespace portapack { namespace spi_flash { @@ -34,8 +34,8 @@ struct region_t { const size_t offset; const size_t size; - constexpr const void* base_address() { - return reinterpret_cast(LPC_SPIFI_DATA_CACHED_BASE + offset); + constexpr const void* base() { + return reinterpret_cast(portapack::memory::map::spifi_cached.base() + offset); } };