linux - PCIe Driver - How does user space access it? -


i writing pcie driver linux, without dma, , need know how read , write pcie device once enabled user space.

in driver basics in probe():

pci_enable_device(); pci_request_regions(); pci_iomap(); 

but how access memory user space read , write? add file operations pcie driver? memory pci_iomap show place user space code can call:

open('mapped memory location'); mmap(...); 

if location?

note: pcie device not plugging linux subsystems such audio, ethernet, etc.

you can register devices using functions register_chrdev , device_create. consider kernel source /dev/null , /dev/mem:

static int __init chr_dev_init(void) {     int minor;      if (register_chrdev(mem_major, "mem", &memory_fops))         printk("unable major %d memory devs\n", mem_major);      mem_class = class_create(this_module, "mem");     if (is_err(mem_class))         return ptr_err(mem_class);      mem_class->devnode = mem_devnode;     (minor = 1; minor < array_size(devlist); minor++) {         if (!devlist[minor].name)             continue;          /*          * create /dev/port?          */         if ((minor == devport_minor) && !arch_has_dev_port())             continue;          device_create(mem_class, null, mkdev(mem_major, minor),                   null, devlist[minor].name);     }      return tty_init(); }  fs_initcall(chr_dev_init); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -