1 / 7

‘Identify Device’

‘Identify Device’. A mandatory command that allows device-drivers to query any standard IDE/ATA hard disk for its parameters. Uses PIO data-in protocol. Our ‘mbr.c’ driver-module reads sector 0 using a well-documented device protocol

lin
Download Presentation

‘Identify Device’

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ‘Identify Device’ A mandatory command that allows device-drivers to query any standard IDE/ATA hard disk for its parameters

  2. Uses PIO data-in protocol • Our ‘mbr.c’ driver-module reads sector 0 using a well-documented device protocol • The IDENTIFY_DEVICE command (0xEC) uses the same basic protocol, except that only a 1-bit parameter is needed, to select the desired device (master=0, slave=1) • You can quickly modify our ‘mbr.c’ module to create a ‘hdid.c’ driver for disk-ID info

  3. Some items of interest • The IDENTIFY-DEVICE command returns 256 words of information (i.e., 512 bytes) • Words 10-19: Hard Disk’s Serial-Number (it consists of 20 ASCII characters) • Words 23-26: Firmware Revision Number (it consists of 8 ASCII characters) • Words 27-46: Hard Disk’s Model Number (it consists of 40 ASCII characters)

  4. Important item: disk’s capacity • Words 60-61: The total number of sectors a device-driver can access (32-bit value) • Allows for disk-capacities up to 2 terabytes (232 sectors)*(512 bytes/sect) = 241 bytes 210: 1 kilobyte = 1024 bytes 220: 1 megabyte = 1024 kilobytes 230: 1 gigabyte = 1024 megabytes 240: 1 terabyte = 1024 gigabytes

  5. C programming “hints” unsigned short idinfo[ 256 ]; unsigned long n_sectors; unsigned long long n_bytes; for (i=0; i<256; i++) idinfo[ i ] = inw( IDE_DATA ); n_sectors = *(unsigned long*)&idinfo[ 60 ]; n_bytes = 512LL * n_sectors; printf( “disk capacity: %llu bytes ”, n_bytes); printf( “(= 0x%llX bytes) \n”, n_bytes );

  6. In-class exercise #1 • Copy our ‘mbr.c’ module from the website, remame it as ‘hdid.c’, then modify a few of its lines as appropriate, so as to create a character-mode device-driver for the Hard Disk’s 256 words of device information • Use our ‘fileview’ utility to browse through this device-file (named ‘/dev/hd’), copying down the number of disk-sectors (in hex)

  7. In-class exercise #2 • Write a short C++ application program that will display these important items of Hard Disk information (in appropriate formats): • Hard Disk’s Serial Number • Firmware’s Revision Number • Hard Disk’s Model ID Number • Number of accessible sectors (hexadecimal) • Disk’s storage capacity in bytes (decimal)

More Related