decompile Memory.cpp
This commit is contained in:
parent
3641f2f542
commit
3e58f7b005
10 changed files with 133 additions and 7 deletions
|
@ -20,7 +20,7 @@
|
|||
,,,,,,80197d50,80197ef4,,,,,,,,,,,,,,,,,,,donut/gfx/XFBManager.o
|
||||
,,,,,,801bd2a4,801bd370,,,,,,,,,,,,,,,,,,,donut/mem/DataBlock.o
|
||||
,,,,,,801bf1b4,801bf1f8,,,,,,,,,,,,,,,,,,,donut/mem/MemBlock.o
|
||||
,,,,,,801bf250,801bf2bc,,,,,,,,,80545bf8,80545ed0,,,8055d2a0,8055d2a8,,,,,donut/mem/Memory.o
|
||||
,,,,,,801bf1f8,801bf618,,,,,,,80459d70,80459d79,80545bf8,80545ed0,80557280,805572b4,8055d2a0,8055d2a8,,,,,donut/mem/Memory.o
|
||||
,,,,,,801bf618,801bf760,80406338,8040633c,,,,,,,,,,,8055d2a8,8055d2b0,,,,,donut/mem/OperatorNewDelete.o
|
||||
,,,,,,80405a9c,80405b68,,,,,,,,,,,,,,,,,,,donut/util/Mutex.o
|
||||
80006684,80006728,,,,,,,8040652c,80406530,80406548,8040654c,,,,,,,,,,,,,,,
|
||||
|
|
|
|
@ -11,6 +11,12 @@ Address,SymbolName
|
|||
8001a2c0,__OSFPRInit
|
||||
8001ad80,OSInit
|
||||
8001b540,__OSSetExceptionHandler
|
||||
8001c370,OSGetMEM1ArenaHi
|
||||
8001c380,OSGetMEM2ArenaHi
|
||||
8001c390,OSGetMEM1ArenaLo
|
||||
8001c3a0,OSGetMEM2ArenaLo
|
||||
8001c3f0,OSAllocFromMEM1ArenaLo
|
||||
8001c430,OSAllocFromMEM2ArenaLo
|
||||
8001d990,OSReport
|
||||
8001da20,OSSetErrorHandler
|
||||
80021820,OSDisableInterrupts
|
||||
|
@ -39,10 +45,12 @@ Address,SymbolName
|
|||
800dd3e0,__ct__Q33hel6common34PointerWrapper<Q23mem10IAllocator>Fv
|
||||
800f16b0,G3dInit__Q24nw4r3g3dFb
|
||||
801007e0,startAddress__Q23mem8MemBlockCFv
|
||||
801401b0,allocFromTailAllocator__Q23mem7HeapExpFv
|
||||
80174de0,__ct__Q23app7AppImplFRQ23app6System
|
||||
801754f4,run__Q23app7AppImplFbbb
|
||||
80175004,__dt__Q33hel6common43ExplicitSingleton<Q26freeze13FreezeManager>Fv
|
||||
80175004,__dt__Q33hel6common38ExplicitSingleton<Q23app11Application>Fv
|
||||
80175004,__dt__Q33hel6common32ExplicitSingleton<Q23mem6Memory>Fv
|
||||
80175b68,__dt__Q33hel6common11NonCopyableFv
|
||||
8018a900,__ct__Q26freeze13FreezeManagerFPUcPUc
|
||||
80196404,__dt__Q23gfx13RenderSettingFv
|
||||
|
@ -52,11 +60,12 @@ Address,SymbolName
|
|||
80197b90,set__Q23gfx9VISettingFUl
|
||||
801a38b0,__ct__Q23hid14LibInitializerFv
|
||||
801a39f8,__dt__Q23hid14LibInitializerFv
|
||||
801bd538,__ct__Q23mem14HeapCompactionFRCQ33hel6common15FixedString<32>RCQ23mem8MemBlockUl
|
||||
801bd720,__dt__Q23mem14HeapCompactionFv
|
||||
801be2b0,__ct__Q23mem7HeapExpFRCQ33hel6common15FixedString<32>RCQ23mem8MemBlockbb
|
||||
801be458,__dt__Q23mem7HeapExpFv
|
||||
801be5a0,free__Q23mem7HeapExpFPv
|
||||
801bf2bc,__ct__Q23mem6MemoryFv
|
||||
801bf520,__dt__Q23mem6MemoryFv
|
||||
801bf5e8,mem1FixHeap__Q23mem6MemoryFv
|
||||
801bf5f8,mem2FixHeap__Q23mem6MemoryFv
|
||||
801be7a0,__ct__Q33hel6common15FixedString<32>FPCc
|
||||
80402ee8,__ct__Q23snd12SoundManagerFv
|
||||
80403150,__dt__Q23snd12SoundManagerFv
|
||||
8055c878,Debug_BBA
|
||||
|
|
|
|
@ -1,12 +1,67 @@
|
|||
#include <defines.h>
|
||||
#include <hel/common/ExplicitSingleton.hpp>
|
||||
#include <mem/Memory.hpp>
|
||||
#include <os.h>
|
||||
|
||||
using namespace hel::common;
|
||||
|
||||
namespace mem {
|
||||
|
||||
namespace {
|
||||
MemBlock t_allocMem(IAllocator &alloc, u32 size) {
|
||||
return MemBlock(alloc.allocatorAlloc(size, 32), size);
|
||||
}
|
||||
void *t_allocMem1(void *hi, void *lo) {
|
||||
return OSAllocFromMEM1ArenaLo((char *)hi - (char *)lo, 32);
|
||||
}
|
||||
MemBlock t_mem1() {
|
||||
void *hi = OSGetMEM1ArenaHi();
|
||||
void *lo = OSGetMEM1ArenaLo();
|
||||
void *ptr = t_allocMem1(hi, lo);
|
||||
return MemBlock(ptr, (u32)hi - (u32)lo);
|
||||
}
|
||||
void *t_allocMem2(void *hi, void *lo) {
|
||||
return OSAllocFromMEM2ArenaLo((char *)hi - (char *)lo, 32);
|
||||
}
|
||||
MemBlock t_mem2() {
|
||||
void *hi = OSGetMEM2ArenaHi();
|
||||
void *lo = OSGetMEM2ArenaLo();
|
||||
void *ptr = t_allocMem2(hi, lo);
|
||||
return MemBlock(ptr, (u32)hi - (u32)lo);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void Memory::SetupIfNotSetup() {
|
||||
if (!ExplicitSingleton<Memory>::object_) {
|
||||
static Memory obj;
|
||||
}
|
||||
}
|
||||
|
||||
Memory::Memory()
|
||||
: arenaM1_(FixedString<32>("ArenaM1"), t_mem1(), false, true),
|
||||
arenaM2_(FixedString<32>("ArenaM2"), t_mem2(), false, true),
|
||||
mem1Fix_(FixedString<32>("Mem1Fix"),
|
||||
t_allocMem(arenaM1_.allocFromTailAllocator(), 0x300000), false,
|
||||
false),
|
||||
scene_(FixedString<32>("Scene"),
|
||||
t_allocMem(arenaM1_.allocFromTailAllocator(), 0xc00000), false,
|
||||
false),
|
||||
mem2Fix_(FixedString<32>("Mem2Fix"), t_allocMem(arenaM2_, 0x1200000),
|
||||
false, false),
|
||||
external_(FixedString<32>("External"), t_allocMem(arenaM2_, 0x2300000),
|
||||
0x400),
|
||||
debug_(FixedString<32>("Debug"), t_allocMem(arenaM2_, 0xc6000), false,
|
||||
false),
|
||||
seq_(FixedString<32>("Seq"), t_allocMem(mem1Fix_, 0x2800), false, false) {
|
||||
object_ = this;
|
||||
}
|
||||
|
||||
Memory::~Memory() { object_ = 0; }
|
||||
|
||||
HeapExp &Memory::mem1FixHeap() { return mem1Fix_; }
|
||||
USED HeapExp &Memory::sceneHeap() { return scene_; }
|
||||
HeapExp &Memory::mem2FixHeap() { return mem2Fix_; }
|
||||
USED HeapCompaction &Memory::externalHeap() { return external_; }
|
||||
USED HeapExp &Memory::debugHeap() { return debug_; }
|
||||
USED HeapExp &Memory::seqHeap() { return seq_; }
|
||||
|
||||
} // namespace mem
|
19
include/hel/common/FixedString.hpp
Normal file
19
include/hel/common/FixedString.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
namespace hel {
|
||||
namespace common {
|
||||
template <class T, u32 N> struct FixedStringIN {
|
||||
T data_[N];
|
||||
inline FixedStringIN() {
|
||||
for (u32 i = 0; i < N; i++)
|
||||
data_[i] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <u32 N> struct FixedString : public FixedStringIN<char, N> {
|
||||
FixedString(const char *val);
|
||||
};
|
||||
} // namespace common
|
||||
} // namespace hel
|
|
@ -1,7 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <hel/common/FixedString.hpp>
|
||||
#include <mem/MemBlock.hpp>
|
||||
|
||||
namespace mem {
|
||||
struct HeapCompaction {
|
||||
int unk[32];
|
||||
HeapCompaction(const hel::common::FixedString<32> &name,
|
||||
const MemBlock &block, u32);
|
||||
~HeapCompaction();
|
||||
};
|
||||
} // namespace mem
|
|
@ -1,11 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <hel/common/FixedString.hpp>
|
||||
#include <mem/IHeap.hpp>
|
||||
#include <mem/MemBlock.hpp>
|
||||
|
||||
namespace mem {
|
||||
struct HeapExp : public IHeap {
|
||||
int unk[20];
|
||||
|
||||
HeapExp(const hel::common::FixedString<32> &name, const MemBlock &block,
|
||||
bool withoutHeapUser, bool clearMem);
|
||||
~HeapExp();
|
||||
|
||||
virtual void *allocatorAlloc(u32 size, s32 align);
|
||||
virtual void allocatorFree(void *ptr);
|
||||
virtual const char *heapName() const;
|
||||
|
@ -14,5 +20,7 @@ struct HeapExp : public IHeap {
|
|||
virtual void heapDump() const;
|
||||
|
||||
void free(void *ptr);
|
||||
|
||||
IAllocator &allocFromTailAllocator();
|
||||
};
|
||||
} // namespace mem
|
|
@ -21,7 +21,11 @@ struct Memory : hel::common::ExplicitSingleton<Memory> {
|
|||
~Memory();
|
||||
|
||||
HeapExp &mem1FixHeap();
|
||||
HeapExp &sceneHeap();
|
||||
HeapExp &mem2FixHeap();
|
||||
HeapCompaction &externalHeap();
|
||||
HeapExp &debugHeap();
|
||||
HeapExp &seqHeap();
|
||||
};
|
||||
} // namespace mem
|
||||
|
||||
|
|
|
@ -11,6 +11,14 @@ void OSReport(const char *fmt, ...);
|
|||
BOOL OSDisableInterrupts(void);
|
||||
BOOL OSResetInterrupts(BOOL enabled);
|
||||
|
||||
void *OSGetMEM1ArenaHi();
|
||||
void *OSGetMEM1ArenaLo();
|
||||
void *OSGetMEM2ArenaHi();
|
||||
void *OSGetMEM2ArenaLo();
|
||||
|
||||
void *OSAllocFromMEM1ArenaLo(u32 size, u32 align);
|
||||
void *OSAllocFromMEM2ArenaLo(u32 size, u32 align);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
17
include/util/PlacementNew.hpp
Normal file
17
include/util/PlacementNew.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
namespace util {
|
||||
template <class T> struct PlacementNew {
|
||||
T *ptr_;
|
||||
alignas(T) char data_[sizeof(T)];
|
||||
inline PlacementNew() : ptr_(0) {}
|
||||
inline ~PlacementNew();
|
||||
|
||||
void destruct();
|
||||
template <class A> inline void construct(A a) {
|
||||
destruct();
|
||||
T *ptr = &data_;
|
||||
ptr_ new (&data_) T(a);
|
||||
}
|
||||
};
|
||||
} // namespace util
|
|
@ -1,6 +1,6 @@
|
|||
use std::{
|
||||
fs::File,
|
||||
io::{BufRead, BufReader, BufWriter, Write},
|
||||
io::{BufReader, BufWriter, Write},
|
||||
num::ParseIntError,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue