Rework to make use of declared memory map regions.

This commit is contained in:
Jared Boone
2015-08-20 17:11:08 -07:00
parent 05690b20ed
commit 1c3e45917c
6 changed files with 20 additions and 10 deletions

View File

@@ -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<void*>(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<uint32_t>(to);
LPC_CREG->M4MEMMAP = to.base();
/* Reset M4 core */
LPC_RGU->RESET_CTRL[0] = (1 << 13);

View File

@@ -24,8 +24,9 @@
#include <cstddef>
#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__*/

View File

@@ -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();

View File

@@ -151,7 +151,7 @@ HackRFFirmwareView::HackRFFirmwareView(NavigationView& nav) {
button_yes.on_select = [&nav](Button&){
shutdown();
m4_init(spi_flash::hackrf, reinterpret_cast<void*>(0x10000000));
m4_init(spi_flash::hackrf, memory::map::m4_code_hackrf);
while(true) {
__WFE();