Exemplo n.º 1
0
        public DeviceInfoClass(RTBus locpciBusDev)
        {
            byte[] byPciData     = new byte[256];
            int    nBytesWritten = locpciBusDev.Read(byPciData, 0, 256);

            PCIConfig = PCICommonConfig.FromBytes(byPciData);

            pciBusDev = locpciBusDev;
        }
Exemplo n.º 2
0
        public SearchedDevice(RTBus locpciBusDev, int BaseNumber, string locName, UInt16 Number)
        {
            myNumber = Number;
            byte[] byPciData = new byte[256];
//#if(WIN32)
            int nBytesWritten = locpciBusDev.Read(byPciData, 0, 256);

//#endif

            PCIConfig = PCICommonConfig.FromBytes(byPciData);
            ///////
//#if(x64)
//            PCIConfig.VendorID = Constants.SEARCHED_VENDOR_ID;
//            PCIConfig.DeviceID = Constants.SEARCHED_DEVICE_ID;
//            PCIConfig.BaseAddress2 = (PCIBaseAddress)45313;
//            PCIConfig.BaseAddress3 = (PCIBaseAddress)45345;
//            PCIConfig.BaseAddress4 = (PCIBaseAddress)45377;
//            PCIConfig.BaseAddress5 = (PCIBaseAddress)45409;
//#endif
            ///////
            pciBusDev = locpciBusDev;
            name      = locName;

            fullInfo = "Имя сетевой платы: " + name + "\nНомер шины: " + pciBusDev.BusNumber.ToString("X04") + "\nСлот: " + pciBusDev.Slot.ToString("X04") +
                       "\nID устройсва: " + PCIConfig.DeviceID.ToString("X04") + "\nVendorID: " + PCIConfig.VendorID.ToString("X04");
            if (BaseNumber == 2)
            {
                myBaseNumber = (UInt16)BaseAddress2;
                text         = name + ": BaseAddress2 = " + (BaseAddress2 - 1).ToString("X04");
                fullInfo    += "\nBaseAddress: " + (BaseAddress2 - 1).ToString("X04");
            }
            if (BaseNumber == 3)
            {
                myBaseNumber = (UInt16)BaseAddress3;
                text         = name + ": BaseAddress3 = " + (BaseAddress3 - 1).ToString("X04");
                fullInfo    += "\nBaseAddress: " + (BaseAddress3 - 1).ToString("X04");
            }
            if (BaseNumber == 4)
            {
                myBaseNumber = (UInt16)BaseAddress4;
                text         = name + ": BaseAddress4 = " + (BaseAddress4 - 1).ToString("X04");
                fullInfo    += "\nBaseAddress: " + (BaseAddress4 - 1).ToString("X04");
            }
            if (BaseNumber == 5)
            {
                myBaseNumber = (UInt16)BaseAddress5;
                text         = name + ": BaseAddress5 = " + (BaseAddress5 - 1).ToString("X04");
                fullInfo    += "\nBaseAddress: " + (BaseAddress5 - 1).ToString("X04");
            }
        }
Exemplo n.º 3
0
        public static List <SearchedDevice> Adapter_id_func()
        {
            int  nDeviceNumber;                                           /// Номер PCI адаптера  / PCI device number for the PCI adapter
            int  nFunctionNumber;                                         /// Номер функции адаптера  / Function number on the specified adapter
            int  nBytesWritten;                                           /// Переменная для возвращения байтового массива функцией RtGetBusDataByOffset  / Return value from RtGetBusDataByOffset
            int  nBus;                                                    /// Номер шины  / Bus number
            bool bFlag = true;                                            /// Флаг имеющий значение TRUE пока еще есть PCI шины  / TRUE as long as we have PCI busses
            //int nCardIndex = 0;   /// The index of this Interl Pro 1000 card
            int nPciSlotNum = 0;                                          /// Номер слота PCI адаптера  / Logical slot number for the PCI adapter

            byte[] byPciData = new byte[Constants.PCI_COMMON_HDR_LENGTH]; /// Байтовый массив для PCI данных  / Byte data array for the PCI data
            //int nVendorID;          /// Vendor ID из заголовка PCI  / Vendor ID from the PCI header
            //int nDeviceID;          /// Device ID из заголовка PCI  / Device ID from the PCI header
            UInt16 Counter = 0;

            GCHandle pinnedPacket = GCHandle.Alloc(byPciData, GCHandleType.Pinned);

            List <SearchedDevice> items = new List <SearchedDevice>(); //создание списка
            PCICommonConfig       locPCICommonConfig;                  //Создание "контейнера" PCI данных

            //DeviceInfoClass mDeviceInfo;
            //int myCount = 0;


//#if (WIN32)

            for (nBus = 0; bFlag; nBus++)                                                                      //Цикл для прохода по всем шинам
            {
                for (nDeviceNumber = 0; nDeviceNumber < Constants.PCI_MAX_DEVICES && bFlag; nDeviceNumber++)   //Цикл для прохода по всем PCI адаптерам
                {
                    for (nFunctionNumber = 0; nFunctionNumber < Constants.PCI_MAX_FUNCTION; nFunctionNumber++) //Цикл для прохода по всем PCI
                    {
                        nPciSlotNum = nDeviceNumber | (nFunctionNumber << 5);                                  //Номер слота PCI адаптера

                        RTBus pciBusDev = new RTBus(BusDataType.PCIConfiguration,                              //Инициализация PCI шины
                                                    nBus, nPciSlotNum,
                                                    Constants.PCI_COMMON_HDR_LENGTH
                                                    );


                        /// Read 64 bytes from PCI bus for this device
                        nBytesWritten = pciBusDev.Read(byPciData, 0, Constants.PCI_COMMON_HDR_LENGTH); // Чтение 256 байтов с PCI шины для данного устройства и зпись в массив byPciData
                        //////


                        /////
                        if (nBytesWritten == 0)
                        {
                            /// out of PCI buses
                            bFlag = false;
                            break;
                        }

                        locPCICommonConfig = PCICommonConfig.FromBytes(byPciData);  //Заполнение контейнера PCI данных из буффера



                        if (nBytesWritten == 2 && locPCICommonConfig.VendorID == Constants.PCI_INVALID_VENDORID)
                        {
                            /// No device at this slot number, skip to next slot
                            break;
                        }
                        //locPCICommonConfig.VendorID = Constants.SEARCHED_VENDOR_ID;
                        //locPCICommonConfig.DeviceID = Constants.SEARCHED_DEVICE_ID;
                        //locPCICommonConfig.SubVendorID = Constants.SEARCHED_SUB_VENDOR_ID;
                        //locPCICommonConfig.SubSystemID = Constants.SEARCHED_SUB_SYSTEM_ID;
                        //!!!!!!!!
                        if (locPCICommonConfig.VendorID == Constants.SEARCHED_VENDOR_ID && locPCICommonConfig.DeviceID == Constants.SEARCHED_DEVICE_ID && locPCICommonConfig.SubVendorID == Constants.SEARCHED_SUB_VENDOR_ID && locPCICommonConfig.SubSystemID == Constants.SEARCHED_SUB_SYSTEM_ID)
                        {
                            string name = "TA-1 PCI4-04";
                            for (int BaseNumber = 2; BaseNumber < 6; BaseNumber++)
                            {
                                pciBusDev.Seek(0, 0);
                                items.Add(new SearchedDevice(pciBusDev, BaseNumber, name, Counter)); //Добваление строки strOut в элемент списка
                                Counter++;
                            }
                            //items.Add(new DeviceInfoClass(pciBusDev));
                        }
                        else if (locPCICommonConfig.VendorID == Constants.SEARCHED_VENDOR_ID_TA1_PE2 && locPCICommonConfig.DeviceID == Constants.SEARCHED_DEVICE_ID_TA1_PE2 && locPCICommonConfig.SubVendorID == Constants.SEARCHED_SUB_VENDOR_ID_TA1_PE2 && locPCICommonConfig.SubSystemID == Constants.SEARCHED_SUB_SYSTEM_ID_TA1_PE2)
                        {
                            string name = "TA-1 PE2";
                            for (int BaseNumber = 2; BaseNumber < 4; BaseNumber++)
                            {
                                pciBusDev.Seek(0, 0);
                                items.Add(new SearchedDevice(pciBusDev, BaseNumber, name, Counter)); //Добваление строки strOut в элемент списка
                                Counter++;
                            }
                            //items.Add(new DeviceInfoClass(pciBusDev));
                        }
                    }
                }
            }


//#else
            //for (int i = 0; i < 1; i++ )
            //{
            //    RTBus pciBusDev = new RTBus(BusDataType.PCIConfiguration,  //Инициализация PCI шины
            //                i, nPciSlotNum,
            //                Constants.PCI_COMMON_HDR_LENGTH
            //                );
            //    locPCICommonConfig = PCICommonConfig.FromBytes(byPciData);  //Заполнение контейнера PCI данных из буффера
            //    locPCICommonConfig.VendorID = Constants.SEARCHED_VENDOR_ID;
            //    locPCICommonConfig.DeviceID = Constants.SEARCHED_DEVICE_ID;
            //    locPCICommonConfig.SubVendorID = Constants.SEARCHED_SUB_VENDOR_ID;
            //    locPCICommonConfig.SubSystemID = Constants.SEARCHED_SUB_SYSTEM_ID;
            //    string name = "TA-1 PCI4-04";
            //    for (int BaseNumber = 2; BaseNumber < 6; BaseNumber++)
            //    {
            //        pciBusDev.Seek(0, 0);
            //        items.Add(new SearchedDevice(pciBusDev, BaseNumber, name)); //Добваление строки strOut в элемент списка
            //    }

            //}
//#endif
            return(items); //Возвращаем сформированный список
        }