pci-bus

How do cdev and its associated file operation work?

橙三吉。 提交于 2019-12-08 03:07:26
Actually working on a PCI driver. I have two PCIe cards with same device ID and vendor ID. So to make a difference, I assign these two cards with two different MINOR numbers. //request for device numbers error = alloc_chrdev_region(&devt, 0, cards_found, DEVICE_NAME); if (error == 0) { major = MAJOR(devt); printk(KERN_INFO "(drv_init): MAJOR number is %d\n", major); printk(KERN_INFO "(drv_init): MINOR number range from 0 to %d\n", cards_found-1); cdevs = cdev_alloc(); cdevs->owner = THIS_MODULE; cdev_init(cdevs, fops); for(i=0;i<cards_found,i++) { devt = MKDEV(major, i); error = cdev_add(cdevs

Retrieving PCI coordinates by Windows' API (user mode)

微笑、不失礼 提交于 2019-12-07 05:28:37
问题 Is there a way to obtain PCI coordinates (bus/slot/function numbers) of devices by using Windows c/c++ API (e.g PnP Configuration Manager API)? I already know how to do it in kernel mode, I need an user-mode solution. My target system is Windows XP-32 bit. 回答1: I've eventually found a simple solution (it was just a matter of digging into MSDN). This minimal code finds the device's PCI coordinates in terms of bus/slot/function: DWORD bus, addr, slot, func; HDEVINFO h; // Obtained by

Proper way to access registers in a PCI configuration space

时间秒杀一切 提交于 2019-12-06 06:22:37
问题 When you need to access registers in the PCI configuration space, do you simply need to used built-in BIOS functions to read/write DWORDs into the configuration space? For example, if I am trying to use an IDE controller that is on B0:D31:F1 do I proceed to read/write the configuration register using that BDF as the parameters to the BIOS functions? So if I wanted to get the vendor id I would read the first DWORD in a given BDF? Or am I just way off base? EDIT: In the PCI BIOS specification,

Determine what (if any) PCI devices are plugged into motherboard PCI(e) slots

扶醉桌前 提交于 2019-12-06 02:22:58
I am writing a program in C# to perform a hardware audit across many Windows XP workstations. I need to determine which PCI devices are actual cards connected via a motherboard slot - NOT onboard devices that also use the PCI buses (built into the motherboard). I can successfully list all devices that use all the PCI buses using a variety of WMI classes, but none provide any indication of what is onboard vs. what is connected via a slot. I am not fussy about how the information is retrieved or from where it sourced (e.g. Pinvoke, WMI, registry, etc) as long as it's reliable. Thank you! After

Retrieving PCI coordinates by Windows' API (user mode)

≯℡__Kan透↙ 提交于 2019-12-05 10:41:45
Is there a way to obtain PCI coordinates (bus/slot/function numbers) of devices by using Windows c/c++ API (e.g PnP Configuration Manager API)? I already know how to do it in kernel mode, I need an user-mode solution. My target system is Windows XP-32 bit. I've eventually found a simple solution (it was just a matter of digging into MSDN). This minimal code finds the device's PCI coordinates in terms of bus/slot/function: DWORD bus, addr, slot, func; HDEVINFO h; // Obtained by SetupDiGetClassDevs SP_DEVINFO_DATA d; // Filled by SetupDiGetDeviceInterfaceDetail SetupDiGetDeviceRegistryProperty(h

Proper way to access registers in a PCI configuration space

冷暖自知 提交于 2019-12-04 15:03:40
When you need to access registers in the PCI configuration space, do you simply need to used built-in BIOS functions to read/write DWORDs into the configuration space? For example, if I am trying to use an IDE controller that is on B0:D31:F1 do I proceed to read/write the configuration register using that BDF as the parameters to the BIOS functions? So if I wanted to get the vendor id I would read the first DWORD in a given BDF? Or am I just way off base? EDIT: In the PCI BIOS specification, I have been looking over the definitions of the BIOS functions for reading and writing words into the

C++ app to talk to an FPGA over PCI in userland using mmap

扶醉桌前 提交于 2019-12-04 10:45:24
First off i'm new to Linux programming so apologies if this makes no sense or I'm barking up the wrong tree, point me in the correct direction. I'm trying to write a cpp app to talk to a FPGA over a pci bus, in userland. The code I have written so far, enumerates over the directories in /sys/bus/pci/devices checking the device and vendor files to locate the correct one. Once I've found the device I know that the mapped regions I need to write to are somehow represented by resource[n] files, but i'm not sure how to use them to read/write some values. From the code written for another OS I know