linux-device-driver

Miscellaneous Device Driver: Unable to open the device with open() system call

大兔子大兔子 提交于 2020-02-25 13:37:49
问题 I am trying to implement a system call interception for sys_open() call via kernel module and for that I have defined a miscellaneous device driver MyDevice which can be inserted as kernel module. Below is the code for my kernel module: #include <linux/version.h> #include <linux/module.h> #include <linux/miscdevice.h> #include <linux/fs.h> #include <linux/highmem.h> #include <asm/unistd.h> MODULE_LICENSE("GPL"); // IOCTL commands #define IOCTL_PATCH_TABLE 0x00000001 #define IOCTL_FIX_TABLE

Miscellaneous Device Driver: Unable to open the device with open() system call

☆樱花仙子☆ 提交于 2020-02-25 13:37:30
问题 I am trying to implement a system call interception for sys_open() call via kernel module and for that I have defined a miscellaneous device driver MyDevice which can be inserted as kernel module. Below is the code for my kernel module: #include <linux/version.h> #include <linux/module.h> #include <linux/miscdevice.h> #include <linux/fs.h> #include <linux/highmem.h> #include <asm/unistd.h> MODULE_LICENSE("GPL"); // IOCTL commands #define IOCTL_PATCH_TABLE 0x00000001 #define IOCTL_FIX_TABLE

Register snd-soc-dummy in a device tree

不羁的心 提交于 2020-02-20 10:26:31
问题 I'm trying to register the ALSA dummy codec provided in soc-utils in my device tree source file, to use it with an i2s device driver (sun8i-i2s). I've tried to set the sound-dai field in my i2s configuration as explained here : https://patchwork.kernel.org/patch/7679391/, but the device driver fails to find the dai name when reading the device tree. I've found two workarounds, which consists in either writing my own dummy codec and giving it to the device tree : / { stupid-codec { #sound-dai

Register snd-soc-dummy in a device tree

会有一股神秘感。 提交于 2020-02-20 10:26:27
问题 I'm trying to register the ALSA dummy codec provided in soc-utils in my device tree source file, to use it with an i2s device driver (sun8i-i2s). I've tried to set the sound-dai field in my i2s configuration as explained here : https://patchwork.kernel.org/patch/7679391/, but the device driver fails to find the dai name when reading the device tree. I've found two workarounds, which consists in either writing my own dummy codec and giving it to the device tree : / { stupid-codec { #sound-dai

System call hooking example arguments are incorrect

馋奶兔 提交于 2020-02-15 07:57:47
问题 I wrote an example of system call hooking from our Linux Kernel module. Updated open system call in system call table to use my entry point instead of the default. #include <linux/module.h> #include <linux/kallsyms.h> MODULE_LICENSE("GPL"); char *sym_name = "sys_call_table"; typedef asmlinkage long (*sys_call_ptr_t)(const struct pt_regs *); static sys_call_ptr_t *sys_call_table; typedef asmlinkage long (*custom_open) (const char __user *filename, int flags, umode_t mode); custom_open old_open

System call hooking example arguments are incorrect

烈酒焚心 提交于 2020-02-15 07:55:47
问题 I wrote an example of system call hooking from our Linux Kernel module. Updated open system call in system call table to use my entry point instead of the default. #include <linux/module.h> #include <linux/kallsyms.h> MODULE_LICENSE("GPL"); char *sym_name = "sys_call_table"; typedef asmlinkage long (*sys_call_ptr_t)(const struct pt_regs *); static sys_call_ptr_t *sys_call_table; typedef asmlinkage long (*custom_open) (const char __user *filename, int flags, umode_t mode); custom_open old_open

Registering multiple Fast interrupt sources on ARM Linux

笑着哭i 提交于 2020-02-01 09:21:32
问题 I have been working with the Linux interrupt on ARM: request_irq() can be used to register an interrupt. On a single interrupt line you can register multiple interrupts with SHA_SHIRQ , i.e normal IRQ. On a particular interrupt line does Linux allow to register multiple SA_INTERRUPT ? That is can we register multiple interrupt handlers for an ARM fast interrupts or FIQ s? 回答1: Like the IRQ , the FIQ has a single point of entry from the vector table. You must inspect the interrupt controller

Registering multiple Fast interrupt sources on ARM Linux

爷,独闯天下 提交于 2020-02-01 09:21:06
问题 I have been working with the Linux interrupt on ARM: request_irq() can be used to register an interrupt. On a single interrupt line you can register multiple interrupts with SHA_SHIRQ , i.e normal IRQ. On a particular interrupt line does Linux allow to register multiple SA_INTERRUPT ? That is can we register multiple interrupt handlers for an ARM fast interrupts or FIQ s? 回答1: Like the IRQ , the FIQ has a single point of entry from the vector table. You must inspect the interrupt controller

Content of /proc/iomem

旧街凉风 提交于 2020-01-25 12:13:43
问题 1) Is it possible to access a physical address which is not defined in /proc/iomem? 2) If the physical address range of a device does not appear in /proc/iomem, does it mean that the device has not been utilized/initialized yet? 回答1: 1) Is it possible to access a physical address which is not defined in /proc/iomem? Yes. Assuming an ARM processor which memory maps all directly-connected periperals, the driver could perform an ioremap() operation to map the physical memory to virtual memory

Get PFN from DMA address (dma_addr_t)?

£可爱£侵袭症+ 提交于 2020-01-24 19:31:08
问题 I would like to get the PFN associated with a memory block allocated with dma_alloc_coherent for use with a PCIe device as shown below: unsigned long pfn; buffer = dma_alloc_coherent(&pcie->dev, size, &bus_addr, GFP_KERNEL); // Get PFN? virt_to_phys(buffer) >> PAGE_SHIFT; I'm aware that this is probably not the correct method, but it seems to work... I'm just looking for the right solution to translate the potential bus address (since I do not know if there is an IOMMU) to a PFN. Thanks in