1 /*---------------------------------------------------------------------------* 2 3 Copyright (C) Nintendo. All rights reserved. 4 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 11 *---------------------------------------------------------------------------*/ 12 /*---------------------------------------------------------------------------* 13 Project: MEM library 14 File: allocator.h 15 Programmers: Takano Makoto 16 17 Copyright (C) Nintendo. All rights reserved. 18 19 These coded instructions, statements, and computer programs contain 20 proprietary information of Nintendo of America Inc. and/or Nintendo 21 Company Ltd., and are protected by Federal copyright law. They may 22 not be disclosed to third parties or copied or duplicated in any form, 23 in whole or in part, without the prior written consent of Nintendo. 24 *---------------------------------------------------------------------------*/ 25 26 #ifndef MEM_ALLOCATOR_H__ 27 #define MEM_ALLOCATOR_H__ 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 34 #include <cafe/mem/heapCommon.h> 35 36 /* ======================================================================== 37 Type Definitions 38 ======================================================================== */ 39 40 typedef struct MEMAllocator MEMAllocator; 41 42 typedef void* (*MEMFuncAllocatorAlloc)( MEMAllocator* pAllocator, u32 size ); 43 44 typedef void (*MEMFuncAllocatorFree) ( MEMAllocator* pAllocator, void* memBlock ); 45 46 typedef struct MEMAllocatorFunc MEMAllocatorFunc; 47 48 struct MEMAllocatorFunc 49 { 50 MEMFuncAllocatorAlloc pfAlloc; 51 MEMFuncAllocatorFree pfFree; 52 }; 53 54 struct MEMAllocator 55 { 56 MEMAllocatorFunc const * pFunc; 57 void* pHeap; 58 u32 heapParam1; 59 u32 heapParam2; 60 }; 61 62 63 /* ======================================================================== 64 Function Prototypes 65 ======================================================================== */ 66 67 void* MEMAllocFromAllocator( MEMAllocator* pAllocator, u32 size ); 68 69 void MEMFreeToAllocator ( MEMAllocator* pAllocator, void* memBlock ); 70 71 void MEMInitAllocatorForExpHeap( 72 MEMAllocator* pAllocator, 73 MEMHeapHandle heap, 74 int alignment ); 75 76 void MEMInitAllocatorForFrmHeap( 77 MEMAllocator* pAllocator, 78 MEMHeapHandle heap, 79 int alignment ); 80 81 void MEMInitAllocatorForUnitHeap( MEMAllocator* pAllocator, MEMHeapHandle heap ); 82 83 void MEMInitAllocatorForDefaultHeap ( MEMAllocator* pAllocator ); 84 85 void MEMInitAllocatorForBlockHeap ( MEMAllocator* pAllocator, MEMHeapHandle heap, int alignment); 86 87 #ifdef __cplusplus 88 } /* extern "C" */ 89 #endif 90 91 /* MEM_ALLOCATOR_H__ */ 92 #endif 93