Linux device driver

1,027 views
901 views

Published on

Linux kernel and Device Driver( Example in how to make kernel module.)

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,027
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
55
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Linux device driver

  1. 1. Linux Device Driver
  2. 2. Agenda History & Why Linux kernel? Device Driver.  Purpose & Design  Kernel mode & User mode  Development  Application & API
  3. 3. History and Why Linux kernel? First developed by Linus Torvals. Linux base on UNIX standard. Workgroup for implement driver & patch with kernel.org. ”Just for fun” - Linux Torvals History.
  4. 4. Pupose & Design Connection between Hardware and Software.  Design communicate on logical layer ( Port : ttyS,lp,hd) and physical layer(Handle stardard of communication protocol).  Linux kernel (.ko file type) & Microsoft (.sys file type ) kernel( Monolithic,Micro,Hybird )
  5. 5. Linux boot sequence on x86 x86 Real Mode BIOS Bootloader ( GRUB/LILO ) Real Mode Kernel X86 Protected Arch/x86/boot/pm.c Mode Protected Mode kernel The init Process User Processes and Daemons Booting up,Essential Linux Device Drivers-Venkateswaran.
  6. 6. User & Kernel mode. Kernel Mode  It can execute any CPU instruction and reference any memory address. Kernel mode is generally reserved for the lowest-level”.  Most, ”trusted functions of the operating system”. User Mode  In User mode, the executing code has no ability to directly access hardware or reference memory.  Code running in user mode must delegate to system APIs to access hardware or memory. Understanding user & kernel mode,Coding Horror-Jeff Atwood
  7. 7. Development Linux System Call. Device Drivers Development Supporting device drivers. Kernel Programming Environment.
  8. 8. Linux System Call Executing in kernel mode.  Kernel mode recognize and particular action is require from the device.  Call to device routine which pass user process to device routine.  Device routine may be shared simulataneously by user application
  9. 9. Device Drivers Development Supporting device drivers. A set of routines that communicate with a hardware device and provide a uniform interface to the operating system kernel. A self-contained component that can be added to, or removed from, the operating system dynamically. Management of data flow and c ontrol between user programs and a peripheral device. A user-defined section of the kernel that allows a program or a peripheral device to appear as a `` /dev device to the rest of the systems software. Write a Linux Hardware Device Driver.FreeSoftware Mag.
  10. 10. Device Driver Programming % make#include <linux/init.h>#include <linux/module.h> make[1]: Entering directory `/usr/src/linux-2.6.10MODULE_LICENSE("Dual BSD/GPL"); CC [M] /home/ldd3/src/misc-modules/hello.o Building modules, stage 2.static int hello_init(void) MODPOST{ CCprintk(KERN_ALERT "Hello, worldn"); /home/ldd3/src/misc-modules/hello.mod.oreturn 0; LD [M] /home/ldd3/src/misc-modules/hello.ko} make[1]: Leaving directory `/usr/src/linux-2.6.10static void hello_exit(void) % su{ root# insmod ./hello.koprintk(KERN_ALERT "Goodbye, cruel worldn"); Hello, world} root# rmmod hello Goodbye cruel worldmodule_init(hello_init); root#module_exit(hello_exit); Linux kernel in a nutshell,3rd-Greg Kroah-Hartman

×