Spaces, spaces everywhere

This commit is contained in:
Aurora 2016-09-06 13:43:00 +02:00
parent 33d3dd256d
commit 8f32048774
9 changed files with 45 additions and 44 deletions

View File

@ -24,15 +24,6 @@
#include "types.h" #include "types.h"
void __attribute__((noreturn)) mcuReboot(void);
void cleanInvalidateDCacheAndDMB(void);
bool cannotAccessVA(const void *address);
void FIQHandler(void);
void undefinedInstructionHandler(void);
void dataAbortHandler(void);
void prefetchAbortHandler(void);
typedef struct __attribute__((packed)) typedef struct __attribute__((packed))
{ {
u32 magic[2]; u32 magic[2];
@ -46,4 +37,13 @@ typedef struct __attribute__((packed))
u32 codeDumpSize; u32 codeDumpSize;
u32 stackDumpSize; u32 stackDumpSize;
u32 additionalDataSize; u32 additionalDataSize;
} ExceptionDumpHeader; } ExceptionDumpHeader;
void __attribute__((noreturn)) mcuReboot(void);
void cleanInvalidateDCacheAndDMB(void);
bool cannotAccessVA(const void *address);
void FIQHandler(void);
void undefinedInstructionHandler(void);
void dataAbortHandler(void);
void prefetchAbortHandler(void);

View File

