Example #1
0
        public static void CheckDeviceForHCI(PCIDeviceNormal aDevice)
        {
            //0x0C = Serial bus controllers
            if (aDevice.ClassCode == 0x0C)
            {
                //0x03 = USB controllers
                if (aDevice.Subclass == 0x03)
                {
                    //xHCI = 0x30
                    if (aDevice.ProgIF == 0x30)
                    {
                        //xHCI detected
#if USB_TRACE
                                        BasicConsole.WriteLine("xHCI detected.");
#endif

                        //TODO - Add xHCI support
                        //Supported by VMWare
                        //  - This is USB 3.0

                        if (!aDevice.Claimed)
                        {
                            NumxHCIDevices++;
                        }
#if USB_TRACE
                            else
                            {
                                BasicConsole.WriteLine(" - Already claimed.");
                            }

                            BasicConsole.DelayOutput(10);
#endif
                    }
                    //EHCI = 0x20
                    else if (aDevice.ProgIF == 0x20)
                    {
                        //EHCI detected
#if USB_TRACE
                            BasicConsole.WriteLine("EHCI detected.");
#endif
                        if (!aDevice.Claimed)
                        {
                            NumEHCIDevices++;

                            PCIDeviceNormal EHCI_PCIDevice = (PCIDeviceNormal)aDevice;
                            EHCI_PCIDevice.Claimed = true;

                            EHCI newEHCI = new EHCI(EHCI_PCIDevice);
                            HCIDevices.Add(newEHCI);
                            DeviceManager.AddDevice(newEHCI);
                        }
#if USB_TRACE
                            else
                            {
                                BasicConsole.WriteLine(" - Already claimed.");
                            }

                            BasicConsole.DelayOutput(10);
#endif
                    }
                    //UHCI = 0x00
                    else if (aDevice.ProgIF == 0x00)
                    {
                        //UHCI detected
#if USB_TRACE
                            BasicConsole.WriteLine("UHCI detected.");
#endif
                        if (!aDevice.Claimed)
                        {
                            NumUHCIDevices++;

                            PCIDeviceNormal UHCI_PCIDevice = (PCIDeviceNormal)aDevice;
                            UHCI_PCIDevice.Claimed = true;

                            UHCI newUHCI = new UHCI(UHCI_PCIDevice);

                            HCIDevices.Add(newUHCI);
                            DeviceManager.AddDevice(newUHCI);
                        }
#if USB_TRACE
                            else
                            {
                                BasicConsole.WriteLine(" - Already claimed.");
                            }

                            BasicConsole.DelayOutput(10);
#endif
                    }
                    //OHCI = 0x10
                    else if (aDevice.ProgIF == 0x10)
                    {
                        //OHCI detected
#if USB_TRACE
                                        BasicConsole.WriteLine("OHCI detected.");
#endif

                        //TODO - Add OHCI support
                        //Not supported by VMWare or my laptop 
                        //  so we aren't going to program this any further for now.

                        if (!aDevice.Claimed)
                        {
                            NumOHCIDevices++;
                        }
#if USB_TRACE
                            else
                            {
                                BasicConsole.WriteLine(" - Already claimed.");
                            }

                            BasicConsole.DelayOutput(10);
#endif
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Initialises USB management. Scans the PCI bus for HCIs and initialises any supported HCIs that are found.
        /// </summary>
        public static void Init()
        {
            //Enumerate PCI devices looking for (unclaimed) USB host controllers

            //      UHCI:  Class ID: 0x0C, Sub-class: 0x03, Prog(ramming) Interface: 0x00
            //      OHCI:  Class ID: 0x0C, Sub-class: 0x03, Prog(ramming) Interface: 0x10
            //      EHCI:  Class ID: 0x0C, Sub-class: 0x03, Prog(ramming) Interface: 0x20
            //      xHCI:  Class ID: 0x0C, Sub-class: 0x03, Prog(ramming) Interface: 0x30

            if (IgnoreUSB10and11Devices)
            {
                BasicConsole.SetTextColour(BasicConsole.warning_colour);
                BasicConsole.WriteLine("USB driver will ignore USB 1.0 and 1.1 mode devices (Low and full-speed devices).");
                BasicConsole.SetTextColour(BasicConsole.default_colour);
            }

            for (int i = 0; i < PCI.PCI.Devices.Count; i++)
            {
                PCIDevice aDevice = (PCIDevice)(PCI.PCI.Devices[i]);
                //0x0C = Serial bus controllers
                if (aDevice.ClassCode == 0x0C)
                {
                    //0x03 = USB controllers
                    if (aDevice.Subclass == 0x03)
                    {
                        //xHCI = 0x30
                        if (aDevice.ProgIF == 0x30)
                        {
                            //xHCI detected
#if USB_TRACE
                                        BasicConsole.WriteLine("xHCI detected.");
#endif

                            //TODO - Add xHCI support
                            //Supported by VMWare
                            //  - This is USB 3.0

                            if (!aDevice.Claimed)
                            {
                                NumxHCIDevices++;
                            }
#if USB_TRACE
                            else
                            {
                                BasicConsole.WriteLine(" - Already claimed.");
                            }

                            BasicConsole.DelayOutput(10);
#endif
                        }
                    }
                }
            }
            for (int i = 0; i < PCI.PCI.Devices.Count; i++)
            {
                PCIDevice aDevice = (PCIDevice)(PCI.PCI.Devices[i]);
                //0x0C = Serial bus controllers
                if (aDevice.ClassCode == 0x0C)
                {
                    //0x03 = USB controllers
                    if (aDevice.Subclass == 0x03)
                    {
                        //EHCI = 0x20
                        if (aDevice.ProgIF == 0x20)
                        {
                            //EHCI detected
#if USB_TRACE
                            BasicConsole.WriteLine("EHCI detected.");
#endif
                            if (!aDevice.Claimed)
                            {
                                NumEHCIDevices++;

                                PCIDeviceNormal EHCI_PCIDevice = (PCIDeviceNormal)aDevice;
                                EHCI_PCIDevice.Claimed = true;

                                //BasicConsole.SetTextColour(BasicConsole.warning_colour);
                                //BasicConsole.WriteLine("WARNING! EHCI device support disabled.");
                                //BasicConsole.SetTextColour(BasicConsole.default_colour);
                                EHCI newEHCI = new EHCI(EHCI_PCIDevice);
                                HCIDevices.Add(newEHCI);
                                DeviceManager.AddDevice(newEHCI);
                            }
#if USB_TRACE
                            else
                            {
                                BasicConsole.WriteLine(" - Already claimed.");
                            }

                            BasicConsole.DelayOutput(10);
#endif
                        }
                    }
                }
            }
            for (int i = 0; i < PCI.PCI.Devices.Count; i++)
            {
                PCIDevice aDevice = (PCIDevice)(PCI.PCI.Devices[i]);
                //0x0C = Serial bus controllers
                if (aDevice.ClassCode == 0x0C)
                {
                    //0x03 = USB controllers
                    if (aDevice.Subclass == 0x03)
                    {
                        //UHCI = 0x00
                        if (aDevice.ProgIF == 0x00)
                        {
                            //UHCI detected
#if USB_TRACE
                            BasicConsole.WriteLine("UHCI detected.");
#endif
                            if (!aDevice.Claimed)
                            {
                                NumUHCIDevices++;

                                PCIDeviceNormal UHCI_PCIDevice = (PCIDeviceNormal)aDevice;
                                UHCI_PCIDevice.Claimed = true;

                                UHCI newUHCI = new UHCI(UHCI_PCIDevice);

                                HCIDevices.Add(newUHCI);
                                DeviceManager.AddDevice(newUHCI);
                            }
#if USB_TRACE
                            else
                            {
                                BasicConsole.WriteLine(" - Already claimed.");
                            }

                            BasicConsole.DelayOutput(10);
#endif
                        }
                        //OHCI = 0x10
                        else if (aDevice.ProgIF == 0x10)
                        {
                            //OHCI detected
#if USB_TRACE
                                        BasicConsole.WriteLine("OHCI detected.");
#endif

                            //TODO - Add OHCI support
                            //Not supported by VMWare or my laptop 
                            //  so we aren't going to program this any further for now.

                            if (!aDevice.Claimed)
                            {
                                NumOHCIDevices++;
                            }
#if USB_TRACE
                            else
                            {
                                BasicConsole.WriteLine(" - Already claimed.");
                            }

                            BasicConsole.DelayOutput(10);
#endif
                        }
                    }
                }
            }
        }