DOC PREVIEW
USF CS 635 - The ATA and IDE Interface

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

The ATA/IDE InterfacePersistent data storageHardware interfacingA few cautionsFixed-Size ‘blocks’Visualizing the hard diskDisk PartitionsMaster Boot RecordFormat of the MBR‘Safe’ areas‘Reading’ the MBRPartition Table EntriesTYPE-IDHow can we read the MBR?Slide 15Command Block registersControl Block RegistersAlgorithm overviewOverview (continued)Overview (conclusion)Status register (port 0x1F7)Device register (0x1F6)Error register (0x1F1)Device Control register (0x3F6)Demo module: ‘mbr.c’In-Class ExerciseThe ATA/IDE InterfaceCan we write a character-mode device driver for the hard disk?Persistent data storage•Our ‘dram.c’ module implemented a Linux driver for the processor’s physical memory•That primary storage was ‘volatile’ – all its data disappears when power is turned off•But secondary storage, provided by disks, is ‘persistent’ – the data is preserved even when the power supply gets interruptedHardware interfacing•To gain experience with writing drivers for actual hardware, we propose to construct a character-mode device driver, similar to our ‘dram.c’ module, which will allow us to read and write to a portion of the hard disk•This will acquaint us – at an elementary level -- with many of the key issues that hardware interfacing typically involvesA 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) •Our first job will be to discover what areas on our hard disk can be safely modifiedFixed-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 sectorsVisualizing the hard disk0 1 2 3 …..A large array of 512-byte disk sectorsDisk storage-capacity (in bytes) = (total number of sectors) x (512 bytes/sector)Disk Partitions•The total storage-area of the hard disk is usually subdivided into non-overlapping regions called ‘disk partitions’ Partition #1 Partition #2 Partition #3unusedMaster Boot Record•A small area at the beginning of the disk is dedicated to ‘managing’ the disk partitions•In particular, sector number 0 is known as the Master Boot Record (very important!)MBR0 1 2 …partition #1Format of the MBR•The MBR is subdivided into three areas:–The bootstrap loader program–The ‘partition table’ data-structure–The MBR signature (i.e., 0x55, 0xAA)signature (2 bytes)Partition Table (64 bytes)Bootstrap Loader(446 bytes) 512bytes‘Safe’ areas•If our hard disk contains ‘unused’ sectors, then we could safely modify their contents•Or if our hard disk contains a partition that nobody currently uses, then we could just take over its sectors for our own purposes -- at least during this current semester •So we need to look at the ‘partition table’ to find out if any ‘safe areas’ are available‘Reading’ the MBR•To get the hard disk’s Partition Table, we must ‘read’ the entire Master Boot Record•(We ignore the boot-loader and signature)•But we will need to understand the format of the data stored in that Partition Table•And we will need to know how to devise a privileged code-fragment that can transfer the MBR (sector 0) from disk to memoryPartition Table Entries•The MBR is an array containing four data-structures (called ‘partition table entries’):Starting sectorID-numberPartition length(in sectors)STATUSTYPE 16bytesSome fields contain ‘obsolete’ informationTYPE-ID•Each partition-table entry has a TYPE-ID–TYPE-ID is 0x07 for a ‘Windows’ partition–TYPE-ID is 0x83 for our ‘Linux’ partition–TYPE-ID is 0x00 when the entry is ‘unused’•You can find a list of TYPE-ID numbers posted on the internet (see our website)•Our hard disks have a ‘Minix’ partition that nobody is using during Spring semesterHow can we read the MBR?•Our device-driver must send a command to the Hard Disk Controller, together with command-parameters that specify which disk sector we want to read (i.e., sector 0)•But we can’t issue a fresh command if the controller is still busy processing an earlier command (e.g., issued by the OS kernel)•So we also need to get controller ‘status’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•PCs have standard i/o port-numbers for communicating with the Disk Controller•Altogether twelve registers are involved, using nine different I/O Port-NumbersCommand 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–CommandControl Block Registers•When reading…–Alternate Status•When writing…–Device ControlINCRITSInterNational Committee on Information Technology StandardsCommittee T-13Algorithm 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 commandOverview (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 to transfer it to your device driver •Use a loop to input 256 words (one sector) from the Command Block’s Data registerOverview (conclusion)•After your driver has transferred a sector, check the Controller Status to see if there was any error (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 (port 0x1F7)BSY DRDY DF DRQ ERRLegend: 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 –


View Full Document

USF CS 635 - The ATA and IDE Interface

Download The ATA and IDE Interface
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The ATA and IDE Interface and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The ATA and IDE Interface 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?