示例#1
0
        public Cpu(IEmulationInstance emulator, ComponentParameters parameters)
        {
            Debug.Assert(emulator != null);
            Debug.Assert(parameters != null);

            _caps     = new CpuCapabilities();
            _stats    = new RuntimeStatistics();
            _emulator = emulator;
            _params   = parameters;

            _lastSyscall = -1;
            _syscalls    = new BiosFunction[1024];

#if STATS
            _timer = new PerformanceTimer();
            _timeSinceLastIpsPrint = 0.0;
#endif

            _clock  = new Clock();
            _memory = new Memory();

            // Order matters as the lookup is linear and stupid... should be changed somehow
            //_memory->DefineSegment( MemoryType::PhysicalMemory, "Main Memory", 0x08000000, 0x01FFFFFF );
            //_memory->DefineSegment( MemoryType::PhysicalMemory, "Hardware Vectors", 0x1FC00000, 0x000FFFFF );
            //_memory->DefineSegment( MemoryType::PhysicalMemory, "Scratchpad", 0x00010000, 0x00003FFF );
            //_memory->DefineSegment( MemoryType::PhysicalMemory, "Frame Buffer", 0x04000000, 0x001FFFFF );
            //_memory->DefineSegment( MemoryType::HardwareMapped, "Hardware IO 1", 0x1C000000, 0x03BFFFFF );
            //_memory->DefineSegment( MemoryType::HardwareMapped, "Hardware IO 2", 0x1FD00000, 0x002FFFFF );

            _core0 = new Core(this, 0, "Allegrex", CoreAttributes.HasCp2);
            _core1 = new Core(this, 1, "Media Engine", CoreAttributes.Default);

            _codeCache      = new CodeCache();
            _context        = new GenerationContext();
            _context.Cpu    = this;
            _context.Core0  = _core0;
            _context.Memory = _memory;

            _executionMode = ExecutionMode.Run;
            _firstExecute  = true;
        }
示例#2
0
        public CpuCapabilities GetCpuCapabilities()
        {
            CpuCapabilities caps = 0;

            // check for an AMD
            if (this.IsAMD == true)
            {
                caps = CpuCapabilities.AMD;
            }
            else
            {
                caps = CpuCapabilities.Intel;
            }

            // TODO: we can't actually make use of any of these features but it would be nice
            // to still identify them.

            // check for Multi Media Extensions

            /*if(HasMMX())
             * {
             *      flags |= CPUID_MMX;
             * }
             *
             * // check for 3DNow!
             * if(Has3DNow())
             * {
             *      flags |= CPUID_3DNOW;
             * }
             *
             * // check for Streaming SIMD Extensions
             * if(HasSSE())
             * {
             *      flags |= CPUID_SSE | CPUID_FTZ;
             * }
             *
             * // check for Streaming SIMD Extensions 2
             * if(HasSSE2())
             * {
             *      flags |= CPUID_SSE2;
             * }
             *
             * // check for Streaming SIMD Extensions 3 aka Prescott's New Instructions
             * if(HasSSE3())
             * {
             *      flags |= CPUID_SSE3;
             * }
             *
             * // check for Hyper-Threading Technology
             * if(HasHTT())
             * {
             *      flags |= CPUID_HTT;
             * }
             *
             * // check for Conditional Move (CMOV) and fast floating point comparison (FCOMI) instructions
             * if(HasCMOV())
             * {
             *      flags |= CPUID_CMOV;
             * }
             *
             * // check for Denormals-Are-Zero mode
             * if(HasDAZ())
             * {
             *      flags |= CPUID_DAZ;
             * }*/

            return(caps);
        }
