SlideShare una empresa de Scribd logo
1 de 26
Linux USB Device Driver
Submitted By:
Sayanton Vhaduri Dibbo
∗ Overview
∗ Device Driver
∗ User & Kernel Interface
∗ Loadable Kernel Module (LKM)
∗ General implementation steps
∗ Register and unregister device
∗ Device Driver Types
∗ kernel functions
∗ Pitfalls
Contents
∗ Write a device driver for a pseudo stack device
∗ Idea fromhttp://www.cs.swarthmore.edu/~newhall/cs45/f01/proj5.html
∗ Linux device type supports the following operations
∗ Open: only one is allowed.
∗ Write: writes an char string to top of the device stack. Error if stack is
empty
∗ Read: reads an item from top of the device stack. Error if stack is
empty
∗ Release: release the device
∗ Install with LKM.
∗ Test: It will be a dedicated standalone machine in the lab. Root
password may be given out. If you mess up, you will re-install the
Overview
∗ A programming module with interfaces
∗ Communication Medium between application/user and
hardware
∗ In Unix,
∗ Kernel module
∗ device driver interface = file interface
∗ What are normal operations?
∗ Block vs. character
What is a device driver?
User program & Kernel interface
Note: This picture is excerpted from Write a Linux Hardware Device Driver, Andrew O’Shauqhnessy, Unix world
USB Subsystem in LINUX
A top-to-bottom view of the USB subsystem in Linux.
∗ A new kernel module can be added on the fly (while
OS is still running)
∗ LKMs are often called “kernel modules”
∗ They are not user program
Loadable Kernel Module (LKM)
∗ Device drivers
∗ Filesystem driver (one for ext2, MSDOS FAT16, 32,
NFS)
∗ System calls
∗ Network Drivers
∗ TTY line disciplines. special terminal devices.
∗ Executable interpreters.
Types of LKM
∗ Every LKM consist of two basic functions (minimum) :
int init_module(void) /*used for all initialition stuff*/
{
...
}
void cleanup_module(void) /*used for a clean shutdown*/
{
...
}
∗ Loading a module - normally retricted to root - is managed by issuing
the follwing command: # insmod module.o
Basic LKM (program)
∗ insmod
∗ Insert an LKM into the kernel.
∗ rmmod
∗ Remove an LKM from the kernel.
∗ depmod
∗ Determine interdependencies between LKMs.
∗ kerneld
∗ Kerneld daemon program
∗ ksyms
∗ Display symbols that are exported by the kernel for use by new LKMs.
∗ lsmod
∗ List currently loaded LKMs.
∗ modinfo
∗ Display contents of .modinfo section in an LKM object file.
∗ modprobe
∗ Insert or remove an LKM or set of LKMs intelligently. For example, if you must load A before
loading B, Modprobe will automatically load A when you tell it to load B.
LKM Utilities cmd
∗ Create a special device file
% mknode /dev/driver c 40 0
∗ Insert a new module
% insmod modname
∗ Remove a module
∗ %rmmod modname
∗ List module
% lsmod
Or % more /proc/modules
audio 37840 0
cmpci 24544 0
soundcore 4208 4 [audio cmpci]
nfsd 70464 8 (autoclean)
Common LKM util cmd
∗ A set of API subroutines (typically system calls)
interface to hardware
∗ Hide implementation and hardware-specific details
from a user program
∗ Typically use a file interface metaphor
∗ Device is a special file
Linux Device Drivers
∗ Manage data flow between a user program and
devices
∗ A self-contained component (add/remove from
kernel)
∗ A user can access the device via file name in /dev ,
e.g. /dev/lp0
Linux Device Drivers (cont.)
1. Understand the device characteristic and supported
commands.
2. Map device specific operations to unix file operation
3. Select the device name (user interface)
∗ Namespace (2-3 characters, /dev/lp0)
1. (optional) select a major number and minor (a device
special file creation) for VFS interface
∗ Mapping the number to right device sub-routines
1. Implement file interface subroutines
2. Compile the device driver
3. Install the device driver module with loadable kernel
module (LKM)
4. or Rebuild (compile) the kernel
General implementation steps
∗ Pooling (or synchronous)
∗ Interrupt based
Read/write (I/O)
int init_module(void) /*used for all initialition stuff*/
{
/* Register the character device (atleast try) */
Major = register_chrdev(0,
DEVICE_NAME,
&Fops);
:
}
void cleanup_module(void) /*used for a clean shutdown*/
{ret = unregister_chrdev(Major, DEVICE_NAME);
...
}
Register and unregister device
∗ compile
-Wall -DMODULE -D__KERNEL__ -DLINUX –DDEBUG -I /usr/include/linux/version.h
-I/lib/modules/`uname -r`/build/include
∗ Install the module
%insmod module.o
∗ List the module
%lsmod
∗ If you let the system pick Major number, you can find the
major number (for special creation) by
% more /proc/devices
∗ Make a special file
% mknod /dev/device_name c major minor
Register and unregister device
∗ A character device driver ( c )
∗ Most devices are this type (e.g.Modem, lp, USB
∗ No buffer.
∗ A block device driver (b)
∗ through a system buffer that acts as a data cache.
∗ Hard drive controller and HDs
Device Driver Types
∗ first things first — get the pen drive’s interface associated with
our USB device driver (pen_register.ko),” consoled Pugs.
• Build the driver (.ko file) by running make.
• Load the driver using insmod.
• List the loaded modules using lsmod.
• Unload the driver using rmmod.
Implementation
∗ Lsusb>>>>>>
Snapshots Lsusb provides
detailed
information
Snapshots Pen drive in
action
∗ add_timer()
∗ Causes a function to be executed when a given amount of time has passed
∗ cli()
∗ Prevents interrupts from being acknowledged
∗ end_request()
∗ Called when a request has been satisfied or aborted
∗ free_irq()
∗ Frees an IRQ previously acquired with request_irq() or irqaction()
∗ get_user*()
∗ Allows a driver to access data in user space, a memory area distinct from the kernel
∗ inb(), inb_p()
∗ Reads a byte from a port. Here, inb() goes as fast as it can, while inb_p() pauses before returning.
∗ irqaction()
∗ Registers an interrupt like a signal.
∗ IS_*(inode)
∗ Tests if inode is on a file system mounted with the corresponding flag.
∗ kfree*()
∗ Frees memory previously allocated with kmalloc()
∗ kmalloc()
∗ Allocates a chu nk of memory no larger than 4096 bytes.
∗ MAJOR()
∗ Reports the major device number for a device.
∗ MINOR()
∗ Reports the minor device number for a device.
kernel functions
∗ memcpy_*fs()
∗ Copies chunks of memory between user space and kernel space
∗ outb(), outb_p()
∗ Writes a byte to a port. Here, outb() goes as fast as it can, while outb_p() pauses before returning.
∗ printk()
∗ A version of printf() for the kernel.
∗ put_user*()
∗ Allows a driver to write data in user space.
∗ register_*dev()
∗ Registers a device with the kernel.
∗ request_irq()
∗ Requests an IRQ from the kernel, and, if successful, installs an IRQ interrupt handler.
∗ select_wait()
∗ Adds a process to the proper select_wait queue.
∗ *sleep_on()
∗ Sleeps on an event, puts a wait_queue entry in the list so that the process can be awakened on that
event.
∗ sti()
∗ Allows interrupts to be acknowledged.
∗ sys_get*()
∗ System calls used to get information regarding the process, user, or group.
∗ wake_up*()
∗ Wakes up a process that has been put to sleep by the matching *sleep_on() function.
kernel functions
1. Using standard libraries: can only use kernel
functions, which are the functions you can see
in /proc/ksyms.
1. Disabling interrupts: You might need to do this for
a short time and that is OK, but if you don't enable
them afterwards, your system will be stuck
2. Changes from version to version
Pitfalls
∗ Linux Kernel API: http://kernelnewbies.org/documents/kdoc/kernel-
api/linuxkernelapi.html
∗ Kernel development tool http://www.jungo.com/products.html
∗ Linux Device Drivers 2nd Edition by Rubini & Corbet, O'Reilly Pub,
ISBN 0-596-00008-1
∗ http://www.opensourceforu.com/2011/10/usb-drivers-in-linux-1/
Resources
END

Más contenido relacionado

La actualidad más candente

Introduction to systemd
Introduction to systemdIntroduction to systemd
Introduction to systemdYusaku OGAWA
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveAlison Chaiken
 
Workshop - Linux Memory Analysis with Volatility
Workshop - Linux Memory Analysis with VolatilityWorkshop - Linux Memory Analysis with Volatility
Workshop - Linux Memory Analysis with VolatilityAndrew Case
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)shimosawa
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel DevelopmentPriyank Kapadia
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modulesdibyajyotig
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and DriversKernel TLV
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programmingMohammed Farrag
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developersAlison Chaiken
 
