Scrivere device driver su Linux. Better Embedded 2012 Andrea Righi

Size: px
Start display at page:

Download "Scrivere device driver su Linux. Better Embedded 2012 Andrea Righi"

Transcription

1 Scrivere device driver su Linux

2 Agenda Overview Kernel-space vs user-space programming Hello, world! kernel module Writing a character device driver Example(s) Q/A

3 Overview

4 What's a kernel? The kernel provides an abstraction layer for the applications to use the physical hardware resources Kernel basic facilities Process management Memory management Device management System call interface

5 Linux kernel key features Portability Compatible with the POSIX standard Reliability (hard and detailed code review process) Modularity (drivers and features can be loaded/unloaded at runtime) Source code availability (GPLv2)

6

7 Kernel-space vs user-space programming

8 User space Good for debugging (gdb) Lots of user-space libraries available Unpredictable latency (context switch, scheduler, syscall,...) Overhead Impossibility to fully interact with interrupt routines Impossibility to access certain memory address More difficult to share certain features with other drivers Reliability: user processes can be terminated upon critical system events (OOM, filesystem errors, etc.)

9 Kernel space Written in C and assembly No debugging tool (kgdb, UML,...) Bugs can hang the entire system User memory is swappable, kernel memory can't be swapped out Kernel stack size is small (8K / 4K - THREAD_SIZE_ORDER) Floating point is forbidden Userspace libraries are not available Linux kernel must be portable (this is important if you consider to contribute mainstream) Closed source kernel modules taint the kernel

10 Hello, world! kernel module

11 Makefile NAME=hello ifndef KERNELRELEASE PWD := $(shell pwd) all: $(MAKE) -C /lib/modules/`uname -r`/build SUBDIRS=$(PWD) modules clean: rm -f *.o *.ko *.mod.*.*.cmd Module.symvers modules.order rm -rf.tmp_versions else obj-m := $(NAME).o endif

12 #include <linux/init.h> #include <linux/module.h> hello.c static int init hello_init(void) { printk(kern_info "Hello, world!\n"); return 0; } static void exit hello_exit(void) { printk(kern_info "Goodbye\n"); } module_init(hello_init); module_exit(hello_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Andrea Righi <>"); MODULE_DESCRIPTION("BetterEmbedded hello world example");

13 Writing a character device driver

14 Kernel interfaces virtual filesystem: procfs/sysfs/cgroupfs/configfs character devices block devices network devices syscall socket: netlink (AF_NETLINK)

15 Character vs block devices Character devices: Access the resource as a stream of bytes serial port, framebuffer, input devices, video capture devices, sound devices, I2C, SPI gateways, etc. Block devices: Access the resource as an array of fixed-size blocks hard disks, DVD drives, USB storage devices, SD/MMC cards, etc.

16 Major/minor numbers Used to map a device driver to a device file (/dev/) Major: identifies the particular device driver Minor: identifies a particular device Example: /dev/sda = block (8,0) major: 8 (SCSI driver) minor: 0 (first disk detected) /dev/zero = character (1,5) /dev/null = character (1,3)

17 Virtual memory Each process can see more memory than the physical memory actually available in the system

18 Virtual memory x86_64: overview Virtual memory (64-bit) Physical memory 0xfffffffffff xffffffff xffffc7ffffffffff 0xffff Kernel space (2GB) Physical RAM (64TB) 64TB 0 Kernel space 0x00007fffffffffff User space (128TB) User space 0x

19 Examples

20 rawmem: requirements Implement a character device that allows to map a virtual address in user-space to a generic physical memory address The mapped pages can be in kernel space, I/O mapped memory, or even a memory areas that belong to different user-space process

21 File operations /* File operations implemented for our rawmem device */ static const struct file_operations rawmem_fops = {.open = rawmem_open,.release = rawmem_release,.mmap = rawmem_mmap,.owner = THIS_MODULE, };

22 rawmem: core implementation static int rawmem_mmap(struct file *file, struct vm_area_struct *vma) { return remap_pfn_range(vma, /* virtual address */ vma->vm_start, /* page frame number: physical address */ vma->vm_pgoff, /* size of the area being mapped */ vma->vm_end - vma->vm_start, /* requested protection */ vma->vm_page_prot); } static struct file_operations rawmem_fops = {.mmap = rawmem_mmap, };

23 rawmem: detailed implementation Look at the source code...

24 References J. Corbet, A. Rubini, G. Kroah-Hartman: Linux Device Drivers 3rd Edition Linux cross reference: Linux weekly news: rawmem source code example Kernel source code...

