linux-device-driver

Linux kernel device driver to DMA into kernel space

余生长醉 提交于 2019-12-03 03:54:28
LDD3 (p:453) demos dma_map_single using a buffer passed in as a parameter. bus_addr = dma_map_single(&dev->pci_dev->dev, buffer, count, dev->dma_dir); Q1 : What/where does this buffer come from? kmalloc ? Q2 : Why does DMA-API-HOWTO.txt state I can use raw kmalloc to DMA into? Form http://www.mjmwired.net/kernel/Documentation/DMA-API-HOWTO.txt L:51 If you acquired your memory via the page allocator kmalloc() then you may DMA to/from that memory using the addresses returned from those routines. L:74 you cannot take the return of a kmap() call and DMA to/from that. So I can pass the address

How the util of iostat is computed?

一世执手 提交于 2019-12-03 03:43:53
问题 iostat -x -d can display many i/o statistic info. For util of iostat, the explanation is : Percentage of CPU time during which I/O requests were issued to the device (band-width utilization for the device). Device saturation occurs when this value is close to 100% I want to know how the util was computed? I make an experiment, (see following code), start 40 thread to randomly read 40 files. I suppose the disk util should be very high, but I am wrong, the iostat is as follow, anyone can give

Memory usage of a kernel module

强颜欢笑 提交于 2019-12-03 03:32:45
While trying to estimate the amount of memory consumed by a kernel module (usually device drivers),I tried using the size utility which gave the size of the static memory areas of the .ko ( .bss, .data, .text etc). So I was expecting the sum of these values to be exactly equal to the output given by the lsmod command immediately after inserting the module. No dynamic memory allocation(kmalloc or vmalloc) is performed in the init() function to ensure that it isn't causing the difference.So why is there a mismatch? Curiously the mismatch was found to be a fixed amount most of the time!! The

Allocating more than 4 MB of pinned contiguous memory in the Linux Kernel

三世轮回 提交于 2019-12-03 03:17:31
问题 For some interaction with a PCI device that is being built, we'd like to create large contiguous pieces of memory that the board can access. As it stands now, the largest piece of memory that I've been able to allocate is 4 megabytes in size. I'm wondering if there are any methods to create larger regions. I do know that I can use the boot option mem= to do this, but for numa reasons, I'd rather not go this route. If, on the other hand, someone knew a way to do this, but distribute it over

Using linux/types.h in user programs, or stdint.h in driver module code…does it matter?

不想你离开。 提交于 2019-12-03 02:48:47
I'm developing a device driver module and associated user libraries to handle the ioctl() calls. The library takes the pertinent info and puts it into a struct, which gets passed into the driver module and unpacked there and then dealt with (I'm omitting a lot of steps, but that's the overall idea). Some of the data being passed through the struct via the ioctl() is uint32_t type. I've discovered that that type is defined in stdint.h AND linux/types.h. So far I've been using linux/types.h to define that value, including down in the user libraries. But I understand it is bad form to use linux/*

How to learn the structure of Linux wireless drivers (mac80211)?

两盒软妹~` 提交于 2019-12-03 02:10:59
问题 There is so many structures in the Linux wireless driver mac80211. Things like struct net_device , struct ieee80211_hw , struct ieee80211_vif and struct ieee80211_local and so on. So many structures that I don't understand what information they contain and when them were initialized. How can I learn about them and the whole architecture of wireless drivers? 回答1: You may want to check out Johannes Berg's (mac80211 maintainer) slides here: http://wireless.kernel.org/en/developers/Documentation

Difference between .o and .ko file

半腔热情 提交于 2019-12-03 02:10:55
问题 I am writing simple Linux module mod.c. When I compile mod.c file, it creates two output file mod.o and mod.ko . So I just want to know, What is the difference between mod.o and mod.ko file? 回答1: The short answer is that the .ko file is your object file linked with some kernel automatically generated data structures that are needed by the kernel. The .o file is the object file of your module - the result of compiling your C file. The kernel build system then automatically creates another C

New to Linux Kernel/Driver development

风流意气都作罢 提交于 2019-12-03 01:32:31
问题 Recently, i began developing a driver of an embedded device running linux. Until now i have only read about linux internals. Having no prior experience in driver devlopment, i am finding it a tad difficult to land my first step. I have downloaded the kernel source-code (v2.6.32). I have read (skimped) Linux Device Drivers (3e) I read a few related posts here on StackOverflow. I understand that linux has a "monolithic" approach. I have built kernel (included existing driver in menuconfig etc.)

Is timer interrupt independent of whether system is in kernel mode or user mode?

一笑奈何 提交于 2019-12-03 00:43:26
In a Linux uni-processor system, is timer interrupt independent of whether system is in kernel mode or user mode? Is there any different behavior for the timer interrupt while system is in kernel mode? The simple answer is that neither the execution of the hardware clock interrupt service routine, nor the scheduling of the dynamic timer handlers are affected by the mode the system was in before the hardware clock interrupt. The reason is that the the clock timer interrupt is a hardware interrupt that is serviced immediately, regardless of whether the execution is in kernel or user context

mapping memory reserved by mmap kernel boot param into user space

假装没事ソ 提交于 2019-12-03 00:33:37
As discussed in this question, i am reserving a memory chunk at the boot time using a kernel boot parameter memmap=8G$64G I have written a character driver kernel module which , during initialization does a ioremap of this reserved memory chunk. As explained here , in my driver mmap all i need to do is remap_pfn_range for this memory chunk pointer returned by the ioremap . I am running this on 3.0 linux kernel . My user space application opens this memory chunk as a device mounted by the driver. When i do mmap from the use space application i see a system hang. my dmesg don't provide me much