Skip to content

Commit

Permalink
Add proper error message when sd card or payload.elf is missing.
Browse files Browse the repository at this point in the history
Fix comment
  • Loading branch information
orboditilt committed Jan 13, 2019
1 parent d05b631 commit c0db699
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/common.h
Expand Up @@ -11,6 +11,7 @@ extern "C" {
#define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x0102A3B4)
#define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, char *symbol, void *address))0x0102B828)
#define OSFatal ((void (*)(char* msg))0x01031618)
#define __os_snprintf ((int(*)(char* s, int n, const char * format, ... ))0x0102F160)

#define ADDRESS_OSTitle_main_entry_ptr 0x1005E040
#define ADDRESS_main_entry_hook 0x0101c56c
Expand Down
8 changes: 5 additions & 3 deletions src/elf_loading.c
Expand Up @@ -29,16 +29,18 @@ static int32_t LoadFileToMem(private_data_t *private_data, const char *filepath,

int32_t status = private_data->FSGetMountSource(pClient, pCmd, 0, tempPath, -1);
if (status != 0) {
OSFatal("FSGetMountSource failed.");
OSFatal("FSGetMountSource failed. Please insert a FAT32 formatted sd card.");
}
status = private_data->FSMount(pClient, pCmd, tempPath, mountPath, FS_MAX_MOUNTPATH_SIZE, -1);
if(status != 0) {
OSFatal("SD mount failed.");
OSFatal("SD mount failed. Please insert a FAT32 formatted sd card.");
}

status = private_data->FSOpenFile(pClient, pCmd, filepath, "r", &iFd, -1);
if(status != 0) {
OSFatal("FSOpenFile failed.");
char buf[0x255];
__os_snprintf(buf,0x254,"FSOpenFile failed. File missing %s",filepath);
OSFatal(buf);
}

FSStat stat;
Expand Down
4 changes: 2 additions & 2 deletions src/memory_setup.c
Expand Up @@ -9,14 +9,14 @@ static void SCSetupIBAT4DBAT5() {
asm volatile("eieio; isync");

// Give our and the kernel full execution rights.
// VA: 00000000..00800000 PA: 30000000..30800000 with r/w for user and supervisor
// 00800000-01000000 => 30800000-31000000 (read/write, user/supervisor)
unsigned int ibat4u = 0x008000FF;
unsigned int ibat4l = 0x30800012;
asm volatile("mtspr 560, %0" : : "r" (ibat4u));
asm volatile("mtspr 561, %0" : : "r" (ibat4l));

// Give our and the kernel full data access rights.
// VA: 00000000..00800000 PA: 30000000..30800000 with r/w for user and supervisor
// 00800000-01000000 => 30800000-31000000 (read/write, user/supervisor)
unsigned int dbat5u = ibat4u;
unsigned int dbat5l = ibat4l;
asm volatile("mtspr 570, %0" : : "r" (dbat5u));
Expand Down

0 comments on commit c0db699

Please sign in to comment.