25 Q/A You're very welcome! #bem2012

26

Linux drivers - Exercise

Linux drivers - Exercise Embedded Realtime Software Linux drivers - Exercise Scope Keywords Prerequisites Contact Learn how to implement a device driver for the Linux OS. Linux, driver Linux basic knowledges Roberto Bucher, roberto.bucher@supsi.ch

More information

Linux Kernel Modules & Device Drivers April 9, 2012

Linux Kernel Modules & Device Drivers April 9, 2012 Linux Kernel Modules & Device Drivers April 9, 2012 Pacific University 1 Resources Linux Device Drivers,3rd Edition, Corbet, Rubini, Kroah- Hartman; O'Reilly kernel 2.6.10 we will use 3.1.9 The current

More information

Linux Kernel Module Programming. Tushar B. Kute,

Linux Kernel Module Programming. Tushar B. Kute, Linux Kernel Module Programming Tushar B. Kute, http://tusharkute.com Kernel Modules Kernel modules are piece of code, that can be loaded and unloaded from kernel on demand. Kernel modules offers an easy

More information

Abstraction via the OS. Device Drivers. Software Layers. Device Drivers. Types of Devices. Mechanism vs. Policy. Jonathan Misurda

Abstraction via the OS. Device Drivers. Software Layers. Device Drivers. Types of Devices. Mechanism vs. Policy. Jonathan Misurda Abstraction via the OS Device Drivers Jonathan Misurda jmisurda@cs.pitt.edu Software Layers level I/O software & libraries Device independent OS software Device drivers Interrupt handlers Hardware Operating

More information

Kernel Modules. Kartik Gopalan

Kernel Modules. Kartik Gopalan Kernel Modules Kartik Gopalan Kernel Modules Allow code to be added to the kernel, dynamically Only those modules that are needed are loaded. Unload when no longer required - frees up memory and other

More information

CS5460/6460: Operating Systems. Lecture 24: Device drivers. Anton Burtsev April, 2014

CS5460/6460: Operating Systems. Lecture 24: Device drivers. Anton Burtsev April, 2014 CS5460/6460: Operating Systems Lecture 24: Device drivers Anton Burtsev April, 2014 Device drivers Conceptually Implement interface to hardware Expose some high-level interface to the kernel or applications

More information

Software Layers. Device Drivers 4/15/2013. User

Software Layers. Device Drivers 4/15/2013. User Software Layers Device Drivers User-level I/O software & libraries Device-independent OS software Device drivers Interrupt handlers Hardware User Operating system (kernel) Abstraction via the OS Device

More information

Tecniche di debugging nel kernel Linux. Andrea Righi -

Tecniche di debugging nel kernel Linux. Andrea Righi - Tecniche di debugging nel kernel Linux Agenda Overview (kernel programming) Kernel crash classification Debugging techniques Example(s) Q/A What's a kernel? The kernel provides an abstraction layer for

More information

/dev/hello_world: A Simple Introduction to Device Drivers under Linux

