mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-03 16:44:20 +01:00
-reserved 6mb exclusively for the sd and usb device and partition
handling, now we have 44mb for everything else left (we had 47mb before)
This commit is contained in:
parent
28900c6ca2
commit
d5d2c6b4de
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <ogcsys.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
|
||||
#include "memory/mem2.hpp"
|
||||
#include "sdhc.h"
|
||||
|
||||
/* IOCTL comamnds */
|
||||
@ -25,8 +25,6 @@ static s32 hid = -1, fd = -1;
|
||||
static u32 sector_size = SDHC_SECTOR_SIZE;
|
||||
static void *sdhc_buf2;
|
||||
|
||||
extern void* SYS_AllocArena2MemLo(u32 size,u32 align);
|
||||
|
||||
bool SDHC_Init(void)
|
||||
{
|
||||
s32 ret;
|
||||
@ -49,7 +47,7 @@ bool SDHC_Init(void)
|
||||
// allocate buf2
|
||||
if (sdhc_buf2 == NULL)
|
||||
{
|
||||
sdhc_buf2 = SYS_AllocArena2MemLo(SDHC_MEM2_SIZE, 32);
|
||||
sdhc_buf2 = MEM2_lo_alloc(SDHC_MEM2_SIZE);
|
||||
if (sdhc_buf2 == NULL) goto err;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "memory/mem2.hpp"
|
||||
#include "usbstorage.h"
|
||||
#include "usbstorage_libogc.h"
|
||||
#include "usbthread.h"
|
||||
@ -69,8 +69,6 @@ u32 hdd_sector_size[2] = { 512, 512 };
|
||||
bool first = false;
|
||||
int usb_libogc_mode = 0;
|
||||
|
||||
extern void* SYS_AllocArena2MemLo(u32 size,u32 align);
|
||||
|
||||
inline s32 __USBStorage_isMEM2Buffer(const void *buffer)
|
||||
{
|
||||
u32 high_addr = ((u32)buffer) >> 24;
|
||||
@ -81,7 +79,7 @@ s32 USBStorage2_Init(u32 port)
|
||||
{
|
||||
/* allocate buf2 */
|
||||
if(mem2_ptr == NULL)
|
||||
mem2_ptr = SYS_AllocArena2MemLo(USB_MEM2_SIZE, 32);
|
||||
mem2_ptr = MEM2_lo_alloc(USB_MEM2_SIZE);
|
||||
|
||||
if(usb_libogc_mode)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ distribution.
|
||||
#include <errno.h>
|
||||
#include <ogc/lwp_heap.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "memory/mem2.hpp"
|
||||
#include <ogc/machine/asm.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#include <ogc/disc_io.h>
|
||||
@ -208,12 +208,7 @@ s32 USBStorage_OGC_Initialize()
|
||||
_CPU_ISR_Disable(level);
|
||||
LWP_InitQueue(&__usbstorage_ogc_waitq);
|
||||
if(!arena_ptr) {
|
||||
arena_ptr = (u8*)ROUNDDOWN32(((u32)SYS_GetArena2Hi() - HEAP_SIZE));
|
||||
if((u32)arena_ptr < (u32)SYS_GetArena2Lo()) {
|
||||
_CPU_ISR_Restore(level);
|
||||
return IPC_ENOMEM;
|
||||
}
|
||||
SYS_SetArena2Hi(arena_ptr);
|
||||
arena_ptr = (u8*)MEM2_lo_alloc(HEAP_SIZE);
|
||||
}
|
||||
__lwp_heap_init(&__heap, arena_ptr, HEAP_SIZE, 32);
|
||||
cbw_buffer=(u8*)__lwp_heap_allocate(&__heap, 32);
|
||||
|
@ -16,10 +16,14 @@ u32 MALLOC_MEM2 = 0;
|
||||
void *MEM1_lo_start = (void*)0x80004000;
|
||||
void *MEM1_lo_end = (void*)0x80620000;
|
||||
|
||||
void *MEM2_start = (void*)0x90200000;
|
||||
void *MEM2_end = (void*)0x93100000;
|
||||
void *MEM2_lo_start = (void*)0x90000000;
|
||||
void *MEM2_lo_end = (void*)0x90600000;
|
||||
|
||||
void *MEM2_start = (void*)0x90600000;
|
||||
void *MEM2_end = (void*)0x93200000;
|
||||
|
||||
static CMEM2Alloc g_mem1lo;
|
||||
static CMEM2Alloc g_mem2lo_gp;
|
||||
static CMEM2Alloc g_mem2gp;
|
||||
|
||||
extern "C"
|
||||
@ -37,7 +41,10 @@ void MEM_init()
|
||||
g_mem1lo.init(MEM1_lo_start, MEM1_lo_end); //about 6mb
|
||||
g_mem1lo.clear();
|
||||
|
||||
g_mem2gp.init(MEM2_start, MEM2_end); //about 47mb
|
||||
g_mem2lo_gp.init(MEM2_lo_start, MEM2_lo_end); //about 6mb
|
||||
g_mem2lo_gp.clear();
|
||||
|
||||
g_mem2gp.init(MEM2_start, MEM2_end); //about 44mb
|
||||
g_mem2gp.clear();
|
||||
}
|
||||
|
||||
@ -80,16 +87,25 @@ unsigned int MEM1_freesize()
|
||||
return (g_mem1lo.FreeSize() + SYS_GetArena1Size());
|
||||
}
|
||||
|
||||
void MEM2_cleanup(void)
|
||||
|
||||
void *MEM2_lo_alloc(unsigned int s)
|
||||
{
|
||||
g_mem2gp.cleanup();
|
||||
return g_mem2lo_gp.allocate(s);
|
||||
}
|
||||
|
||||
void MEM2_clear(void)
|
||||
void *MEM2_lo_realloc(void *p, unsigned int s)
|
||||
{
|
||||
g_mem2gp.clear();
|
||||
return g_mem2lo_gp.reallocate(p, s);
|
||||
}
|
||||
|
||||
void MEM2_lo_free(void *p)
|
||||
{
|
||||
if(!p)
|
||||
return;
|
||||
g_mem2lo_gp.release(p);
|
||||
}
|
||||
|
||||
|
||||
void MEM2_free(void *p)
|
||||
{
|
||||
if(!p)
|
||||
@ -188,7 +204,12 @@ void __wrap_free(void *p)
|
||||
return;
|
||||
|
||||
if(((u32)p & 0x10000000) != 0)
|
||||
g_mem2gp.release(p);
|
||||
{
|
||||
if(p > MEM2_start)
|
||||
g_mem2gp.release(p);
|
||||
else
|
||||
g_mem2lo_gp.release(p);
|
||||
}
|
||||
else
|
||||
MEM1_free(p);
|
||||
}
|
||||
|
@ -20,8 +20,10 @@ void *MEM1_realloc(void *p, unsigned int s);
|
||||
void MEM1_free(void *p);
|
||||
unsigned int MEM1_freesize();
|
||||
|
||||
void MEM2_cleanup(void);
|
||||
void MEM2_clear(void);
|
||||
void *MEM2_lo_alloc(unsigned int s);
|
||||
void *MEM2_lo_realloc(void *p, unsigned int s);
|
||||
void MEM2_lo_free(void *p);
|
||||
|
||||
void MEM2_free(void *p);
|
||||
void *MEM2_alloc(unsigned int s);
|
||||
void *MEM2_memalign(unsigned int /* alignment */, unsigned int s);
|
||||
|
@ -4,21 +4,8 @@
|
||||
#include <ogc/cache.h>
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
|
||||
#define IOS_RELOAD_AREA 0x90200000
|
||||
|
||||
#include "lockMutex.hpp"
|
||||
|
||||
void CMEM2Alloc::init(unsigned int size)
|
||||
{
|
||||
m_baseAddress = (SBlock *)std::max(((u32)SYS_GetArena2Lo() + 31) & ~31, IOS_RELOAD_AREA);
|
||||
m_endAddress = (SBlock *)((u8*)m_baseAddress + std::min(size * 0x100000, SYS_GetArena2Size() & ~31));
|
||||
if (m_endAddress > (SBlock *)0x93100000) //rest is reserved for usb/usb2/network and other stuff... (0xE0000 bytes)
|
||||
m_endAddress = (SBlock *)0x93100000;
|
||||
SYS_SetArena2Lo(m_endAddress);
|
||||
LWP_MutexInit(&m_mutex, 0);
|
||||
}
|
||||
|
||||
void CMEM2Alloc::init(void *addr, void *end)
|
||||
{
|
||||
m_baseAddress = (SBlock *)(((u32)addr + 31) & ~31);
|
||||
@ -32,8 +19,8 @@ void CMEM2Alloc::cleanup(void)
|
||||
m_mutex = 0;
|
||||
m_first = 0;
|
||||
// Try to release the range we took through SYS functions
|
||||
if (SYS_GetArena2Lo() == m_endAddress)
|
||||
SYS_SetArena2Lo(m_baseAddress);
|
||||
/*if (SYS_GetArena2Lo() == m_endAddress)
|
||||
SYS_SetArena2Lo(m_baseAddress);*/
|
||||
m_baseAddress = 0;
|
||||
m_endAddress = 0;
|
||||
}
|
||||
|
@ -961,7 +961,6 @@ void CMenu::_launchHomebrew(const char *filepath, vector<string> arguments)
|
||||
|
||||
Playlog_Delete();
|
||||
cleanup(); // wifi and sd gecko doesnt work anymore after cleanup
|
||||
loadIOS(58, true);
|
||||
|
||||
LoadHomebrew(filepath);
|
||||
AddBootArgument(filepath);
|
||||
@ -970,6 +969,7 @@ void CMenu::_launchHomebrew(const char *filepath, vector<string> arguments)
|
||||
gprintf("Argument: %s\n", arguments[i].c_str());
|
||||
AddBootArgument(arguments[i].c_str());
|
||||
}
|
||||
loadIOS(58, false);
|
||||
ShutdownBeforeExit();
|
||||
BootHomebrew();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user