示例#1
0
        public void AttachDevice(IUSBPeripheral device, byte port)
        {
            if (device.GetSpeed() == USBDeviceSpeed.High)
            {
                ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection | (uint)PortStatus.PortHighSpeed;
            }
            else
            if (device.GetSpeed() == USBDeviceSpeed.Low)
            {
                ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection | (uint)PortStatus.PortLowSpeed;
            }
            else
            {
                ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection;
            }

            registeredDevices.Add(port, device);

            changed = true;
            /* Connect device to controller and send interrupt*/
            var connected = Connected;

            if (connected != null)
            {
                connected(DeviceAddress);
            }
        }
        public PortStatusAndControlRegisterChanges Attach(IUSBPeripheral portDevice)
        {
            uint oldPortValue = portValue;

            portValue |= CurrentConnectStatus | PortEnabledDisabled | PortEnabledDisabledChange | ConnectStatusChange;
            device     = portDevice;
            attached   = true;
            return(checkChanges(oldPortValue, portValue));
        }
 public PortStatusAndControlRegisterChanges Attach(IUSBPeripheral portDevice)
 {
     uint oldPortValue = portValue;
     portValue |= CurrentConnectStatus | PortEnabledDisabled | PortEnabledDisabledChange | ConnectStatusChange;
     device = portDevice;
     attached = true;
     return checkChanges(oldPortValue, portValue);
 }
示例#4
0
        public void ProcessClassSet(USBPacket packet, USBSetupPacket setupPacket)
        {
            //MessageRecipient recipient = (MessageRecipient)(setupPacket.requestType & 0x3);
            ushort index   = setupPacket.index;
            byte   request = setupPacket.request;
            ushort value   = setupPacket.value;

            switch ((HUBRequestCode)request)
            {
            case HUBRequestCode.ClearHubFeature:
                if (index > 0)
                {
                    switch ((PortFeature)value)
                    {
                    case PortFeature.CPortSuspend:
                        ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortSuspend)));
                        break;

                    case PortFeature.CPortOverCurrent:
                        ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortOverCurrent)));
                        break;

                    case PortFeature.CPortEnable:
                        ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortEnable)));
                        break;

                    case PortFeature.PortEnable:
                        ports[index - 1] = (uint)(ports[index - 1] & (uint)PortStatus.PortEnable);
                        break;

                    case PortFeature.PortSuspend:
                        ports[index - 1] = (uint)(ports[index - 1] & (uint)PortStatus.PortSuspend);
                        break;

                    case PortFeature.CPortConnection:
                        ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortConnection)));
                        break;

                    case PortFeature.CPortReset:
                        ActiveDevice(this.GetDevice((byte)(index)));
                        ports[index - 1] = (uint)(ports[index - 1] & (~((uint)PortStatus.CPortReset)));
                        break;

                    default:
                        this.Log(LogLevel.Warning, "Unsupported ClearHubFeature request!!!");
                        break;
                    }
                }
                break;

            case HUBRequestCode.SetHubFeature:
                if (index > 0)
                {
                    if ((PortFeature)value == PortFeature.PortReset)
                    {
                        IUSBPeripheral device = GetDevice((byte)(index));
                        ports[index - 1] |= (uint)PortStatus.CPortReset;
                        ports[index - 1] |= (uint)PortStatus.PortEnable;
                        if (device != null)
                        {
                            device.SetAddress(0);
                            device.Reset();
                        }
                    }
                    else if ((PortFeature)value == PortFeature.PortSuspend)
                    {
                        ports[index - 1] |= (uint)PortStatus.PortSuspend;
                    }
                }

                break;

            default:
                this.Log(LogLevel.Warning, "Unsupported HUB ProcessClassSet request!!!");
                break;
            }
        }
示例#5
0
 public void Unregister(IUSBPeripheral peripheral)
 {
     DetachDevice(registrationPoints[peripheral].Address.Value);
     machine.UnregisterAsAChildOf(this, registrationPoints[peripheral]);
     registrationPoints.Remove(peripheral);
 }
示例#6
0
 public IEnumerable <USBRegistrationPoint> GetRegistrationPoints(IUSBPeripheral peripheral)
 {
     throw new System.NotImplementedException();
 }
示例#7
0
 public void Register(IUSBPeripheral peripheral, USBRegistrationPoint registrationPoint)
 {
     AttachDevice(peripheral, registrationPoint.Address.Value);
     machine.RegisterAsAChildOf(this, peripheral, registrationPoint);
     registrationPoints.Add(peripheral, registrationPoint);
 }
示例#8
0
文件: UsbHub.cs 项目: rte-se/emul8
        public void AttachDevice(IUSBPeripheral device, byte port)
        {
            if (device.GetSpeed()==USBDeviceSpeed.High)
                ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection | (uint)PortStatus.PortHighSpeed;
            else
                if (device.GetSpeed()==USBDeviceSpeed.Low)
                    ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection | (uint)PortStatus.PortLowSpeed;
            else
                ports[port - 1] |= (uint)PortStatus.CPortConnection | (uint)PortStatus.PortConnection;

            registeredDevices.Add(port, device);

            changed = true;
            /* Connect device to controller and send interrupt*/
            var connected = Connected;
            if(connected != null)
            {
                connected(DeviceAddress);
            }
        }
示例#9
0
文件: UsbHub.cs 项目: rte-se/emul8
 public IEnumerable<USBRegistrationPoint> GetRegistrationPoints(IUSBPeripheral peripheral)
 {
     throw new System.NotImplementedException();
 }
示例#10
0
文件: UsbHub.cs 项目: rte-se/emul8
 public void Unregister(IUSBPeripheral peripheral)
 {
     DetachDevice(registrationPoints[peripheral].Address.Value);
     machine.UnregisterAsAChildOf(this, registrationPoints[peripheral]);
     registrationPoints.Remove(peripheral);
 }
示例#11
0
文件: UsbHub.cs 项目: rte-se/emul8
 public void Register(IUSBPeripheral peripheral, USBRegistrationPoint registrationPoint)
 {
     AttachDevice(peripheral, registrationPoint.Address.Value);
     machine.RegisterAsAChildOf(this, peripheral, registrationPoint);
     registrationPoints.Add(peripheral, registrationPoint);
 }