/dev/hello_world: A Simple Introduction to Device Drivers under Linux Published on Linux DevCenter (http://www.linuxdevcenter.com/) See this if you're having trouble printing code examples /dev/hello_world: A Simple Introduction to Device Drivers under Linux by Valerie Henson

More information

Itron Riva Kernel Module Building

Itron Riva Kernel Module Building Itron Riva Kernel Module Building Table of Contents Introduction... 2 Creating the Project Directory... 2 Creating the Makefile... 3 Creating main.c... 5 Building The Kernel Module... 6 1 Introduction

More information

Linux Loadable Kernel Modules (LKM)

Linux Loadable Kernel Modules (LKM) Device Driver Linux Loadable Kernel Modules (LKM) A way dynamically ADD code to the Linux kernel LKM is usually used for dynamically add device drivers filesystem drivers system calls network drivers executable

More information

Virtual File System (VFS) Implementation in Linux. Tushar B. Kute,

Virtual File System (VFS) Implementation in Linux. Tushar B. Kute, Virtual File System (VFS) Implementation in Linux Tushar B. Kute, http://tusharkute.com Virtual File System The Linux kernel implements the concept of Virtual File System (VFS, originally Virtual Filesystem

More information

Device Drivers. CS449 Fall 2017

Device Drivers. CS449 Fall 2017 Device Drivers CS449 Fall 2017 Software Layers User-level I/O so7ware & libraries Device-independent OS so7ware Device drivers Interrupt handlers User OperaEng system (kernel) Hardware Device Drivers User

More information

Developing Real-Time Applications

Developing Real-Time Applications Developing Real-Time Applications Real Time Operating Systems and Middleware Luca Abeni luca.abeni@unitn.it Characterised by temporal constraints deadlines Concurrent (application: set of real-time tasks)

More information

I/O Devices. I/O Management Intro. Sample Data Rates. I/O Device Handling. Categories of I/O Devices (by usage)

I/O Devices. I/O Management Intro. Sample Data Rates. I/O Device Handling. Categories of I/O Devices (by usage) I/O Devices I/O Management Intro Chapter 5 There exists a large variety of I/O devices: Many of them with different properties They seem to require different interfaces to manipulate and manage them We

More information

ASE++ : Linux Kernel Programming

ASE++ : Linux Kernel Programming ASE++ : Linux Kernel Programming Giuseppe Lipari (giuseppe.lipari@univ-lille.fr) April 8, 2018 Contents 1 Introduction 1 2 Setting up the environment 2 3 Writing a kernel module 5 4 Other useful information

More information

Linux Device Drivers

Linux Device Drivers Linux Device Drivers Modules A piece of code that can be added to the kernel at runtime is called a module A device driver is one kind of module Each module is made up of object code that can be dynamically

More information

7.3 Simplest module for embedded Linux drivers

7.3 Simplest module for embedded Linux drivers 401 7.3 Simplest module for embedded Linux drivers Section 7.1 introduce a simple Linux program Hello World, which is run in user mode applications, we now introduce a run in kernel mode Hello World program,

More information

The device driver (DD) implements these user functions, which translate system calls into device-specific operations that act on real hardware

The device driver (DD) implements these user functions, which translate system calls into device-specific operations that act on real hardware Introduction (Linux Device Drivers, 3rd Edition (www.makelinux.net/ldd3)) Device Drivers -> DD They are a well defined programming interface between the applications and the actual hardware They hide completely

More information

I/O Management Intro. Chapter 5

I/O Management Intro. Chapter 5 I/O Management Intro Chapter 5 1 Learning Outcomes A high-level understanding of the properties of a variety of I/O devices. An understanding of methods of interacting with I/O devices. An appreciation

More information

esi-risc Development Suite Getting Started Guide

esi-risc Development Suite Getting Started Guide 1 Contents 1 Contents 2 2 Overview 3 3 Starting the Integrated Development Environment 4 4 Hello World Tutorial 5 5 Next Steps 8 6 Support 10 Version 2.5 2 of 10 2011 EnSilica Ltd, All Rights Reserved

More information

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems Deep C Multifile projects Getting it running Data types Typecasting Memory management Pointers Fabián E. Bustamante, Fall 2004 Multifile Projects Give your project a structure Modularized design Reuse

More information

Creating a system call in Linux. Tushar B. Kute,

Creating a system call in Linux. Tushar B. Kute, Creating a system call in Linux Tushar B. Kute, http://tusharkute.com x86 Protection Rings Privileged instructions Can be executed only When current privileged Level (CPL) is 0 Operating system kernel

More information

CPSC Tutorial 17

CPSC Tutorial 17 CPSC 457 - Tutorial 17 Loadable Kernel Modules Department of Computer Science University of Calgary March 27, 2012 1 / 10 Reminder Homework 4 is due to March 31, 2012 at 11:59pm (Saturday) Thursday, March

More information

SuSE Labs / Novell.

SuSE Labs / Novell. Write a real Linux driver Greg Kroah-Hartman SuSE Labs / Novell http://www.kroah.com/usb.tar.gz gregkh@suse.de greg@kroah.com Agenda Intro to kernel modules sysfs basics USB basics Driver to device binding

More information

Memory Mapping. Sarah Diesburg COP5641

Memory Mapping. Sarah Diesburg COP5641 Memory Mapping Sarah Diesburg COP5641 Memory Mapping Translation of address issued by some device (e.g., CPU or I/O device) to address sent out on memory bus (physical address) Mapping is performed by

More information

Unix (Linux) Device Drivers

Unix (Linux) Device Drivers Unix (Linux) Device Drivers Kernel module that handles the interaction with an specific hardware device, hiding its operational details behind a common interface Three basic categories Character Block

More information

REVISION HISTORY NUMBER DATE DESCRIPTION NAME

REVISION HISTORY NUMBER DATE DESCRIPTION NAME i ii REVISION HISTORY NUMBER DATE DESCRIPTION NAME iii Contents 1 The structure of a Linux kernel module 1 1.1 Install XV6...................................................... 1 1.2 Compile and load a

More information

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2 Compiling a C program CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Example of a small program Makefile Define Variables Compilation options Conclusion Berner Fachhochschule Haute

More information

CS Basics 15) Compiling a C prog.

