Wednesday 16 August 2017

Linux Kernel

Ways to assign the Major/Minor number to any device?

statically and dynamically(Run time) 
1) statically means : 

first=MKDEV(int major, int minor); 
then 
u can use the return type of MKDEV that is first in this function 

int register_chrdev_region(dev_t first, unsigned int count, 
char *name); 

2) dynamic means :in run time u need to create device file there u need to enter 
eg mknod /dev/filename typeofdevice majornumber minornumber


When is that we we want to use "user virtual address" instead of "kernel virtual address"?
when we are running a program in userspace, we don't have access to the kernel virtual memory addresses.

When we are running code in kernel mode, say, as a kernel module or driver, we normally access kernel virtual memory. But if the situation comes where our kernel mode code has to interact with some userspace component, we must be extremely careful that we translate "kernel virtual addresses" to "user virtual addresses" before passing them off, and vice-versa.
copy_to_user() copy_from_user() requires user virtual address




 

No comments:

Post a Comment