relocator: Save the address of the PhysicalToEffective + EffectiveToPhysical function from the memory module is present.

This commit is contained in:
Maschell 2020-05-30 21:59:42 +02:00
parent f6031a0ef0
commit 8d46cf5303
3 changed files with 25 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "utils/logger.h"
#include "utils/dynamic.h"
#include "globals.h"
#define gModuleData ((module_information_t *) (0x00880000))
@ -113,6 +114,20 @@ extern "C" void doStart(int argc, char **argv) {
if (!gInitCalled) {
gInitCalled = 1;
CallInitHook(loadedModules);
for(auto& curModule : loadedModules){
if(curModule.getExportName().compare("homebrew_memorymapping") == 0){
for(auto& curExport : curModule.getExportDataList()){
if(curExport.getName().compare("MemoryMappingEffectiveToPhysical") == 0){
DEBUG_FUNCTION_LINE("Setting MemoryMappingEffectiveToPhysicalPTR to %08X\n", curExport.getAddress());
MemoryMappingEffectiveToPhysicalPTR = (uint32_t) curExport.getAddress();
}else if(curExport.getName().compare("MemoryMappingPhysicalToEffective") == 0){
DEBUG_FUNCTION_LINE("Setting MemoryMappingPhysicalToEffectivePTR to %08X\n", curExport.getAddress());
MemoryMappingPhysicalToEffectivePTR = (uint32_t) curExport.getAddress();
}
}
break;
}
}
}
for (int i = 0; i < gModuleData->number_used_modules; i++) {

View File

@ -0,0 +1,4 @@
#include "globals.h"
uint32_t MemoryMappingEffectiveToPhysicalPTR = 0;
uint32_t MemoryMappingPhysicalToEffectivePTR = 0;

6
relocator/src/globals.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <cstdint>
extern uint32_t MemoryMappingEffectiveToPhysicalPTR;
extern uint32_t MemoryMappingPhysicalToEffectivePTR;