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 * 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. * 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 */ /* 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 /* M4 core is assumed to be sleeping with interrupts off, so we can mess
* with its address space and RAM without concern. * with its address space and RAM without concern.
*/ */
LPC_CREG->M4MEMMAP = reinterpret_cast<uint32_t>(to); LPC_CREG->M4MEMMAP = to.base();
/* Reset M4 core */ /* Reset M4 core */
LPC_RGU->RESET_CTRL[0] = (1 << 13); LPC_RGU->RESET_CTRL[0] = (1 << 13);

View File

@ -24,8 +24,9 @@
#include <cstddef> #include <cstddef>
#include "memory_map.hpp"
#include "spi_image.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__*/ #endif/*__M4_STARTUP_H__*/

View File

@ -247,7 +247,7 @@ int main(void) {
ui::Painter painter; ui::Painter painter;
EventDispatcher event_dispatcher { &system_view, painter, context }; 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(); controls_init();
lcd_frame_sync_configure(); lcd_frame_sync_configure();

View File

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

View File

@ -21,4 +21,13 @@
#include "portapack_shared_memory.hpp" #include "portapack_shared_memory.hpp"
SharedMemory& shared_memory = *reinterpret_cast<SharedMemory*>(0x10088000); #include "memory_map.hpp"
SharedMemory& shared_memory = *reinterpret_cast<SharedMemory*>(
portapack::memory::map::shared_memory.base()
);
static_assert(
sizeof(SharedMemory) <= portapack::memory::map::shared_memory.size(),
"SharedMemory is too large"
);

View File

@ -25,7 +25,7 @@
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
#include "hal.h" #include "memory_map.hpp"
namespace portapack { namespace portapack {
namespace spi_flash { namespace spi_flash {
@ -34,8 +34,8 @@ struct region_t {
const size_t offset; const size_t offset;
const size_t size; const size_t size;
constexpr const void* base_address() { constexpr const void* base() {
return reinterpret_cast<void*>(LPC_SPIFI_DATA_CACHED_BASE + offset); return reinterpret_cast<void*>(portapack::memory::map::spifi_cached.base() + offset);
} }
}; };