linux-device-driver

How do “pinned” pages in Linux present (or actually “pin”) themselves

白昼怎懂夜的黑 提交于 2019-12-06 01:49:31
I am using get_user_pages in a Linux kernel driver to pin memory for the purposes of [hardware] DMA. It all seems to work fine - but I am having a hard time proving that the "pinning" is doing the proper thing. When I inspect the flags on the physical pages after doing get_user_pages - the pages don't appear "locked" (as one might think they should be). In fact, I see no difference between the flags of otherwise "active" pages vs. those I have "pinned" via get_user_pages . The only difference I see is that get_user_pages has taken a refcount on the page. So I guess my question is - is holding

How GPIO is mapped in memory?

。_饼干妹妹 提交于 2019-12-06 00:36:42
问题 I am recently browsing GPIO driver for pi2, I found user space pi2 GPIO lib (like RPi.GPIO 0.5.11 of python) use /dev/mem for BCM2708 (begins at 0x20000000,and GPIO begins at 0x200000 relatively) to mmap a user space memory region in order to handler GPIO. But I found drivers/gpio in linux source tree is designed to be handled by /sys/class/gpio/* . I found nothing like I/O ports mapping like request_io_region and __io_remap . My question is How GPIO for BCM2708 mapped in memory ? Is there

drop/rewrite/generate keyboard events under Linux

别来无恙 提交于 2019-12-05 22:28:21
问题 I would like to hook into, intercept, and generate keyboard (make/break) events under Linux before they get delivered to any application. More precisely, I want to detect patterns in the key event stream and be able to discard/insert events into the stream depending on the detected patterns. I've seen some related questions on SO, but: either they only deal with how to get at the key events (key loggers etc.), and not how to manipulate the propagation of them (they only listen, but don't

Get man pages for driver functions

一世执手 提交于 2019-12-05 20:19:33
I am new to linux device drivers. I would like to know if there are man pages for the driver functions like register_chrdev. If yes, then how do I get them? Is there a package that I can download using apt-get? The Linux kernel pages in the man program reside in section 9, which is (un)fortunately a non-standard section. See this . Popular Linux distributions like Ubuntu don't distribute the man pages that fall under this section through their software channels (?). They're still available, for example, Debian provides one . There are also online versions of the man pages. Actually the kernel

How to test your own Linux module?

别来无恙 提交于 2019-12-05 19:37:30
Today I am getting started with developing Linux modules. It was rather hard to write, compile and work with Helloworld, but I've done it. My second module with open, write, read functions is ready, but I really dont know how to test it. Write method just makes printk(). My module is loaded, its name is iamnoob. How to test this write(...) function and to find smth in var/log/syslog? cat > iamnoob just writes a file to the dir. Same with cp and other. Sorry for noob question, i've googled, but no answer has been found. Sorry for poor English. A basic kernel module would normally include

device-tree mismatch: .probe never called

試著忘記壹切 提交于 2019-12-05 19:00:53
问题 I'm having trouble understanding how device-tree works, or specifically why this driver won't init. This is in the rockchip vendor kernel for android, version 3.10 drivers/watchdog/rk29_wdt.c (reduced for readability) static const struct of_device_id of_rk29_wdt_match[] = { { .compatible = "rockchip,watch dog" } }; static struct platform_driver rk29_wdt_driver = { .probe = rk29_wdt_probe, [..] .of_match_table = of_rk29_wdt_match, .name = "rk29-wdt", }, }; static int __init watchdog_init(void)

Static functions in Linux device driver?

自作多情 提交于 2019-12-05 17:42:19
问题 Is there a reason why most function definition in device driver in linux code is defined as static? Is there a reason for this? I was told this is for scoping and to prevent namespace pollution, could anyone explain it in detail why static definition is used in this context? 回答1: Functions declared static are not visible outside the translation unit they are defined in (a translation unit is basically a .c file). If a function does not need to be called from outside the file, then it should

Creating a debug target in Linux 2.6 driver module makefile

夙愿已清 提交于 2019-12-05 17:41:06
I'm trying to be able to execute "make debug" at the command line and it will build my driver module with the -DDEBUG_OUTPUT define, which will cause certain sections of code to be compiled in. In 2.4 kernel makefiles, this is pretty easy. I just create a debug: target and included "-DDEBUG_OUTPUT" in the cc compilation command arguments for that target. Easy. Unfortunately (for me), 2.6 completely changed how modules are compiled, and I can ONLY seem to find the trivial "all" and "clean" examples, which don't show adding custom defines at compilation time. I tried this: debug: make -C $

What is dev_id parameter in request_irq?

北城余情 提交于 2019-12-05 17:15:43
In the function declaration int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), unsigned long irqflags, const char *devname, void *dev_id); Is dev_id an 'in' parameter or an 'out' parameter ? Where do we get this number from ? Dev_id is an input argument and must be globally unique. Normally the address of the device data structure is used as the Dev_id . It has value NULL if the interrupt line is NOT shared. It holds relevance only when the interrupt line is being shared. When it is shared, this parameter uniquely identifies the interrupt handler on the

How do you get a struct device for a Linux character device

时光毁灭记忆、已成空白 提交于 2019-12-05 14:36:53
I have a Linux kernel module that implements a character device driver. I've read through Linux Device Drivers and followed several tutorials. At this point, I have a simple module that provides open , release , and write file operations. I'm trying to use the Generic DMA Layer to create a streaming DMA mapping. I'm confused by the following excerpt from LDD: Many of the functions below require a struct device . This structure is the low-level representation of a device within the Linux device model. It is not something that drivers often have to work with directly, but you do need ot when