Destroy and create the heaps at every application start

This commit is contained in:
Maschell 2020-05-30 21:48:50 +02:00
parent 0f81a4cc8f
commit 3a0abb940f
3 changed files with 31 additions and 7 deletions

View File

@ -19,9 +19,12 @@ WUMS_INITIALIZE(){
ucSetupRequired = 0;
MemoryMapping::setupMemoryMapping();
MemoryMapping::CreateHeaps();
}
int main(int argc, char **argv) {
MemoryMapping::DestroyHeaps();
MemoryMapping::CreateHeaps();
return 0;
}

View File

@ -347,13 +347,6 @@ void MemoryMapping::setupMemoryMapping() {
DCFlushRange(pageTableCpy,sizeof(pageTableCpy));
DEBUG_FUNCTION_LINE("done");
for(int32_t i = 0; /* waiting for a break */; i++) {
if(mem_mapping[i].physical_addresses == NULL) {
break;
}
MEMCreateExpHeapEx((void *) (mem_mapping[i].effective_start_address), mem_mapping[i].effective_end_address - mem_mapping[i].effective_start_address, 0);
}
//printPageTableTranslation(srTableCpy,pageTableCpy);
//runOnAllCores(readAndPrintSegmentRegister,NULL,0,16,0x80000);
@ -396,6 +389,30 @@ void MemoryMapping::free(void* ptr){
}
}
void MemoryMapping::CreateHeaps() {
for (int32_t i = 0; /* waiting for a break */; i++) {
if (mem_mapping[i].physical_addresses == NULL) {
break;
}
void *address = (void *) (mem_mapping[i].effective_start_address);
uint32_t size = mem_mapping[i].effective_end_address - mem_mapping[i].effective_start_address;
MEMCreateExpHeapEx(address, size, 0);
DEBUG_FUNCTION_LINE("Created heap @%08X, size %d KiB", address, size / 1024);
}
}
void MemoryMapping::DestroyHeaps() {
for (int32_t i = 0; /* waiting for a break */; i++) {
if (mem_mapping[i].physical_addresses == NULL) {
break;
}
void *address = (void *) (mem_mapping[i].effective_start_address);
uint32_t size = mem_mapping[i].effective_end_address - mem_mapping[i].effective_start_address;
MEMDestroyExpHeap((MEMHeapHandle) address);
memset(address, 0, size);
DEBUG_FUNCTION_LINE("Destroyed heap @%08X", address);
}
}
uint32_t MemoryMapping::getAreaSizeFromPageTable(uint32_t start, uint32_t maxSize) {
sr_table_t srTable;

View File

@ -165,6 +165,10 @@ public:
static void setupMemoryMapping();
static void CreateHeaps();
static void DestroyHeaps();
static void printPageTableTranslation(sr_table_t srTable, uint32_t *translation_table);
static void writeTestValuesToMemory();