Linux Kernel Module Programming

Slides:



Advertisements
Similar presentations
Hardware Lesson 3 Inside your computer.
Advertisements

There are 3 basic steps to move information or data through the computer. The 1st step is when you give information to the computer it is called INPUT.
DEVICE DRIVER VINOD KAMATH CS691X PROJECT WORK. Introduction How to write/install device drivers Systems, Kernel Programming Character, Block and Network.
Computer System Laboratory
Devices and Drivers (Chapter 7) Khattab Alhabashi UNIX System Administration.
David Abarca, Instructor Del Mar College Computer Science and Information Technology Department Computer Corner Computer Corner.
COMPUTER SYSTEM CAN BE DIVIDED INTO : 1- General Computer 2- Special Computer.
Chapter 12 Installing and Maintaining Hardware in a Linux Environment Hardware Terms, Concepts, and Components Hardware Installation, Configuration,
52 Advanced Operating Systems Writing Device Drivers.
Computer Terminology … Remember: Knowledge is Power!
Embedded System Programming Introduction to Device Drivers.
Computer Hardware.
Xuan Guo Chapter 1 What is UNIX? Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, 2003 Original Notes.
Word Processing, Web Browsing, File Access, etc. Windows Operating System (Kernel) Window (GUI) Platform Dependent Code Virtual Memory “Swap” Block Data.
Information Technology
Operating Systems Who’s in charge in there?. Types of Software Application Software : Does things we want to do System Software : Does things we need.
Linux Installation and Administration – Lesson 5 Tutor: George Papamarkos Topic: Devices in Linux.
An Introduction To Computer Hardware
Configuration.
1 Lecture 20: I/O n I/O hardware n I/O structure n communication with controllers n device interrupts n device drivers n streams.
How Hardware and Software Work Together
1 What is a Kernel The kernel of any operating system is the core of all the system’s software. The only thing more fundamental than the kernel is the.
Troubleshooting and Performance
Kernel Modules. Kernel Module Pieces of code that can be loaded and unloaded into the kernel upon demand. Compiled as an independent program With appropriate.
SAPC Hardware Pentium CPU (or 486) 4M usable memory no hard disk; boot from floppy no keyboard or monitor or mouse COM2 serial port: used for console i/o.
LINUX System : Lecture 7 Bong-Soo Sohn Lecture notes acknowledgement : The design of UNIX Operating System.
Computer Systems Mrs. Butera. Computer Systems Hardware Software.
Linux Kernel Management. Module 9 – Kernel Administration ♦ Overview The innermost layer of Linux operating system is the kernel, which is a thin layer.
Computer Basics Common Components
An Introduction to Device Drivers Ted Baker  Andy Wang COP 5641 / CIS 4930.
Computer Hardware. The Desk Top Computer A PC is a general-purpose information processing device. It can take data from a person (through the keyboard.
Page 1 Printing & Terminal Services Lecture 8 Hassan Shuja 11/16/2004.
CSC414 “Introduction to UNIX/ Linux” Lecture 2. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
ICOM Noack Linux I/O structure Device special files Device switch tables and fops How the kernel finds a device Parts of a device driver or module.
Computer Parts Review. A small data storage device that uses flash memory. A. USB B. CPU C. Flash Drive D. CD Drive.
Kernel Modules – Introduction CSC/ECE 573, Sections 001 Fall, 2012.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
OPERATING SYSTEMS (OS) By the end of this lesson you will be able to explain: 1. What an OS is 2. The relationship between the OS & application programs.
The Personal Computer. Input devices & accessories.
Identify internal hardware devices (e. g
Introduction to Operating Systems Concepts
Input/Output (I/O) Important OS function – control I/O
Linux Details: Device Drivers
Operating System Review
Information Technology
UBUNTU INSTALLATION
Avani R.Vasant V.V.P. Engineering College
Linux Operating System Architecture
Operating System Structure
CS703 - Advanced Operating Systems
Introduction to the Kernel and Device Drivers
Computer System Basics- The Pieces & Parts
Operating System Review
An Introduction to Device Drivers
CPSC 457 Operating Systems
0. What is a Computer?.
SAPC Hardware Pentium CPU (or 486) 4M usable memory
Linux Details: Device Drivers
Linux Architecture Overview.
Chapter 2: The Linux System Part 5
LINUX System : Lecture 7 Lecture notes acknowledgement : The design of UNIX Operating System.
1.00 Examine the role of hardware and software.
Computer System Laboratory
ITEC 1011 Introduction to Information Technologies 0. What is a Computer?
Understanding input, output and storage devices
Chapter 1 What is UNIX? Graham Glass and King Ables,
Operating System Concepts
Operating System Concepts
Computer Electronic device Accepts data - input
Presentation transcript:

Linux Kernel Module Programming Arş. Grv. R. Can AYGÜN

Outline Linux Kernel Kernel Modules Device Drivers Parallel Port Device Driver Implementation

Linux Kernel Monolithic kernel, Preemptive scheduling But not a static kernel like the traditional monolithic kernels. Device drivers can be load to kernel as “Module”. Abstraction of underlaying hardware File system management, CPU scheduling, memory management, Networking, Security

Linux Kernel

Kernel Module Modules are pieces of code that can be loaded and unloaded into the kernel upon demand Extents the kernel functionality No reboot required to use new functionality Loadable kernel modules can be device drivers,additional file system supports and new system calls

Kernel Module ~ Operations List running modules → lsmod Insert a module to kernel → insmod or modprobe Delete a module from kernel → rmmod

Device Driver A driver is the part of the OS that manages communication with devices. Peripheral or internal devices allow users to communicate with the computer. keyboards, monitors, floppy and hard disks, CD-ROMs, printers, mice (serial/parallel), networks, modems, etc.

Device Drivers Character Device Drivers: Write and read operations are done char by char Works in Blocking Mode; write and wait, synchronously such as; LPT printer Block Device Drivers: Write and read → block by block Working in Asynchronous mode. Such as; usb drives, mouse

Device File Interface between user space and kernel User space applications can only access device via device file Device files are placed in /dev directory A major and minor number must be assigned to any device file.

Parallel Port Char Device Driver Implementation Output of the parallel port will be showed via led lambs.

Parallel Port Pin Out

Breadboard Setup - 1

Breadboard Setup - 2

Parallel Port Device Driver Implementation Steps : Writing the module code Creating a make file which includes kernel libraries to compile the code as loadable kernel module Check parallel port availability → cat proc/ioports (parallel port – ioport number: 0x378 ) Add to blacklist other drivers which use the parallel port(if it is necessary). /etc/modprobe.d/parport_pc.conf Edit parport_pc.conf's inside as “blacklist parport_pc” Restart the computer Create device file → mknod dev/parlelport c 61 0 Give permissions to device file chmod 666 /dev/parlelport İnstall our module to kernel → insmod pardrive.ko Check if our module controls the parallel port or not ? cat proc/ioports Testing: echo –n A >/dev/parlelport

References http://tldp.org/LDP/lkmpg/2.6/html/ http://www.tuxradar.com/content/how-linux-kernel-works http://www.linuxjournal.com/article/7353?page=0,1 http://matthias.vallentin.net/blog/2007/04/writing-a-linux- kernel-driver-for-an-unknown-usb-device/ http://www.jespersaur.com/drupal/book/export/html/21 http://d4web.net/sths/TEJ/U04Interfacing/A01Parallel/parallel Port.html