PS2SDK
PS2 Homebrew Libraries
sysmem.h
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
16 #ifndef __SYSMEM_H__
17 #define __SYSMEM_H__
18 
19 #include <types.h>
20 #include <irx.h>
21 #include <stdarg.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 // Allocation strategies
28 #define ALLOC_FIRST 0
29 #define ALLOC_LAST 1
30 #define ALLOC_ADDRESS 2
31 
32 // see QueryBlockTopAddress, QueryBlockSize
33 #define USED 0x00000000
34 #define FREE 0x80000000
35 
36 typedef struct sysmem_alloc_element_
37 {
38  struct sysmem_alloc_element_ *next;
39  unsigned int info;
41 
42 typedef struct sysmem_alloc_table_
43 {
44  struct sysmem_alloc_table_ *next;
45  sysmem_alloc_element_t list[31];
46  int padding;
48 
50 typedef struct sysmem_internals_
51 {
52  int memsize;
53  sysmem_alloc_table_t *alloclist;
54  /* The following members may change depending on the version of the module. */
55  void *intr_suspend_tbl;
56  int allocation_count;
57  sysmem_alloc_table_t *smemupdate_cur;
59 
60 extern sysmem_internals_t *GetSysmemInternalData(void);
61 
62 extern void * AllocSysMemory(int mode, int size, void *ptr);
63 
64 extern int FreeSysMemory(void *ptr);
65 
66 extern u32 QueryMemSize();
67 // In liberx, the following is QueryFreeMemSize
68 extern u32 QueryMaxFreeMemSize();
69 extern u32 QueryTotalFreeMemSize();
70 // In liberx, the following is QueryBlockInfo
71 extern void * QueryBlockTopAddress(void *address);
72 extern int QueryBlockSize(void *address);
73 
74 typedef int (KprintfHandler_t)(void *context, const char *format, va_list ap);
75 
76 extern int Kprintf(const char *format,...);
77 extern void KprintfSet(KprintfHandler_t *, void *context);
78 
79 #define sysmem_IMPORTS_start DECLARE_IMPORT_TABLE(sysmem, 1, 1)
80 #define sysmem_IMPORTS_end END_IMPORT_TABLE
81 
82 #define I_GetSysmemInternalData DECLARE_IMPORT(3, GetSysmemInternalData)
83 #define I_AllocSysMemory DECLARE_IMPORT(4, AllocSysMemory)
84 #define I_FreeSysMemory DECLARE_IMPORT(5, FreeSysMemory)
85 #define I_QueryMemSize DECLARE_IMPORT(6, QueryMemSize)
86 #define I_QueryMaxFreeMemSize DECLARE_IMPORT(7, QueryMaxFreeMemSize)
87 #define I_QueryTotalFreeMemSize DECLARE_IMPORT(8, QueryTotalFreeMemSize)
88 #define I_QueryBlockTopAddress DECLARE_IMPORT(9, QueryBlockTopAddress)
89 #define I_QueryBlockSize DECLARE_IMPORT(10, QueryBlockSize)
90 #define I_Kprintf DECLARE_IMPORT(14, Kprintf)
91 #define I_KprintfSet DECLARE_IMPORT(15, KprintfSet)
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* IOP_SYSMEM_H */
sysmem_internals_t
struct sysmem_internals_ sysmem_internals_t
s_info
Definition: xprintf.c:78
sysmem_alloc_element_
Definition: sysmem.h:36
irx.h
sysmem_alloc_table_
Definition: sysmem.h:42
sysmem_internals_
Definition: sysmem.h:50