CS Basics 15) Compiling a C prog. CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 Compiling a C program Example of a small

More information

Applying User-level Drivers on

Applying User-level Drivers on Applying User-level Drivers on DTV System Gunho Lee, Senior Research Engineer, ELC, April 18, 2007 Content Background Requirements of DTV Device Drivers Design of LG DTV User-level Drivers Implementation

More information

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University Prof. Peng Li TA: Andrew Targhetta (Lab exercise created by A Targhetta and P Gratz) Laboratory

More information

Introduction to Linux Device Drivers Recreating Life One Driver At a Time

Introduction to Linux Device Drivers Recreating Life One Driver At a Time Introduction to Linux Device Drivers Recreating Life One Driver At a Time Muli Ben-Yehuda mulix@mulix.org IBM Haifa Research Labs, Haifa Linux Club Linux Device Drivers, Technion, Jan 2004 p.1/42 why write

More information

Loadable Kernel Modules

Loadable Kernel Modules Loadable Kernel Modules Kevin Dankwardt, Ph.D. kevin.dankwardt@gmail.com Topics 1. Why loadable kernel modules? 2. Using Modules 3. Writing modules 4. Compiling & Installing Modules 5. Example : Simple

More information

Kernel hacking su Android. Better Embedded Andrea Righi

Kernel hacking su Android. Better Embedded Andrea Righi Kernel hacking su Android Agenda Overview Android Programming Android Power Management Q/A Overview What is Android OS? Linux kernel Android patches Bionic libc Dalvik VM (Java Virtual Machine) Application

More information

seven Virtual Memory Introduction

seven Virtual Memory Introduction Virtual Memory seven Exercise Goal: You will study how Linux implements virtual memory. A general architecture-independent memory model is the basis of all Linux virtual memory implementations, though

More information

Finish up OS topics Group plans

Finish up OS topics Group plans Finish up OS topics Group plans Today Finish up and review Linux device driver stuff Walk example again See how it all goes together Discuss talking to MMIO RTOS (on board) Deferred interrupts Discussion

More information

Memory Management. Fundamentally two related, but distinct, issues. Management of logical address space resource

Memory Management. Fundamentally two related, but distinct, issues. Management of logical address space resource Management Fundamentally two related, but distinct, issues Management of logical address space resource On IA-32, address space may be scarce resource for a user process (4 GB max) Management of physical

More information

CS 453: Operating Systems Programming Project 5 (100 points) Linux Device Driver

CS 453: Operating Systems Programming Project 5 (100 points) Linux Device Driver CS 453: Operating Systems Programming Project 5 (100 points) Linux Device Driver 1 Setup In this assignment, we will write a simple character driver called booga. Please do a git pull --rebase in your

More information

Final Step #7. Memory mapping For Sunday 15/05 23h59

Final Step #7. Memory mapping For Sunday 15/05 23h59 Final Step #7 Memory mapping For Sunday 15/05 23h59 Remove the packet content print in the rx_handler rx_handler shall not print the first X bytes of the packet anymore nor any per-packet message This

More information

Loadable Kernel Module

Loadable Kernel Module Instituto Superior de Engenharia do Porto Mestrado em Engenharia Eletrotécnica e de Computadores Arquitetura de Computadores Loadable Kernel Module The objective of this lesson is to analyze, compile and

More information

I/O Management Software. Chapter 5

I/O Management Software. Chapter 5 I/O Management Software Chapter 5 1 Learning Outcomes An understanding of the structure of I/O related software, including interrupt handers. An appreciation of the issues surrounding long running interrupt

More information

Kernel. Kernel = computer program that connects the user applications to the system hardware Handles:

Kernel. Kernel = computer program that connects the user applications to the system hardware Handles: Kernel programming Kernel Kernel = computer program that connects the user applications to the system hardware Handles: Memory management CPU scheduling (Process and task management) Disk management User

More information

Working with Kernel Modules Lab Wind River Systems, Inc

Working with Kernel Modules Lab Wind River Systems, Inc Working with Kernel Modules Lab 2013 Wind River Systems, Inc Working with Kernel Modules Lab Objective In this lab, you will learn how to manage kernel modules in your projects, as well as how to develop

More information

Analysis of User Level Device Driver usability in embedded application

