Esempio n. 1
0
 public override void Initialise()
 {
     for (int i = 0; i < memory.Length; i++)
     {
         NativeMemoryUtils.memset(memory[i], 0, 0, pageSize);
     }
 }
Esempio n. 2
0
        protected internal override void memcpy(int destination, int source, int Length, bool checkOverlap)
        {
            if (Length <= 0)
            {
                return;
            }

            destination &= addressMask;
            source      &= addressMask;
            Modules.sceDisplayModule.write(destination);

            if (!checkOverlap || source >= destination || !areOverlapping(destination, source, Length))
            {
                NativeMemoryUtils.memcpy(memory, destination, memory, source, Length);
            }
            else
            {
                // Source and destination are overlapping and source < destination,
                // copy from the tail.
                for (int i = Length - 1; i >= 0; i--)
                {
                    int b = NativeMemoryUtils.read8(memory, source + i);
                    NativeMemoryUtils.write8(memory, destination + i, b);
                }
            }
        }
Esempio n. 3
0
        public override bool allocate()
        {
            NativeMemoryUtils.init();

            memorySize = MemoryMap.END_RAM + 1;
            memory     = new long[System.Math.Max((memorySize + pageSize - 1) >> pageShift, 1)];
            for (int i = 0; i < memory.Length; i++)
            {
                memory[i] = NativeMemoryUtils.alloc(pageSize);
                if (memory[i] == 0)
                {
                    // Not enough native memory available
                    for (int j = 0; j < i; j++)
                    {
                        NativeMemoryUtils.free(memory[j]);
                    }
                    return(false);
                }
            }

//JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET:
//ORIGINAL LINE: Console.WriteLine(String.format("Using SparseNativeMemory(littleEndian=%b)", NativeMemoryUtils.isLittleEndian()));
            Console.WriteLine(string.Format("Using SparseNativeMemory(littleEndian=%b)", NativeMemoryUtils.LittleEndian));

            return(base.allocate());
        }
Esempio n. 4
0
        protected internal override void memcpy(int destination, int source, int Length, bool checkOverlap)
        {
            if (Length <= 0)
            {
                return;
            }

            destination &= addressMask;
            source      &= addressMask;
            Modules.sceDisplayModule.write(destination);

            if (!checkOverlap || source >= destination || !areOverlapping(destination, source, Length))
            {
                while (Length > 0)
                {
                    int pageLengthDestination = System.Math.Min(pageSize - (destination & pageMask), Length);
                    int pageLengthSource      = System.Math.Min(pageSize - (source & pageMask), Length);
                    int pageLength            = System.Math.Min(pageLengthDestination, pageLengthSource);
                    NativeMemoryUtils.memcpy(memory[destination >> pageShift], destination & pageMask, memory[source >> pageShift], source & pageMask, pageLength);
                    Length      -= pageLength;
                    destination += pageLength;
                    source      += pageLength;
                }
            }
            else
            {
                // Source and destination are overlapping and source < destination,
                // copy from the tail.
                for (int i = Length - 1; i >= 0; i--)
                {
                    int b = read8(source + i);
                    write8(destination + i, (sbyte)b);
                }
            }
        }
Esempio n. 5
0
 public override void memset(int address, sbyte data, int Length)
 {
     address &= addressMask;
     while (Length > 0)
     {
         int pageLength = System.Math.Min(pageSize - (address & pageMask), Length);
         NativeMemoryUtils.memset(memory[address >> pageShift], address & pageMask, data, pageLength);
         Length  -= pageLength;
         address += pageLength;
     }
 }
Esempio n. 6
0
 public override void copyToMemory(int address, ByteBuffer source, int Length)
 {
     address &= addressMask;
     Length   = System.Math.Min(Length, source.capacity());
     if (source.Direct)
     {
         NativeMemoryUtils.copyBufferToMemory(memory, address, source, source.position(), Length);
     }
     else
     {
         for (; Length > 0; address++, Length--)
         {
             NativeMemoryUtils.write8(memory, address, source.get());
         }
     }
 }
Esempio n. 7
0
        public override Buffer getBuffer(int address, int Length)
        {
            address &= addressMask;
            ByteBuffer buffer = NativeMemoryUtils.getBuffer(memory, address, Length);

            // Set the correct byte order
            if (NativeMemoryUtils.LittleEndian)
            {
                buffer.order(ByteOrder.LITTLE_ENDIAN);
            }
            else
            {
                buffer.order(ByteOrder.BIG_ENDIAN);
            }

            return(buffer);
        }
Esempio n. 8
0
        public override bool allocate()
        {
            NativeMemoryUtils.init();

            memorySize = MemoryMap.END_RAM + 1;
            memory     = NativeMemoryUtils.alloc(memorySize);

            if (memory == 0)
            {
                // Not enough native memory available
                return(false);
            }

//JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET:
//ORIGINAL LINE: Console.WriteLine(String.format("Using NativeMemory(littleEndian=%b)", NativeMemoryUtils.isLittleEndian()));
            Console.WriteLine(string.Format("Using NativeMemory(littleEndian=%b)", NativeMemoryUtils.LittleEndian));

            return(base.allocate());
        }
Esempio n. 9
0
 public override void memset(int address, sbyte data, int Length)
 {
     address &= addressMask;
     NativeMemoryUtils.memset(memory, address, data, Length);
 }
Esempio n. 10
0
 public override void write32(int address, int data)
 {
     address &= addressMask;
     NativeMemoryUtils.write32(memory, address, data);
     Modules.sceDisplayModule.write32(address);
 }
Esempio n. 11
0
 public override int read32(int address)
 {
     address &= addressMask;
     return(NativeMemoryUtils.read32(memory, address));
 }
Esempio n. 12
0
 public override void Initialise()
 {
     NativeMemoryUtils.memset(memory, 0, 0, memorySize);
 }
Esempio n. 13
0
 public override int read16(int address)
 {
     address &= addressMask;
     return(NativeMemoryUtils.read16(memory[address >> pageShift], address & pageMask));
 }
Esempio n. 14
0
 public override void write16(int address, short data)
 {
     address &= addressMask;
     NativeMemoryUtils.write16(memory[address >> pageShift], address & pageMask, data);
     Modules.sceDisplayModule.write16(address);
 }