示例#1
0
        public void Transfer(Dma.Direction Direction, int Size, DmaEnum Address, ref uint Value)
        {
            switch (Address)
            {
                case DmaEnum.KIRK_PATTERN:
                    Value = 1;
                    break;
                case DmaEnum.KIRK_COMMAND:
                    TransferUtils.Transfer(Direction, ref KirkCommand, ref Value);
                    break;
                case DmaEnum.KIRK_RESULT:
                    TransferUtils.Transfer(Direction, ref KirkResult, ref Value);
                    break;
                case DmaEnum.KIRK_SOURCE_ADDRESS:
                    TransferUtils.Transfer(Direction, ref KirkSource, ref Value);
                    break;
                case DmaEnum.KIRK_DESTINATION_ADDRESS:
                    TransferUtils.Transfer(Direction, ref KirkDestination, ref Value);
                    break;
                case DmaEnum.KIRK_START:
                    if (KirkCommand != 1) throw(new NotImplementedException());

                    var SourcePtr = (byte *)Memory.PspAddressToPointerSafe(KirkSource);
                    var DestinationPtr = (byte*)Memory.PspAddressToPointerSafe(KirkDestination);

                    //var Out = new byte[10000];

                    //fixed (byte* OutPtr = Out)
                    {
                        //DestinationPtr = OutPtr;
                        Console.WriteLine("Input:");
                        ArrayUtils.HexDump(PointerUtils.PointerToByteArray(SourcePtr, 0x200));

                        /*
                        try
                        {
                            Kirk.kirk_CMD1(DestinationPtr, SourcePtr, -1, true);
                            this.KirkResult = (uint)Kirk.ResultEnum.OK;
                        }
                        catch (Kirk.KirkException KirkException)
                        {
                            this.KirkResult = (uint)KirkException.Result;
                            Console.Error.WriteLine("Kirk.KirkException : {0}", KirkException);
                        }
                        */

                        this.KirkResult = (uint)Kirk.sceUtilsBufferCopyWithRange(DestinationPtr, -1, SourcePtr, -1, 1);

                        Console.WriteLine("Output:");
                        ArrayUtils.HexDump(PointerUtils.PointerToByteArray(DestinationPtr, 0x200));
                        Console.WriteLine("LOADADDR:{0:X8}", ((uint*)DestinationPtr)[0]);
                        Console.WriteLine("BLOCKSIZE:{0:X8}", ((uint*)DestinationPtr)[1]);
                        Console.WriteLine("ENTRY:{0:X8}", ((uint*)DestinationPtr)[2]);
                        Console.WriteLine("CHECKSUM:{0:X8}", ((uint*)DestinationPtr)[3]);
                    }

                    //Thread.Sleep(4);
                    break;
            }
        }
示例#2
0
文件: Dma.cs 项目: soywiz/cspspemu
 public void TransferDMA(Dma.Direction Direction, int Size, DmaEnum Address, ref uint Value)
 {
     if (false) { }
     /*
     else if ((uint)Address >= 0x1FD00000 && (uint)Address <= 0x1FD00000 + 0x1000)
     {
         TransferUtils.TransferToArray(Direction, Test, (int)(Address - 0x1FD00000), Size, ref Value);
     }
     */
     else if (Address >= DmaEnum.GPIO && Address <= DmaEnum.GPIO__PORT_CLEAR) { LLEState.GPIO.Transfer(Direction, Size, (DmaEnum)Address, ref Value); return; }
     else if (Address >= DmaEnum.NAND__CONTROL && Address <= DmaEnum.NAND__READDATA) { LLEState.NAND.Transfer(Direction, Size, (DmaEnum)Address, ref Value); return; }
     else if (Address >= DmaEnum.NAND__DATA_PAGE_START && Address <= DmaEnum.NAND__DATA_EXTRA_END) { LLEState.NAND.Transfer(Direction, Size, (DmaEnum)Address, ref Value); return; }
     else if (Address >= DmaEnum.KIRK_SIGNATURE && Address <= DmaEnum.KIRK_UNK_50) { LLEState.LleKirk.Transfer(Direction, Size, (DmaEnum)Address, ref Value); return; }
     else
     {
         Console.WriteLine("Unprocessed LLEState.Memory:{0}", LLEState.Memory.MountedPreIpl);
         //Thread.Sleep(100);
     }
 }
