Exemplo n.º 1
0
        /// <summary>
        /// Handle writing a value to a socket device of a specified type.
        /// </summary>
        /// <param name="aAddr">The socket device address.</param>
        /// <param name="aValue">
        /// The value to be written to the socket device.
        /// </param>
        /// <param name="aVm">
        /// The virtual machine instance in which the interrupt
        /// should be handled.
        /// </param>
        public static void Write(SocketAddresses aAddr,
                                 int aValue,
                                 VirtualMachine aVm)
        {
            if (!WriteSockets.TryGetValue(aAddr, out var device))
            {
                throw new Exception($"Write: unmapped socket address 0x{aAddr:X}.");
            }

            device.HandleWrite(aAddr, aValue, aVm);
        }
Exemplo n.º 2
0
        public void HandleRead(SocketAddresses aAddr,
                               Registers aReg,
                               VirtualMachine aVm,
                               SecurityContext aContext)
        {
            var result = aAddr switch
            {
                SocketAddresses.ConsoleData => Console.Read(),
                _ => 0
            };

            aVm.Cpu.Registers[(aReg, aContext)] = result;
Exemplo n.º 3
0
        /// <summary>
        /// Handle reading the value from a socket device of a
        /// specified type into a register.
        /// </summary>
        /// <param name="aAddr">The socket device address.</param>
        /// <param name="aReg">
        /// The register into which the value read from the device
        /// should be placed.
        /// </param>
        /// <param name="aVm">
        /// The virtual machine instance in which the interrupt
        /// should be handled.
        /// </param>
        /// <param name="aContext">
        /// The security context to be used when writing this
        /// value into the register.
        /// </param>
        public static void Read(SocketAddresses aAddr,
                                Registers aReg,
                                VirtualMachine aVm,
                                SecurityContext aContext)
        {
            if (!ReadSockets.TryGetValue(aAddr, out var device))
            {
                throw new Exception($"Read: unmapped socket address 0x{aAddr:X}.");
            }

            device.HandleRead(aAddr, aReg, aVm, aContext);
        }
Exemplo n.º 4
0
 public SocketAttribute(SocketAddresses aDeviceSocketAddr,
                        SocketAccess aAccess)
 {
     SocketAddress = aDeviceSocketAddr;
     Access        = aAccess;
 }