The IDE/ATA Interface How can our mini-Operating System, executing in protected mode, access the hard disk?

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

The IDE/ATA Interface How can our mini-Operating System, executing in protected mode, access the hard disk?
Chapter 4 Device Management and Disk Scheduling DEVICE MANAGEMENT Content I/O device overview I/O device overview I/O organization and architecture I/O.
Input and Output CS 215 Lecture #20.
The ATA/IDE Interface Can we write a character-mode device driver for the hard disk?
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
I/O Unit.
CS4315A. Berrached:CMS:UHD1 Operating Systems and Computer Organization Chapter 4.
CS-334: Computer Architecture
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
CS 326 Operating Systems Fall 2004 Professor Allan B. Cruse University of San Francisco.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
OS Spring’03 Introduction Operating Systems Spring 2003.
Operating Systems CS208. What is Operating System? It is a program. It is the first piece of software to run after the system boots. It coordinates the.
Computer System Overview Chapter 1. Basic computer structure CPU Memory memory bus I/O bus diskNet interface.
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
Operating Systems.
Group 7 Jhonathan Briceño Reginal Etienne Christian Kruger Felix Martinez Dane Minott Immer S Rivera Ander Sahonero.
INPUT/OUTPUT ARCHITECTURE By Truc Truong. Input Devices Keyboard Keyboard Mouse Mouse Scanner Scanner CD-Rom CD-Rom Game Controller Game Controller.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
Chapter 7 Input/Output Luisa Botero Santiago Del Portillo Ivan Vega.
Objectives To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
CHAPTER 2 OPERATING SYSTEM OVERVIEW 1. Operating System Operating System Definition A program that controls the execution of application programs and.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Interrupts and DMA CSCI The Role of the Operating System in Performing I/O Two main jobs of a computer are: –Processing –Performing I/O manage and.
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.
1. Introduction 2. Methods for I/O Operations 3. Buses 4. Liquid Crystal Displays 5. Other Types of Displays 6. Graphics Adapters 7. Optical Discs 10/01/20151Input/Output.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
I/O Example: Disk Drives To access data: — seek: position head over the proper track (8 to 20 ms. avg.) — rotational latency: wait for desired sector (.5.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Advanced Computer Architecture 0 Lecture # 1 Introduction by Husnain Sherazi.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Modes of transfer in computer
Fall 2000M.B. Ibáñez Lecture 25 I/O Systems. Fall 2000M.B. Ibáñez Categories of I/O Devices Human readable –used to communicate with the user –video display.
L/O/G/O Input Output Chapter 4 CS.216 Computer Architecture and Organization.
Computer Hardware A computer is made of internal components Central Processor Unit Internal External and external components.
The computer system’s I/O architecture is its interface to the outside world. This architecture provides a systematic means of controlling interaction.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
IT3002 Computer Architecture
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
Week1: Introduction to Computer Networks. Copyright © 2012 Cengage Learning. All rights reserved.2 Objectives 2 Describe basic computer components and.
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
بسم الله الرحمن الرحيم MEMORY AND I/O.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
ECE 456 Computer Architecture Lecture #9 – Input/Output Instructor: Dr. Honggang Wang Fall 2013.
Hands-On Microsoft Windows Server 2008 Chapter 7 Configuring and Managing Data Storage.
This slide deck is for LPI Academy instructors to use for lectures for LPI Academy courses. ©Copyright Network Development Group Module 10 Understanding.
Review ATA - IDE Project name : ATA – IDE Training Engineer : Minh Nguyen.
System Components Operating System Services System Calls.
Introduction to Operating Systems Concepts
I/O SYSTEMS MANAGEMENT Krishna Kumar Ahirwar ( )
Operating Systems (CS 340 D)
Introduction of microprocessor
CS703 - Advanced Operating Systems
Module 2: Computer-System Structures
Chapter 2: Operating-System Structures
Module 2: Computer-System Structures
Chapter 2: Operating-System Structures
Chapter 13: I/O Systems.
Presentation transcript:

The IDE/ATA Interface How can our mini-Operating System, executing in protected mode, access the hard disk?

The EDD services So far we have relied upon the Extended Disk Drive service-functions (available in real-mode via ‘int $0x13’) to perform any transfers of data between main memory and our computer system’s hard disk But these service-functions in ROM-BIOS are designed to be executed in real-mode Can we achieve their effects when PE=1?

Persistent data storage Any operating system we might design, no matter how minimal, would need to offer a way to write and to read ‘persistent data’, organized into some kind of ‘file system’ that is maintained on a secondary storage device, such as a hard disk or a diskette

Hardware interfacing Modern computer platforms are expected to provide a specially designed peripheral processor, the hard disk controller, which can be programmed by system software to carry out data-transfers between a disk and the computer’s primary memory The programming interface for hard disk controllers continues to evolve, but a stable set of standard capabilities exists

A few cautions Our classroom and laboratory computers are shared by many users who are taking various computer sciences courses Writing to the hard disk in a careless way can do damage to the operating systems (making a machine completely unusable) In your early experiments you will need to use great caution to avoid corrupting vital areas of these shared hard disks!

Typical Chipset Layout MCH Memory Controller Hub (Northbridge) ICH I/O Controller Hub (Southbridge) CPU Central Processing Unit DRAM Dynamic Random Access Memory NIC Network Interface Controller HDC Hard Disk Controller AC Audio Controller Graphics Controller TimerKeyboardMouseClock Multimedia Controller Firmware Hub

Which I/O ports? The disk-controller on our USF systems is a component within the I/O-Controller Hub The port-addresses used for accessing it are assigned by the ROM-BIOS during the system- startup process and are stored in certain Base-Address registers within the PCI Configuration Space for Intel’s SATA Controller component of the ICH device

Tools we used We used our ‘pciprobe.cpp’ application to perform a PCI bus scan and report all the PCI devices which our system contains We used the PCI CLASS-CODE for SATA Mass Storage devices (code 0x010601) to identify the hard-disk’s controller device We wrote an LKM (Linux Kernel Module) that shows the PCI Configuration Space

BAR field-formats i/o-port address10 reserved I/O Space Indicator memory address0 Type Memory Space Indicator PREFPREF 000

SATA Controller BARs IDE Command-Block for Primary Drive BAR0 BAR1 BAR2 BAR3 BAR4 BAR5 IDE Control-Block for Primary Drive IDE Command-Block for Secondary Drive IDE Control-Block for Secondary Drive DMA Control-Block

Fixed-Size ‘blocks’ All data-transfers to and from the hard disk are comprised of fixed-size blocks called ‘sectors’ (whose size equals 512 bytes) On modern hard disks, these sectors are identified by sector-numbers starting at 0 This scheme for addressing disk sectors is known as Logical Block Addressing (LBA) So the hard disk is just an array of sectors

Platform-specific parameters Although older PCs used some standard I/O port-addresses for communicating with their Disk Controllers, newer PCs like ours allow these port-addresses to be assigned dynamically during the system’s startup To keep our demonstration-code as short and uncluttered as possible, we will ‘hard- code’ the port-numbers our machines use

The ATA/IDE Interface All communication between our driver and the Hard Disk Controller is performed with ‘in’ and ‘out’ instructions that refer to ports Older PCs had standard i/o port-numbers for communicating with the Disk Controller But newer PCs assign these dynamically

IDE Command Block registers When reading… –Data –Error –Sector Count –LBA Low –LBA Mid –LBA High –Device –Status When writing… –Data –Features –Sector Count –LBA Low –LBA Mid –LBA High –Device –Command

IDE Control Block Registers When reading… –Alternate Status When writing… –Device Control INCRITS InterNational Committee on Information Technology Standards Committee T-13

Bus Master DMA When reading… –Primary DMA Control –Primary DMA Status –Primary PRD Pointer When writing… –Primary DMA Control –Primary DMA Status –Primary PRD Pointer INTEL ICH7 I/O Controller Hub Datasheet SATA Controller Registers PRD = Physical Region Descriptor

Two I/O design-paradigms PIO: Programmed I/O for ‘reading’ –The cpu outputs parameters to the controller –The cpu waits till the data becomes available –The cpu transfers the data into main memory DMA: Direct Memory Access for ‘reading’ –The cpu outputs parameters to the controller –The cpu activates the DMA engine to begin –The cpu deactivates the DMA engine to end

PIO algorithm overview First select the device to read from: –Wait until the controller is not busy and does not have any data that it wants to transfer –Write to Command Block’s Device register to select the disk to send the command to –Wait until the controller indicates that it is ready to receive your new command

PIO overview (continued) Place the command’s parameters into the appropriate Command Block registers Put command-code in Command register Then wait until the controller indicates that it has read the requested sector’s data and is ready for you to transfer it into memory Use a loop to input 256 words (one sector) from the Command Block’s Data register

PIO overview (conclusion) After you have transferred a sector, check the Controller Status to see if there were any errors (if so read the Error register) To implement this algorithm, we need to look at the meaning of some individual bits in the Status register (and Error register)

Status register (cmd+7) BSYDRDYDFDRQERR Legend: BSY (Device still Busy with prior command): 1=yes, 0=no DRDY (Device is Ready for a new command): 1=yes, 0=no DF (Device Fault – command cannot finish): 1=yes, 0=no DRQ (Data-transfer is currently Requested): 1=yes, 0=no ERR (Error information is in Error Register): 1 = yes, 0=no

Device register (cmd+6) 1 LBA (=1) 1 DEV (0/1) Sector-ID[ ] Legend: LBA (Logical Block Addressing): 1=yes, 0=no DEV (Device selection): 1=slave, 0=master Sector-ID: Most significant 4-bits of 28-bit Sector-Address

Error register (cmd+1) UNCMCIDNFMCRABRTNM Legend: UNC (Data error was UnCorrectable): 1=yes, 0=no MC (Media was Changed): 1=yes, 0=no IDNF (ID Not Found): 1=yes, 0=no MCR (Media Change was Requested): 1=yes, 0=no ABRT (Command was Aborted): 1 = yes, 0=no NM (No Media was present): 1=yes, 0=no

Device Control register (ctl+2) HOB0000SRSTnIEN0 Legend: HOB (High-Order Byte): 1=yes, 0=no SRST (Software Reset requested): 1=yes, 0=no nIEN (negate Interrupt Enabled): 1=yes, 0=no NOTE: The HOB-bit is unimplemented on our machines; it is for large-capacity disks that require 44-bit sector-addresses

Advantage of DMA For a multiprogramming operating system that employs ‘timesharing’ to concurrently execute multiple tasks, there is an obvious advantage in ‘offloading’ the data-transfer step to a peripheral processor It frees the CPU to do work on other tasks during the time-interval when the data is actually being transferred

DMA Command register 0000 Read/ Write 00 Start /Stop Legend: Start/Stop: 1 = Start DMA transfer; 0 = Stop DMA transfer Read/Write: 1 = Read to memory; 0 = Write from memory

DMA Status register PRDIS--00INTERRACT Legend: ACT (DMA engine is currectly Active): 1 = yes; 0 = no ERR (The controller encountered an Error): 1=yes; 0=no INT (The controller generated an Interrupt: 1=yes; 0=no PRDIS: (PRD Interrupt Status): 1=active, 0=inactive Software clears these labeled bits by writing 1’s to them

PRD Pointer register Physical memory-address of the PRD Table (must be quadword aligned) 310 Base-address of the physical region Each PRD (Physical Region Descriptor) consists of these three fields: Size of the region Reserved (0) bytes 3..0 bytes 7..4 EOTEOT NOTE: The total size of the PRD Table cannot exceed 64KB

DMA algorithm overview First select the device to read from: –Wait until the controller is not busy and does not have any data that it wants to transfer –Write to Command Block’s Device register to select the disk to send the command to –Wait until the controller indicates that it is ready to receive your new command NOTE: This step is the same as for PIO

DMA overview (continued) Engage the DMA engine for writing to memory by outputting 0x08 to the DMA Command Port Clear the labeled bits in the DMA Status register Place the command’s parameters into the appropriate IDE Command Block registers Put command-code in IDE Command register Activate the DMA data-transfer by outputting 0x09 to the DMA Command register Then wait until the DMA Status register indicates that the DMA data-transfer has been completed

DMA algorithm (concluded) Turn off the DMA engine by writing 0x08 to the DMA Command register (to clear ACT) Clear the labeled bits in the DMA Status register (by writing ‘1’s to those bits) Read the IDE Status register (to clear any interrupt from the IDE Controller), and if bit 0 is set (indicating some error-information is available), then read IDE Error register

DMA demo: ‘satademo.s’ We created this example showing how to program the Disk-Drive controller while in protected mode to read in the hard disk’s Master Boot Record and then display its four Partition-Table entries It shows how to read a disk-sector using the hardware’s DMA capability

In-class exercise Use our ‘satainfo.c’ Linux module to learn which i/o-port addresses are assigned to Intel’s SATA Controller on the machines in our classroom Then modify the code in our ‘satademo.s’ source-file so that it can be used to display the Partition-Table’s entries for a machine in our classroom