Information Technology Reference
In-Depth Information
#include <conio.h>
int main(void)
{
int sectors=4, sector_no=7, cylinder=150, drive=0, command=0x33, i;
unsigned int buff[1024], *buff_pointer;
do
{
/* wait until BSY signal is set to a 1 */
} while (( _inp(0x1f7) & 0x80) != 0x80);
_outp(0x1f2,sectors); /* set number of sectors
*/
_outp(0x1f3,sector_no); /* set sector number
*/
_outp(0x1f4,cylinder & 0x0ff); /* set cylinder number LSB
*/
_outp(0x1f5,cylinder & 0xf00); /* set cylinder number MSB
*/
_outp(0x1f6,drive); /* set DRV=0 and head=0
*/
_outp(0x1f7,command); /* 0011 0011 (write sector)
*/
do
{
/* wait until BSY signal is set to a 1 and DRQ is set to a 1 */
} while ( ((_inp(0x1f7) & 0x80) != 0x80) &&
((_inp(0x1f7) & 0x08) !=0x08) );
buff_pointer= buff;
for (i=0;i<512;i++,buff_pointer++)
{
_outp(0x1f0,*buff_pointer); /* output 16-bits at a time */
}
return(0);
}
Note that if the L bit is set then an extra four ECC (error correcting code) bytes must be writ-
ten to the sector (thus a total of 516 bytes are written to each sector). The code used is cyclic
redundancy check, which, while it cannot correct errors is very powerful at detecting them.
6.8.3 E-IDE
The main differences between IDE and E-IDE are:
E-IDE support removable media.
E-IDE supports a 16-bit cylinder value, which gives a maximum of 65 636 cylinders.
Higher transfer rates. In mode 4, E-IDE has a 120 ns read/write cycle time, which gives a
16.6 MB/s burst data transfer rate.
E-IDE supports LBA (logical block addressing) which differs from CHS (cylinder head
sector) in that the disk drive appears to be a continuous stream of sequential blocks. The
addressing of these blocks is achieved from within the controller and the system does not
have to bother about which cylinder, header and sector is being used.
IDE is limited to 1024 cylinders, 16 heads (drive/head register has only four bits for the
number of heads) and 63 sectors, which gives
Disk capacity = 1024
×
16
×
63
×
512 = 504 MB
With enhanced BIOS this is increased to 1024 cylinders, 256 heads (8-bit definition for the
number of heads) and 63 sectors, to give
Search WWH ::




Custom Search