示例#3
0
		public Cpu( IEmulationInstance emulator, ComponentParameters parameters )
		{
			Debug.Assert( emulator != null );
			Debug.Assert( parameters != null );

			_caps = new CpuCapabilities();
			_stats = new RuntimeStatistics();
			_emulator = emulator;
			_params = parameters;

			_lastSyscall = -1;
			_syscalls = new BiosFunction[ 1024 ];

#if STATS
			_timer = new PerformanceTimer();
			_timeSinceLastIpsPrint = 0.0;
#endif

			_clock = new Clock();
			_memory = new Memory();
			
			// Order matters as the lookup is linear and stupid... should be changed somehow
			//_memory->DefineSegment( MemoryType::PhysicalMemory, "Main Memory", 0x08000000, 0x01FFFFFF );
			//_memory->DefineSegment( MemoryType::PhysicalMemory, "Hardware Vectors", 0x1FC00000, 0x000FFFFF );
			//_memory->DefineSegment( MemoryType::PhysicalMemory, "Scratchpad", 0x00010000, 0x00003FFF );
			//_memory->DefineSegment( MemoryType::PhysicalMemory, "Frame Buffer", 0x04000000, 0x001FFFFF );
			//_memory->DefineSegment( MemoryType::HardwareMapped, "Hardware IO 1", 0x1C000000, 0x03BFFFFF );
			//_memory->DefineSegment( MemoryType::HardwareMapped, "Hardware IO 2", 0x1FD00000, 0x002FFFFF );

			_core0 = new Core( this, 0, "Allegrex", CoreAttributes.HasCp2 );
			_core1 = new Core( this, 1, "Media Engine", CoreAttributes.Default );

			_codeCache = new CodeCache();
			_context = new GenerationContext();
			_context.Cpu = this;
			_context.Core0 = _core0;
			_context.Memory = _memory;

			_executionMode = ExecutionMode.Run;
			_firstExecute = true;
		}
示例#4
0
        static int Main(string[] args)
        {
            bool dumpCoreInfo     = false;
            bool dumpCoreFeatures = false;
            bool dumpGroups       = false;
            bool dumpCaches       = false;
            bool dumpNuma         = false;
            bool dumpSockets      = false;
            bool dumpNumaCost     = false;
            bool dumpVirt         = false;

            if (args.Length == 0)
            {
                dumpCoreInfo     = true;
                dumpCoreFeatures = true;
                dumpGroups       = true;
                dumpCaches       = true;
                dumpNuma         = true;
                dumpSockets      = true;
                dumpNumaCost     = true;
            }

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "-c")
                {
                    dumpCoreInfo = true;
                }
                else if (args[i] == "-f")
                {
                    dumpCoreFeatures = true;
                }
                else if (args[i] == "-g")
                {
                    dumpGroups = true;
                }
                else if (args[i] == "-l")
                {
                    dumpCaches = true;
                }
                else if (args[i] == "-n")
                {
                    dumpNuma = true;
                }
                else if (args[i] == "-s")
                {
                    dumpSockets = true;
                }
                else if (args[i] == "-m")
                {
                    dumpNumaCost = true;
                }
                else if (args[i] == "-v")
                {
                    dumpVirt = true;
                }
                else
                {
                    Usage();
                    return(1);
                }
            }

            try
            {
                if (dumpCoreFeatures || dumpVirt)
                {
                    CpuCapabilities.Dump(null, dumpVirt);
                    Console.WriteLine();
                }

                if (dumpCoreInfo)
                {
                    Console.WriteLine("Logical to Physical Processor Map:");
                    CpuCoreInfo.Dump();
                    Console.WriteLine();
                }

                if (dumpSockets)
                {
                    Console.WriteLine("Logical Processor to Socket Map:");
                    CpuSocketInfo.Dump();
                    Console.WriteLine();
                }

                if (dumpNuma)
                {
                    Console.WriteLine("Logical Processor to NUMA Node Map:");
                    CpuNumaNodeInfo.Dump();
                    Console.WriteLine();
                }

                if (dumpNumaCost)
                {
                    if (CpuNumaNodeInfo.NumberOfNumaNodes > 1)
                    {
                        CpuNumaNodeInfo.DumpCost();
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine("No NUMA configured.");
                        Console.WriteLine();
                    }
                }

                if (dumpCaches)
                {
                    Console.WriteLine("Logical Processor to Cache Map:");
                    CpuCacheInfo.Dump();
                    Console.WriteLine();
                }

                if (dumpGroups)
                {
                    Console.WriteLine("Logical Processor to Group Map:");
                    CpuGroupInfo.Dump();
                    Console.WriteLine();
                }

                return(0);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
                return(ex.HResult);
            }
        }