#include "fake_env.h" #include #include #define DEFINE_MEMORY_SEGMENT(name, start_addr, end_addr) \ static void* fake_##name = NULL; \ void* load_fake_##name##__ () \ { \ if (fake_##name == NULL) { \ fake_##name = malloc((end_addr) - (start_addr)); \ assert(fake_##name != NULL); \ } \ return fake_##name; \ } /* Reset and clock control. */ DEFINE_MEMORY_SEGMENT(rcc, 0x40021000, 0x400210A0) /* Peripheral buses */ DEFINE_MEMORY_SEGMENT(apb1, 0x40000000, 0x40010000) DEFINE_MEMORY_SEGMENT(apb2, 0x40010000, 0x40020000) DEFINE_MEMORY_SEGMENT(ahb1, 0x40020000, 0x40024400) DEFINE_MEMORY_SEGMENT(ahb2, 0x48000000, 0x50060C00) /* System Control Block */ DEFINE_MEMORY_SEGMENT(scb, 0xE000E008, 0xE000EF04) /* Nested Vector Interrupt Controller (NVIC) */ /* Note that this memory space acutally overlaps with the SCB, but * they are functionally distinct entitites and such are modeled as * separate structures in memeory. */ DEFINE_MEMORY_SEGMENT(nvic, 0xE000E004, 0xE000E4F0) /* SRAM */ DEFINE_MEMORY_SEGMENT(sram1, 0x20000000, 0x2000C000) DEFINE_MEMORY_SEGMENT(sram2, 0x2000C000, 0x20018000) /* Serial Peripheral Interface */ DEFINE_MEMORY_SEGMENT(spi1, 0x40013000, 0x400133FF) DEFINE_MEMORY_SEGMENT(spi3, 0x40003C00, 0x40003FFF)