@ -42,7 +42,7 @@ _commonHandler:
mrs r2, spsr mrs r2, spsr
mov r6, sp mov r6, sp
mrs r3, cpsr mrs r3, cpsr
tst r2, #0x20 tst r2, #0x20
bne noFPUInitNorSvcBreak bne noFPUInitNorSvcBreak
sub r0, lr, #4 sub r0, lr, #4
@ -54,7 +54,7 @@ _commonHandler:
ldr r4, [lr, #-4] ldr r4, [lr, #-4]
cmp r1, #1 cmp r1, #1
bne noFPUInit bne noFPUInit
lsl r4, #4 lsl r4, #4
sub r4, #0xc0000000 sub r4, #0xc0000000
cmp r4, #0x30000000 cmp r4, #0x30000000
@ -62,7 +62,7 @@ _commonHandler:
fmrx r0, fpexc fmrx r0, fpexc
tst r0, #0x40000000 tst r0, #0x40000000
bne noFPUInitNorSvcBreak bne noFPUInitNorSvcBreak
sub lr, #4 sub lr, #4
srsfd sp!, #0x13 srsfd sp!, #0x13
ldmfd sp!, {r0-r7} @ restore context ldmfd sp!, {r0-r7} @ restore context
@ -99,7 +99,7 @@ _commonHandler:
stmfd r6!, {r8-lr} stmfd r6!, {r8-lr}
msr cpsr_c, r3 @ restore processor mode msr cpsr_c, r3 @ restore processor mode
mov sp, r6 mov sp, r6
stmfd sp!, {r2,lr} stmfd sp!, {r2,lr}
mrc p15,0,r4,c5,c0,0 @ dfsr mrc p15,0,r4,c5,c0,0 @ dfsr
@ -108,13 +108,13 @@ _commonHandler:
fmrx r7, fpexc fmrx r7, fpexc
fmrx r8, fpinst fmrx r8, fpinst
fmrx r9, fpinst2 fmrx r9, fpinst2
stmfd sp!, {r4-r9} @ it's a bit of a mess, but we will fix that later stmfd sp!, {r4-r9} @ it's a bit of a mess, but we will fix that later
@ order of saved regs now: dfsr, ifsr, far, fpexc, fpinst, fpinst2, cpsr, pc + (2/4/8), r8-r14, r0-r7 @ order of saved regs now: dfsr, ifsr, far, fpexc, fpinst, fpinst2, cpsr, pc + (2/4/8), r8-r14, r0-r7
bic r3, #(1<<31) bic r3, #(1<<31)
fmxr fpexc, r3 @ clear the VFP11 exception flag (if it's set) fmxr fpexc, r3 @ clear the VFP11 exception flag (if it's set)
mov r0, sp mov r0, sp
mrc p15,0,r2,c0,c0,5 @ CPU ID register mrc p15,0,r2,c0,c0,5 @ CPU ID register
@ -129,7 +129,7 @@ GEN_HANDLER dataAbortHandler
.type mcuReboot, %function .type mcuReboot, %function
mcuReboot: mcuReboot:
b . @ will be replaced b . @ will be replaced
.global cleanInvalidateDCacheAndDMB .global cleanInvalidateDCacheAndDMB
.type cleanInvalidateDCacheAndDMB, %function .type cleanInvalidateDCacheAndDMB, %function
cleanInvalidateDCacheAndDMB: cleanInvalidateDCacheAndDMB:

View File

@ -23,7 +23,7 @@
.global _start .global _start
_start: _start:
add pc, r0, #(handlers - .) @ Dummy instruction to prevent compiler optimizations add pc, r0, #(handlers - .) @ Dummy instruction to prevent compiler optimizations
handlers: handlers:
.word FIQHandler .word FIQHandler
.word undefinedInstructionHandler .word undefinedInstructionHandler

View File

@ -21,25 +21,26 @@
*/ */
#pragma once #pragma once
#include "types.h"
u32 readMPUConfig(u32 regionSettings[8]); #include "types.h"
void FIQHandler(void);
void undefinedInstructionHandler(void);
void dataAbortHandler(void);
void prefetchAbortHandler(void);
typedef struct __attribute__((packed)) typedef struct __attribute__((packed))
{ {
u32 magic[2]; u32 magic[2];
u16 versionMinor, versionMajor; u16 versionMinor, versionMajor;
u16 processor, core; u16 processor, core;
u32 type; u32 type;
u32 totalSize; u32 totalSize;
u32 registerDumpSize; u32 registerDumpSize;
u32 codeDumpSize; u32 codeDumpSize;
u32 stackDumpSize; u32 stackDumpSize;
u32 additionalDataSize; u32 additionalDataSize;
} ExceptionDumpHeader; } ExceptionDumpHeader;
u32 readMPUConfig(u32 regionSettings[8]);
void FIQHandler(void);
void undefinedInstructionHandler(void);
void dataAbortHandler(void);
void prefetchAbortHandler(void);

View File

@ -24,7 +24,7 @@
\name: \name:
ldr sp, =#0x02000000 @ We make the (full descending) stack point to the end of ITCM for our exception handlers. ldr sp, =#0x02000000 @ We make the (full descending) stack point to the end of ITCM for our exception handlers.
@ It doesn't matter if we're overwriting stuff here, since we're going to reboot. @ It doesn't matter if we're overwriting stuff here, since we're going to reboot.
stmfd sp!, {r0-r7} @ FIQ has its own r8-r14 regs stmfd sp!, {r0-r7} @ FIQ has its own r8-r14 regs
ldr r1, =\@ @ macro expansion counter ldr r1, =\@ @ macro expansion counter
b _commonHandler b _commonHandler
@ -78,12 +78,12 @@ _commonHandler:
stmfd r6!, {r8-lr} stmfd r6!, {r8-lr}
msr cpsr_c, r3 @ restore processor mode msr cpsr_c, r3 @ restore processor mode
mov sp, r6 mov sp, r6
stmfd sp!, {r2,lr} @ it's a bit of a mess, but we will fix that later stmfd sp!, {r2,lr} @ it's a bit of a mess, but we will fix that later
@ order of saved regs now: cpsr, pc + (2/4/8), r8-r14, r0-r7 @ order of saved regs now: cpsr, pc + (2/4/8), r8-r14, r0-r7
mov r0, sp mov r0, sp
b mainHandler b mainHandler
GEN_HANDLER FIQHandler GEN_HANDLER FIQHandler

View File

@ -68,19 +68,19 @@ static u32 __attribute__((noinline)) copyMemory(void *dst, const void *src, u32
void __attribute__((noreturn)) mainHandler(u32 regs[REG_DUMP_SIZE / 4], u32 type) void __attribute__((noreturn)) mainHandler(u32 regs[REG_DUMP_SIZE / 4], u32 type)
{ {
ExceptionDumpHeader dumpHeader; ExceptionDumpHeader dumpHeader;
u32 registerDump[REG_DUMP_SIZE / 4]; u32 registerDump[REG_DUMP_SIZE / 4];
u8 codeDump[CODE_DUMP_SIZE]; u8 codeDump[CODE_DUMP_SIZE];
dumpHeader.magic[0] = 0xDEADC0DE; dumpHeader.magic[0] = 0xDEADC0DE;
dumpHeader.magic[1] = 0xDEADCAFE; dumpHeader.magic[1] = 0xDEADCAFE;
dumpHeader.versionMajor = 1; dumpHeader.versionMajor = 1;
dumpHeader.versionMinor = 2; dumpHeader.versionMinor = 2;
dumpHeader.processor = 9; dumpHeader.processor = 9;
dumpHeader.core = 0; dumpHeader.core = 0;
dumpHeader.type = type; dumpHeader.type = type;
dumpHeader.registerDumpSize = REG_DUMP_SIZE; dumpHeader.registerDumpSize = REG_DUMP_SIZE;
dumpHeader.codeDumpSize = CODE_DUMP_SIZE; dumpHeader.codeDumpSize = CODE_DUMP_SIZE;
dumpHeader.additionalDataSize = 0; dumpHeader.additionalDataSize = 0;
@ -94,16 +94,16 @@ void __attribute__((noreturn)) mainHandler(u32 regs[REG_DUMP_SIZE / 4], u32 type
registerDump[16] = cpsr; registerDump[16] = cpsr;
for(u32 i = 0; i < 7; i++) registerDump[8 + i] = regs[2 + i]; for(u32 i = 0; i < 7; i++) registerDump[8 + i] = regs[2 + i];
for(u32 i = 0; i < 8; i++) registerDump[i] = regs[9 + i]; for(u32 i = 0; i < 8; i++) registerDump[i] = regs[9 + i];
//Dump code //Dump code
u8 *instr = (u8 *)pc + ((cpsr & 0x20) ? 2 : 4) - dumpHeader.codeDumpSize; //Doesn't work well on 32-bit Thumb instructions, but it isn't much of a problem u8 *instr = (u8 *)pc + ((cpsr & 0x20) ? 2 : 4) - dumpHeader.codeDumpSize; //Doesn't work well on 32-bit Thumb instructions, but it isn't much of a problem
dumpHeader.codeDumpSize = copyMemory(codeDump, instr, dumpHeader.codeDumpSize, ((cpsr & 0x20) != 0) ? 2 : 4); dumpHeader.codeDumpSize = copyMemory(codeDump, instr, dumpHeader.codeDumpSize, ((cpsr & 0x20) != 0) ? 2 : 4);
//Copy register dump and code dump //Copy register dump and code dump
u8 *final = (u8 *)(FINAL_BUFFER + sizeof(ExceptionDumpHeader)); u8 *final = (u8 *)(FINAL_BUFFER + sizeof(ExceptionDumpHeader));
final += copyMemory(final, registerDump, dumpHeader.registerDumpSize, 1); final += copyMemory(final, registerDump, dumpHeader.registerDumpSize, 1);
final += copyMemory(final, codeDump, dumpHeader.codeDumpSize, 1); final += copyMemory(final, codeDump, dumpHeader.codeDumpSize, 1);
//Dump stack in place //Dump stack in place
dumpHeader.stackDumpSize = copyMemory(final, (const void *)registerDump[13], 0x1000 - (registerDump[13] & 0xFFF), 1); dumpHeader.stackDumpSize = copyMemory(final, (const void *)registerDump[13], 0x1000 - (registerDump[13] & 0xFFF), 1);

View File

@ -23,10 +23,9 @@
.global _start .global _start
_start: _start:
add pc, r0, #(handlers - .) @ Dummy instruction to prevent compiler optimizations add pc, r0, #(handlers - .) @ Dummy instruction to prevent compiler optimizations
handlers: handlers:
.word FIQHandler .word FIQHandler
.word undefinedInstructionHandler .word undefinedInstructionHandler
.word prefetchAbortHandler .word prefetchAbortHandler
.word dataAbortHandler .word dataAbortHandler

View File

@ -537,7 +537,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
break; break;
} }
case 0x0004003000008A02LL: // ErrDisp case 0x0004003000008A02LL: // ErrDisp
{ {
if(CONFIG_DEVOPTIONS == 0) if(CONFIG_DEVOPTIONS == 0)
@ -568,6 +568,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
sizeof(unitinfoCheckPatch), 3 sizeof(unitinfoCheckPatch), 3
); );
} }
break; break;
} }

View File

@ -29,9 +29,9 @@ void main(void)
{ {
void *payloadAddress = (void *)0x23F00000; void *payloadAddress = (void *)0x23F00000;
memcpy(payloadAddress, (void*)0x24F00000, payloadSize); memcpy(payloadAddress, (void *)0x24F00000, payloadSize);
flushCaches(); flushCaches();
((void (*)())payloadAddress)(); ((void (*)())payloadAddress)();
} }