// SDK location: /user/pspthreadman.h:1340 // SDK declaration: int sceKernelReferVplStatus(SceUID uid, SceKernelVplInfo *info); public int sceKernelReferVplStatus(int uid, int info) { KVariablePool pool = _kernel.GetHandle <KVariablePool>(uid); if (pool == null) { return(-1); } Debug.Assert(info != 0); unsafe { byte *p = _memorySystem.Translate((uint)info); // If the sizeof is not 52, we are screwed Debug.Assert(*( int * )p == 52); *((int *)(p + 0)) = 52; for (int i = 0; i < 31; i++) { *((char *)(p + 4 + i)) = (i < pool.Name.Length) ? pool.Name[i] : (char)0; } *((uint *)(p + 36)) = pool.Attributes; *((uint *)(p + 40)) = pool.BlockSize * (uint)pool.Blocks.Count; *((uint *)(p + 44)) = pool.BlockSize * (uint)pool.FreeBlocks.Count; *((uint *)(p + 48)) = (uint)pool.WaitingThreads.Count; } return(0); }
// SDK location: /user/pspthreadman.h:1300 // SDK declaration: int sceKernelTryAllocateVpl(SceUID uid, unsigned int size, void **data); public int sceKernelTryAllocateVpl(int uid, int size, int data) { KVariablePool pool = _kernel.GetHandle <KVariablePool>(uid); if (pool == null) { return(-1); } KMemoryBlock block = pool.Allocate(); if (block == null) { return(-1); } Debug.Assert(data != 0); unsafe { uint *pdata = ( uint * )_memorySystem.Translate(( uint )data); * pdata = block.Address; } return(0); }
// SDK location: /user/pspthreadman.h:1265 // SDK declaration: int sceKernelDeleteVpl(SceUID uid); public int sceKernelDeleteVpl(int uid) { KVariablePool pool = _kernel.GetHandle <KVariablePool>(uid); if (pool == null) { return(-1); } pool.Dispose(); _kernel.RemoveHandle(pool.UID); return(0); }
// SDK location: /user/pspthreadman.h:1310 // SDK declaration: int sceKernelFreeVpl(SceUID uid, void *data); public int sceKernelFreeVpl(int uid, int data) { KVariablePool pool = _kernel.GetHandle <KVariablePool>(uid); if (pool == null) { return(-1); } bool wokeWaiter = pool.Free(data); if (wokeWaiter == true) { _kernel.Schedule(); } return(0); }
// SDK location: /user/pspthreadman.h:1256 // SDK declaration: SceUID sceKernelCreateVpl(const char *name, int part, int attr, unsigned int size, struct SceKernelVplOptParam *opt); public int sceKernelCreateVpl(int name, int part, int attr, int size, int opt) { KPartition partition = _kernel.Partitions[part]; Debug.Assert(partition != null); if (partition == null) { return(-1); } KVariablePool pool = new KVariablePool(_kernel, partition, _kernel.ReadString(( uint )name), ( uint )attr, ( uint )size); _kernel.AddHandle(pool); // option unused? Debug.Assert(opt == 0); return(( int )pool.UID); }
// SDK location: /user/pspthreadman.h:1277 // SDK declaration: int sceKernelAllocateVpl(SceUID uid, unsigned int size, void **data, unsigned int *timeout); public int sceKernelAllocateVpl(int uid, int size, int data, int timeout) { KVariablePool pool = _kernel.GetHandle <KVariablePool>(uid); if (pool == null) { return(-1); } KMemoryBlock block = pool.Allocate(); if (block != null) { Debug.Assert(data != 0); unsafe { uint *pdata = ( uint * )_memorySystem.Translate(( uint )data); * pdata = block.Address; } return(0); } else { uint timeoutUs = 0; if (timeout != 0) { unsafe { uint *ptimeout = ( uint * )_memorySystem.Translate(( uint )timeout); timeoutUs = *ptimeout; } } KThread thread = _kernel.ActiveThread; Debug.Assert(thread != null); thread.Wait(pool, ( uint )data, timeoutUs, false); return(0); } }
public int sceKernelCreateVpl( int name, int part, int attr, int size, int opt ) { KPartition partition = _kernel.Partitions[ part ]; Debug.Assert( partition != null ); if( partition == null ) return -1; KVariablePool pool = new KVariablePool( _kernel, partition, _kernel.ReadString( ( uint )name ), ( uint )attr, ( uint )size ); _kernel.AddHandle( pool ); // option unused? Debug.Assert( opt == 0 ); return ( int )pool.UID; }