public int sceKernelAllocPartitionMemory(MemoryPartitions PartitionId, string Name, HleMemoryManager.BlockTypeEnum Type, int Size, /* void* */uint Address) { if ((int)PartitionId <= 0 || (int)PartitionId == 7 || (int)PartitionId >= 10) throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_ARGUMENT)); if (Size <= 0) throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_FAILED_ALLOC_MEMBLOCK)); //Console.Error.WriteLineColored(ConsoleColor.Yellow, "sceKernelAllocPartitionMemory: {0}, {1}, {2}, {3}, {4}", PartitionId, MemoryManager.GetPartition(PartitionId).MaxFreeSize, Name, Type, Size); if (Name == null) throw (new SceKernelException(SceKernelErrors.ERROR_ERROR)); MemoryPartition MemoryPartition; int Alignment = 1; switch (Type) { case HleMemoryManager.BlockTypeEnum.HighAligned: case HleMemoryManager.BlockTypeEnum.LowAligned: Alignment = (int)Address; break; } if ((Alignment == 0) || !MathUtils.IsPowerOfTwo((uint)Alignment)) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_ALIGNMENT_SIZE)); } try { switch (Type) { case HleMemoryManager.BlockTypeEnum.Low: case HleMemoryManager.BlockTypeEnum.LowAligned: MemoryPartition = MemoryManager.GetPartition(PartitionId).Allocate(Size, MemoryPartition.Anchor.Low, Alignment: Alignment, Name: Name ); break; case HleMemoryManager.BlockTypeEnum.High: case HleMemoryManager.BlockTypeEnum.HighAligned: MemoryPartition = MemoryManager.GetPartition(PartitionId).Allocate(Size, MemoryPartition.Anchor.High, Alignment: Alignment, Name: Name); break; case HleMemoryManager.BlockTypeEnum.Address: if (Address == 0) throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_FAILED_ALLOC_MEMBLOCK)); MemoryPartition = MemoryManager.GetPartition(PartitionId).Allocate(Size, MemoryPartition.Anchor.Low, Position: Address, Alignment: Alignment, Name: Name); break; default: Console.Error.WriteLineColored(ConsoleColor.Red, "Not Implemented sceKernelAllocPartitionMemory with Type='" + Type + "'"); throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_MEMBLOCK_ALLOC_TYPE)); } } catch (MemoryPartitionNoMemoryException MemoryPartitionNoMemoryException) { //Console.Error.WriteLine(InvalidOperationException); Console.Error.WriteLine(MemoryPartitionNoMemoryException); throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_NO_MEMORY)); } //Console.Error.WriteLineColored(ConsoleColor.Cyan, " sceKernelAllocPartitionMemory: {0}", MemoryPartition); return (int)MemoryManager.MemoryPartitionsUid.Create(MemoryPartition); //return MemoryPartition; }
public MsgPipe sceKernelCreateMsgPipe(string Name, MemoryPartitions 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(ThreadManager, MemoryManager.Memory, MemoryManager); return MsgPipe; }
public FixedPool sceKernelCreateFpl(string Name, MemoryPartitions PartitionId, FplAttributes Attributes, int BlockSize, int NumberOfBlocks, FplOptionsStruct* Options) { var FixedPool = new FixedPool(this) { MemoryManager = MemoryManager, Name = Name, PartitionId = PartitionId, Attributes = Attributes, BlockSize = BlockSize, NumberOfBlocks = NumberOfBlocks, }; if (Options != null) FixedPool.Options = *Options; FixedPool.Init(); return FixedPool; }
public VariablePool sceKernelCreateVpl(string Name, MemoryPartitions PartitionId, VplAttributeEnum Attribute, int Size, void *Options) { var VariablePool = new VariablePool(this) { PartitionId = PartitionId, Info = new SceKernelVplInfo() { Attribute = Attribute, PoolSize = Size, FreeSize = Size, } }; VariablePool.Init(); return(VariablePool); }
public MsgPipe sceKernelCreateMsgPipe(string Name, MemoryPartitions 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(ThreadManager, MemoryManager.Memory, MemoryManager); return(MsgPipe); }
public FixedPool sceKernelCreateFpl(string Name, MemoryPartitions PartitionId, FplAttributes Attributes, int BlockSize, int NumberOfBlocks, FplOptionsStruct *Options) { var FixedPool = new FixedPool(this) { MemoryManager = MemoryManager, Name = Name, PartitionId = PartitionId, Attributes = Attributes, BlockSize = BlockSize, NumberOfBlocks = NumberOfBlocks, }; if (Options != null) { FixedPool.Options = *Options; } FixedPool.Init(); return(FixedPool); }
public VariablePool sceKernelCreateVpl(string Name, MemoryPartitions PartitionId, VplAttributeEnum Attribute, int Size, void* Options) { var VariablePool = new VariablePool(this) { PartitionId= PartitionId, Info = new SceKernelVplInfo() { Attribute = Attribute, PoolSize = Size, FreeSize = Size, } }; VariablePool.Init(); return VariablePool; }
public MemoryPartition GetPartition(MemoryPartitions Partition) { return(MemoryPartitionsUid.Get((int)Partition)); }
public MemoryPartition GetPartition(MemoryPartitions Partition) { return MemoryPartitionsUid.Get((int)Partition); }
public int sceKernelAllocPartitionMemory(MemoryPartitions PartitionId, string Name, HleMemoryManager.BlockTypeEnum Type, int Size, /* void* */ uint Address) { if ((int)PartitionId <= 0 || (int)PartitionId == 7 || (int)PartitionId >= 10) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_ARGUMENT)); } if (Size <= 0) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_FAILED_ALLOC_MEMBLOCK)); } //Console.Error.WriteLineColored(ConsoleColor.Yellow, "sceKernelAllocPartitionMemory: {0}, {1}, {2}, {3}, {4}", PartitionId, MemoryManager.GetPartition(PartitionId).MaxFreeSize, Name, Type, Size); if (Name == null) { throw (new SceKernelException(SceKernelErrors.ERROR_ERROR)); } MemoryPartition MemoryPartition; int Alignment = 1; switch (Type) { case HleMemoryManager.BlockTypeEnum.HighAligned: case HleMemoryManager.BlockTypeEnum.LowAligned: Alignment = (int)Address; break; } if ((Alignment == 0) || !MathUtils.IsPowerOfTwo((uint)Alignment)) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_ALIGNMENT_SIZE)); } try { switch (Type) { case HleMemoryManager.BlockTypeEnum.Low: case HleMemoryManager.BlockTypeEnum.LowAligned: MemoryPartition = MemoryManager.GetPartition(PartitionId).Allocate(Size, MemoryPartition.Anchor.Low, Alignment: Alignment, Name: Name); break; case HleMemoryManager.BlockTypeEnum.High: case HleMemoryManager.BlockTypeEnum.HighAligned: MemoryPartition = MemoryManager.GetPartition(PartitionId).Allocate(Size, MemoryPartition.Anchor.High, Alignment: Alignment, Name: Name); break; case HleMemoryManager.BlockTypeEnum.Address: if (Address == 0) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_FAILED_ALLOC_MEMBLOCK)); } MemoryPartition = MemoryManager.GetPartition(PartitionId).Allocate(Size, MemoryPartition.Anchor.Low, Position: Address, Alignment: Alignment, Name: Name); break; default: Console.Error.WriteLineColored(ConsoleColor.Red, "Not Implemented sceKernelAllocPartitionMemory with Type='" + Type + "'"); throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_MEMBLOCK_ALLOC_TYPE)); } } catch (MemoryPartitionNoMemoryException MemoryPartitionNoMemoryException) { //Console.Error.WriteLine(InvalidOperationException); Console.Error.WriteLine(MemoryPartitionNoMemoryException); throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_NO_MEMORY)); } //Console.Error.WriteLineColored(ConsoleColor.Cyan, " sceKernelAllocPartitionMemory: {0}", MemoryPartition); return((int)MemoryManager.MemoryPartitionsUid.Create(MemoryPartition)); //return MemoryPartition; }
public int sceKernelAllocPartitionMemory(MemoryPartitions 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 = MemoryManager.GetPartition(PartitionId).Allocate( Size, MemoryPartition.Anchor.Low, Alignment: Alignment, Name: Name ); } catch (MemoryPartitionNoMemoryException MemoryPartitionNoMemoryException) { //Console.Error.WriteLine(InvalidOperationException); Console.Error.WriteLine(MemoryPartitionNoMemoryException); throw(new SceKernelException(SceKernelErrors.ERROR_KERNEL_NO_MEMORY)); } } else { //throw (new NotImplementedException()); Console.WriteLine("Not Implemented sceKernelAllocPartitionMemory with Type='" + Type + "'"); throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_MEMBLOCK_ALLOC_TYPE)); //return SceKernelErrors.ERROR_KERNEL_ILLEGAL_MEMBLOCK_ALLOC_TYPE; } return (int)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; } */ }