linux-device-driver

Registering Platform Device with info from Device Tree

流过昼夜 提交于 2019-12-25 05:05:48
问题 I am using Petalinux for a Xilinx Zynq application, and I am new to kernel driver development. I created a kernel module for a platform driver for an AXI FIFO interface. The devices seems to be recognised from the device tree using the .of_match_table, since I can see the correct memory space reserved with cat /proc/iomem . If I search for the driver name xxx I get ./lib/modules/4.4.0-xilinx/extra/xxx.ko ./sys/bus/platform/drivers/xxx ./sys/module/xxx ./sys/module/xxx/drivers/platform:xxx I

Calling a user defined function in kernel space from user space application program

岁酱吖の 提交于 2019-12-25 04:19:34
问题 I have written a user defined function in my device driver and I want to call it from user space application program. How do I achieve this? What I mean by user defined function is, any function other than the kernel defined functions. Pointers to which is defined in struct file_operations , as below. struct file_operations { struct module *owner; loff_t (*llseek) (struct file *, loff_t, int); ssize_t (*read) (struct file *, char *, size_t, loff_t *); ssize_t (*write) (struct file *, const

How Callback is maintained from Userspace to Kernel Space

做~自己de王妃 提交于 2019-12-25 01:45:28
问题 I am learning about the driver and looking into the watchdog driver code where some value is being written to /sys/devices/virtual/wdc_per now I guess this is the logic how driver gets its value from userspace and exposed file in user space is "sys/devices/virtual/wdc_per" But now how actually this value from wdc_per is reached to driver, there must some callback maintained In My case its GPIO based Watchdog driver and gpio_wdt.c may be having this callback. But I really could not figure out

i have enabled the Uart in linux source and created a image how to test the uart working

折月煮酒 提交于 2019-12-25 01:44:47
问题 hi I am newbie please help me i have enabled the Uart in linux source and created a image,and while kernel boot time its showing me the log Serial: 8250/16550 driver, 5 ports, IRQ sharing disabled serial8250.0: ttyS0 at MMIO 0x4000c000 (irq = 5) is a 16550A console [ttyS0] enabled serial8250.2: ttyS1 at MMIO 0x40098000 (irq = 7) is a 16550A serial8250.3: ttyS2 at MMIO 0x4009c000 (irq = 8) is a 16550A and ttyS0 is used for interaction between host terminal and my target board that is working

Why the number of minor devices are not listed here in this program in /dev?

大兔子大兔子 提交于 2019-12-24 16:25:26
问题 I want to create the number of minor character drivers for my module. I want to see it at the /dev/ . However, I see only one driver. What is the problem in my code? What should be the right code? #include <linux/init.h> #include <linux/module.h> /** needed by all modules **/ #include <linux/kernel.h> /** This is for KERN_ALERT **/ #include <linux/fs.h> /** for file operations **/ #include <linux/cdev.h> /** character device **/ #include <linux/device.h> /** for sys device registration in

Analyzing kmemleak result

北战南征 提交于 2019-12-24 12:09:26
问题 I am running kmemleak on one of my modules to find leaks, below is the result after a while. From the result, what i understand is below address are object/s address in the .ko or .o file. unreferenced object 0xffff8803c9708f10 (size 32): comm "resiter_access_i_o", pid 2320, jiffies 4294798486 hex dump (first 32 bytes): d8 8e 70 c9 03 88 ff ff a0 8e 70 c9 03 88 ff ff ..p.......p..... 68 8e 70 c9 03 88 ff ff 30 8e 70 c9 03 88 ff ff h.p.....0.p..... backtrace: [<ffffffff81516e3e>] kmemleak

Unknown symbol flush_tlb_all (err 0)

霸气de小男生 提交于 2019-12-24 09:16:01
问题 I tried to make a simple kernel module invalidating all tlb entries through user-level ioctl. Below is my example code [flush_tlb.c] /* * flush_tlb.c */ #include <linux/uaccess.h> #include <linux/fs.h> #include <linux/miscdevice.h> #include <linux/module.h> #include <linux/mm.h> #include <asm/tlbflush.h> #include <asm/tlb.h> #include "flush_tlb.h" MODULE_LICENSE("GPL"); static long flush_tlb_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int ret = 0; unsigned int size = _IOC

Is it possible in linux to register a interrupt handler from any user-space program?

此生再无相见时 提交于 2019-12-24 09:02:25
问题 I am studying about Linux Interrupt handling mechanism, just got doubt whether registering an interrupt handler from user-space is allowed or not? 回答1: No, interrupts are registered in the kernel and a driver / module must be loaded into kernel space to receive the interrupt. It could pass handling onto a user space daemon that hooks into the kernel module, but the something must be inserted into the kernel. 回答2: Cannot register user space interrupt handler directly. Kernel ISR indicates

Possible de-reference of private data using net_device

▼魔方 西西 提交于 2019-12-24 05:54:21
问题 I have a specific question regarding using net_device module in linux kernel. Lets address this code example please. When i init my device, i call alloc_netdev and provide it with the private data size , so it will properly allocate it. Now, What happens when i call snull_cleanup when i wish to stop using this device. i see it basically free's the structure (including the private data). The question is, what if the code currently running is an inside function inside my device module which