示例#3
0
        public void TransferDma(Dma.Direction direction, int size, DmaEnum address, ref uint value)
        {
            if (false)
            {
            }

            /*
             * else if ((uint)Address >= 0x1FD00000 && (uint)Address <= 0x1FD00000 + 0x1000)
             * {
             *  TransferUtils.TransferToArray(Direction, Test, (int)(Address - 0x1FD00000), Size, ref Value);
             * }
             */
            else if (address >= DmaEnum.GPIO && address <= DmaEnum.GPIO__PORT_CLEAR)
            {
                LleState.Gpio.Transfer(direction, size, (DmaEnum)address, ref value);
                return;
            }
            else if (address >= DmaEnum.NAND__CONTROL && address <= DmaEnum.NAND__READDATA)
            {
                LleState.Nand.Transfer(direction, size, (DmaEnum)address, ref value);
                return;
            }
            else if (address >= DmaEnum.NAND__DATA_PAGE_START && address <= DmaEnum.NAND__DATA_EXTRA_END)
            {
                LleState.Nand.Transfer(direction, size, (DmaEnum)address, ref value);
                return;
            }
            else if (address >= DmaEnum.KIRK_SIGNATURE && address <= DmaEnum.KIRK_UNK_50)
            {
                LleState.LleKirk.Transfer(direction, size, (DmaEnum)address, ref value);
                return;
            }
            else
            {
                Console.WriteLine("Unprocessed LLEState.Memory:{0}", LleState.Memory.MountedPreIpl);
                //Thread.Sleep(100);
            }
        }
示例#4
0
 public void Transfer(Dma.Direction Direction, int Size, DmaEnum Address, ref uint Value)
 {
 }
 public void Transfer(Dma.Direction direction, int size, DmaEnum address, ref uint value)
 {
 }
示例#6
0
        public void Transfer(Dma.Direction direction, int size, DmaEnum address, ref uint value)
        {
            switch (address)
            {
            case DmaEnum.KIRK_PATTERN:
                value = 1;
                break;

            case DmaEnum.KIRK_COMMAND:
                TransferUtils.Transfer(direction, ref _kirkCommand, ref value);
                break;

            case DmaEnum.KIRK_RESULT:
                TransferUtils.Transfer(direction, ref _kirkResult, ref value);
                break;

            case DmaEnum.KIRK_SOURCE_ADDRESS:
                TransferUtils.Transfer(direction, ref _kirkSource, ref value);
                break;

            case DmaEnum.KIRK_DESTINATION_ADDRESS:
                TransferUtils.Transfer(direction, ref _kirkDestination, ref value);
                break;

            case DmaEnum.KIRK_START:
                if (_kirkCommand != 1)
                {
                    throw new NotImplementedException();
                }

                var sourcePtr      = (byte *)Memory.PspAddressToPointerSafe(_kirkSource);
                var destinationPtr = (byte *)Memory.PspAddressToPointerSafe(_kirkDestination);

                //var Out = new byte[10000];

                //fixed (byte* OutPtr = Out)
                {
                    //DestinationPtr = OutPtr;
                    Console.WriteLine("Input:");
                    ArrayUtils.HexDump(PointerUtils.PointerToByteArray(sourcePtr, 0x200));

                    /*
                     * try
                     * {
                     *  Kirk.kirk_CMD1(DestinationPtr, SourcePtr, -1, true);
                     *  this.KirkResult = (uint)Kirk.ResultEnum.OK;
                     * }
                     * catch (Kirk.KirkException KirkException)
                     * {
                     *  this.KirkResult = (uint)KirkException.Result;
                     *  Console.Error.WriteLine("Kirk.KirkException : {0}", KirkException);
                     * }
                     */

                    this._kirkResult = (uint)Kirk.SceUtilsBufferCopyWithRange(destinationPtr, -1, sourcePtr, -1, 1);

                    Console.WriteLine("Output:");
                    ArrayUtils.HexDump(PointerUtils.PointerToByteArray(destinationPtr, 0x200));
                    Console.WriteLine("LOADADDR:{0:X8}", ((uint *)destinationPtr)[0]);
                    Console.WriteLine("BLOCKSIZE:{0:X8}", ((uint *)destinationPtr)[1]);
                    Console.WriteLine("ENTRY:{0:X8}", ((uint *)destinationPtr)[2]);
                    Console.WriteLine("CHECKSUM:{0:X8}", ((uint *)destinationPtr)[3]);
                }

                //Thread.Sleep(4);
                break;
            }
        }
