mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-30 15:14:18 +01:00
-changed a few things about booting homebrew, hopefully it boots
everything correctly again now
This commit is contained in:
parent
e28b91f536
commit
5a2efc4e3b
@ -7,6 +7,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "smartptr.hpp"
|
#include "smartptr.hpp"
|
||||||
#include "gecko.h"
|
#include "gecko.h"
|
||||||
|
#include "mem2.hpp"
|
||||||
|
|
||||||
#define EXECUTE_ADDR ((u8 *)0x92000000)
|
#define EXECUTE_ADDR ((u8 *)0x92000000)
|
||||||
#define BOOTER_ADDR ((u8 *)0x93000000)
|
#define BOOTER_ADDR ((u8 *)0x93000000)
|
||||||
@ -23,8 +24,8 @@ extern const u32 stub_bin_size;
|
|||||||
typedef void (*entrypoint) (void);
|
typedef void (*entrypoint) (void);
|
||||||
extern "C" { void __exception_closeall(); }
|
extern "C" { void __exception_closeall(); }
|
||||||
|
|
||||||
static u8 *homebrewbuffer = EXECUTE_ADDR;
|
u8 *tmpbuffer = NULL;
|
||||||
static u32 homebrewsize = 0;
|
u32 tmpbuffer_size = 0;
|
||||||
static vector<string> Arguments;
|
static vector<string> Arguments;
|
||||||
|
|
||||||
static u32 stubtitlepositions[8] = { 0x80001bf2, 0x80001bf3, 0x80001c06, 0x80001c07,
|
static u32 stubtitlepositions[8] = { 0x80001bf2, 0x80001bf3, 0x80001c06, 0x80001c07,
|
||||||
@ -61,10 +62,11 @@ int LoadHomebrew(const char *filepath)
|
|||||||
u32 filesize = ftell(file);
|
u32 filesize = ftell(file);
|
||||||
rewind(file);
|
rewind(file);
|
||||||
|
|
||||||
fread(homebrewbuffer, 1, filesize, file);
|
tmpbuffer_size = filesize;
|
||||||
|
tmpbuffer = (u8*)MEM1_alloc(tmpbuffer_size);
|
||||||
|
fread(tmpbuffer, 1, tmpbuffer_size, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
homebrewsize += filesize;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,25 +139,24 @@ static void writeStub(u64 chan_title)
|
|||||||
|
|
||||||
int BootHomebrew(u64 chan_title)
|
int BootHomebrew(u64 chan_title)
|
||||||
{
|
{
|
||||||
|
writeStub(chan_title);
|
||||||
struct __argv args;
|
struct __argv args;
|
||||||
if (!IsDollZ(homebrewbuffer))
|
if (!IsDollZ(tmpbuffer))
|
||||||
SetupARGV(&args);
|
SetupARGV(&args);
|
||||||
|
|
||||||
memcpy(BOOTER_ADDR, app_booter_bin, app_booter_bin_size);
|
memcpy(BOOTER_ADDR, app_booter_bin, app_booter_bin_size);
|
||||||
DCFlushRange(BOOTER_ADDR, app_booter_bin_size);
|
DCFlushRange(BOOTER_ADDR, app_booter_bin_size);
|
||||||
|
|
||||||
|
memcpy(EXECUTE_ADDR, tmpbuffer, tmpbuffer_size);
|
||||||
|
DCFlushRange(EXECUTE_ADDR, tmpbuffer_size);
|
||||||
|
MEM1_free(tmpbuffer);
|
||||||
|
|
||||||
entrypoint entry = (entrypoint)BOOTER_ADDR;
|
entrypoint entry = (entrypoint)BOOTER_ADDR;
|
||||||
|
|
||||||
memmove(ARGS_ADDR, &args, sizeof(args));
|
memmove(ARGS_ADDR, &args, sizeof(args));
|
||||||
DCFlushRange(ARGS_ADDR, sizeof(args) + args.length);
|
DCFlushRange(ARGS_ADDR, sizeof(args) + args.length);
|
||||||
|
|
||||||
writeStub(chan_title);
|
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
|
||||||
|
|
||||||
/* Shutdown IOS subsystems */
|
|
||||||
u32 level = IRQ_Disable();
|
|
||||||
__IOS_ShutdownSubsystems();
|
|
||||||
__exception_closeall();
|
|
||||||
entry();
|
entry();
|
||||||
IRQ_Restore(level);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
// Forbid the use of MEM2 through malloc
|
// Forbid the use of MEM2 through malloc
|
||||||
u32 MALLOC_MEM2 = 0;
|
u32 MALLOC_MEM2 = 0;
|
||||||
|
|
||||||
|
int wrapMEM2 = 1;
|
||||||
|
|
||||||
static CMEM2Alloc g_mem2gp;
|
static CMEM2Alloc g_mem2gp;
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
@ -94,10 +96,15 @@ unsigned int MEM2_freesize()
|
|||||||
return g_mem2gp.FreeSize();
|
return g_mem2gp.FreeSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MEM2_wrap(int v)
|
||||||
|
{
|
||||||
|
wrapMEM2 = v;
|
||||||
|
}
|
||||||
|
|
||||||
void *__wrap_malloc(size_t size)
|
void *__wrap_malloc(size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE)
|
if(wrapMEM2 && (SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE))
|
||||||
{
|
{
|
||||||
p = g_mem2gp.allocate(size);
|
p = g_mem2gp.allocate(size);
|
||||||
if(p != 0)
|
if(p != 0)
|
||||||
@ -113,7 +120,7 @@ void *__wrap_malloc(size_t size)
|
|||||||
void *__wrap_calloc(size_t n, size_t size)
|
void *__wrap_calloc(size_t n, size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || (n * size) >= MEM2_PRIORITY_SIZE)
|
if(wrapMEM2 && (SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || (n * size) >= MEM2_PRIORITY_SIZE))
|
||||||
{
|
{
|
||||||
p = g_mem2gp.allocate(n * size);
|
p = g_mem2gp.allocate(n * size);
|
||||||
if (p != 0)
|
if (p != 0)
|
||||||
@ -136,7 +143,7 @@ void *__wrap_calloc(size_t n, size_t size)
|
|||||||
void *__wrap_memalign(size_t a, size_t size)
|
void *__wrap_memalign(size_t a, size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE)
|
if(wrapMEM2 && (SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE))
|
||||||
{
|
{
|
||||||
p = MEM2_memalign(a, size);
|
p = MEM2_memalign(a, size);
|
||||||
if (p != 0)
|
if (p != 0)
|
||||||
|
@ -21,6 +21,7 @@ void MEM2_init(unsigned int mem2Size);
|
|||||||
void MEM2_cleanup(void);
|
void MEM2_cleanup(void);
|
||||||
void MEM2_clear(void);
|
void MEM2_clear(void);
|
||||||
void MEM2_free(void *p);
|
void MEM2_free(void *p);
|
||||||
|
void MEM2_wrap(int v);
|
||||||
void *MEM2_alloc(unsigned int s);
|
void *MEM2_alloc(unsigned int s);
|
||||||
void *MEM2_memalign(unsigned int a, unsigned int s);
|
void *MEM2_memalign(unsigned int a, unsigned int s);
|
||||||
void *MEM2_realloc(void *p, unsigned int s);
|
void *MEM2_realloc(void *p, unsigned int s);
|
||||||
|
@ -870,8 +870,6 @@ void CMenu::_launchHomebrew(const char *filepath, vector<string> arguments)
|
|||||||
if(channel.GetRequestedIOS(RETURN_CHANNEL) != 0)
|
if(channel.GetRequestedIOS(RETURN_CHANNEL) != 0)
|
||||||
title = RETURN_CHANNEL;
|
title = RETURN_CHANNEL;
|
||||||
|
|
||||||
gprintf("Filepath of homebrew: %s\n",filepath);
|
|
||||||
|
|
||||||
m_gcfg1.save(true);
|
m_gcfg1.save(true);
|
||||||
m_gcfg2.save(true);
|
m_gcfg2.save(true);
|
||||||
m_cat.save(true);
|
m_cat.save(true);
|
||||||
@ -879,18 +877,16 @@ void CMenu::_launchHomebrew(const char *filepath, vector<string> arguments)
|
|||||||
|
|
||||||
Playlog_Delete();
|
Playlog_Delete();
|
||||||
cleanup(); // wifi and sd gecko doesnt work anymore after cleanup
|
cleanup(); // wifi and sd gecko doesnt work anymore after cleanup
|
||||||
|
MEM2_wrap(0);
|
||||||
|
|
||||||
LoadHomebrew(filepath);
|
LoadHomebrew(filepath);
|
||||||
//ISFS_Deinitialize();
|
|
||||||
USBStorage_Deinit();
|
|
||||||
AddBootArgument(filepath);
|
AddBootArgument(filepath);
|
||||||
for(u32 i = 0; i < arguments.size(); ++i)
|
for(u32 i = 0; i < arguments.size(); ++i)
|
||||||
{
|
|
||||||
gprintf("Boot argument: %s\n", arguments[i].c_str());
|
|
||||||
AddBootArgument(arguments[i].c_str());
|
AddBootArgument(arguments[i].c_str());
|
||||||
}
|
|
||||||
gprintf("Return to Channel: %08x %08x\n", TITLE_UPPER(title), TITLE_LOWER(title));
|
ISFS_Deinitialize();
|
||||||
gprintf("Booting Homebrew application...\n");
|
USBStorage_Deinit();
|
||||||
|
MEM2_clear();
|
||||||
BootHomebrew(title);
|
BootHomebrew(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user