Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "‘Identify Device’ A mandatory command that allows device-drivers to query any standard IDE/ATA hard disk for its parameters."— 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 (2 32 sectors)*(512 bytes/sect) = 2 41 bytes 2 10 : 1 kilobyte = 1024 bytes 2 20 : 1 megabyte = 1024 kilobytes 2 30 : 1 gigabyte = 1024 megabytes 2 40 : 1 terabyte = 1024 gigabytes

5 C programming “hints” unsigned shortidinfo[ 256 ]; unsigned longn_sectors; unsigned long longn_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)


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

Similar presentations


Ads by Google