Clean-up, fixed mistake
GCC, why no u warn me of strict aliasing
This commit is contained in:
parent
6707a36ffe
commit
9468582d83
@ -33,7 +33,7 @@ ARCH := -mthumb -mthumb-interwork
|
|||||||
|
|
||||||
CFLAGS := -g -Wall -O2\
|
CFLAGS := -g -Wall -O2\
|
||||||
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
|
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
|
||||||
-ffast-math -std=c99\
|
-ffast-math -Wno-main -std=c99\
|
||||||
$(ARCH)
|
$(ARCH)
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -DARM9
|
CFLAGS += $(INCLUDE) -DARM9
|
||||||
|
@ -1,151 +0,0 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Sample code of OS dependent controls for FatFs */
|
|
||||||
/* (C)ChaN, 2014 */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "../ff.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if _FS_REENTRANT
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Create a Synchronization Object */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called in f_mount() function to create a new
|
|
||||||
/ synchronization object, such as semaphore and mutex. When a 0 is returned,
|
|
||||||
/ the f_mount() function fails with FR_INT_ERR.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_cre_syncobj ( /* !=0:Function succeeded, ==0:Could not create due to any error */
|
|
||||||
BYTE vol, /* Corresponding logical drive being processed */
|
|
||||||
_SYNC_t *sobj /* Pointer to return the created sync object */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
|
|
||||||
*sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */
|
|
||||||
ret = (int)(*sobj != INVALID_HANDLE_VALUE);
|
|
||||||
|
|
||||||
// *sobj = SyncObjects[vol]; /* uITRON (give a static created sync object) */
|
|
||||||
// ret = 1; /* The initial value of the semaphore must be 1. */
|
|
||||||
|
|
||||||
// *sobj = OSMutexCreate(0, &err); /* uC/OS-II */
|
|
||||||
// ret = (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
// *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */
|
|
||||||
// ret = (int)(*sobj != NULL);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Delete a Synchronization Object */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called in f_mount() function to delete a synchronization
|
|
||||||
/ object that created with ff_cre_syncobj function. When a 0 is returned,
|
|
||||||
/ the f_mount() function fails with FR_INT_ERR.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_del_syncobj ( /* !=0:Function succeeded, ==0:Could not delete due to any error */
|
|
||||||
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
|
|
||||||
ret = CloseHandle(sobj); /* Win32 */
|
|
||||||
|
|
||||||
// ret = 1; /* uITRON (nothing to do) */
|
|
||||||
|
|
||||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */
|
|
||||||
// ret = (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
// vSemaphoreDelete(sobj); /* FreeRTOS */
|
|
||||||
// ret = 1;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Request Grant to Access the Volume */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called on entering file functions to lock the volume.
|
|
||||||
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */
|
|
||||||
_SYNC_t sobj /* Sync object to wait */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = (int)(WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */
|
|
||||||
|
|
||||||
// ret = (int)(wai_sem(sobj) == E_OK); /* uITRON */
|
|
||||||
|
|
||||||
// OSMutexPend(sobj, _FS_TIMEOUT, &err)); /* uC/OS-II */
|
|
||||||
// ret = (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
// ret = (int)(xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE); /* FreeRTOS */
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Release Grant to Access the Volume */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called on leaving file functions to unlock the volume.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void ff_rel_grant (
|
|
||||||
_SYNC_t sobj /* Sync object to be signaled */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ReleaseMutex(sobj); /* Win32 */
|
|
||||||
|
|
||||||
// sig_sem(sobj); /* uITRON */
|
|
||||||
|
|
||||||
// OSMutexPost(sobj); /* uC/OS-II */
|
|
||||||
|
|
||||||
// xSemaphoreGive(sobj); /* FreeRTOS */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if _USE_LFN == 3 /* LFN with a working buffer on the heap */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Allocate a memory block */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block */
|
|
||||||
UINT msize /* Number of bytes to allocate */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Free a memory block */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void ff_memfree (
|
|
||||||
void* mblock /* Pointer to the memory block to free */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
free(mblock); /* Discard the memory block with POSIX API */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -4,12 +4,12 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define u8 uint8_t
|
//Common data types
|
||||||
#define u16 uint16_t
|
typedef uint8_t u8;
|
||||||
#define u32 uint32_t
|
typedef uint16_t u16;
|
||||||
#define u64 uint64_t
|
typedef uint32_t u32;
|
||||||
|
typedef uint64_t u64;
|
||||||
#define vu8 volatile u8
|
typedef volatile u8 vu8;
|
||||||
#define vu16 volatile u16
|
typedef volatile u16 vu16;
|
||||||
#define vu32 volatile u32
|
typedef volatile u32 vu32;
|
||||||
#define vu64 volatile u64
|
typedef volatile u64 vu64;
|
@ -4,12 +4,7 @@
|
|||||||
|
|
||||||
@waitcycles ( u32 us )
|
@waitcycles ( u32 us )
|
||||||
waitcycles:
|
waitcycles:
|
||||||
PUSH {R0-R2,LR}
|
waitcycles_loop:
|
||||||
STR R0, [SP,#4]
|
subs r0, #1
|
||||||
waitcycles_loop:
|
bgt waitcycles_loop
|
||||||
LDR R3, [SP,#4]
|
bx lr
|
||||||
SUBS R2, R3, #1
|
|
||||||
STR R2, [SP,#4]
|
|
||||||
CMP R3, #0
|
|
||||||
BNE waitcycles_loop
|
|
||||||
POP {R0-R2,PC}
|
|
||||||
|
@ -337,7 +337,7 @@ static int SD_Init()
|
|||||||
{
|
{
|
||||||
inittarget(&handleSD);
|
inittarget(&handleSD);
|
||||||
|
|
||||||
waitcycles(1u << 19); //Card needs a little bit of time to be detected, it seems
|
waitcycles(1u << 18); //Card needs a little bit of time to be detected, it seems
|
||||||
|
|
||||||
//If not inserted
|
//If not inserted
|
||||||
if (!(*((vu16*)0x1000601c) & TMIO_STAT0_SIGSTATE)) return -1;
|
if (!(*((vu16*)0x1000601c) & TMIO_STAT0_SIGSTATE)) return -1;
|
||||||
|
@ -124,5 +124,4 @@ u32 sdmmc_sdcard_writesectors(u32 sector_no, u32 numsectors, vu8 *in);
|
|||||||
mmcdevice *getMMCDevice(int drive);
|
mmcdevice *getMMCDevice(int drive);
|
||||||
|
|
||||||
u32 sdmmc_nand_readsectors(u32 sector_no, u32 numsectors, vu8 *out);
|
u32 sdmmc_nand_readsectors(u32 sector_no, u32 numsectors, vu8 *out);
|
||||||
u32 sdmmc_nand_writesectors(u32 sector_no, u32 numsectors, vu8 *in);
|
u32 sdmmc_nand_writesectors(u32 sector_no, u32 numsectors, vu8 *in);
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#define PAYLOAD_ADDRESS 0x23F00000
|
#define PAYLOAD_ADDRESS 0x23F00000
|
||||||
|
|
||||||
int main()
|
void main()
|
||||||
{
|
{
|
||||||
FATFS fs;
|
FATFS fs;
|
||||||
FIL payload;
|
FIL payload;
|
||||||
@ -14,6 +14,4 @@ int main()
|
|||||||
f_read(&payload, (void *)PAYLOAD_ADDRESS, f_size(&payload), &br);
|
f_read(&payload, (void *)PAYLOAD_ADDRESS, f_size(&payload), &br);
|
||||||
((void (*)())PAYLOAD_ADDRESS)();
|
((void (*)())PAYLOAD_ADDRESS)();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 1;
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
// From http://github.com/b1l1s/ctr
|
// From http://github.com/b1l1s/ctr
|
||||||
|
|
||||||
#ifndef CRYPTO_INC
|
#pragma once
|
||||||
#define CRYPTO_INC
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
@ -51,6 +50,4 @@
|
|||||||
//NAND/FIRM stuff
|
//NAND/FIRM stuff
|
||||||
void nandFirm0(u8 *outbuf, u32 size, u32 console);
|
void nandFirm0(u8 *outbuf, u32 size, u32 console);
|
||||||
void decArm9Bin(u8 *armHdr, u32 mode);
|
void decArm9Bin(u8 *armHdr, u32 mode);
|
||||||
void setKeyXs(u8 *armHdr);
|
void setKeyXs(u8 *armHdr);
|
||||||
|
|
||||||
#endif
|
|
@ -4,12 +4,9 @@
|
|||||||
* Copyright (c) 2015 All Rights Reserved
|
* Copyright (c) 2015 All Rights Reserved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DRAW_INC
|
#pragma once
|
||||||
#define DRAW_INC
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
void loadSplash(void);
|
void loadSplash(void);
|
||||||
void __attribute__((naked)) shutdownLCD(void);
|
void __attribute__((naked)) shutdownLCD(void);
|
||||||
|
|
||||||
#endif
|
|
@ -4,8 +4,7 @@
|
|||||||
* Copyright (c) 2015 All Rights Reserved
|
* Copyright (c) 2015 All Rights Reserved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EMUNAND_INC
|
#pragma once
|
||||||
#define EMUNAND_INC
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
@ -14,6 +13,4 @@
|
|||||||
void getEmunandSect(u32 *off, u32 *head);
|
void getEmunandSect(u32 *off, u32 *head);
|
||||||
void getSDMMC(void *pos, u32 *off, u32 size);
|
void getSDMMC(void *pos, u32 *off, u32 size);
|
||||||
void getEmuRW(void *pos, u32 size, u32 *readOff, u32 *writeOff);
|
void getEmuRW(void *pos, u32 size, u32 *readOff, u32 *writeOff);
|
||||||
void getMPU(void *pos, u32 *off, u32 size);
|
void getMPU(void *pos, u32 *off, u32 size);
|
||||||
|
|
||||||
#endif
|
|
@ -1,151 +0,0 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Sample code of OS dependent controls for FatFs */
|
|
||||||
/* (C)ChaN, 2014 */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "../ff.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if _FS_REENTRANT
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Create a Synchronization Object */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called in f_mount() function to create a new
|
|
||||||
/ synchronization object, such as semaphore and mutex. When a 0 is returned,
|
|
||||||
/ the f_mount() function fails with FR_INT_ERR.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_cre_syncobj ( /* !=0:Function succeeded, ==0:Could not create due to any error */
|
|
||||||
BYTE vol, /* Corresponding logical drive being processed */
|
|
||||||
_SYNC_t *sobj /* Pointer to return the created sync object */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
|
|
||||||
*sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */
|
|
||||||
ret = (int)(*sobj != INVALID_HANDLE_VALUE);
|
|
||||||
|
|
||||||
// *sobj = SyncObjects[vol]; /* uITRON (give a static created sync object) */
|
|
||||||
// ret = 1; /* The initial value of the semaphore must be 1. */
|
|
||||||
|
|
||||||
// *sobj = OSMutexCreate(0, &err); /* uC/OS-II */
|
|
||||||
// ret = (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
// *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */
|
|
||||||
// ret = (int)(*sobj != NULL);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Delete a Synchronization Object */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called in f_mount() function to delete a synchronization
|
|
||||||
/ object that created with ff_cre_syncobj function. When a 0 is returned,
|
|
||||||
/ the f_mount() function fails with FR_INT_ERR.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_del_syncobj ( /* !=0:Function succeeded, ==0:Could not delete due to any error */
|
|
||||||
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
|
|
||||||
ret = CloseHandle(sobj); /* Win32 */
|
|
||||||
|
|
||||||
// ret = 1; /* uITRON (nothing to do) */
|
|
||||||
|
|
||||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */
|
|
||||||
// ret = (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
// vSemaphoreDelete(sobj); /* FreeRTOS */
|
|
||||||
// ret = 1;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Request Grant to Access the Volume */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called on entering file functions to lock the volume.
|
|
||||||
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */
|
|
||||||
_SYNC_t sobj /* Sync object to wait */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = (int)(WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */
|
|
||||||
|
|
||||||
// ret = (int)(wai_sem(sobj) == E_OK); /* uITRON */
|
|
||||||
|
|
||||||
// OSMutexPend(sobj, _FS_TIMEOUT, &err)); /* uC/OS-II */
|
|
||||||
// ret = (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
// ret = (int)(xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE); /* FreeRTOS */
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Release Grant to Access the Volume */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called on leaving file functions to unlock the volume.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void ff_rel_grant (
|
|
||||||
_SYNC_t sobj /* Sync object to be signaled */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ReleaseMutex(sobj); /* Win32 */
|
|
||||||
|
|
||||||
// sig_sem(sobj); /* uITRON */
|
|
||||||
|
|
||||||
// OSMutexPost(sobj); /* uC/OS-II */
|
|
||||||
|
|
||||||
// xSemaphoreGive(sobj); /* FreeRTOS */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if _USE_LFN == 3 /* LFN with a working buffer on the heap */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Allocate a memory block */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block */
|
|
||||||
UINT msize /* Number of bytes to allocate */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Free a memory block */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void ff_memfree (
|
|
||||||
void* mblock /* Pointer to the memory block to free */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
free(mblock); /* Discard the memory block with POSIX API */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,15 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "../../types.h"
|
||||||
#define u8 uint8_t
|
|
||||||
#define u16 uint16_t
|
|
||||||
#define u32 uint32_t
|
|
||||||
#define u64 uint64_t
|
|
||||||
|
|
||||||
#define vu8 volatile u8
|
|
||||||
#define vu16 volatile u16
|
|
||||||
#define vu32 volatile u32
|
|
||||||
#define vu64 volatile u64
|
|
@ -4,12 +4,7 @@
|
|||||||
|
|
||||||
@waitcycles ( u32 us )
|
@waitcycles ( u32 us )
|
||||||
waitcycles:
|
waitcycles:
|
||||||
PUSH {R0-R2,LR}
|
waitcycles_loop:
|
||||||
STR R0, [SP,#4]
|
subs r0, #1
|
||||||
waitcycles_loop:
|
bgt waitcycles_loop
|
||||||
LDR R3, [SP,#4]
|
bx lr
|
||||||
SUBS R2, R3, #1
|
|
||||||
STR R2, [SP,#4]
|
|
||||||
CMP R3, #0
|
|
||||||
BNE waitcycles_loop
|
|
||||||
POP {R0-R2,PC}
|
|
||||||
|
@ -337,7 +337,7 @@ static int SD_Init()
|
|||||||
{
|
{
|
||||||
inittarget(&handleSD);
|
inittarget(&handleSD);
|
||||||
|
|
||||||
waitcycles(1u << 19); //Card needs a little bit of time to be detected, it seems
|
waitcycles(1u << 18); //Card needs a little bit of time to be detected, it seems
|
||||||
|
|
||||||
//If not inserted
|
//If not inserted
|
||||||
if (!(*((vu16*)0x1000601c) & TMIO_STAT0_SIGSTATE)) return -1;
|
if (!(*((vu16*)0x1000601c) & TMIO_STAT0_SIGSTATE)) return -1;
|
||||||
|
@ -124,5 +124,4 @@ u32 sdmmc_sdcard_writesectors(u32 sector_no, u32 numsectors, vu8 *in);
|
|||||||
mmcdevice *getMMCDevice(int drive);
|
mmcdevice *getMMCDevice(int drive);
|
||||||
|
|
||||||
u32 sdmmc_nand_readsectors(u32 sector_no, u32 numsectors, vu8 *out);
|
u32 sdmmc_nand_readsectors(u32 sector_no, u32 numsectors, vu8 *out);
|
||||||
u32 sdmmc_nand_writesectors(u32 sector_no, u32 numsectors, vu8 *in);
|
u32 sdmmc_nand_writesectors(u32 sector_no, u32 numsectors, vu8 *in);
|
||||||
|
|
@ -28,7 +28,7 @@ static const char *firmPathPatched = NULL;
|
|||||||
void setupCFW(void){
|
void setupCFW(void){
|
||||||
|
|
||||||
//Determine if booting with A9LH via PDN_SPI_CNT
|
//Determine if booting with A9LH via PDN_SPI_CNT
|
||||||
u8 a9lhBoot = (*(u8 *)0x101401C0 == 0x0) ? 1 : 0;
|
u32 a9lhBoot = (*(u8 *)0x101401C0 == 0x0) ? 1 : 0;
|
||||||
//Retrieve the last booted FIRM via CFG_BOOTENV
|
//Retrieve the last booted FIRM via CFG_BOOTENV
|
||||||
u8 previousFirm = *(u8 *)0x10010000;
|
u8 previousFirm = *(u8 *)0x10010000;
|
||||||
u32 overrideConfig = 0;
|
u32 overrideConfig = 0;
|
||||||
@ -135,11 +135,11 @@ static u32 loadEmu(void){
|
|||||||
|
|
||||||
u32 emuOffset = 0,
|
u32 emuOffset = 0,
|
||||||
emuHeader = 0,
|
emuHeader = 0,
|
||||||
emuRead = 0,
|
emuRead,
|
||||||
emuWrite = 0,
|
emuWrite,
|
||||||
sdmmcOffset = 0,
|
sdmmcOffset,
|
||||||
mpuOffset = 0,
|
mpuOffset,
|
||||||
emuCodeOffset = 0;
|
emuCodeOffset;
|
||||||
|
|
||||||
//Read emunand code from SD
|
//Read emunand code from SD
|
||||||
const char path[] = "/rei/emunand/emunand.bin";
|
const char path[] = "/rei/emunand/emunand.bin";
|
||||||
@ -197,23 +197,21 @@ u32 patchFirm(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Disable signature checks
|
//Disable signature checks
|
||||||
u32 sigOffset = 0,
|
u32 sigOffset,
|
||||||
sigOffset2 = 0;
|
sigOffset2;
|
||||||
|
|
||||||
getSignatures(firmLocation, firmSize, &sigOffset, &sigOffset2);
|
getSignatures(firmLocation, firmSize, &sigOffset, &sigOffset2);
|
||||||
memcpy((void *)sigOffset, sigPat1, sizeof(sigPat1));
|
memcpy((void *)sigOffset, sigPat1, sizeof(sigPat1));
|
||||||
memcpy((void *)sigOffset2, sigPat2, sizeof(sigPat2));
|
memcpy((void *)sigOffset2, sigPat2, sizeof(sigPat2));
|
||||||
|
|
||||||
//Patch ARM9 entrypoint on N3DS to skip arm9loader
|
//Patch ARM9 entrypoint on N3DS to skip arm9loader
|
||||||
if(console){
|
if(console)
|
||||||
u32 *arm9 = (u32 *)&firmLocation->arm9Entry;
|
firmLocation->arm9Entry = (u8 *)0x801B01C;
|
||||||
*arm9 = 0x801B01C;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Patch FIRM reboots, not on 9.0 FIRM as it breaks firmlaunchhax
|
//Patch FIRM reboots, not on 9.0 FIRM as it breaks firmlaunchhax
|
||||||
if(mode){
|
if(mode){
|
||||||
u32 rebootOffset = 0,
|
u32 rebootOffset,
|
||||||
fOpenOffset = 0;
|
fOpenOffset;
|
||||||
|
|
||||||
//Read reboot code from SD
|
//Read reboot code from SD
|
||||||
const char path[] = "/rei/reboot/reboot.bin";
|
const char path[] = "/rei/reboot/reboot.bin";
|
||||||
@ -254,10 +252,10 @@ void launchFirm(void){
|
|||||||
vu32 *const arm11 = (u32 *)0x1FFFFFF8;
|
vu32 *const arm11 = (u32 *)0x1FFFFFF8;
|
||||||
*arm11 = (u32)shutdownLCD;
|
*arm11 = (u32)shutdownLCD;
|
||||||
while(*arm11);
|
while(*arm11);
|
||||||
|
|
||||||
//Set ARM11 kernel
|
//Set ARM11 kernel
|
||||||
*arm11 = (u32)firmLocation->arm11Entry;
|
*arm11 = (u32)firmLocation->arm11Entry;
|
||||||
|
|
||||||
//Final jump to arm9 binary
|
//Final jump to arm9 binary
|
||||||
((void (*)())firmLocation->arm9Entry)();
|
((void (*)())firmLocation->arm9Entry)();
|
||||||
}
|
}
|
@ -4,8 +4,7 @@
|
|||||||
* Copyright (c) 2015 All Rights Reserved
|
* Copyright (c) 2015 All Rights Reserved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FIRM_INC
|
#pragma once
|
||||||
#define FIRM_INC
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
@ -17,9 +16,25 @@
|
|||||||
#define BUTTON_A 1
|
#define BUTTON_A 1
|
||||||
#define SAFEMODE (BUTTON_L1R1 | BUTTON_A | (1 << 6))
|
#define SAFEMODE (BUTTON_L1R1 | BUTTON_A | (1 << 6))
|
||||||
|
|
||||||
|
//FIRM Header layout
|
||||||
|
typedef struct firmSectionHeader {
|
||||||
|
u32 offset;
|
||||||
|
u8 *address;
|
||||||
|
u32 size;
|
||||||
|
u32 procType;
|
||||||
|
u8 hash[0x20];
|
||||||
|
} firmSectionHeader;
|
||||||
|
|
||||||
|
typedef struct firmHeader {
|
||||||
|
u32 magic;
|
||||||
|
u32 reserved1;
|
||||||
|
u8 *arm11Entry;
|
||||||
|
u8 *arm9Entry;
|
||||||
|
u8 reserved2[0x30];
|
||||||
|
firmSectionHeader section[4];
|
||||||
|
} firmHeader;
|
||||||
|
|
||||||
void setupCFW(void);
|
void setupCFW(void);
|
||||||
u32 loadFirm(void);
|
u32 loadFirm(void);
|
||||||
u32 patchFirm(void);
|
u32 patchFirm(void);
|
||||||
void launchFirm(void);
|
void launchFirm(void);
|
||||||
|
|
||||||
#endif
|
|
@ -2,8 +2,7 @@
|
|||||||
* fs.h
|
* fs.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FS_INC
|
#pragma once
|
||||||
#define FS_INC
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
@ -11,6 +10,4 @@ u32 mountSD(void);
|
|||||||
u32 fileRead(u8 *dest, const char *path, u32 size);
|
u32 fileRead(u8 *dest, const char *path, u32 size);
|
||||||
u32 fileWrite(const u8 *buffer, const char *path, u32 size);
|
u32 fileWrite(const u8 *buffer, const char *path, u32 size);
|
||||||
u32 fileSize(const char *path);
|
u32 fileSize(const char *path);
|
||||||
u32 fileExists(const char *path);
|
u32 fileExists(const char *path);
|
||||||
|
|
||||||
#endif
|
|
@ -2,11 +2,8 @@
|
|||||||
* loader.h
|
* loader.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LOADER_INC
|
#pragma once
|
||||||
#define LOADER_INC
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
void loadPayload(void);
|
void loadPayload(void);
|
||||||
|
|
||||||
#endif
|
|
@ -4,14 +4,11 @@
|
|||||||
* Copyright (c) 2015 All Rights Reserved
|
* Copyright (c) 2015 All Rights Reserved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MEMORY_INC
|
#pragma once
|
||||||
#define MEMORY_INC
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
void memcpy(void *dest, const void *src, u32 size);
|
void memcpy(void *dest, const void *src, u32 size);
|
||||||
void memset(void *dest, int filler, u32 size);
|
void memset(void *dest, int filler, u32 size);
|
||||||
int memcmp(const void *buf1, const void *buf2, u32 size);
|
int memcmp(const void *buf1, const void *buf2, u32 size);
|
||||||
void *memsearch(void *start_pos, const void *search, u32 size, u32 size_search);
|
void *memsearch(void *start_pos, const void *search, u32 size, u32 size_search);
|
||||||
|
|
||||||
#endif
|
|
@ -4,8 +4,7 @@
|
|||||||
* Copyright (c) 2015 All Rights Reserved
|
* Copyright (c) 2015 All Rights Reserved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PATCHES_INC
|
#pragma once
|
||||||
#define PATCHES_INC
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
@ -25,6 +24,4 @@ const u8 emuInstr[5];
|
|||||||
void getSignatures(void *pos, u32 size, u32 *off, u32 *off2);
|
void getSignatures(void *pos, u32 size, u32 *off, u32 *off2);
|
||||||
void getReboot(void *pos, u32 size, u32 *off);
|
void getReboot(void *pos, u32 size, u32 *off);
|
||||||
void getfOpen(void *pos, u32 size, u32 *off);
|
void getfOpen(void *pos, u32 size, u32 *off);
|
||||||
void getFIRMWrite(void *pos, u32 size, u32 *off);
|
void getFIRMWrite(void *pos, u32 size, u32 *off);
|
||||||
|
|
||||||
#endif
|
|
@ -4,8 +4,7 @@
|
|||||||
* Copyright (c) 2015 All Rights Reserved
|
* Copyright (c) 2015 All Rights Reserved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TYPES_INC
|
#pragma once
|
||||||
#define TYPES_INC
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -15,27 +14,7 @@ typedef uint8_t u8;
|
|||||||
typedef uint16_t u16;
|
typedef uint16_t u16;
|
||||||
typedef uint32_t u32;
|
typedef uint32_t u32;
|
||||||
typedef uint64_t u64;
|
typedef uint64_t u64;
|
||||||
typedef volatile uint8_t vu8;
|
typedef volatile u8 vu8;
|
||||||
typedef volatile uint16_t vu16;
|
typedef volatile u16 vu16;
|
||||||
typedef volatile uint32_t vu32;
|
typedef volatile u32 vu32;
|
||||||
typedef volatile uint64_t vu64;
|
typedef volatile u64 vu64;
|
||||||
|
|
||||||
//FIRM Header layout
|
|
||||||
typedef struct firmSectionHeader {
|
|
||||||
u32 offset;
|
|
||||||
u8 *address;
|
|
||||||
u32 size;
|
|
||||||
u32 procType;
|
|
||||||
u8 hash[0x20];
|
|
||||||
} firmSectionHeader;
|
|
||||||
|
|
||||||
typedef struct firmHeader {
|
|
||||||
u32 magic;
|
|
||||||
u32 reserved1;
|
|
||||||
u8 *arm11Entry;
|
|
||||||
u8 *arm9Entry;
|
|
||||||
u8 reserved2[0x30];
|
|
||||||
firmSectionHeader section[4];
|
|
||||||
} firmHeader;
|
|
||||||
|
|
||||||
#endif
|
|
Reference in New Issue
Block a user