Analysis of User Level Device Driver usability in embedded application Analysis of User Level Device Driver usability in embedded application -Technique to achieve good real-time performance- Katsuya Matsubara Takanari Hayama Hitomi Takahashi Hisao Munakata IGEL Co., Ltd

More information

CEC 450 Real-Time Systems

CEC 450 Real-Time Systems CEC 450 Real-Time Systems Lecture 10 Device Interface Drivers and MMIO October 29, 2015 Sam Siewert MMIO Interfacing to Off-Chip Devices Sam Siewert 2 Embedded I/O (HW View) Analog I/O DAC analog output:

More information

MP3: VIRTUAL MEMORY PAGE FAULT MEASUREMENT

MP3: VIRTUAL MEMORY PAGE FAULT MEASUREMENT MP3: VIRTUAL MEMORY PAGE FAULT MEASUREMENT University of Illinois at Urbana-Champaign Department of Computer Science CS423 Fall 2011 Keun Soo Yim GOAL A Linux kernel module to profile VM system events

More information

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF

More information

RTAI 3.8 ON Ubuntu(9.10)-Linux-kernel :

RTAI 3.8 ON Ubuntu(9.10)-Linux-kernel : RTAI 3.8 ON Ubuntu(9.10)-Linux-kernel : 2.6.31.8 1: Installing Rtai 3.8 Manuel Arturo Deza The following Tech Report / Guide is a compendium of instructions necessary for installing RTAI 3.8 on Ubuntu

More information

Kthreads, Mutexes, and Debugging. Sarah Diesburg CS 3430 Operating Systems

Kthreads, Mutexes, and Debugging. Sarah Diesburg CS 3430 Operating Systems Kthreads, Mutexes, and Debugging Sarah Diesburg CS 3430 Operating Systems 1 Story of Kernel Development Some context 2 In the old days There were no modules or virtual machines The kernel is a program

More information

PFStat. Global notes

PFStat. Global notes PFStat Global notes Counts expand_stack returns in case of error, so the stack_low count needed to be inside transparent huge page, 2 cases : There is no PMD, we should create a transparent one (There

More information

Linux Device Driver. Amir Hossein Payberah. (Kmod & Advanced Modularization)

Linux Device Driver. Amir Hossein Payberah. (Kmod & Advanced Modularization) Linux Device Driver (Kmod & Advanced Modularization) Amir Hossein Payberah payberah@yahoo.com Contents Loading Module on Demand Intermodule Communication 2 Loading Module on Demand To make it easier for

More information

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems Programs CSCI 4061 Introduction to Operating Systems C Program Structure Libraries and header files Compiling and building programs Executing and debugging Instructor: Abhishek Chandra Assume familiarity

More information

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

More information

CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A)

CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A) CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A) Professor Adam Bates Fall 2018 Learning Objectives: Talk about the relevant skills required in MP1 Announcements: MP1

More information

What is a Linux Device Driver? Kevin Dankwardt, Ph.D. VP Technology Open Source Careers

What is a Linux Device Driver? Kevin Dankwardt, Ph.D. VP Technology Open Source Careers What is a Linux Device Driver? Kevin Dankwardt, Ph.D. VP Technology Open Source Careers kdankwardt@oscareers.com What does a driver do? Provides a more convenient interface to user-space for the hardware.

More information

Kernel Module Programming

Kernel Module Programming Kernel Module Programming Alessandro Barenghi Dipartimento di Elettronica e Informazione Politecnico di Milano barenghi - at - elet.polimi.it June 7, 2012 Recap By now, you should be familiar with... Programming

More information

Operating System Architecture. CS3026 Operating Systems Lecture 03

Operating System Architecture. CS3026 Operating Systems Lecture 03 Operating System Architecture CS3026 Operating Systems Lecture 03 The Role of an Operating System Service provider Provide a set of services to system users Resource allocator Exploit the hardware resources

More information

User Space Device Drivers Introduction and Implementation using VGAlib library

User Space Device Drivers Introduction and Implementation using VGAlib library User Space Device Drivers Introduction and Implementation using VGAlib library Prabhat K. Saraswat Btech 6th Semester Information and Communication Technology Dhirubhai Ambani Institute of Information

More information

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science High Performance Computing Lecture 1 Matthew Jacob Indian Institute of Science Agenda 1. Program execution: Compilation, Object files, Function call and return, Address space, Data & its representation

More information

Conoscere e ottimizzare l'i/o su Linux. Andrea Righi -

