Add chainloader (stage2) (need to edit more files)
This commit is contained in:
12
fusee/fusee-secondary/src/chainloader.c
Normal file
12
fusee/fusee-secondary/src/chainloader.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "chainloader.h"
|
||||
|
||||
uint8_t g_payload_arg_data[PAYLOAD_ARG_DATA_MAX_SIZE] = {1};
|
||||
|
||||
#pragma GCC optimize (3)
|
||||
void relocate_and_chainload_main(uintptr_t load_address, uintptr_t src_address, size_t size, int argc) {
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
*(uint8_t *)(load_address + i) = *(uint8_t *)(src_address + i);
|
||||
}
|
||||
|
||||
((void (*)(int, void *))load_address)(argc, g_payload_arg_data);
|
||||
}
|
||||
13
fusee/fusee-secondary/src/chainloader.h
Normal file
13
fusee/fusee-secondary/src/chainloader.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef FUSEE_CHAINLOADER_H
|
||||
#define FUSEE_CHAINLOADER_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define PAYLOAD_ARG_DATA_MAX_SIZE 0x1000
|
||||
|
||||
extern uint8_t g_payload_arg_data[PAYLOAD_ARG_DATA_MAX_SIZE];
|
||||
|
||||
void relocate_and_chainload(uintptr_t load_address, uintptr_t src_address, size_t size, int argc);
|
||||
|
||||
#endif
|
||||
@@ -2,10 +2,11 @@
|
||||
mov r\@, #0
|
||||
.endm
|
||||
|
||||
.section .text.start
|
||||
.section .text.start, "ax", %progbits
|
||||
.arm
|
||||
.align 5
|
||||
.global _start
|
||||
.type _start, %function
|
||||
_start:
|
||||
/* Insert NOPs for convenience (i.e. to use Nintendo's BCTs, for example) */
|
||||
.rept 16
|
||||
@@ -57,3 +58,12 @@ _start:
|
||||
ldmfd sp!, {r0, r1}
|
||||
bl main
|
||||
b .
|
||||
|
||||
.section .chainloader.text.start, "ax", %progbits
|
||||
.arm
|
||||
.align 5
|
||||
.global relocate_and_chainload
|
||||
.type relocate_and_chainload, %function
|
||||
relocate_and_chainload:
|
||||
ldr sp, =0x40010000
|
||||
b relocate_and_chainload_main
|
||||
|
||||
Reference in New Issue
Block a user