26 lines
697 B
C
26 lines
697 B
C
#include <stdint.h>
|
|
#include <lib.h>
|
|
#include <moduleLoader.h>
|
|
#include <naiveConsole.h>
|
|
|
|
static uint32_t readUint32(uint8_t ** address) {
|
|
uint32_t result = *(uint32_t*)(*address);
|
|
*address += sizeof(uint32_t);
|
|
return result;
|
|
}
|
|
|
|
static void loadModule(uint8_t ** module, void * targetModuleAddress) {
|
|
uint32_t moduleSize = readUint32(module);
|
|
|
|
memcpy(targetModuleAddress, *module, moduleSize);
|
|
*module += moduleSize;
|
|
}
|
|
|
|
void loadModules(void * payloadStart, void ** targetModuleAddress) {
|
|
int i;
|
|
uint8_t * currentModule = (uint8_t*)payloadStart;
|
|
uint32_t moduleCount = readUint32(¤tModule);
|
|
|
|
for (i = 0; i < moduleCount; i++)
|
|
loadModule(¤tModule, targetModuleAddress[i]);
|
|
} |