示例#1
0
        /// <summary>
        /// Returns the current value of the input status 1 register.
        /// </summary>
        /// <returns>Current value of the input status 1 register.</returns>
        private static byte GetInputStatus1Value()
        {
            uint value = InterruptTimer.IsInRealtimeInterval(VerticalBlankingTime, RefreshRate) ? 0x09u : 0x00u;

            if (InterruptTimer.IsInRealtimeInterval(HorizontalBlankingTime, HorizontalPeriod))
            {
                value |= 0x01u;
            }

            return((byte)value);
        }
示例#2
0
 public override void Close()
 {
     if (@out != null)
     {
         try
         {
             if (outNeedsEnd)
             {
                 outNeedsEnd = false;
                 pckOut.End();
             }
             @out.Close();
         }
         catch (IOException)
         {
         }
         finally
         {
             // Ignore any close errors.
             @out   = null;
             pckOut = null;
         }
     }
     if (@in != null)
     {
         try
         {
             @in.Close();
         }
         catch (IOException)
         {
         }
         finally
         {
             // Ignore any close errors.
             @in   = null;
             pckIn = null;
         }
     }
     if (myTimer != null)
     {
         try
         {
             myTimer.Terminate();
         }
         finally
         {
             myTimer    = null;
             timeoutIn  = null;
             timeoutOut = null;
         }
     }
 }
示例#3
0
        public VirtualMachine(int physicalMemorySize)
        {
            if (physicalMemorySize < 1 || physicalMemorySize > 2048)
            {
                throw new ArgumentOutOfRangeException(nameof(physicalMemorySize));
            }

            lock (globalInitLock)
            {
                if (!instructionSetInitialized)
                {
                    InstructionSet.Initialize();
                    instructionSetInitialized = true;
                }
            }

            this.PhysicalMemory       = new PhysicalMemory(physicalMemorySize * 1024 * 1024);
            this.Keyboard             = new Keyboard.KeyboardDevice();
            this.ConsoleIn            = new ConsoleInStream(this.Keyboard);
            this.Video                = new Video.VideoHandler(this);
            this.ConsoleOut           = new ConsoleOutStream(this.Video.TextConsole);
            this.Dos                  = new Dos.DosHandler(this);
            this.Mouse                = new Mouse.MouseHandler();
            this.InterruptTimer       = new InterruptTimer();
            this.emm                  = new ExpandedMemoryManager();
            this.xmm                  = new ExtendedMemoryManager();
            this.DmaController        = new DmaController(this);
            this.Console              = new VirtualConsole(this);
            this.multiplexHandler     = new MultiplexInterruptHandler();
            this.PhysicalMemory.Video = this.Video;

            this.Dos.InitializationComplete();

            RegisterVirtualDevice(this.Dos);
            RegisterVirtualDevice(this.Video);
            RegisterVirtualDevice(this.Keyboard);
            RegisterVirtualDevice(this.Mouse);
            RegisterVirtualDevice(new RealTimeClockHandler());
            RegisterVirtualDevice(new ErrorHandler());
            RegisterVirtualDevice(this.InterruptController);
            RegisterVirtualDevice(this.InterruptTimer);
            RegisterVirtualDevice(this.emm);
            RegisterVirtualDevice(this.DmaController);
            RegisterVirtualDevice(this.multiplexHandler);
            RegisterVirtualDevice(new BiosServices.SystemServices());
            RegisterVirtualDevice(this.xmm);
            RegisterVirtualDevice(new Dos.CD.Mscdex());
            RegisterVirtualDevice(new LowLevelDisk.LowLevelDiskInterface());

            this.PhysicalMemory.AddTimerInterruptHandler();
        }
示例#4
0
        /// <summary>Configure this connection with the directional pipes.</summary>
        /// <remarks>Configure this connection with the directional pipes.</remarks>
        /// <param name="myIn">
        /// input stream to receive data from the peer. Caller must ensure
        /// the input is buffered, otherwise read performance may suffer.
        /// </param>
        /// <param name="myOut">
        /// output stream to transmit data to the peer. Caller must ensure
        /// the output is buffered, otherwise write performance may
        /// suffer.
        /// </param>
        protected internal void Init(InputStream myIn, OutputStream myOut)
        {
            int timeout = transport.GetTimeout();

            if (timeout > 0)
            {
                Sharpen.Thread caller = Sharpen.Thread.CurrentThread();
                myTimer    = new InterruptTimer(caller.GetName() + "-Timer");
                timeoutIn  = new TimeoutInputStream(myIn, myTimer);
                timeoutOut = new TimeoutOutputStream(myOut, myTimer);
                timeoutIn.SetTimeout(timeout * 1000);
                timeoutOut.SetTimeout(timeout * 1000);
                myIn  = timeoutIn;
                myOut = timeoutOut;
            }
            @in         = myIn;
            @out        = myOut;
            pckIn       = new PacketLineIn(@in);
            pckOut      = new PacketLineOut(@out);
            outNeedsEnd = true;
        }
示例#5
0
 /// <summary>Execute the upload task on the socket.</summary>
 /// <remarks>Execute the upload task on the socket.</remarks>
 /// <param name="input">
 /// raw input to read client commands from. Caller must ensure the
 /// input is buffered, otherwise read performance may suffer.
 /// </param>
 /// <param name="output">
 /// response back to the Git network client, to write the pack
 /// data onto. Caller must ensure the output is buffered,
 /// otherwise write performance may suffer.
 /// </param>
 /// <param name="messages">
 /// secondary "notice" channel to send additional messages out
 /// through. When run over SSH this should be tied back to the
 /// standard error channel of the command execution. For most
 /// other network connections this should be null.
 /// </param>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 public virtual void Upload(InputStream input, OutputStream output, OutputStream messages
                            )
 {
     try
     {
         rawIn  = input;
         rawOut = output;
         if (timeout > 0)
         {
             Sharpen.Thread caller = Sharpen.Thread.CurrentThread();
             timer = new InterruptTimer(caller.GetName() + "-Timer");
             TimeoutInputStream  i = new TimeoutInputStream(rawIn, timer);
             TimeoutOutputStream o = new TimeoutOutputStream(rawOut, timer);
             i.SetTimeout(timeout * 1000);
             o.SetTimeout(timeout * 1000);
             rawIn  = i;
             rawOut = o;
         }
         pckIn  = new PacketLineIn(rawIn);
         pckOut = new PacketLineOut(rawOut);
         Service();
     }
     finally
     {
         walk.Release();
         if (timer != null)
         {
             try
             {
                 timer.Terminate();
             }
             finally
             {
                 timer = null;
             }
         }
     }
 }