Conoscere e ottimizzare l'i/o su Linux. Andrea Righi - Conoscere e ottimizzare l'i/o su Linux Agenda Overview I/O Monitoring I/O Tuning Reliability Q/A Overview File I/O in Linux READ vs WRITE READ synchronous: CPU needs to wait the completion of the READ

More information

전공핵심실습 1: 운영체제론 Lecture 5. System Call

전공핵심실습 1: 운영체제론 Lecture 5. System Call 1 전공핵심실습 1: 운영체제론 Lecture 5. System Call Sungkyunkwan University Dongkun Shin Contents 2 Interrupt System Call Practice 1. Tizen App Calling a System Call Practice 2. Making a New System Call Practice

More information

Introduction to the Linux Kernel. Hao-Ran Liu

Introduction to the Linux Kernel. Hao-Ran Liu Introduction to the Linux Kernel Hao-Ran Liu The history Initially developed by Linus Torvalds in 1991 Source code is released under GNU Public License (GPL) If you modify and release a program protected

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 2: Hello World! Cristina Nita-Rotaru Lecture 2/ Fall 2013 1 Introducing C High-level programming language Developed between 1969 and 1973 by Dennis Ritchie at the Bell Labs

More information

Advanced Operating Systems #13

Advanced Operating Systems #13 http://www.pf.is.s.u-tokyo.ac.jp/class.html Advanced Operating Systems #13 Shinpei Kato Associate Professor Department of Computer Science Graduate School of Information Science and Technology

More information

Computer System Architecture. CMPT 300 Operating Systems I. Summer Segment 3: Computer System Architecture. Melissa O Neill

Computer System Architecture. CMPT 300 Operating Systems I. Summer Segment 3: Computer System Architecture. Melissa O Neill CMPT 300 Operating Systems I Computer System Architecture Summer 1999 disk disk printer tape drives on-line Segment 3: Computer System Architecture CPU disk controller printer controller tape-drive controller

More information

OS Structure. Kevin Webb Swarthmore College January 25, Relevant xkcd:

OS Structure. Kevin Webb Swarthmore College January 25, Relevant xkcd: OS Structure Kevin Webb Swarthmore College January 25, 2018 Relevant xkcd: One of the survivors, poking around in the ruins with the point of a spear, uncovers a singed photo of Richard Stallman. They

More information

Embedded Systems Programming

Embedded Systems Programming Embedded Systems Programming Work Queue and Input Processing in Linux (Module 16) Yann-Hang Lee Arizona State University yhlee@asu.edu (480) 727-7507 Summer 2014 Example of Work Structure and Handler #include

More information

Reliable C++ development - session 1: From C to C++ (and some C++ features)

Reliable C++ development - session 1: From C to C++ (and some C++ features) Reliable C++ development - session 1: From C to C++ (and some C++ features) Thibault CHOLEZ - thibault.cholez@loria.fr TELECOM Nancy - Université de Lorraine LORIA - INRIA Nancy Grand-Est From Nicolas

More information

Operating systems for embedded systems. Embedded Operating Systems

Operating systems for embedded systems. Embedded Operating Systems Operating systems for embedded systems Embedded operating systems How do they differ from desktop operating systems? Programming model Process-based Event-based How is concurrency handled? How are resource

More information

CPSC 822 MIDTERM EXAM, SPRING 2015

CPSC 822 MIDTERM EXAM, SPRING 2015 CPSC 822 MIDTERM EXAM, SPRING 2015 NAME: 1. (5) In our warm-up C code that was used to configure a NetApp file server,we see the line while(wait(&status)!=pid); The wait suspends us until we receive any

More information

Step Motor. Step Motor Device Driver. Step Motor. Step Motor (2) Step Motor. Step Motor. source. open loop,

Step Motor. Step Motor Device Driver. Step Motor. Step Motor (2) Step Motor. Step Motor. source. open loop, Step Motor Device Driver Step Motor Step Motor Step Motor source Embedded System Lab. II Embedded System Lab. II 2 Step Motor (2) open loop, : : Pulse, Pulse,, -, +5%, step,, Step Motor Step Motor ( ),

More information

PMON Module An Example of Writing Kernel Module Code for Debian 2.6 on Genesi Pegasos II

PMON Module An Example of Writing Kernel Module Code for Debian 2.6 on Genesi Pegasos II Freescale Semiconductor Application Note AN2744 Rev. 1, 12/2004 PMON Module An Example of Writing Kernel Module Code for Debian 2.6 on Genesi Pegasos II by Maurie Ommerman CPD Applications Freescale Semiconductor,

More information

Operating System System Call & Debugging Technique

