linux-device-driver

Finding original MAC address from Hardware itself

纵饮孤独 提交于 2019-12-03 14:33:45
问题 Os:REDHAT LINUX Linux manage: 2.6.18.8-1 # Is this possible to read MAC address form NIC directly ? I have below code but it just read from above layer but not the card itself !!! I'm trying to figure out how to find the original MAC address of an ethernet NIC on my linux box. I understand how to find the current MAC address using ifconfig, but if the address has been changed, say by using 'ifconfig eth0 hw ether uu:vv:ww:yy:xx:zz' ,or I set "permanent" it using vi /etc/sysconfig/network

Enabling write-combining IO access in userspace

独自空忆成欢 提交于 2019-12-03 13:41:53
I have a PCIe device with a userspace driver. I'm writing commands to the device through a BAR, the commands are latency sensitive and amount of data is small (~64-bytes) so I don't want to use DMA. If I remap the physical address of the BAR in the kernel using ioremap_wc and then write 64-bytes to the BAR inside the kernel , I can see that the 64-bytes are written as a single TLP over PCIe. If I allow my userspace program to mmap the region with the MAP_SHARED flag and then write 64-bytes I see multiple TPLs on the PCIe bus, rather than a single transaction. According to the kernel PAT

What is DMA mapping and DMA engine in context of linux kernel?

匆匆过客 提交于 2019-12-03 13:24:30
What is DMA mapping and DMA engine in context of linux kernel? When DMA mapping API and DMA engine API can be used in Linux Device Driver? Any real Linux Device Driver example as a reference would be great. Punit Vara What is DMA mapping and DMA engine in context of linux kernel? The kernel normally uses virtual address. Functions like kmalloc() , vmalloc() normally return virtual address. It can be stored in void* . Virtual memory system converts these addresses to physical addresses. These physical addresses are not actually useful to drivers. Drivers must use ioremap() to map the space and

What is the significance of THIS_MODULE in Linux kernel module drivers?

一笑奈何 提交于 2019-12-03 12:51:29
In linux device driver development, the file_operations structure uses "struct module *owner". What is the use of this structure when we always initialize it with THIS_MODULE ? When can this field be set to NULL? this field tells who is owner of struct file_operations. This prevents module to get unloaded when it is in operation. When initialized with THIS_MODULE current module holds the ownership on it Minimal runnable example Whenever you create a kernel module, the kernel's build machinery generates a struct module object for you, and makes THIS_MODULE point to it. This struct contains many

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

吃可爱长大的小学妹 提交于 2019-12-03 12:21:49
问题 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

Accessing a serial port from a linux kernel module

可紊 提交于 2019-12-03 11:33:30
Hello Linux Kernel Driver Gurus! I'm writing a v4l2 driver for a camera that uses a serial interface for configuration. I'd like the driver to configure the camera, as it keeps the client code consistent across camera models. The question is: what's the best way to access the camera's serial interface from the driver module? From what I hear, accessing files from a kernel driver is a big no-no, but it can be done. As such, I'm currently using the following code snippet, but it feels like a hack. oldfs = get_fs(); set_fs(KERNEL_DS); fd->f_pos=0; fd->f_op->write(fd, data, data_len, &fd->f_pos);

How to pass a value to a builtin Linux kernel module at boot time?

痴心易碎 提交于 2019-12-03 10:20:37
问题 I want to pass a custom parameter to the kernel at boot time, which my new code will use. This parameter is a number. I know how to pass value to kernel module using kernel command line i.e module_param() . Now i want to pass value from u-boot. Is there a way to do this, either during or after boot? 回答1: Modify your board file present in include/config/board_xxx.h of U-Boot, modify $bootargs similar to the last variable that is set in this example: setenv bootargs display=\${display} console=

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

安稳与你 提交于 2019-12-03 10:14:31
问题 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? 回答1: 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

Device Tree and code size

穿精又带淫゛_ 提交于 2019-12-03 09:10:21
As per my understanding of device trees , one of main uses is to remove platform specific code from drivers to support multiple platforms. How does device tree handle multiple configuration for a single peripheral? For example if I want to use LCD Panel A in Platform A and LCD Panel B in Platform B, do I need to keep both LCD Panel A and Panel B related code in the final binary? If that is the case and there are multiple peripherals with more than one option, it seems there will be huge additional code in the binary. kzs Suppose consider if you have 5 LCD panels and 5 platform(machines), keep

Do I need to “enable” a PCIe memory region in a Linux 3.12 driver?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 08:55:25
I have code, called from the probe() function of my PCIe driver (loosely based on this post ): EDIT: Based on Andreas Bombe's response, I changed the code to use pci_iomap() , but I'm still experience the system hang static my_pci_dev pci_dev; /* local structure */ static int pci_setup_region(struct pci_dev *dev) { int bar = 0; pci_dev.physical.addr = pci_resource_start(dev, bar); pci_dev.physical.size = pci_resource_len(dev, bar); pci_dev.virtual.addr = pci_iomap(dev, bar, pci_dev.physical.size); if (NULL == pci_dev.virtual.addr) { return -ENOMEM; } else { pci_dev.virtual.size = pci_dev