/[qemu]/qemu/hw/ide.c
ViewVC logotype

Diff of /qemu/hw/ide.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.29 by bellard, Tue Nov 9 22:04:05 2004 UTC revision 1.30 by bellard, Tue Nov 16 01:45:27 2004 UTC
# Line 1826  struct partition { Line 1826  struct partition {
1826          uint32_t nr_sects;              /* nr of sectors in partition */          uint32_t nr_sects;              /* nr of sectors in partition */
1827  } __attribute__((packed));  } __attribute__((packed));
1828    
1829  /* try to guess the IDE geometry from the MSDOS partition table */  /* try to guess the IDE physical geometry from the MSDOS partition table */
1830  static void ide_guess_geometry(IDEState *s)  static void ide_guess_geometry(IDEState *s)
1831  {  {
1832      uint8_t buf[512];      uint8_t buf[512];
1833      int ret, i;      int ret, i, heads, sectors, cylinders;
1834      struct partition *p;      struct partition *p;
1835      uint32_t nr_sects;      uint32_t nr_sects;
1836    
# Line 1848  static void ide_guess_geometry(IDEState Line 1848  static void ide_guess_geometry(IDEState
1848          if (nr_sects && p->end_head) {          if (nr_sects && p->end_head) {
1849              /* We make the assumption that the partition terminates on              /* We make the assumption that the partition terminates on
1850                 a cylinder boundary */                 a cylinder boundary */
1851              s->heads = p->end_head + 1;              heads = p->end_head + 1;
1852              s->sectors = p->end_sector & 63;              if (heads < 1 || heads > 16)
1853              s->cylinders = s->nb_sectors / (s->heads * s->sectors);                  continue;
1854                sectors = p->end_sector & 63;
1855                if (sectors == 0)
1856                    continue;
1857                cylinders = s->nb_sectors / (heads * sectors);
1858                if (cylinders < 1 || cylinders > 16383)
1859                    continue;
1860                s->heads = heads;
1861                s->sectors = sectors;
1862                s->cylinders = cylinders;
1863  #if 0  #if 0
1864              printf("guessed partition: CHS=%d %d %d\n",              printf("guessed partition: CHS=%d %d %d\n",
1865                     s->cylinders, s->heads, s->sectors);                     s->cylinders, s->heads, s->sectors);
# Line 1885  static void ide_init2(IDEState *ide_stat Line 1894  static void ide_init2(IDEState *ide_stat
1894              } else {              } else {
1895                  ide_guess_geometry(s);                  ide_guess_geometry(s);
1896                  if (s->cylinders == 0) {                  if (s->cylinders == 0) {
1897                      /* if no geometry, use a LBA compatible one */                      /* if no geometry, use a standard physical disk geometry */
1898                      cylinders = nb_sectors / (16 * 63);                      cylinders = nb_sectors / (16 * 63);
1899                      if (cylinders > 16383)                      if (cylinders > 16383)
1900                          cylinders = 16383;                          cylinders = 16383;

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26