Operating System System Call & Debugging Technique 1 Operating System System Call & Debugging Technique 진주영 jjysienna@gmail.com System Call 2 A way for user-space programs to interact with the kernel System Call enables application programs in user-mode

More information

Linux Kernel Development (LKD)

Linux Kernel Development (LKD) Linux Kernel Development (LKD) Session 1 Loadable Kernel Modules (LKM) Paulo Baltarejo Sousa pbs@isep.ipp.pt 2017 PBS LKD: S1 1 / 66 Disclaimer Material and Slides Some of the material/slides are adapted

More information

HOW TO INTEGRATE NFC FRONTENDS IN LINUX

HOW TO INTEGRATE NFC FRONTENDS IN LINUX HOW TO INTEGRATE NFC FRONTENDS IN LINUX JORDI JOFRE NFC READERS NFC EVERYWHERE 14/09/2017 WEBINAR SERIES: NFC SOFTWARE INTEGRATION PUBLIC Agenda NFC software integration webinar series Session I, 14th

More information

BLOCK DEVICES. Philipp Dollst

BLOCK DEVICES. Philipp Dollst BLOCK DEVICES Philipp Dollst BASICS A block driver provides access to devices that transfer randomly accessible data in fixed-size blocks disk drives, primarily. The Linux kernel sees block devices a being

More information

Quiz 12.1: Paging. Goals for Today. Quiz 12.1: Paging. Page 1. CS162 Operating Systems and Systems Programming Lecture 12.

Quiz 12.1: Paging. Goals for Today. Quiz 12.1: Paging. Page 1. CS162 Operating Systems and Systems Programming Lecture 12. Quiz 12.1: Paging CS162 Operating Systems and Systems Programming Lecture 12 Kernel/User, I/O October 14, 2013 Anthony D. Joseph and John Canny http://inst.eecs.berkeley.edu/~cs162 Q1: True _ False _ Inverse

More information

NPTEL Course Jan K. Gopinath Indian Institute of Science

NPTEL Course Jan K. Gopinath Indian Institute of Science Storage Systems NPTEL Course Jan 2012 (Lecture 17) K. Gopinath Indian Institute of Science Accessing Devices/Device Driver Many ways to access devices under linux Non-block based devices ( char ) - stream

More information

Intel Architecture. Compass Security Schweiz AG Werkstrasse 20 Postfach 2038 CH-8645 Jona

Intel Architecture. Compass Security Schweiz AG Werkstrasse 20 Postfach 2038 CH-8645 Jona Intel Architecture Compass Security Schweiz AG Werkstrasse 20 Postfach 2038 CH-8645 Jona Tel +41 55 214 41 60 Fax +41 55 214 41 61 team@csnc.ch www.csnc.ch Content Intel Architecture Memory Layout C Arrays

More information

Linux kernel. Tutorials to discover how to do some stuff on linux kernel. If you have any suggestions or if you find any problem, please report it!

Linux kernel. Tutorials to discover how to do some stuff on linux kernel. If you have any suggestions or if you find any problem, please report it! Tutorials to discover how to do some stuff on linux kernel. If you have any suggestions or if you find any problem, please report it! Important These tutorials are based on linux kernel 4.x. It is very

More information

Interrupt response times on Arduino and Raspberry Pi. Tomaž Šolc

Interrupt response times on Arduino and Raspberry Pi. Tomaž Šolc Interrupt response times on Arduino and Raspberry Pi Tomaž Šolc tomaz.solc@ijs.si Introduction Full-featured Linux-based systems are replacing microcontrollers in some embedded applications for low volumes,

More information

CSE 306/506 Operating Systems Process Address Space. YoungMin Kwon

CSE 306/506 Operating Systems Process Address Space. YoungMin Kwon CSE 306/506 Operating Systems Process Address Space YoungMin Kwon Process s Address Space Memory allocation for user processes On request, a right to use a new range of linear address is given to the process

More information

University of Texas at Arlington. CSE Spring 2018 Operating Systems Project 4a - The /Proc File Systems and mmap. Instructor: Jia Rao

University of Texas at Arlington. CSE Spring 2018 Operating Systems Project 4a - The /Proc File Systems and mmap. Instructor: Jia Rao University of Texas at Arlington CSE 3320 - Spring 2018 Operating Systems Project 4a - The /Proc File Systems and mmap Instructor: Jia Rao Introduction Points Possible: 100 Handed out: Apr. 20, 2018 Due

More information

- Knowledge of basic computer architecture and organization, ECE 445