示例#7
0
        public void Transfer(Dma.Direction direction, int size, DmaEnum address, ref uint value)
        {
            // Reading sector
            if (address >= DmaEnum.NAND__DATA_PAGE_START && address < DmaEnum.NAND__DATA_PAGE_END)
            {
                var offset = (int)(address - DmaEnum.NAND__DATA_PAGE_START);
                //Console.WriteLine("{0:X8}", (uint)Address);
                //Console.WriteLine("Transfer {0} / {1} [{2}]", Offset, Size, NandBlock.Length);
                TransferUtils.TransferToArray(direction, NandBlock, offset, size, ref value);
                return;
            }

            if (address >= DmaEnum.NAND__DATA_SPARE_BUF0_REG && address < DmaEnum.NAND__DATA_EXTRA_END)
            {
                var offset = (int)(address - DmaEnum.NAND__DATA_SPARE_BUF0_REG);
                TransferUtils.TransferToArray(direction, NandBlock, 512 + offset + 4, size, ref value);
                return;
            }

            switch (address)
            {
            case DmaEnum.NAND__CONTROL:
                TransferUtils.Transfer(direction, ref _controlRegister, ref value);
                break;

            case DmaEnum.NAND__STATUS:
                TransferUtils.Transfer(direction, ref _status, ref value);
                //Thread.Sleep(200);
                break;

            case DmaEnum.NAND__COMMAND:
                TransferUtils.Transfer(direction, ref _command, ref value);

                // Reset
                if (direction == Dma.Direction.Write)
                {
                    switch ((EnumCommands)value)
                    {
                    case EnumCommands.Reset:
                        _status = EnumStatus.Ready;
                        break;
                    }
                }
                break;

            case DmaEnum.NAND__ADDRESS:
                TransferUtils.Transfer(direction, ref address, ref value);
                break;

            case DmaEnum.NAND__RESET:
                if (direction == Dma.Direction.Write)
                {
                    Reset();
                }
                break;

            case DmaEnum.NAND__DMA_ADDRESS:
                TransferUtils.Transfer(direction, ref _dmaAddress, ref value);
                break;

            case DmaEnum.NAND__DMA_CONTROL:
                if (direction == Dma.Direction.Write)
                {
                    if (value == 0x301)
                    {
                        //0x20000/2/512*(512+16)
                        NandStream.Position = _dmaAddress / 2 / 512 * (512 + 16);
                        NandBlock           = NandStream.ReadBytes(512 + 16);
                        Console.WriteLine("Read from NAND: 0x{0:X8}", _dmaAddress);
                        ArrayUtils.HexDump(NandBlock);

                        //Thread.Sleep(TimeSpan.FromSeconds(0.5));
                        //Thread.Sleep(-1);
                    }
                }
                else
                {
                    value = 0;
                }
                break;

            case DmaEnum.NAND__DMA_ERROR:
                value = 0;
                break;
            }
        }
示例#8
0
        public void Transfer(Dma.Direction Direction, int Size, DmaEnum Address, ref uint Value)
        {
            // Reading sector
            if ((Address >= DmaEnum.NAND__DATA_PAGE_START) && (Address < DmaEnum.NAND__DATA_PAGE_END))
            {
                var Offset = (int)(Address - DmaEnum.NAND__DATA_PAGE_START);
                //Console.WriteLine("{0:X8}", (uint)Address);
                //Console.WriteLine("Transfer {0} / {1} [{2}]", Offset, Size, NandBlock.Length);
                TransferUtils.TransferToArray(Direction, NandBlock, Offset, Size, ref Value);
                return;
            }

            if ((Address >= DmaEnum.NAND__DATA_SPARE_BUF0_REG) && (Address < DmaEnum.NAND__DATA_EXTRA_END))
            {
                var Offset = (int)(Address - DmaEnum.NAND__DATA_SPARE_BUF0_REG);
                TransferUtils.TransferToArray(Direction, NandBlock, 512 + Offset + 4, Size, ref Value);
                return;
            }

            switch (Address)
            {
                case DmaEnum.NAND__CONTROL: TransferUtils.Transfer(Direction, ref ControlRegister, ref Value); break;
                case DmaEnum.NAND__STATUS:
                    TransferUtils.Transfer(Direction, ref Status, ref Value);
                    //Thread.Sleep(200);
                    break;
                case DmaEnum.NAND__COMMAND:
                    TransferUtils.Transfer(Direction, ref Command, ref Value);

                    // Reset
                    if (Direction == Dma.Direction.Write)
                    {
                        switch ((EnumCommands)Value)
                        {
                            case EnumCommands.Reset:
                                Status = EnumStatus.Ready;
                                break;
                        }
                    }
                break;
                case DmaEnum.NAND__ADDRESS: TransferUtils.Transfer(Direction, ref Address, ref Value); break;
                case DmaEnum.NAND__RESET:
                    if (Direction == Dma.Direction.Write)
                    {
                        Reset();
                    }
                break;
                case DmaEnum.NAND__DMA_ADDRESS: TransferUtils.Transfer(Direction, ref DmaAddress, ref Value); break;
                case DmaEnum.NAND__DMA_CONTROL:
                    if (Direction == Dma.Direction.Write)
                    {
                        if (Value == 0x301)
                        {
                            //0x20000/2/512*(512+16)
                            NandStream.Position = ((DmaAddress / 2 / 512) * (512 + 16));
                            NandBlock = NandStream.ReadBytes(512 + 16);
                            Console.WriteLine("Read from NAND: 0x{0:X8}", DmaAddress);
                            ArrayUtils.HexDump(NandBlock);

                            //Thread.Sleep(TimeSpan.FromSeconds(0.5));
                            //Thread.Sleep(-1);
                        }
                    }
                    else
                    {
                        Value = 0;
                    }
                    break;
                case DmaEnum.NAND__DMA_ERROR:
                    Value = 0;
                    break;
            }
        }