linux-device-driver

how to write cross-version/platform Linux kernel modules?

偶尔善良 提交于 2019-12-07 06:33:22
问题 I'm new to programming Linux kernel modules, and many getting started guides on the topic include little information about how to build a kernel module which will run on many versions and CPU platforms of Linux. Most of the guides I've seen simply state things like, "Linux doesn't ensure any ABI/API compatibility between versions." However, other OSes do provide these guarantees for major versions, and the guides are mostly targeting 2.7 (which is a bit old now). I was wondering if there is

What are the consequences of calling write() with zero length?

送分小仙女□ 提交于 2019-12-07 06:05:53
问题 At fairly high level in the Linux write() function, it filters out requests for writing 0 length buffers. Which makes sense. Who'd want to the OS wasting it's time drilling through layers only to determine there is no work to be done? Well ... me. It's related to this question; and the discovery that the bit-banged I2C driver will give a potentially useful return code if the address (sent on the bus before data) will give an error if the handshaking is wrong. One could send dummy data after

Is it efficient to use epoll with devices (/dev/event/…)?

隐身守侯 提交于 2019-12-07 05:30:25
问题 I am working on a monothreaded process applet which creates a proxy virtual device (more precisely a virtual Xbox 360 pad); I do manage to create it with the uinput interface, I set it up properly and it works just fine. In order to feed commands to this virtual device , I read events from another real interface (in this case a PS3 pad), and I open the real device file with these flags: fd = open("/dev/input/event22", O_RDONLY); // open the PS3 pad The main loop is something like (minus error

Notify gpio interrupt to user space from a kernel module [closed]

£可爱£侵袭症+ 提交于 2019-12-07 05:24:56
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I have a code which detects GPIO interrupt in a kernel module. Now,I am looking for a mechanism to notify user space upon detecting gpio interrupt from kernel module. Any example / code snippet with certain advantages/disadvantages over different options? I would appreciate

Difference between arm-eabi arm-gnueabi and gnueabi-hf compilers [closed]

假如想象 提交于 2019-12-07 04:38:41
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last month . What is the difference between arm-eabi, gnueabi and gnueabi-hf cross compilers. I am kind of finding it difficult to choose the compilers. Is there a native compiler for arm? 回答1: I'm not completely sure: the eabi stands for the compilation of code which will run on bare metal arm core. the gnueabi stands for

Linux Kernel Module/IOCTL: inappropriate ioctl for device

做~自己de王妃 提交于 2019-12-07 02:43:03
问题 I am in the process of writing a Linux Kernel Module (LKM) serving as a pseudo-driver - I am unable to figure out how to make IOCTL calls between the LKM ( wait.c ) and the user-level program ( user.c ). The magic number for the device driver is 0xBF - the LKM does not communicate with a physical block/char device, it is simply an exercise. From what I can tell, the IOCTL call to KERN_IOCTL_CREATE_EVENT is not formatted properly & the magic number is incorrect. The IOCTL call that I am

Why do we need to call poll_wait in poll?

╄→尐↘猪︶ㄣ 提交于 2019-12-06 22:24:46
问题 In LDD3, i saw such codes static unsigned int scull_p_poll(struct file *filp, poll_table *wait) { struct scull_pipe *dev = filp->private_data; unsigned int mask = 0; /* * The buffer is circular; it is considered full * if "wp" is right behind "rp" and empty if the * two are equal. */ down(&dev->sem); poll_wait(filp, &dev->inq, wait); poll_wait(filp, &dev->outq, wait); if (dev->rp != dev->wp) mask |= POLLIN | POLLRDNORM; /* readable */ if (spacefree(dev)) mask |= POLLOUT | POLLWRNORM; /*

Missing flow control data (0x13) from reading device data stream

有些话、适合烂在心里 提交于 2019-12-06 21:33:32
I have written a Linux app to read & write binary data to a remote device over a USB port that is emulating a serial port. When I read data from the device, I have a USB sniffer that shows a binary data stream like this (0x01, 0x0A......0x13), but when my program reads the bytes, the 0x13 is not in the byte stream - this is the XOFF char, but I am not using XON/XOFF flow control (I think). Tried both open read and write, as well as fopen fread and fwrite in binary mode, same result. Any ideas? Thanks for any responses, like the website. Turns out stty showed: # stty -F /dev/ttyUSB0 speed

Kernel panic using deferred_io on kmalloced buffer

痴心易碎 提交于 2019-12-06 15:38:46
I'm writing a framebuffer for an SPI LCD display on ARM. Before I complete that, I've written a memory only driver and trialled it under Ubuntu (Intel, Virtualbox). The driver works fine - I've allocated a block of memory using kmalloc, page aligned it (it's page aligned anyway actually), and used the framebuffer system to create a /dev/fb1. I have my own mmap function if that's relevant (deferred_io ignores it and uses its own by the look of it). I have set: info->screen_base = (u8 __iomem *)kmemptr; info->fix.smem_len = kmem_size; When I open /dev/fb1 with a test program and mmap it, it

Ring buffers and DMA

守給你的承諾、 提交于 2019-12-06 14:29:28
问题 I'm trying to understand everything that happens in between the time a packet reaches the NIC until the time the packet is received by the target application. Assumption: buffers are big enough to hold an entire packet. [I know it is not always the case, but I don't want to introduce too many technical details] One option is: 1. Packet reaches the NIC. 2. Interrupt is raised. 2. Packet is transferred from the NIC buffer to OS's memory by means of DMA. 3. Interrupt is raised and the OS copies