direct-io.hg

changeset 5645:e3dcc10765ea

Improve the IDE HD geometry auto detection algorithm.
Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: Asit K Mallick <asit.k.mallick@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jul 01 21:24:09 2005 +0000 (2005-07-01)
parents 2420e309074b
children 82390e707bb9
files tools/ioemu/hw/ide.c
line diff
     1.1 --- a/tools/ioemu/hw/ide.c	Fri Jul 01 17:26:37 2005 +0000
     1.2 +++ b/tools/ioemu/hw/ide.c	Fri Jul 01 21:24:09 2005 +0000
     1.3 @@ -1850,7 +1850,11 @@ static void ide_guess_geometry(IDEState 
     1.4                 a cylinder boundary */
     1.5              s->heads = p->end_head + 1;
     1.6              s->sectors = p->end_sector & 63;
     1.7 +            if (s->sectors == 0)
     1.8 +                continue;
     1.9              s->cylinders = s->nb_sectors / (s->heads * s->sectors);
    1.10 +            if (s->cylinders < 1 || s->cylinders > 16383)
    1.11 +                continue;
    1.12  #if 0
    1.13              printf("guessed partition: CHS=%d %d %d\n", 
    1.14                     s->cylinders, s->heads, s->sectors);
    1.15 @@ -1884,8 +1888,12 @@ static void ide_init2(IDEState *ide_stat
    1.16                  s->sectors = secs;
    1.17              } else {
    1.18                  ide_guess_geometry(s);
    1.19 -                if (s->cylinders == 0) {
    1.20 -                    /* if no geometry, use a LBA compatible one */
    1.21 +
    1.22 +                /* if heads > 16, it means that a BIOS LBA
    1.23 +                   translation was active, so the default
    1.24 +                   hardware geometry is OK */
    1.25 +                if ((s->heads > 16) || (s->cylinders == 0)) {
    1.26 +                    /* if no geometry, use a standard physical disk geometry */
    1.27                      cylinders = nb_sectors / (16 * 63);
    1.28                      if (cylinders > 16383)
    1.29                          cylinders = 16383;