CS4101 嵌入式系統概論 I/O Drivers Prof. Chung-Ta King

Slides:



Advertisements
Similar presentations
LAB 9: Environment Setup for Tower System Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
Advertisements

File I/O Lesson CS1313 Spring File I/O Lesson Outline 1.File I/O Lesson Outline 2.File I/O Using Redirection #1 3.File I/O Using Redirection #2.
CS 206 Introduction to Computer Science II 01 / 21 / 2009 Instructor: Michael Eckmann.
Introduction to Systems Architecture Kieran Mathieson.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
C Arrays. One-Dimensional Arrays Proper ways of declare an array in C: int hours[ 24]; double Temp [24]; int test_score [15] = { 77, 88, 99, 100, 87,
CS2422 Assembly Language and System Programming High-Level Language Interface Department of Computer Science National Tsing Hua University.
CS4101 嵌入式系統概論 RTOS and MQX Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from Freescale; Prof.
TM Freescale, the Freescale logo, AltiVec, C-5, CodeTest, CodeWarrior, ColdFire, C-Ware, mobileGT, PowerQUICC, StarCore, and Symphony are trademarks of.
Outline Introduction to MQX Initializing and starting MQX
LAB 11: Task Synchronization Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
Real-time Systems Lab, Computer Science and Engineering, ASU Linux Input Systems (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
Unit R005: Understanding Computer Systems Introduction System Software Software (i.e., programs) used to control the hardware directly Used to run the.
©G. Millbery 2003Systems and User Interface SoftwareSlide 1 Self Documenting Systems  Systems where no external documentation is necessary  Includes:
Department of Electrical Engineering, National Taiwan Ocean University NuMicro MCU Learning Board SDK Installation 1/29/2015 Richard.
LAB 12: Timer and Interrupt Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
Lesson 1 Operating Systems, Part 1. Objectives Describe and list different operating systems Understand file extensions Manage files and folders.
Lecture 8a: File I/O BJ Furman 21MAR2011. Learning Objectives Explain what is meant by a data stream Explain the concept of a ‘file’ Open and close files.
LAB 13: IO Driver Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13.
1 2/2/05CS250 Introduction to Computer Science II Pointers.
Major OS Components CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
Computer Science 209 Software Development Packages.
Intelligent Data Systems Lab. Department of Computer Science & Engineering Python Installation guide 컴퓨터의 개념 및 실습.
File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.
Chapter 4. CONCEPT OF THE OPERATING SYSTEM MANAGING ESSENTIAL FILE OPERATIONS.
Introduction In this lab , we will learn
MQX GPIO.
Topic 2: Hardware and Software
Outline Installing Gem5 SPEC2006 for Gem5 Configuring Gem5.
Lab 7 Basic 1: Game of Memory
Introduction In this lab , we will learn
Recap More and more physical things will be augmented or embedded with computing Things become “smarter” Computing becomes ubiquitous An embedded system.
AURDINO AS EMBEDDED INDUSTRIAL CONTROLLER
Outline Introduction to digital-to-analog converter (DAC)
Outline Introduction to task synchronization MQX events MQX mutexs
Outline Introduction Centralized shared-memory architectures (Sec. 5.2) Distributed shared-memory and directory-based coherence (Sec. 5.4) Synchronization:
CS4101 嵌入式系統概論 General Purpose IO
Introduction Trace-driven simulation is frequently used to evaluate the performance of memory hierarchy Trace-driven simulation is particularly useful.
CS4101 Introduction to Embedded Systems Lab 10: Tasks and Scheduling
CS4101 Introduction to Embedded Systems Lab 8: Tower System
CS501 Advanced Computer Architecture
Chapter 7 Text Input/Output Objectives
Chapter 7 Text Input/Output Objectives
CS4101 Introduction to Embedded Systems Lab 12: Task Synchronization
CS4101 Introduction to Embedded Systems Lab 11: Sensors
CS4101 Introduction to Embedded Systems Lab 1: General Purpose IO
CS4101 Introduction to Embedded Systems Lab 13: Task Synchronization
Chapter 7 Text Input/Output Objectives
Instructor : Ahmed Alalawi Slides from Chung –Ta King
CS4101 Introduction to Embedded Systems Lab 9: NuMaker ADC and LCD
CS4101 嵌入式系統概論 General Purpose IO
CS4101 Introduction to Embedded Systems Design and Implementation
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 2: Timer and Clock Prof. Chung-Ta King Department of Computer Science National.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 3: Interrupt Prof. Chung-Ta King Department of Computer Science National Tsing.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 6: Serial Communication Prof. Chung-Ta King Department of Computer Science National.
Writing and Testing Your First RTOS Project with MQX
Threads and Cooperation
NetSilicon & Digi Confidential
File I/O Lesson Outline
Manipulating File IO in Visual C++
Computer Fundamentals
CS4101 嵌入式系統概論 RTOS Prof. Chung-Ta King Department of Computer Science
Computer System Laboratory
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
EECE.2160 ECE Application Programming
Department of Computer Science
CS4101 嵌入式系統概論 Device Drivers
Presentation transcript:

CS4101 嵌入式系統概論 I/O Drivers Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan (Materials from How to Develop I/O Drivers for MQX, Freescale MQX I/O Drivers Users Guide)

Outline Basics of I/O device drivers Null driver Random number generator driver

I/O Device Drivers Dynamically installed software packages that provide a direct interface to hardware Driver installation: Each device driver has a driver-specific installation function, io_device_install(), which is called in init_bsp.c under “mqx\source\bsp\” directory. The installation function then calls _io_dev_install() to register the device with MQX. To install a new device driver, the init_bsp.c needs to be modified and the BSP rebuilt

I/O Device Drivers Device names Device name must end with :, e.g. _io_mfs_install("mfs1:" ...) Characters following : are information passed to device driver by fopen() call, e.g., fopen("mfs1:bob.txt") opens file bob.txt on device mfs1: I/O device drivers provide following services: _io_device_open: required _io_device_close: required _io_device_read: optional _io_device_write: optional _io_device_ioctl: optional

Null Driver The null device driver is an I/O device that functions as a device driver but does not perform any work. Code at “mqx\source\io\io_null\”

Null Driver _mqx_uint _io_null_install(char_ptr identifier) /* “idetifier” identifies the device for fopen */ { _mqx_uint result; result = _io_dev_install(identifier, _io_null_open, _io_null_close, _io_null_read, _io_null_write, _io_null_ioctl, NULL); return result; } 5 5

Null Driver /* This function is called when the user calls fopen. It prepares the driver for subsequent read, write, and ioctl operations.*/ _mqx_int _io_null_open(MQX_FILE_PTR fd_ptr, char_ptr open_name_ptr, char_ptr flags) { /* Nothing to do */ return(MQX_OK); } 6 6

Null Driver _mqx_int _io_null_read(MQX_FILE_PTR fd_ptr, char_ptr data_ptr, _mqx_int num) { /* Body */ return(0); } /* Endbody */ _mqx_int _io_null_ioctl(MQX_FILE_PTR fd_ptr, _mqx_uint cmd, pointer param_ptr) return IO_ERROR_INVALID_IOCTL_CMD; ... 7 7

Using Null Driver #include <my_null_io.h> #define MY_TASK 5 extern void my_task(uint_32); TASK_TEMPLATE_STRUCT MQX_template_list[] = { {MY_TASK, my_task, 1500, 9, "null_test", MQX_AUTO_START_TASK, 0, 0}, {0} }; void my_task(uint_32 initial_data) { FILE_PTR null_file; uint_8 data[10]; if (IO_OK != _io_my_null_install("null:")) { printf("Error opening Null\n"); } 8 8

Using Null Driver if (NULL == (null_file = fopen("null:", NULL ))) { printf("Opening NULL device driver failed.\n"); _mqx_exit(-1); } if (write(null_file, data, 4 ) != 4) { printf("Writing to NULL driver failed.\n"); fclose(null_file); printf ("NULL driver working\n"); _mqx_exit(0); 9 9