Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/goddard/gd_memory.h
7858 views
1
#ifndef GD_MEMORY_H
2
#define GD_MEMORY_H
3
4
#include <PR/ultratypes.h>
5
6
/// A structure that holds information about memory allocation on goddard's heap.
7
struct GMemBlock {
8
/* 0x00 */ u8 *ptr;
9
/* 0x04 */ u32 size;
10
/* 0x08 */ u8 blockType;
11
/* 0x09 */ u8 permFlag; ///< Permanent (upper four bits) or Temporary (lower four bits)
12
/* 0x0C */ struct GMemBlock *next;
13
/* 0x10 */ struct GMemBlock *prev;
14
};
15
16
/// Block list types for `GMemBlock.blockType`. Note that Empty Blocks don't have
17
/// a specific value.
18
enum GMemBlockTypes {
19
G_MEM_BLOCK_FREE = 1,
20
G_MEM_BLOCK_USED = 2
21
};
22
/* Block Permanence Defines */
23
/* This may be collections of certain allocation types
24
* eg. 0x10 = Object; 0x20 = Color Buffer; 0x40 = Z Buf; 0x01 = basic; etc. */
25
#define PERM_G_MEM_BLOCK 0xF0
26
#define TEMP_G_MEM_BLOCK 0x0F
27
28
// functions
29
extern u32 gd_free_mem(void *ptr);
30
extern void *gd_request_mem(u32 size, u8 permanence);
31
extern struct GMemBlock *gd_add_mem_to_heap(u32 size, void *addr, u8 permanence);
32
extern void init_mem_block_lists(void);
33
extern void mem_stats(void);
34
35
#endif // GD_MEMORY_H
36
37