linux-device-driver

What is the difference between module_init and init_module in a Linux kernel module?

坚强是说给别人听的谎言 提交于 2019-12-08 23:11:26
问题 I have been trying to port few linux drivers and realized that there is substantial difference between kernel version 2.4 and 2.6 of linux. In the 2.4 version of kernel, the module programming was as below - #define MODULE #include <linux/module.h> #include <linux/kernel.h> int init_module(void) { printk(KERN_INFO "Hi \n"); return 0; } void cleanup_module(void) { printk(KERN_INFO "Bye \n"); } But, with the 2.6 version of kernel, the following has to be done for modules - #include <linux/init

What does ERESTARTSYS used while writing linux driver?

偶尔善良 提交于 2019-12-08 22:49:17
问题 I'm learning about the blocking I/O functions for writing linux device driver and I'm wondering what is the usage of ERESTARTSYS . Consider the following: Global variable : wait_queue_head_t my_wait_q_head; int read_avail = 0; device_init() : init_waitqueue_head(&my_wait_q_head); device_read(): printk("I'm inside driver read!\n"); wait_event_interruptible(&my_wait_q_head, read_avail != 0); printk("I'm awaken!\n"); device_write(): read_avail = 1; wake_up_interruptible(&my_wait_q_head); When I

Why are SIMD instructions not used in kernel?

好久不见. 提交于 2019-12-08 20:38:35
问题 I couldn't find much use of SIMD instructions (like SSE/AVX) in kernel (except one place where they were used to speedup parity computation of RAID6). Q1) Any specific reason for this or just the lack of use-case? Q2) What needs to be done today if I want to use SIMD instruction, in say a device driver? Q3) How hard will it be to incorporate framework like ISPC into kernel (just for experimentation)? 回答1: Saving/restoring FPU (including SIMD vector registers) state is more expensive than just

Which processor would execute hardware interrupt in a muticore system

帅比萌擦擦* 提交于 2019-12-08 19:38:31
In general hardware interrupts need to be processed immediately, at least so as to acknowledge it and do some first level of processing. As I understand this is not scheduled activity. Please correct me. So the question is how to choose a processor that would actually execute this hardware interrupt handler? One can answer this for Linux and/or BSD systems In general, this depends on the functionality offered by multi-core processor and OS. While using multi-core processors, you might need to configure the affinity of the interrupt as per your requirement. In the case of linux , the /proc file

What's the CONFIG_OF in linux?

£可爱£侵袭症+ 提交于 2019-12-08 17:24:38
问题 I see that it is being widely used at many places but could not understand in what scenarios i need to use it. What is CONFIG_OF? What is the full name of "OF"? 回答1: Open Firmware. This was invented long time ago when Apple was producing laptops based on PowerPC CPUs. Openfirmware provides a good description of the devices connected to the platform. In Linux kernel the part that works with device data is called Device Tree (DT). More details in the Usage model. 来源: https://stackoverflow.com

Adding entry to task_struct and initializing to default value

ε祈祈猫儿з 提交于 2019-12-08 16:45:40
问题 I want to add an entry to process control block structure ( task_struct ). Let say a way to tag some process. I want to initialize this field to 0 for all the process except "some special processes", later by calling sched_setscheduler() I will set this flag for the "special processes". Does anybody have an idea how to assign a default value to a member variable in task_struct ? 回答1: I'm assuming you are talking about a recent Linux kernel, because implementation detail changes over time.

How to communicate with the USB Host from a Linux USB Client

时光总嘲笑我的痴心妄想 提交于 2019-12-08 14:47:28
The host part will be a PC program made from c# in which I will use LibUSBdotnet to do the communication. My problem is how do I make the Linux side pickup and respond. I don't really know where to start. Whenever I try to search for it, all result show are "how linux communicates with a device attached to it". Or it does not matter if a device is host or client, because they utilize the same pipes/bus? Can I use something in "/dev/usb***"? I have seen "libusb" which I believe is the linux cousin of libusbdotnet. Can I somehow use this library? If anyone can show me the right direction, I

Linux allocates memory at specific physical address

試著忘記壹切 提交于 2019-12-08 13:17:23
问题 I am testing a PCI Endpoint driver, I would like to do simple copy from the PCI RootPort side to the PCI Endpoint side. In PCI Endpoint side, we have address translation from PCI address to CPU physical address. We can configure the CPU physical address in the translation so that it maps to the specific DRAM region. The problem is how can we allocate a memory buffer at that specific CPU physical address to make sure the write from RootPort side really works? Any recommendations are

Why is tcsendbreak() necessary for serial communication to start working?

元气小坏坏 提交于 2019-12-08 12:50:34
问题 We are migrating from an older OS (OpenSuse 10.2) to Ubuntu 16.04 , and one of our applications communicates via a serial port. Communication stopped working on Ubunutu, but with a small hack(?) it does start working. That hack is to send a tcsendbreak( ) right after the call to open, like so: fd = open(pname, O_RDWR | O_NOCTTY); //pname becomes /dev/ttyS6 if (fd < 0) { printf("Couldnt open comms port \"%s\".\n", pname); return SYSERR; } if (tcsendbreak(fd, 0) < 0) { printf("tcsendbreak error

spidev Linux driver on Intel Atom board

烈酒焚心 提交于 2019-12-08 12:30:24
问题 I am working on bringing up SPI on Kontron's Atom-based SMARC-sXBTi board under Linux. Kontron provided Yocto BSP but it does not include SPI driver. I rebuilt Linux with SPI support. I can see the SPI controller in lspci and in sysfs the SPI PCI device is bound to pca2xx_spi_pci driver. As I understand this is a platform driver which does not expose user mode API and I need spidev to be able to work via /dev/spidev but when I modeprobe spidev I don't see anything happening: no file added to