sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
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
17#ifndef __SYSMEM_H__
18#define __SYSMEM_H__
19
20#include <types.h>
21#include <irx.h>
22#include <stdarg.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28// Allocation strategies
29#define ALLOC_FIRST 0
30#define ALLOC_LAST 1
31#define ALLOC_ADDRESS 2
32
33// see QueryBlockTopAddress, QueryBlockSize
34#define USED 0x00000000
35#define FREE 0x80000000
36
38{
39 struct sysmem_alloc_element_ *next;
40 unsigned int info;
41} sysmem_alloc_element_t;
42
43typedef struct sysmem_alloc_table_
44{
45 struct sysmem_alloc_table_ *next;
46 sysmem_alloc_element_t list[31];
47 int padding;
48} sysmem_alloc_table_t;
49
51typedef struct sysmem_internals_
52{
53 int memsize;
54 sysmem_alloc_table_t *alloclist;
55 /* The following members may change depending on the version of the module. */
56 void *intr_suspend_tbl;
57 int allocation_count;
58 sysmem_alloc_table_t *smemupdate_cur;
60
61extern sysmem_internals_t *GetSysmemInternalData(void);
62
63extern void * AllocSysMemory(int mode, int size, void *ptr);
64
65extern int FreeSysMemory(void *ptr);
66
67extern u32 QueryMemSize();
68// In liberx, the following is QueryFreeMemSize
69extern u32 QueryMaxFreeMemSize();
70extern u32 QueryTotalFreeMemSize();
71// In liberx, the following is QueryBlockInfo
72extern void * QueryBlockTopAddress(void *address);
73extern int QueryBlockSize(void *address);
74
75typedef int (KprintfHandler_t)(void *context, const char *format, va_list ap);
76
77extern int Kprintf(const char *format,...);
78extern void KprintfSet(KprintfHandler_t *, void *context);
79
80#define sysmem_IMPORTS_start DECLARE_IMPORT_TABLE(sysmem, 1, 1)
81#define sysmem_IMPORTS_end END_IMPORT_TABLE
82
83#define I_GetSysmemInternalData DECLARE_IMPORT(3, GetSysmemInternalData)
84#define I_AllocSysMemory DECLARE_IMPORT(4, AllocSysMemory)
85#define I_FreeSysMemory DECLARE_IMPORT(5, FreeSysMemory)
86#define I_QueryMemSize DECLARE_IMPORT(6, QueryMemSize)
87#define I_QueryMaxFreeMemSize DECLARE_IMPORT(7, QueryMaxFreeMemSize)
88#define I_QueryTotalFreeMemSize DECLARE_IMPORT(8, QueryTotalFreeMemSize)
89#define I_QueryBlockTopAddress DECLARE_IMPORT(9, QueryBlockTopAddress)
90#define I_QueryBlockSize DECLARE_IMPORT(10, QueryBlockSize)
91#define I_Kprintf DECLARE_IMPORT(14, Kprintf)
92#define I_KprintfSet DECLARE_IMPORT(15, KprintfSet)
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif /* IOP_SYSMEM_H */
struct sysmem_internals_ sysmem_internals_t