Linux Kernel Programming
Linux Kernel ProgrammingLinux Kernel Programming
Linux Kernel ProgrammingNalin Sharma
 
IRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the PreemptibleIRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the PreemptibleAlison Chaiken
 
Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)RajKumar Rampelli
 
Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Boden Russell
 

La actualidad más candente (20)

Linux Kernel I/O Schedulers
Linux Kernel I/O SchedulersLinux Kernel I/O Schedulers
Linux Kernel I/O Schedulers
 
Introduction to systemd
Introduction to systemdIntroduction to systemd
Introduction to systemd
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
Workshop - Linux Memory Analysis with Volatility
Workshop - Linux Memory Analysis with VolatilityWorkshop - Linux Memory Analysis with Volatility
Workshop - Linux Memory Analysis with Volatility
 
Basic of Systemd
Basic of SystemdBasic of Systemd
Basic of Systemd
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and Drivers
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Kernel modules
Kernel modulesKernel modules
Kernel modules
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
 
Linux programming - Getting self started
Linux programming - Getting self started Linux programming - Getting self started
Linux programming - Getting self started
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developers
 
Linux Kernel Programming
Linux Kernel ProgrammingLinux Kernel Programming
Linux Kernel Programming
 
IRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the PreemptibleIRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the Preemptible
 
Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)
 
Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)
 

