copy homebuttonLib from oot-vc (#2960)

* initial copy of hbm from sdk_2009-12-11

* some more nw4hbm cleanup

* nw4hbm db mostly done

* nw4hbm snd copied from oot-vc

* nw4hbm ut copied

* nw4hbm lyt copied

* nw4hbm copied, mostly matching usa 1.0

* setup nw4hbm debug define

* fix HBMDataInfo struct

* add rvl sdk card lib
This commit is contained in:
TakaRikka
2025-12-16 16:55:07 +02:00
committed by GitHub
parent c8104b6d62
commit 8185d87f85
235 changed files with 32438 additions and 320 deletions
+37
View File
@@ -0,0 +1,37 @@
#ifndef _REVOLUTION_MEM_ALLOCATOR_H_
#define _REVOLUTION_MEM_ALLOCATOR_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <revolution/mem/heapCommon.h>
#include <revolution/types.h>
typedef struct MEMAllocator MEMAllocator;
typedef void* (*MEMFuncAllocatorAlloc)(MEMAllocator* pAllocator, u32 size);
typedef void (*MEMFuncAllocatorFree)(MEMAllocator* pAllocator, void* memBlock);
typedef struct MEMAllocatorFunc MEMAllocatorFunc;
struct MEMAllocatorFunc {
MEMFuncAllocatorAlloc pfAlloc;
MEMFuncAllocatorFree pfFree;
};
struct MEMAllocator {
const MEMAllocatorFunc* pFunc;
void* pHeap;
u32 heapParam1;
u32 heapParam2;
};
void* MEMAllocFromAllocator(MEMAllocator*, u32);
void MEMFreeToAllocator(MEMAllocator*, void*);
void MEMInitAllocatorForExpHeap(MEMAllocator*, MEMHeapHandle, int);
void MEMInitAllocatorForFrmHeap(MEMAllocator* allocator, struct MEMiHeapHead* heap, s32 align);
#ifdef __cplusplus
}
#endif
#endif // _REVOLUTION_MEM_ALLOCATOR_H_
+50
View File
@@ -0,0 +1,50 @@
#ifndef _REVOLUTION_MEM_EXPHEAP_H_
#define _REVOLUTION_MEM_EXPHEAP_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <revolution/mem/heapCommon.h>
typedef struct MEMiExpHeapMBlockHead MEMiExpHeapMBlockHead;
struct MEMiExPheapMBlockHead {
u16 signature;
union {
u16 val;
struct {
u16 allocDir : 1;
u16 alignment : 7;
u16 groupID : 8;
} fields;
} attribute;
u32 blockSize;
MEMiExpHeapMBlockHead* prev;
MEMiExpHeapMBlockHead* next;
};
MEMHeapHandle MEMCreateExpHeapEx(void*, u32, u16);
void* MEMDestroyExpHeap(MEMHeapHandle);
void* MEMAllocFromExpHeapEx(MEMHeapHandle, u32, int);
void MEMFreeToExpHeap(MEMHeapHandle, void*);
u32 MEMGetAllocatableSizeForExpHeapEx(MEMHeapHandle, int);
MEMHeapHandle MEMCreateFrmHeapEx(void* start, u32 size, u16 opt);
MEMHeapHandle MEMDestroyFrmHeap(MEMHeapHandle heap);
static inline MEMHeapHandle MEMCreateExpHeap(void* start, u32 size) {
return MEMCreateExpHeapEx(start, size, 0);
}
static inline void* MEMAllocFromExpHeap(MEMHeapHandle heap, u32 size) {
return MEMAllocFromExpHeapEx(heap, size, 4);
}
#ifdef __cplusplus
}
#endif
#endif // _REVOLUTION_MEM_EXPHEAP_H_
+43
View File
@@ -0,0 +1,43 @@
#ifndef _REVOLUTION_MEM_HEAPCOMMON_H_
#define _REVOLUTION_MEM_HEAPCOMMON_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <revolution/mem/list.h>
#include <revolution/os.h>
typedef struct MEMiHeapHead MEMiHeapHead;
struct MEMiHeapHead {
u32 signature;
MEMLink link;
MEMList childList;
void* heapStart;
void* heapEnd;
OSMutex mutex;
union {
u32 val;
struct {
u32 reserved : 24;
u32 optFlag : 8;
} fields;
} attribute;
};
typedef MEMiHeapHead* MEMHeapHandle;
typedef u32 UIntPtr;
static inline UIntPtr GetUIntPtr(const void* ptr) {
return (UIntPtr)(ptr);
}
#ifdef __cplusplus
}
#endif
#endif // _REVOLUTION_MEM_HEAPCOMMON_H_
+31
View File
@@ -0,0 +1,31 @@
#ifndef _REVOLUTION_MEM_LIST_H_
#define _REVOLUTION_MEM_LIST_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <revolution/types.h>
typedef struct {
void* prev;
void* next;
} MEMLink;
typedef struct {
void* head;
void* tail;
u16 num;
u16 offs;
} MEMList;
void MEMInitList(MEMList*, u16);
void MEMAppendListObject(MEMList*, void*);
void MEMRemoveListObject(MEMList*, void*);
void* MEMGetNextListObject(MEMList*, void*);
#ifdef __cplusplus
}
#endif
#endif // _REVOLUTION_MEM_LIST_H_