- Knowledge of basic computer architecture and organization, ECE 445 ECE 446: Device Driver Development Fall 2014 Wednesdays 7:20-10 PM Office hours: Wednesdays 6:15-7:15 PM or by appointment, Adjunct office Engineering Building room 3707/3708 Last updated: 8/24/14 Instructor:

More information

Introduction to Computer Systems

Introduction to Computer Systems Introduction to Computer Systems Today:! Welcome to EECS 213! Lecture topics and assignments Next time:! Bits & bytes! and some Boolean algebra Fabián E. Bustamante, 2007 Welcome to Intro. to Computer

More information

Operating systems for embedded systems

Operating systems for embedded systems Operating systems for embedded systems Embedded operating systems How do they differ from desktop operating systems? Programming model Process-based Event-based How is concurrency handled? How are resource

More information

Introduction to Computer Systems

Introduction to Computer Systems Introduction to Computer Systems Today: Welcome to EECS 213 Lecture topics and assignments Next time: Bits & bytes and some Boolean algebra Fabián E. Bustamante, Spring 2010 Welcome to Intro. to Computer

More information

ECE 598 Advanced Operating Systems Lecture 22

ECE 598 Advanced Operating Systems Lecture 22 ECE 598 Advanced Operating Systems Lecture 22 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 19 April 2016 Announcements Project update HW#9 posted, a bit late Midterm next Thursday

More information

RetroBSD - a minimalistic Unix system. Igor Mokoš bsd_day Bratislava

RetroBSD - a minimalistic Unix system. Igor Mokoš bsd_day Bratislava RetroBSD - a minimalistic Unix system Igor Mokoš pito@volna.cz bsd_day Bratislava 5.11.2011 RetroBSD RetroBSD is a port of 2.11BSD Unix intended for small embedded systems Currently Microchip PIC32MX 32bit

More information

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel CIS 657 Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler (2%

More information

John A. Ronciak Staff Engineer NCG/NID/LAO Intel Corp.

John A. Ronciak Staff Engineer NCG/NID/LAO Intel Corp. John A. Ronciak Staff Engineer NCG/NID/LAO Corp. February 15-17, 17, 2000 Agenda l Learning the Cross Development Platform l Make the Device Driver IA-64 Clean l Building an IA-64 Linux Driver l Debugging

More information

I/O Management Intro. Chapter 5

I/O Management Intro. Chapter 5 I/O Management Intro Chapter 5 1 Learning Outcomes A high-level understanding of the properties of a variety of I/O devices. An understanding of methods of interacting with I/O devices. 2 I/O Devices There

More information

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent? Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler

More information

Passing Time with a SPI Framebuffer Driver

Passing Time with a SPI Framebuffer Driver Passing Time with a SPI Framebuffer Driver Matt Porter Texas Instruments February 15, 2012 Overview How did this project come about? (or how to mix work and fun) SPI display controllers and the little

More information

CS 300 Leftovers. CS460 Pacific University 1

CS 300 Leftovers. CS460 Pacific University 1 CS 300 Leftovers Pacific University 1 argc/argv The C Programming Language section 5.10, page 114 int main(int argc, char** argv) argc - number of entries in argv argv - array of character pointers containing

More information

CPSC 8220 FINAL EXAM, SPRING 2016

CPSC 8220 FINAL EXAM, SPRING 2016 CPSC 8220 FINAL EXAM, SPRING 2016 NAME: Questions are short answer and multiple choice. For each of the multiple choice questions, put a CIRCLE around the letter of the ONE correct answer. Make sure that

More information

Tolerating Malicious Drivers in Linux. Silas Boyd-Wickizer and Nickolai Zeldovich

Tolerating Malicious Drivers in Linux. Silas Boyd-Wickizer and Nickolai Zeldovich XXX Tolerating Malicious Drivers in Linux Silas Boyd-Wickizer and Nickolai Zeldovich How could a device driver be malicious? Today's device drivers are highly privileged Write kernel memory, allocate memory,...

More information

Kprobes Presentation Overview

Kprobes Presentation Overview Kprobes Presentation Overview This talk is about how using the Linux kprobe kernel debugging API, may be used to subvert the kernels integrity by manipulating jprobes and kretprobes to patch the kernel.

More information

CSC369 Lecture 2. Larry Zhang

CSC369 Lecture 2. Larry Zhang CSC369 Lecture 2 Larry Zhang 1 Announcements Lecture slides Midterm timing issue Assignment 1 will be out soon! Start early, and ask questions. We will have bonus for groups that finish early. 2 Assignment

More information