예제 #1
0
        public static void NmiIntHandler()
        {
            RemoveInterruptEvent();
            CP0_STATUS_REG = (CP0_STATUS_REG & ~0x00380000UL) | 0x00500004;
            CP0_CAUSE_REG  = 0;

            /* R4300 Software Reset */
            SoftBootManager.SetupExecutionState(BootMode.HLE_IPL);

            CP0_COUNT_REG = 0;
            /* TODO: VI Counter = 0 */
            InitInterrupt();

            /* TODO: AI Status reg */
            CP0_ERROREPC_REG = (UInt64)m_Core.State.PC;

            if (m_Core.State.BranchEnabled)
            {
                CP0_ERROREPC_REG -= 4;
            }

            m_Core.State.BranchEnabled = false;
            LastPc          = 0xA4000040;
            m_Core.State.PC = 0xA40000040;
        }
예제 #2
0
파일: Machine.cs 프로젝트: TylerCode/Soft64
        internal void Boot()
        {
            if (m_Booted)
            {
                return;
            }

            try
            {
                /* Hardware Init */
                Memory.Initialize();

                /* A/D CPU <-> RCP Bus Connection Hack */
                /* TODO: We are only use a simple IO stream to connect the CPU to physical memory */
                DeviceCPU.SysAdBus = Memory;

                DevicePIF.Initialize();
                DeviceRCP.Initialize();
                DeviceCPU.Initialize();

                logger.Info("##### Starting emulation core");
                OnMachineEventNotification(MachineEventType.PreBooted);

                logger.Debug("Executing N64 firmware: " + SystemBootMode.GetFriendlyName());
                SoftBootManager.SetupExecutionState(SystemBootMode);

                /* Initialize core comparing */
                if (Machine.Current.MipsCompareEngine != null)
                {
                    logger.Trace("Mips compare engine found");

                    try
                    {
                        Machine.Current.MipsCompareEngine.Init();
                        logger.Trace("Initialized mips compare engine");

                        Task.Factory.StartNew(
                            Machine.Current.MipsCompareEngine.Run,
                            new CancellationToken(),
                            TaskCreationOptions.LongRunning,
                            TaskScheduler.Default);

                        logger.Trace($"Scheduled mips engine task on {TaskScheduler.Default.ToString()} scheduler");

                        Thread.Sleep(500);
                    }
                    catch (Exception e)
                    {
                        logger.Error(e);
                    }
                }
                else
                {
                    logger.Trace("Skipped mips compare engine");
                }

                m_Booted = true;
                OnMachineEventNotification(MachineEventType.Booted);

                logger.Info("#### Boot sucessful");
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw new InvalidOperationException("An exception occuring during the boot process, see inner exception for details", e);
            }
        }