Пример #1
0
 private void InterruptHendler(SimulatorEvents Interrupt, int info)
 {
     if (Interrupt == SimulatorEvents.CLOCK_INTERRUPT)
     {
         if (info == VAX11Simulator.Console.INIT_CLOCK)
         {
             InitClockInterrupt();
         }
         else if (info == VAX11Simulator.Console.ABORT_CLOCK)
         {
             AbortClockInterrupt();
         }
         else
         {
             throw new PanicException();
         }
     }
     else if (Interrupt == SimulatorEvents.POWER_DOWN_INTERRUPT)
     {
         //if we want to send event do it here.
         bConsoleClosed = true;
         BreakPointWait.Set();
         if (bInDebug && info == 1)
         {
             _theMainApplication.Invoke(new ProgramEndHandler(_theMainApplication.InterfaceDoRestartDebuggedProgram), new object[] { "Program ended because Console has been closed" });
         }
     }
     else
     {
         theSimulator.SendEvent(Interrupt, info);
     }
 }
Пример #2
0
 public SimEvent(SimulatorEvents vEvent, int vOffset, int vIPL, SimulatorEventsTypes vType)
 {
     _e            = vEvent;
     _SCBB_OFFSET  = vOffset;
     _IPL          = vIPL;
     _EventOccured = false;
     _type         = vType;
 }
