linux-device-driver

Uinput virtual device is detected as physical keyboard on android

三世轮回 提交于 2019-12-19 11:35:02
问题 I've created a simple native library in C that allows the user to create a device using uinput module. The code seems to work, but there's a problem: my virtual device is detected as physical keyboard and, when I need to write some text, the soft keyboard doesn't appear since android detects a real keyboard connected. How to set this device virtual? If i don't set the keybits it is not detected as a physical keyboard, but I need the keys enabled. #include <string.h> #include <jni.h> #include

Regarding NAPI implementation in Linux Kernel

半城伤御伤魂 提交于 2019-12-19 03:39:10
问题 I am trying to understand the NAPI enabled Network driver and have some doubts regarding the same. If I talk about in layman's term whenever a network packets comes at the interface, it is notified to CPU and appropriate Ethernet driver(interrupt handler) code is executed.Ethernet driver code then copy the packet from Ethernet's Device memory to DMA buffers and finally packets are pushed to upper layer. Is above true for NAPI disabled Ethernet driver? Now for NAPI enabled Ethernet driver

insmod error: inserting './hello.ko': -1 Invalid module format"

冷暖自知 提交于 2019-12-18 13:09:33
问题 I have just made my first driver module, the hello world module following LDD3. However unfortunately encountered this error: insmod: error inserting './hello.ko': -1 Invalid module format. I am doing this on Ubuntu 11.04, and my environment: $ uname -r 2.6.38-8-generic I get the kernel source like this: sudo apt-cache search linux-source linux-source - Linux kernel source with Ubuntu patches linux-source-2.6.38 - Linux kernel source for version 2.6.38 with Ubuntu patches $sudo apt-get

How to filter and intercept Linux packets by using net_dev_add() API?

自古美人都是妖i 提交于 2019-12-18 11:44:37
问题 I'm writing ethernet network driver for linux. I want to receive packets, edit and resend them. I know how to edit the packet in packet_interceptor function, but how can I drop incoming packets in this function?? #include <linux/netdevice.h> #include <linux/skbuff.h> #include <linux/ip.h> #include <net/sock.h> struct packet_type my_proto; int packet_interceptor(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { // I dont want certain packets go

Building kernel modules for different linux version

你。 提交于 2019-12-18 11:34:26
问题 I am new to writing kernel modules, so facing few non-technical problems. Since for creating kernel module for a specific kernel version ( say 3.0.0-10, 10 is patch number) requires same version kernel headers, so it looks straight to install kernel headers and start development over there. But kernel headers for patched kernel version are not available. As I have a guest kernel vmlinuz-3.0.0-10 running in machine and upon downloading kernel headers it says not found. other approach is to get

Understanding loff_t *offp for file_operations

醉酒当歌 提交于 2019-12-18 11:05:47
问题 I'm designing a device driver that simply reads and writes to a character buffer. My question is however regarding the two functions in the file_operations structure read and write . I don't truly understand what loff_t *offp really is. I know that for both the read and write operations that *offp is the file offset meaning the current reading/writing position of the file, however I'm not even sure what it means to write or read to/from a device file. From what I gathered, and this is how I

Understanding loff_t *offp for file_operations

核能气质少年 提交于 2019-12-18 11:05:02
问题 I'm designing a device driver that simply reads and writes to a character buffer. My question is however regarding the two functions in the file_operations structure read and write . I don't truly understand what loff_t *offp really is. I know that for both the read and write operations that *offp is the file offset meaning the current reading/writing position of the file, however I'm not even sure what it means to write or read to/from a device file. From what I gathered, and this is how I

What are linux irq domains, why are they needed?

落爺英雄遲暮 提交于 2019-12-18 10:46:22
问题 What are irq domains, i read kernel documentation (https://www.kernel.org/doc/Documentation/IRQ-domain.txt) they say: The number of interrupt controllers registered as unique irqchips show a rising tendency: for example subdrivers of different kinds such as GPIO controllers avoid reimplementing identical callback mechanisms as the IRQ core system by modeling their interrupt handlers as irqchips, i.e. in effect cascading interrupt controllers. How GPIO controller can be called as interrupt

Userspace vs kernel space driver

三世轮回 提交于 2019-12-17 21:57:55
问题 I am looking to write a PWM driver. I know that there are two ways we can control a hardware driver: User space driver. Kernel space driver If in general (do not consider a PWM driver case) we have to make a decision whether to go for user space or kernel space driver. Then what factors we have to take into consideration apart from these? User space driver can directly mmap() /dev/mem memory to their virtual address space and need no context switching. Userspace driver cannot have interrupt

module_init() vs. core_initcall() vs. early_initcall()

不想你离开。 提交于 2019-12-17 17:30:43
问题 In drivers I often see these three types of init functions being used. module_init() core_initcall() early_initcall() Under what circumstances should I use them? Also, are there any other ways of init? 回答1: They determine the initialization order of built-in modules. Drivers will use device_initcall (or module_init ; see below) most of the time. Early initialization ( early_initcall ) is normally used by architecture-specific code to initialize hardware subsystems (power management, DMAs, etc