Fixed crashes loading an emuNAND if the SD was too small to be able to hold it

This commit is contained in:
Aurora 2016-05-02 02:02:31 +02:00
parent 113059e57c
commit 95d06c115a
8 changed files with 31 additions and 33 deletions

View File

@ -7,6 +7,7 @@
#include "types.h" #include "types.h"
#define HID_PAD (*(vu32 *)0x10146000 ^ 0xFFF) #define HID_PAD (*(vu32 *)0x10146000 ^ 0xFFF)
#define BUTTON_R1 (1 << 8) #define BUTTON_R1 (1 << 8)
#define BUTTON_L1 (1 << 9) #define BUTTON_L1 (1 << 9)
#define BUTTON_A 1 #define BUTTON_A 1
@ -19,6 +20,7 @@
#define BUTTON_LEFT (1 << 5) #define BUTTON_LEFT (1 << 5)
#define BUTTON_UP (1 << 6) #define BUTTON_UP (1 << 6)
#define BUTTON_DOWN (1 << 7) #define BUTTON_DOWN (1 << 7)
#define SAFE_MODE (BUTTON_R1 | BUTTON_L1 | BUTTON_A | BUTTON_UP) #define SAFE_MODE (BUTTON_R1 | BUTTON_L1 | BUTTON_A | BUTTON_UP)
#define OVERRIDE_BUTTONS (BUTTON_B ^ 0xFFF) #define OVERRIDE_BUTTONS (BUTTON_B ^ 0xFFF)
#define SINGLE_PAYLOAD_BUTTONS (BUTTON_LEFT | BUTTON_RIGHT | BUTTON_UP | BUTTON_DOWN | BUTTON_START | BUTTON_X | BUTTON_Y) #define SINGLE_PAYLOAD_BUTTONS (BUTTON_LEFT | BUTTON_RIGHT | BUTTON_UP | BUTTON_DOWN | BUTTON_START | BUTTON_X | BUTTON_Y)

View File

@ -10,9 +10,6 @@
#include "memory.h" #include "memory.h"
#include "font.h" #include "font.h"
#define SCREEN_TOP_WIDTH 400
#define SCREEN_TOP_HEIGHT 240
static const struct fb { static const struct fb {
u8 *top_left; u8 *top_left;
u8 *top_right; u8 *top_right;

View File

@ -8,8 +8,12 @@
#include "types.h" #include "types.h"
#define SCREEN_TOP_WIDTH 400
#define SCREEN_TOP_HEIGHT 240
#define SPACING_Y 10 #define SPACING_Y 10
#define SPACING_X 8 #define SPACING_X 8
#define COLOR_TITLE 0xFF9900 #define COLOR_TITLE 0xFF9900
#define COLOR_WHITE 0xFFFFFF #define COLOR_WHITE 0xFFFFFF
#define COLOR_RED 0x0000FF #define COLOR_RED 0x0000FF

View File

@ -15,18 +15,16 @@ void getEmunandSect(u32 *off, u32 *head, u32 *emuNAND)
(nandSize > 0x200000 ? 0x400000 : 0x200000); (nandSize > 0x200000 ? 0x400000 : 0x200000);
//Check for RedNAND //Check for RedNAND
if(sdmmc_sdcard_readsectors(nandOffset + 1, 1, temp) == 0) if(!sdmmc_sdcard_readsectors(nandOffset + 1, 1, temp) &&
{ *(u32 *)(temp + 0x100) == NCSD_MAGIC)
if(*(u32 *)(temp + 0x100) == NCSD_MAGIC)
{ {
*off = nandOffset + 1; *off = nandOffset + 1;
*head = nandOffset + 1; *head = nandOffset + 1;
} }
//Check for Gateway emuNAND //Check for Gateway emuNAND
else if(sdmmc_sdcard_readsectors(nandOffset + nandSize, 1, temp) == 0) else if(!sdmmc_sdcard_readsectors(nandOffset + nandSize, 1, temp) &&
{ *(u32 *)(temp + 0x100) == NCSD_MAGIC)
if(*(u32 *)(temp + 0x100) == NCSD_MAGIC)
{ {
*off = nandOffset; *off = nandOffset;
*head = nandOffset + nandSize; *head = nandOffset + nandSize;
@ -40,8 +38,6 @@ void getEmunandSect(u32 *off, u32 *head, u32 *emuNAND)
if(*emuNAND) getEmunandSect(off, head, emuNAND); if(*emuNAND) getEmunandSect(off, head, emuNAND);
} }
} }
}
}
u32 getSDMMC(u8 *pos, u32 size) u32 getSDMMC(u8 *pos, u32 size)
{ {

View File

@ -9,9 +9,6 @@
#include "buttons.h" #include "buttons.h"
#include "../build/loader.h" #include "../build/loader.h"
#define PAYLOAD_ADDRESS 0x24F00000
#define PATTERN(a) a "_*.bin"
static FATFS sdFs, static FATFS sdFs,
nandFs; nandFs;

View File

@ -6,6 +6,9 @@
#include "types.h" #include "types.h"
#define PAYLOAD_ADDRESS 0x24F00000
#define PATTERN(a) a "_*.bin"
u32 mountFs(void); u32 mountFs(void);
u32 fileRead(void *dest, const char *path, u32 size); u32 fileRead(void *dest, const char *path, u32 size);
u32 fileWrite(const void *buffer, const char *path, u32 size); u32 fileWrite(const void *buffer, const char *path, u32 size);

View File

@ -12,8 +12,6 @@
#include "i2c.h" #include "i2c.h"
#include "../build/screeninit.h" #include "../build/screeninit.h"
#define SCREENINIT_ADDRESS 0x24F02000
vu32 *arm11Entry = (u32 *)0x1FFFFFF8; vu32 *arm11Entry = (u32 *)0x1FFFFFF8;
void deinitScreens(void) void deinitScreens(void)

View File

@ -10,6 +10,7 @@
#include "types.h" #include "types.h"
#define PDN_GPU_CNT (*(vu8 *)0x10141200) #define PDN_GPU_CNT (*(vu8 *)0x10141200)
#define SCREENINIT_ADDRESS 0x24F02000
void deinitScreens(void); void deinitScreens(void);
void initScreens(void); void initScreens(void);