mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Rework to make use of declared memory map regions.
This commit is contained in:
parent
05690b20ed
commit
1c3e45917c
@ -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);
|
||||
|
@ -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__*/
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -21,4 +21,13 @@
|
||||
|
||||
#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"
|
||||
);
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
#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<void*>(LPC_SPIFI_DATA_CACHED_BASE + offset);
|
||||
constexpr const void* base() {
|
||||
return reinterpret_cast<void*>(portapack::memory::map::spifi_cached.base() + offset);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user