1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
#ifndef _DOLCESDK_PSP2_KERNEL_SYSMEM_MEMBLOCK_H_
#define _DOLCESDK_PSP2_KERNEL_SYSMEM_MEMBLOCK_H_
#include <psp2/cdefs.h>
#include <psp2/kernel/types.h>
/** @name sceKernelAllocMemBlockで指定可能なメモリタイプ
*/
/*@{*/
/**
* memory block type for read write cache allocated on LPDDR2
*/
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RW 0x0c20d060U
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA SCE_KERNEL_MEMBLOCK_TYPE_USER_RW
/**
* memory block type for read execute cache allocated on LPDDR2
*/
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RX 0x0c20d050U
/**
* memory block type for read write uncache allocated on LPDDR2
*/
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_NC_RW 0x0c208060U
/**
* alias of SCE_KERNEL_MEMBLOCK_TYPE_USER_NC_RW
*/
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE SCE_KERNEL_MEMBLOCK_TYPE_USER_NC_RW
/**
* alias of SCE_KERNEL_MEMBLOCK_TYPE_USER_NC_RW
*/
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE
/**
* memory block type for read write cache allocated on LPDDR2 physical continuous area
*/
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW 0x0c80d060U
/**
* memory block type for read write uncache allocated on LPDDR2 physical continuous area
*/
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW 0x0d808060U
/**
* memory block type for read write uncache allocated on CDRAM
*/
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW 0x09408060U
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RWDATA SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW
/*@}*/
SCE_CDECL_BEGIN
#if !defined(_LANGUAGE_ASSEMBLY)
typedef struct SceKernelAllocMemBlockOpt0940 {
SceSize size;
SceUInt32 attr;
SceSize alignment;
SceUID uidBaseBlock;
const char *strBaseBlockName;
} SceKernelAllocMemBlockOpt0940;
/**
* Option parameter for sceKernelAllocMemBlock
*/
typedef struct SceKernelAllocMemBlockOpt {
/**
* size of this
*/
SceSize size;
/**
* attributes field
*/
SceUInt32 attr;
/**
* alignment option
* must set SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_ALIGNMENT to 'attr'
*/
SceSize alignment;
/**
* reserved
*/
SceUInt32 reserved;
/**
* reserved2
*/
const char *strBaseBlockName;
#if 0
/**
* mapped base address [out]
*/
void *mappedBase;
/**
* mapped size [out]
*/
SceSize mappedSize;
/**
* memory type [out]
*/
SceKernelMemoryType memoryType;
SceUInt32 access;
#endif
} SceKernelAllocMemBlockOpt;
/**
* Enable 'alignment' member
*/
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_ALIGNMENT 0x00000004U
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_PHYCONT 0x00200000U
/**
* Allocating memory block
*
* @param[in] name memory block name
* @param[in] vsize memory block virtual size
* @param[in] flags options
* @retval id UID of memory block
* @retval <SCE_OK Error code
*
*/
SceUID sceKernelAllocMemBlock(
const char *name,
SceKernelMemBlockType type,
SceSize vsize,
const struct SceKernelAllocMemBlockOpt *pOpt);
/**
* free memory block
* @param[in] uid block uid
*/
int sceKernelFreeMemBlock(SceUID uid);
/**
* Get base address of memory block.
* @param[in] uid block id
* @param[out] ppBase base address of memory block
* @retval SCE_OK success
* @retval <SCE_OK Error
*/
#if !defined(__INTELLISENSE__)
int sceKernelGetMemBlockBase(SceUID uid, void **ppBase)
__attribute__((__nonnull__(2)));
#else /* !defined(__INTELLISENSE__) */
int sceKernelGetMemBlockBase(SceUID uid, void **ppBase);
#endif /* !defined(__INTELLISENSE__) */
/**
* Find memory block by virtual range (base address and size)
* If size == 0, API returns a memory block which contains 'start'
* If size > 0, API returns a memory block just fit range [start, start + size].
* @param[in] vaddr base address
* @param[in] size address size
* @retval >=SCE_OK block id
* @retval <SCE_OK error
*/
SceUID sceKernelFindMemBlockByAddr(
void *uaddr,
SceSize size);
/**
* type for memory block type used in sceKernelAllocMemBlock
*/
typedef int SceKernelMemoryType;
/**
* information structure for memory block
*/
typedef struct SceKernelMemBlockInfo {
SceSize size; /**< sizeof this */
void *mappedBase; /**< mapped base address */
SceSize mappedSize; /**< mapped size */
SceKernelMemoryType memoryType; /**< memory type like cache, uncache */
SceUInt32 access; /**< memory access permission */
SceKernelMemBlockType type; /**< Memory Block type */
} SceKernelMemBlockInfo;
/*----- memory access permission -----*/
/**
* readable memory
*/
#define SCE_KERNEL_MEMORY_ACCESS_R 0x04U
/**
* writable memory
*/
#define SCE_KERNEL_MEMORY_ACCESS_W 0x02U
/**
* executable memory
*/
#define SCE_KERNEL_MEMORY_ACCESS_X 0x01U
/*----- memory type -----*/
/**
* uncache normal memory
*/
#define SCE_KERNEL_MEMORY_TYPE_NORMAL_NC 0x80
/**
* cache normal memory
*/
#define SCE_KERNEL_MEMORY_TYPE_NORMAL 0xD0
/**
* Get memory block information by giving virtual address
* @param[in] vbase base address
* @param[inout] pInfo pointer to information structure
*/
#if !defined(__INTELLISENSE__)
int sceKernelGetMemBlockInfoByAddr(
void *vbase,
SceKernelMemBlockInfo *pInfo)
__attribute__((__nonnull__(1,2), __warn_unused_result__));
#else /* !defined(__INTELLISENSE__) */
int sceKernelGetMemBlockInfoByAddr(
void *vbase,
SceKernelMemBlockInfo *pInfo);
#endif /* !defined(__INTELLISENSE__) */
/**
* Get memory block informaton by virtuak address range
* @param[in] vbase base address
* @param[in] vsize size
* @param[inout] pInfo information structure
*/
#if !defined(__INTELLISENSE__)
int sceKernelGetMemBlockInfoByRange(
void *vbase,
SceSize vsize,
SceKernelMemBlockInfo *pInfo)
__attribute__((__nonnull__(1,3), __warn_unused_result__));
#else /* !defined(__INTELLISENSE__) */
int sceKernelGetMemBlockInfoByRange(
void *vbase,
SceSize vsize,
SceKernelMemBlockInfo *pInfo);
#endif /* !defined(__INTELLISENSE__) */
#endif /* !defined(_LANGUAGE_ASSEMBLY) */
SCE_CDECL_END
#endif /* _DOLCESDK_PSP2_KERNEL_SYSMEM_MEMBLOCK_H_ */
|