public MsgPipeId sceKernelCreateMsgPipe(string Name, HleMemoryManager.Partitions PartitionId, MsgPipeAttributes Attributes, int Size, void *Options) { if (Options != null) { throw(new NotImplementedException()); } var MsgPipe = new MsgPipe() { Name = Name, PartitionId = PartitionId, Size = Size, Attributes = Attributes, }; MsgPipe.Init(HleState.ThreadManager, HleState.MemoryManager.Memory, HleState.MemoryManager); return(MessagePipeList.Create(MsgPipe)); }
public PoolId sceKernelCreateFpl(string Name, HleMemoryManager.Partitions PartitionId, int Attributes, int BlockSize, int NumberOfBlocks, void *Options) { if (Options != null) { throw(new NotImplementedException()); } var FixedPool = new FixedPool() { MemoryManager = HleState.MemoryManager, Name = Name, PartitionId = PartitionId, Attributes = Attributes, BlockSize = BlockSize, NumberOfBlocks = NumberOfBlocks, }; FixedPool.Init(); return(FixedPoolList.Create(FixedPool)); }
public VariablePoolId sceKernelCreateVpl(string Name, HleMemoryManager.Partitions PartitionId, VplAttribute Attribute, int Size, void *Options) { var VariablePool = new VariablePool() { Info = new SceKernelVplInfo() { Attribute = Attribute, FreeSize = Size, } }; /* * if (Attribute.HasFlag(VplAttribute.PSP_VPL_ATTR_ADDR_HIGH)) * { * HleState.MemoryManager.GetPartition(PartitionId).Allocate(Size) * } else { * } */ VariablePool.Init(); return(VariablePoolList.Create(VariablePool)); /* * throw(new NotImplementedException()); * const PSP_VPL_ATTR_MASK = 0x41FF; // Anything outside this mask is an illegal attr. * const PSP_VPL_ATTR_ADDR_HIGH = 0x4000; // Create the vpl in high memory. * const PSP_VPL_ATTR_EXT = 0x8000; // Extend the vpl memory area (exact purpose is unknown). * //new MemorySegment * logWarning("sceKernelCreateVpl('%s', %d, %d, %d)", name, part, attr, size); * VariablePool variablePool; * if (attr & PSP_VPL_ATTR_ADDR_HIGH) { * variablePool = new VariablePool(hleEmulatorState.moduleManager.get!SysMemUserForUser()._allocateMemorySegmentHigh(part, dupStr(name), size)); * } else { * variablePool = new VariablePool(hleEmulatorState.moduleManager.get!SysMemUserForUser()._allocateMemorySegmentLow(part, dupStr(name), size)); * } * logWarning("%s", variablePool); * return uniqueIdFactory.add(variablePool); */ }
public int sceKernelAllocPartitionMemory(HleMemoryManager.Partitions PartitionId, string Name, HleMemoryManager.BlockTypeEnum Type, int Size, /* void* */ uint Address) { MemoryPartition MemoryPartition; int Alignment = 1; switch (Type) { case HleMemoryManager.BlockTypeEnum.HighAligned: case HleMemoryManager.BlockTypeEnum.LowAligned: Alignment = (int)Address; break; } if (Type == HleMemoryManager.BlockTypeEnum.Low || Type == HleMemoryManager.BlockTypeEnum.LowAligned) { try { MemoryPartition = HleState.MemoryManager.GetPartition(PartitionId).Allocate(Size, MemoryPartition.Anchor.Low, Alignment: Alignment); } catch (InvalidOperationException InvalidOperationException) { //Console.Error.WriteLine(InvalidOperationException); Console.Error.WriteLine(InvalidOperationException.Message); throw(new SceKernelException(SceKernelErrors.ERROR_KERNEL_NO_MEMORY)); } } else { throw (new NotImplementedException("Not Implemented sceKernelAllocPartitionMemory with '" + Type + "'")); } return((int)HleState.MemoryManager.MemoryPartitionsUid.Create(MemoryPartition)); /* * throw(new NotImplementedException()); * const uint ERROR_KERNEL_ILLEGAL_MEMBLOCK_ALLOC_TYPE = 0x800200d8; * const uint ERROR_KERNEL_FAILED_ALLOC_MEMBLOCK = 0x800200d9; * * try { * MemorySegment memorySegment; * * Logger.log(Logger.Level.INFO, "SysMemUserForUser", "sceKernelAllocPartitionMemory(%d:'%s':%s:%d,0x%08X)", PartitionId, Name, std.conv.to!string(Type), Size, Address); * //Logger.log(Logger.Level.INFO, "SysMemUserForUser", "sceKernelAllocPartitionMemory(%d:'%s':%d:%d)", partitionid, name, (type), size); * * int alignment = 1; * if ((Type == PspSysMemBlockTypes.PSP_SMEM_Low_Aligned) || (Type == PspSysMemBlockTypes.PSP_SMEM_High_Aligned)) { * alignment = Address; * } * * switch (Type) { * default: return ERROR_KERNEL_ILLEGAL_MEMBLOCK_ALLOC_TYPE; * case PspSysMemBlockTypes.PSP_SMEM_Low_Aligned: * case PspSysMemBlockTypes.PSP_SMEM_Low : memorySegment = pspMemorySegment[PartitionId].allocByLow (Size, dupStr(Name), 0, alignment); break; * case PspSysMemBlockTypes.PSP_SMEM_High_Aligned: * case PspSysMemBlockTypes.PSP_SMEM_High: memorySegment = pspMemorySegment[PartitionId].allocByHigh(Size, dupStr(Name), alignment); break; * case PspSysMemBlockTypes.PSP_SMEM_Addr: memorySegment = pspMemorySegment[PartitionId].allocByAddr(Address, Size, dupStr(Name)); break; * } * * if (memorySegment is null) return ERROR_KERNEL_FAILED_ALLOC_MEMBLOCK; * * SceUID sceUid = uniqueIdFactory.add(memorySegment); * * Logger.log(Logger.Level.INFO, "SysMemUserForUser", "sceKernelAllocPartitionMemory(%d:'%s':%s:%d) :: (%d) -> %s", PartitionId, Name, std.conv.to!string(Type), Size, sceUid, memorySegment.block); * //Logger.log(Logger.Level.INFO, "SysMemUserForUser", "sceKernelAllocPartitionMemory(%d:'%s':%d:%d) :: (%d) -> %s", partitionid, name, (type), size, sceUid, memorySegment.block); * * return sceUid; * } * catch (Exception Exception) * { * //logError("ERROR: %s", o); * return ERROR_KERNEL_FAILED_ALLOC_MEMBLOCK; * } */ }