Similar a Driver_linux

Linuxdd[1]
Linuxdd[1]Linuxdd[1]
Linuxdd[1]mcganesh
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debuggingHao-Ran Liu
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device driversAlexandre Moreno
 
Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxRajKumar Rampelli
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedureDhaval Kaneria
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedureDhaval Kaneria
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentalsBimal Jain
 
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungdns -
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System AdministrationSreenatha Reddy K R
 
Linux or unix interview questions
Linux or unix interview questionsLinux or unix interview questions
Linux or unix interview questionsTeja Bheemanapally
 
Unix Shell and System Boot Process
Unix Shell and System Boot ProcessUnix Shell and System Boot Process
Unix Shell and System Boot ProcessArvind Krishnaa
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot) Omkar Rane
 
Grub and dracut ii
Grub and dracut iiGrub and dracut ii
Grub and dracut iiplarsen67
 

Similar a Driver_linux (20)

Linuxdd[1]
Linuxdd[1]Linuxdd[1]
Linuxdd[1]
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 
Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linux
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Ch04 system administration
Ch04 system administration Ch04 system administration
Ch04 system administration
 
Ch04
Ch04Ch04
Ch04
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesung
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
 
Linux or unix interview questions
Linux or unix interview questionsLinux or unix interview questions
Linux or unix interview questions
 
Unix Shell and System Boot Process
Unix Shell and System Boot ProcessUnix Shell and System Boot Process
Unix Shell and System Boot Process
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
 
Linux admin course
Linux admin courseLinux admin course
Linux admin course
 
Device Drivers
Device DriversDevice Drivers
Device Drivers
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot)
 
Grub and dracut ii
Grub and dracut iiGrub and dracut ii
Grub and dracut ii
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
 

Más de Sayanton Vhaduri

Más de Sayanton Vhaduri (7)

CSS_Dibbo
CSS_DibboCSS_Dibbo
CSS_Dibbo
 
Result_Processing
Result_ProcessingResult_Processing
Result_Processing
 
Cell Phone Operated Land Rover
Cell Phone Operated Land RoverCell Phone Operated Land Rover
Cell Phone Operated Land Rover
 
Power Sector In Bangladesh
Power Sector In BangladeshPower Sector In Bangladesh
Power Sector In Bangladesh
 
Place_Identifier_App
Place_Identifier_AppPlace_Identifier_App
Place_Identifier_App
 
Diabetic_Monitor
Diabetic_MonitorDiabetic_Monitor
Diabetic_Monitor
 
