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