2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _CARAMMANAGER
|
|
|
|
#define _CARAMMANAGER
|
2022-04-10 00:17:06 +00:00
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
2023-10-12 11:10:49 +00:00
|
|
|
#include <dolphin/arq.h>
|
|
|
|
|
|
|
|
#include <rstl/list.hpp>
|
|
|
|
|
2022-04-10 00:17:06 +00:00
|
|
|
class CARAMManager {
|
|
|
|
public:
|
2022-12-06 07:59:41 +00:00
|
|
|
enum EDMAPriority {
|
|
|
|
kDMAPrio_Zero,
|
|
|
|
kDMAPrio_One,
|
|
|
|
kDMAPrio_Two,
|
|
|
|
kDMAPrio_Three,
|
|
|
|
kDMAPrio_Four,
|
|
|
|
kDMAPrio_Five,
|
|
|
|
kDMAPrio_Six,
|
|
|
|
};
|
|
|
|
|
2023-10-12 11:10:49 +00:00
|
|
|
static bool Initialize(uint);
|
2022-04-10 00:17:06 +00:00
|
|
|
static void Shutdown();
|
2023-10-12 11:10:49 +00:00
|
|
|
static void* Alloc(uint len);
|
|
|
|
static uint FindFreeBlocks(uint, uint, uint);
|
|
|
|
static bool Free(const void* ptr);
|
|
|
|
static uint DMAToARAM(void*, void*, uint, EDMAPriority);
|
|
|
|
static int DMAToMRAM(void*, void*, uint, EDMAPriority);
|
|
|
|
static bool IsDMACompleted(uint handle);
|
|
|
|
static void WaitForDMACompletion(uint handle);
|
|
|
|
static void WaitForAllDMAsToComplete();
|
|
|
|
static bool CancelDMA(uint);
|
|
|
|
static void AramManagerDMACallback(u32 result);
|
|
|
|
static void RefreshActiveDMAList();
|
2022-04-10 00:17:06 +00:00
|
|
|
static void CollectGarbage();
|
2023-10-12 11:10:49 +00:00
|
|
|
|
2022-09-18 06:05:46 +00:00
|
|
|
static void PreInitializeAlloc(uint size) { mPreInitializeAlloc += size; }
|
2022-12-06 07:59:41 +00:00
|
|
|
static const void* GetInvalidAlloc() { return (const void*)kInvalidAlloc; }
|
|
|
|
static const uint GetInvalidDMAHandle() { return kInvalidHandle; }
|
2023-10-12 11:10:49 +00:00
|
|
|
static uint GetAndIncrementUniqueID() {
|
|
|
|
mDMAUniqueID++;
|
|
|
|
if (mDMAUniqueID == GetInvalidDMAHandle()) {
|
|
|
|
mDMAUniqueID++;
|
|
|
|
}
|
|
|
|
return mDMAUniqueID;
|
|
|
|
}
|
|
|
|
|
2022-09-13 04:26:54 +00:00
|
|
|
private:
|
2023-10-12 11:10:49 +00:00
|
|
|
struct SAramDMARequest {
|
|
|
|
ARQRequest mRequest;
|
|
|
|
uint mUniqueID;
|
|
|
|
bool mComplete;
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool mbInitialized;
|
|
|
|
static u32 mpARAMStart;
|
|
|
|
static uint mChunkSize;
|
|
|
|
static uint mNumChunks;
|
|
|
|
static uint* mpBookKeepingMemory;
|
2022-10-09 05:37:23 +00:00
|
|
|
static uint mPreInitializeAlloc;
|
2023-10-12 11:10:49 +00:00
|
|
|
static uint mDMAUniqueID;
|
|
|
|
static uint mChunksAllocated;
|
|
|
|
static rstl::list< SAramDMARequest* > mActiveDMAs;
|
2022-12-06 07:59:41 +00:00
|
|
|
static const int kInvalidAlloc;
|
|
|
|
static const int kInvalidHandle;
|
2022-04-10 00:17:06 +00:00
|
|
|
};
|
|
|
|
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _CARAMMANAGER
|