Memento pattern
Memento patternMemento pattern
Memento pattern
 

Driver_linux

  • 1. Linux USB Device Driver Submitted By: Sayanton Vhaduri Dibbo
  • 2. ∗ Overview ∗ Device Driver ∗ User & Kernel Interface ∗ Loadable Kernel Module (LKM) ∗ General implementation steps ∗ Register and unregister device ∗ Device Driver Types ∗ kernel functions ∗ Pitfalls Contents
  • 3. ∗ Write a device driver for a pseudo stack device ∗ Idea fromhttp://www.cs.swarthmore.edu/~newhall/cs45/f01/proj5.html ∗ Linux device type supports the following operations ∗ Open: only one is allowed. ∗ Write: writes an char string to top of the device stack. Error if stack is empty ∗ Read: reads an item from top of the device stack. Error if stack is empty ∗ Release: release the device ∗ Install with LKM. ∗ Test: It will be a dedicated standalone machine in the lab. Root password may be given out. If you mess up, you will re-install the Overview
  • 4. ∗ A programming module with interfaces ∗ Communication Medium between application/user and hardware ∗ In Unix, ∗ Kernel module ∗ device driver interface = file interface ∗ What are normal operations? ∗ Block vs. character What is a device driver?
  • 5. User program & Kernel interface Note: This picture is excerpted from Write a Linux Hardware Device Driver, Andrew O’Shauqhnessy, Unix world
  • 6. USB Subsystem in LINUX A top-to-bottom view of the USB subsystem in Linux.
  • 7. ∗ A new kernel module can be added on the fly (while OS is still running) ∗ LKMs are often called “kernel modules” ∗ They are not user program Loadable Kernel Module (LKM)
  • 8. ∗ Device drivers ∗ Filesystem driver (one for ext2, MSDOS FAT16, 32, NFS) ∗ System calls ∗ Network Drivers ∗ TTY line disciplines. special terminal devices. ∗ Executable interpreters. Types of LKM
  • 9. ∗ Every LKM consist of two basic functions (minimum) : int init_module(void) /*used for all initialition stuff*/ { ... } void cleanup_module(void) /*used for a clean shutdown*/ { ... } ∗ Loading a module - normally retricted to root - is managed by issuing the follwing command: # insmod module.o Basic LKM (program)
  • 10. ∗ insmod ∗ Insert an LKM into the kernel. ∗ rmmod ∗ Remove an LKM from the kernel. ∗ depmod ∗ Determine interdependencies between LKMs. ∗ kerneld ∗ Kerneld daemon program ∗ ksyms ∗ Display symbols that are exported by the kernel for use by new LKMs. ∗ lsmod ∗ List currently loaded LKMs. ∗ modinfo ∗ Display contents of .modinfo section in an LKM object file. ∗ modprobe ∗ Insert or remove an LKM or set of LKMs intelligently. For example, if you must load A before loading B, Modprobe will automatically load A when you tell it to load B. LKM Utilities cmd
  • 11. ∗ Create a special device file % mknode /dev/driver c 40 0 ∗ Insert a new module % insmod modname ∗ Remove a module ∗ %rmmod modname ∗ List module % lsmod Or % more /proc/modules audio 37840 0 cmpci 24544 0 soundcore 4208 4 [audio cmpci] nfsd 70464 8 (autoclean) Common LKM util cmd
  • 12. ∗ A set of API subroutines (typically system calls) interface to hardware ∗ Hide implementation and hardware-specific details from a user program ∗ Typically use a file interface metaphor ∗ Device is a special file Linux Device Drivers
  • 13. ∗ Manage data flow between a user program and devices ∗ A self-contained component (add/remove from kernel) ∗ A user can access the device via file name in /dev , e.g. /dev/lp0 Linux Device Drivers (cont.)
  • 14. 1. Understand the device characteristic and supported commands. 2. Map device specific operations to unix file operation 3. Select the device name (user interface) ∗ Namespace (2-3 characters, /dev/lp0) 1. (optional) select a major number and minor (a device special file creation) for VFS interface ∗ Mapping the number to right device sub-routines 1. Implement file interface subroutines 2. Compile the device driver 3. Install the device driver module with loadable kernel module (LKM) 4. or Rebuild (compile) the kernel General implementation steps
  • 15. ∗ Pooling (or synchronous) ∗ Interrupt based Read/write (I/O)
  • 16. int init_module(void) /*used for all initialition stuff*/ { /* Register the character device (atleast try) */ Major = register_chrdev(0, DEVICE_NAME, &Fops); : } void cleanup_module(void) /*used for a clean shutdown*/ {ret = unregister_chrdev(Major, DEVICE_NAME); ... } Register and unregister device
  • 17. ∗ compile -Wall -DMODULE -D__KERNEL__ -DLINUX –DDEBUG -I /usr/include/linux/version.h -I/lib/modules/`uname -r`/build/include ∗ Install the module %insmod module.o ∗ List the module %lsmod ∗ If you let the system pick Major number, you can find the major number (for special creation) by % more /proc/devices ∗ Make a special file % mknod /dev/device_name c major minor Register and unregister device
  • 18. ∗ A character device driver ( c ) ∗ Most devices are this type (e.g.Modem, lp, USB ∗ No buffer. ∗ A block device driver (b) ∗ through a system buffer that acts as a data cache. ∗ Hard drive controller and HDs Device Driver Types
  • 19. ∗ first things first — get the pen drive’s interface associated with our USB device driver (pen_register.ko),” consoled Pugs. • Build the driver (.ko file) by running make. • Load the driver using insmod. • List the loaded modules using lsmod. • Unload the driver using rmmod. Implementation
  • 20. ∗ Lsusb>>>>>> Snapshots Lsusb provides detailed information
  • 21. Snapshots Pen drive in action
  • 22. ∗ add_timer() ∗ Causes a function to be executed when a given amount of time has passed ∗ cli() ∗ Prevents interrupts from being acknowledged ∗ end_request() ∗ Called when a request has been satisfied or aborted ∗ free_irq() ∗ Frees an IRQ previously acquired with request_irq() or irqaction() ∗ get_user*() ∗ Allows a driver to access data in user space, a memory area distinct from the kernel ∗ inb(), inb_p() ∗ Reads a byte from a port. Here, inb() goes as fast as it can, while inb_p() pauses before returning. ∗ irqaction() ∗ Registers an interrupt like a signal. ∗ IS_*(inode) ∗ Tests if inode is on a file system mounted with the corresponding flag. ∗ kfree*() ∗ Frees memory previously allocated with kmalloc() ∗ kmalloc() ∗ Allocates a chu nk of memory no larger than 4096 bytes. ∗ MAJOR() ∗ Reports the major device number for a device. ∗ MINOR() ∗ Reports the minor device number for a device. kernel functions
  • 23. ∗ memcpy_*fs() ∗ Copies chunks of memory between user space and kernel space ∗ outb(), outb_p() ∗ Writes a byte to a port. Here, outb() goes as fast as it can, while outb_p() pauses before returning. ∗ printk() ∗ A version of printf() for the kernel. ∗ put_user*() ∗ Allows a driver to write data in user space. ∗ register_*dev() ∗ Registers a device with the kernel. ∗ request_irq() ∗ Requests an IRQ from the kernel, and, if successful, installs an IRQ interrupt handler. ∗ select_wait() ∗ Adds a process to the proper select_wait queue. ∗ *sleep_on() ∗ Sleeps on an event, puts a wait_queue entry in the list so that the process can be awakened on that event. ∗ sti() ∗ Allows interrupts to be acknowledged. ∗ sys_get*() ∗ System calls used to get information regarding the process, user, or group. ∗ wake_up*() ∗ Wakes up a process that has been put to sleep by the matching *sleep_on() function. kernel functions
  • 24. 1. Using standard libraries: can only use kernel functions, which are the functions you can see in /proc/ksyms. 1. Disabling interrupts: You might need to do this for a short time and that is OK, but if you don't enable them afterwards, your system will be stuck 2. Changes from version to version Pitfalls
  • 25. ∗ Linux Kernel API: http://kernelnewbies.org/documents/kdoc/kernel- api/linuxkernelapi.html ∗ Kernel development tool http://www.jungo.com/products.html ∗ Linux Device Drivers 2nd Edition by Rubini & Corbet, O'Reilly Pub, ISBN 0-596-00008-1 ∗ http://www.opensourceforu.com/2011/10/usb-drivers-in-linux-1/ Resources
  • 26. END