1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using System; 9 using Antmicro.Renode.Utilities; 10 11 namespace Antmicro.Renode.Peripherals.USBDeprecated 12 { 13 public class USBCommunicationClass 14 { USBCommunicationClass()15 public USBCommunicationClass () 16 { 17 //deviceDescriptor.DeviceClass = DeviceClassCode; 18 //endpointDescriptor.Type = (DescriptorType) CommunicationClassDescriptorType.Interface; 19 } 20 protected const byte DeviceClassCode = 0x02; 21 protected const byte InterfaceClassCode = 0x02; 22 protected const byte DataInterfaceClassCode = 0x0A; 23 24 25 protected enum SubclassCode : byte 26 { 27 Reserved = 0x00, 28 DirectLineControlModel = 0x01, 29 AbstractControlModel = 0x02, 30 TelephoneControlModel = 0x03, 31 MultiChannelControlModel = 0x04, 32 CAPIControlModel = 0x05, 33 EthernetNetworkingControlModel = 0x06, 34 ATMNetworkingControlModel = 0x07, 35 WirellecHandsetControlModel = 0x08, 36 DeviceManagement = 0x09, 37 MobileDirectLineModel = 0x0A, 38 OBEX = 0x0B 39 } 40 41 protected enum ProtocolCode : byte 42 { 43 NoClassSpecific = 0x00, 44 ATCommandsV250 = 0x01, 45 ATCommandsPCCA101 = 0x02, 46 ATCommandsPCCa101AnnexO = 0x03, 47 ATCommandsGSM = 0x04, 48 ATCommands3GPP = 0x05, 49 ATCommandsTIA = 0x06, 50 USBEEM = 0x07, 51 ExternalProtocol = 0xFE, 52 VendorSpecific = 0xFF 53 } 54 55 protected enum DataProtocolCode : byte 56 { 57 NoClassSpecific = 0x00, 58 NetworkTransferBlock = 0x01, 59 PhysicalInterafaceISDN = 0x30, 60 HDLC = 0x31, 61 Transparent = 0x32, 62 MenagementProtocolQ921 = 0x50, 63 DataLinkProtocolQ921 = 0x51, 64 TEIMultiplexorQ921 = 0x52, 65 DataCompressionProcedures = 0x90, 66 EuroISDN = 0x91, 67 V24RateAdaptationtoISDN = 0x92, 68 CAPICommands = 0x93, 69 HostBasedDriver = 0xFD, 70 CDCSpecification = 0xFE, 71 VendorSpecific = 0xFF 72 73 } 74 protected enum CommunicationClassDescriptorType : byte 75 { 76 Interface = 0x24, 77 Endpoint = 0x25 78 } 79 80 protected enum CommunicationClassFunctionalDescriptorsSubType : byte 81 { 82 Headerr = 0x00, 83 CallManagement = 0x01, 84 AbstractControlManagement = 0x02, 85 DirectLineManagement = 0x03, 86 TelephoneRinger = 0x04, 87 TelephoneCallAndLineReportingCapabilities = 0x05, 88 Union = 0x06, 89 CountrySelection = 0x07, 90 TelephoneOperationalModes = 0x08, 91 USBTerminal = 0x09, 92 NetworkChannelTerminal = 0x0A, 93 ProtocolUnit = 0x0B, 94 ExtentsionUnit = 0x0C, 95 MultiChannelManagement = 0x0D, 96 CAPIControlManagement = 0x0E, 97 EthernetNetworking = 0x0F, 98 ATMNetworking = 0x10, 99 WirelessHandsetControl = 0x11, 100 MobileDirectLineModel = 0x12, 101 MDLMDetail = 0x13, 102 DeviceManagementModel = 0x14, 103 OBEX = 0x15, 104 CommandSet = 0x16, 105 CommandSetDetail = 0x17, 106 TelephoneControlModel = 0x18, 107 OBEXServiceIdentifier = 0x19, 108 NCMFunctionalDescriptor = 0x1A 109 } 110 111 protected enum ClassSpecificRequestCodes : byte 112 { 113 SendEncaplsulatedCommand = 0x00, 114 GetEncapsulatedResponse = 0x01, 115 SetCommFeature = 0x02, 116 GetCommFeature = 0x03, 117 ClearCommFeature = 0x04, 118 SetAuxLIneState = 0x10, 119 SetHookState = 0x11, 120 PulseSetup = 0x12, 121 SendPulse = 0x13, 122 SetPulseTime = 0x14, 123 RingAuxJack = 0x15, 124 SetLineCoding = 0x20, 125 GetLineCoding = 0x21, 126 SetControlLineState = 0x22, 127 SendBreak = 0x23, 128 SetRingerParams = 0x30, 129 GetRingerParams = 0x31, 130 SetOperationParms = 0x32, 131 GetOperationParms = 0x33, 132 SetLineParms = 0x34, 133 GetLineParms = 0x35, 134 DialDigits = 0x36, 135 SetUnitParameter = 0x37, 136 GetUnitParameter = 0x38, 137 GetProfile = 0x3A, 138 SetEthernetMulticastFilters = 0x40, 139 SetEthernetPowerManagementPatternFilter = 0x41, 140 GetEthernetPowerManagementPatternFilter = 0x42, 141 SetEthernetPacketFilter = 0x43, 142 GetEthernetStatistic = 0x44, 143 SetAtmDataFormat = 0x50, 144 GetAtmDeviceStatistics = 0x51, 145 SetAtmDefaultVc = 0x52, 146 GetAtmVcStatistics = 0x53, 147 GetNtbParameters = 0x80, 148 GetNetAddress = 0x81, 149 SetNetAddress = 0x82, 150 GetNtbFormat = 0x83, 151 SetNtbFormat = 0x84, 152 GetNtbInputSize = 0x85, 153 SetNtbInputSize = 0x86, 154 GetMaxDatagramSize = 0x87, 155 SetMaxDatagramSize = 0x88, 156 GetCRCMode = 0x89, 157 SetCRCMode = 0x8A 158 } 159 160 protected enum ClassSpecificNotificationCodes : byte 161 { 162 NetworkConnection = 0x00, 163 ResponseAvaliable = 0x01, 164 AuxJackHookState = 0x08, 165 RingDetect = 0x09, 166 SerialState = 0x20, 167 CAllStateChange = 0x28, 168 LineStateChange = 0x29, 169 ConnectedSpeedChange = 0x2A 170 } 171 172 173 protected class HeaderFunctionalDescriptor : USBDescriptor 174 { 175 HeaderFunctionalDescriptor()176 public HeaderFunctionalDescriptor() 177 { 178 base.Length = 0x04; 179 base.Type = (DescriptorType) CommunicationClassDescriptorType.Interface; 180 } 181 public byte Subtype{get; set;} 182 public ushort bcdCDC{get; set;} 183 ToArray()184 public override byte[] ToArray () 185 { 186 187 var arr = base.ToArray (); 188 arr[0x2] = Subtype; 189 arr[0x3] = bcdCDC.LoByte(); 190 arr[0x4] = bcdCDC.HiByte(); 191 return arr; 192 } 193 } 194 195 protected class UnionFunctionalDescriptor : USBDescriptor 196 { UnionFunctionalDescriptor(byte subordinateInterfacesNumber)197 public UnionFunctionalDescriptor(byte subordinateInterfacesNumber) 198 { 199 base.Length = (byte)(subordinateInterfacesNumber + 0x04); 200 base.Type = (DescriptorType) CommunicationClassDescriptorType.Interface; 201 SubordinateInterface = new byte[subordinateInterfacesNumber]; 202 } 203 public byte Subtype{get; set;} 204 public byte ControllInterface{get; set;} 205 public byte[] SubordinateInterface{get; set;} 206 ToArray()207 public override byte[] ToArray () 208 { 209 var arr = base.ToArray (); 210 arr[0x2] = Subtype; 211 arr[0x3] = ControllInterface; 212 Array.Copy(SubordinateInterface, 0,arr, 0x4, SubordinateInterface.Length); 213 return arr; 214 215 } 216 } 217 218 protected class CountrySelectionFunctionalDescriptor : USBDescriptor 219 { 220 CountrySelectionFunctionalDescriptor(byte countryCodesNumber)221 public CountrySelectionFunctionalDescriptor(byte countryCodesNumber) 222 { 223 base.Length = (byte)(countryCodesNumber * 2 + 4); 224 base.Type = (DescriptorType) CommunicationClassDescriptorType.Interface; 225 CountryCode = new byte[countryCodesNumber]; 226 } 227 228 public byte Subtype{get; set;} 229 public byte CountryCodeReleaseDate{get; set;} 230 public byte[] CountryCode{get; set;} 231 ToArray()232 public override byte[] ToArray () 233 { 234 var arr = base.ToArray (); 235 arr[0x2] = Subtype; 236 arr[0x3] = CountryCodeReleaseDate; 237 Array.Copy(CountryCode,0,arr,0x4,CountryCode.Length); 238 return arr; 239 } 240 241 } 242 243 244 //protected ConfigurationUSBDescriptor configurationDescriptor; 245 //protected StandardUSBDescriptor deviceDescriptor; 246 //protected InterfaceUSBDescriptor interfaceDescriptor; 247 //protected EndpointUSBDescriptor endpointDescriptor; 248 //protected StringUSBDescriptor stringDesriptor; 249 250 251 } 252 } 253 254