DataBlock, MemBlock and Mutex
This commit is contained in:
parent
7144e7f1da
commit
9f3eae615a
10 changed files with 76 additions and 5 deletions
|
@ -18,6 +18,9 @@
|
|||
,,,,,,8019607c,801961fc,,,,,,,,,,,,,8055d1b4,8055d1b9,,,,,donut/gfx/GXFifoMemoryManager.o
|
||||
,,,,,,801962a8,80196404,,,,,,,,,,,,,,,8055f720,8055f730,,,donut/gfx/RenderSetting.o
|
||||
,,,,,,80197d50,80197ef4,,,,,,,,,,,,,,,,,,,donut/gfx/XFBManager.o
|
||||
,,,,,,801bd2a4,801bd370,,,,,,,,,,,,,,,,,,,donut/mem/DataBlock.o
|
||||
,,,,,,801bf1b4,801bf1f8,,,,,,,,,,,,,,,,,,,donut/mem/MemBlock.o
|
||||
,,,,,,801bf250,801bf2bc,,,,,,,,,80545bf8,80545ed0,,,8055d2a0,8055d2a1,,,,,donut/mem/Memory.o
|
||||
,,,,,,80405a9c,80405b68,,,,,,,,,,,,,,,,,,,donut/util/Mutex.o
|
||||
80006684,80006728,,,,,,,8040652c,80406530,80406548,8040654c,,,,,,,,,,,,,,,
|
||||
80006728,80006728,800068cc,800068cc,800069e4,800069e4,80406244,80406244,80406530,80406530,8040654c,8040654c,80421030,80421030,804966fc,804966fc,8055640c,8055640c,8055c6d0,8055c6d0,8055df74,8055df74,805643b0,805643b0,805643fc,805643fc,
|
|
|
@ -17,6 +17,9 @@ Address,SymbolName
|
|||
80021820,__RAS_OSDisableInterrupts_begin
|
||||
8002182c,__RAS_OSDisableInterrupts_end
|
||||
80021860,OSRestoreInterrupts
|
||||
80022b60,OSInitMutex
|
||||
80022ba0,OSLockMutex
|
||||
80022c80,OSUnlockMutex
|
||||
80023820,OSResetSystem
|
||||
80028530,__init_user
|
||||
800285a0,exit
|
||||
|
@ -46,7 +49,6 @@ Address,SymbolName
|
|||
80197b90,set__Q23gfx9VISettingFUl
|
||||
801a38b0,__ct__Q23hid14LibInitializerFv
|
||||
801a39f8,__dt__Q23hid14LibInitializerFv
|
||||
801bd2a4,__ct__Q23mem9DataBlockFUllRQ23mem10IAllocator
|
||||
801be5a0,free__Q23mem7HeapExpFPv
|
||||
801bf2bc,__ct__Q23mem6MemoryFv
|
||||
801bf520,__dt__Q23mem6MemoryFv
|
||||
|
@ -55,5 +57,4 @@ Address,SymbolName
|
|||
801bf714,__dl__FPv
|
||||
80402ee8,__ct__Q23snd12SoundManagerFv
|
||||
80403150,__dt__Q23snd12SoundManagerFv
|
||||
80405a9c,__ct__Q24util5MutexFv
|
||||
8055c878,Debug_BBA
|
||||
|
|
|
|
@ -1,3 +1,4 @@
|
|||
#define MEM_BLOCK_CONSTRUCTOR_HACK
|
||||
#include <gfx/XFBManager.hpp>
|
||||
#include <mem/Memory.hpp>
|
||||
#include <vi.h>
|
||||
|
|
7
donut/mem/DataBlock.cpp
Normal file
7
donut/mem/DataBlock.cpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <mem/DataBlock.hpp>
|
||||
|
||||
namespace mem {
|
||||
DataBlock::DataBlock(u32 size, s32 align, IAllocator &alloc)
|
||||
: alloc_(alloc), block_(alloc.allocatorAlloc(size, align), size) {}
|
||||
DataBlock::~DataBlock() { alloc_.allocatorFree(block_.ptr_); }
|
||||
} // namespace mem
|
6
donut/mem/MemBlock.cpp
Normal file
6
donut/mem/MemBlock.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include <mem/MemBlock.hpp>
|
||||
|
||||
namespace mem {
|
||||
MemBlock MemBlock::EmptyBlock() { return MemBlock(0, 0); }
|
||||
MemBlock::MemBlock(void *ptr, u32 size) : size_(size), ptr_(ptr) {}
|
||||
} // namespace mem
|
14
donut/util/Mutex.cpp
Normal file
14
donut/util/Mutex.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <util/Mutex.hpp>
|
||||
|
||||
#ifdef __CWCC__
|
||||
#pragma dont_inline on
|
||||
#endif
|
||||
|
||||
namespace util {
|
||||
Mutex::Mutex() { OSInitMutex(&inner_); }
|
||||
void Mutex::lock() { OSLockMutex(&inner_); }
|
||||
void Mutex::unlock() { OSUnlockMutex(&inner_); }
|
||||
|
||||
ScopedMutex::ScopedMutex(Mutex &mutex) : mutex_(mutex) { mutex.lock(); }
|
||||
ScopedMutex::~ScopedMutex() { mutex_.unlock(); }
|
||||
} // namespace util
|
|
@ -4,9 +4,14 @@
|
|||
|
||||
namespace mem {
|
||||
struct MemBlock {
|
||||
u32 size;
|
||||
void *ptr;
|
||||
u32 size_;
|
||||
void *ptr_;
|
||||
|
||||
// terrible hack that hopefully makes the code compile correctly
|
||||
#ifndef MEM_BLOCK_CONSTRUCTOR_HACK
|
||||
MemBlock(void *ptr, u32 size);
|
||||
#endif
|
||||
void *startAddress() const;
|
||||
static MemBlock EmptyBlock();
|
||||
};
|
||||
} // namespace mem
|
20
include/os/osMutex.h
Normal file
20
include/os/osMutex.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <defines.h>
|
||||
#include <types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct OSMutex {
|
||||
int unk[6];
|
||||
} OSMutex;
|
||||
|
||||
void OSInitMutex(OSMutex *mutex);
|
||||
void OSLockMutex(OSMutex *mutex);
|
||||
void OSUnlockMutex(OSMutex *mutex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,8 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <os/osMutex.h>
|
||||
|
||||
namespace util {
|
||||
struct Mutex {
|
||||
int unk[6];
|
||||
OSMutex inner_;
|
||||
Mutex();
|
||||
void lock();
|
||||
void unlock();
|
||||
};
|
||||
|
||||
struct ScopedMutex {
|
||||
Mutex &mutex_;
|
||||
ScopedMutex(Mutex &mutex);
|
||||
~ScopedMutex();
|
||||
};
|
||||
|
||||
} // namespace util
|
|
@ -29,7 +29,10 @@ const SOURCES: &[(&str, &str)] = &[
|
|||
("donut/gfx/GXFifoMemoryManager.cpp", "donut"),
|
||||
("donut/gfx/RenderSetting.cpp", "donut"),
|
||||
("donut/gfx/XFBManager.cpp", "donut"),
|
||||
("donut/mem/DataBlock.cpp", "donut"),
|
||||
("donut/mem/MemBlock.cpp", "donut"),
|
||||
("donut/mem/Memory.cpp", "donut"),
|
||||
("donut/util/Mutex.cpp", "donut"),
|
||||
];
|
||||
|
||||
const ASM_SOURCES: &[&str] = &["sdk/trk/__exception.S"];
|
||||
|
|
Loading…
Reference in a new issue