Пример #3
0
        /// <summary>
        /// Get events and translate it to VAX-11 events
        /// </summary>
        /// <param name="e">The Event</param>
        /// <param name="iValue">Addition Information</param>
        public void SendEvent(SimulatorEvents e, int iValue)
        {
            // Handle all posibble events
            if (e == SimulatorEvents.CLOCK_INTERRUPT)
            {
                lock (this)
                {                // if (!HardwareInterruptsChecker[(int)SimulatorEvents.CLOCK_INTERRUPT].EventOccured)
                    {
                        if (HardwareInterruptsChecker[(int)SimulatorEvents.CLOCK_INTERRUPT].IPL < r.PSL.IPL)
                        {
                            return;
                        }
                        // ICCS = 24, ICR = 26
                        if ((r[24] & (uint)1) != 0)                                                     // Run
                        {
                            if ((uint)r[26] + (uint)Settings.Simulator.ClockResolution * 1000 > (uint)r[26])
                            {
                                r[26] += Settings.Simulator.ClockResolution * 1000;
                            }
                            else
                            {
                                r[26] = 0;
                            }
                        }
                        if ((r[24] & (uint)0x80) != 0)
                        {
                            r[24] = (uint)r[24] | (uint)0x80000000;                                             // Err bit
                        }
                        else
                        {
                            r[24] = (uint)r[24] | (uint)0x80;                                                           // Int ICR
                        }
                        if ((int)r[26] == 0)
                        {
                            HardwareInterruptsChecker[(int)SimulatorEvents.CLOCK_INTERRUPT].EventOccured = true;
                            r[26] = r[25].ReadLong();
                        }
                    }
                }
            }
            else if (e == SimulatorEvents.INPUT_INTERRUPT)
            {
                lock (this)
                {
                    r[33] = iValue;                             // RXDB
                    r[32].SetBits(7, 7, 1);                     // RXCS

                    // Strange, but if we write "(int)(SimulatorEvents.INPUT_INTERRUPT)"
                    // directly in the array [], it won't work
                    int iInputInterruptIndex = (int)(SimulatorEvents.INPUT_INTERRUPT);

                    if (HardwareInterruptsChecker[iInputInterruptIndex].IPL < r.PSL.IPL)
                    {
                        return;
                    }
                    if (r[32].GetBits(6, 6) == 1)
                    {
                        HardwareInterruptsChecker[iInputInterruptIndex].EventOccured = true;
                    }
                }
            }
            else if (e == SimulatorEvents.OUTPUT_INTERRUPT)
            {
                lock (this)
                {
                    int iOutputInterruptIndex = (int)(SimulatorEvents.OUTPUT_INTERRUPT);
                    // Strange, but if we write "(int)(SimulatorEvents.OUTPUT_INTERRUPT)"
                    // directly in the array [], it won't work
                    if (HardwareInterruptsChecker[iOutputInterruptIndex].IPL < r.PSL.IPL)
                    {
                        return;
                    }
                    if (r[34].GetBits(6, 6) == 1)                    //if the output interrupts are activate
                    {
                        r[34].SetBits(7, 7, 0);
                        //HardwareInterruptsChecker[iOutputInterruptIndex].EventOccured = true;
                        if (OutputThreadOn)
                        {
                            OutputInterruptThread.Abort();
                        }
                        OutputInterruptThread          = new Thread(new ThreadStart(OutputInterruptHandler));
                        OutputThreadOn                 = true;
                        OutputInterruptThread.Priority = ThreadPriority.AboveNormal;
                        OutputInterruptThread.Name     = "Output Interrupt Handler";
                        OutputInterruptThread.Start();
                        Console.AllThreads.Add(OutputInterruptThread);
                    }
                    else
                    {
                        if (OutputThreadOn)
                        {
                            OutputInterruptThread.Abort();
                        }
                    }
                }
            }
            else if (e == SimulatorEvents.POWER_DOWN_INTERRUPT)
            {
                //console has been close...
                if (OutputThreadOn)
                {
                    OutputInterruptThread.Abort();
                }
            }
            else if (e == SimulatorEvents.ARITHMETIC)
            {
                int iInterruptIndex = (int)SimulatorEvents.ARITHMETIC;
                if (HardwareInterruptsChecker[iInterruptIndex].IPL < r.PSL.IPL)
                {
                    return;
                }
                push(iValue, 4);                 // push the extra info that describe the arithmetic exception
                HardwareInterruptsChecker[iInterruptIndex].EventOccured = true;
            }
            else if (e == SimulatorEvents.RESERVED_OPERAND)
            {
                int iInterruptIndex = (int)SimulatorEvents.RESERVED_OPERAND;
                HardwareInterruptsChecker[iInterruptIndex].EventOccured = true;
            }
            else
            {
                throw new PanicException();
            }

            if (HardwareInterruptsChecker[(int)e].Type == SimulatorEventsTypes.FAULT)
            {
                switch (e)
                {
                case SimulatorEvents.RESERVED_OPERAND:
                    throw new RuntimeError(SimulatorMessage.RESERVED_OPERAND, r[15].ReadLong());

                default:
                    throw new RuntimeError(SimulatorMessage.GENERAL_FAULT_EXCEPTION, r[15].ReadLong());
                }
            }

            else if (HardwareInterruptsChecker[(int)e].Type == SimulatorEventsTypes.TRAP)
            {
                int iAddress = HardwareInterruptsChecker[(int)SimulatorEvents.ARITHMETIC].SCBB_OFFSET + r[17];
                if (((int)Mem.Read(iAddress, 4, false)) == 0)                 // then we need to halt, no one catch the trap
                {
                    switch (e)
                    {
                    case SimulatorEvents.ARITHMETIC:
                    {
                        switch (iValue)
                        {
                        case (int)ARITHMETIC_TRAPS.INTEGER_DIVIDE_BY_ZERO:
                            throw new RuntimeError(SimulatorMessage.DIVIDE_BY_ZERO, r[15].ReadLong());

                        case (int)ARITHMETIC_TRAPS.SUBSCRIPT_RANGE:
                            throw new RuntimeError(SimulatorMessage.SUBSCRIPT_RANGE, r[15].ReadLong());

                        default:
                            throw new RuntimeError(SimulatorMessage.ARITHMETIC_EXCEPTION, r[15].ReadLong());
                        }
                        ;
                    }

                    default:
                        throw new RuntimeError(SimulatorMessage.TRAP_NOT_HANDLED, r[15].ReadLong());
                    }
                }
            }
        }