Commit 4dbb0f5006c7a729e20199f08a9d338b11f61fef

Authored by ths
1 parent 6850dd94

Fix for hard disk translation hints, by Volker Ruppert.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2297 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 17 additions and 5 deletions
hw/ide.c
... ... @@ -2069,7 +2069,7 @@ static void ide_init2(IDEState *ide_state,
2069 2069 {
2070 2070 IDEState *s;
2071 2071 static int drive_serial = 1;
2072   - int i, cylinders, heads, secs, translation;
  2072 + int i, cylinders, heads, secs, translation, lba_detected = 0;
2073 2073 int64_t nb_sectors;
2074 2074  
2075 2075 for(i = 0; i < 2; i++) {
... ... @@ -2083,6 +2083,7 @@ static void ide_init2(IDEState *ide_state,
2083 2083 s->nb_sectors = nb_sectors;
2084 2084 /* if a geometry hint is available, use it */
2085 2085 bdrv_get_geometry_hint(s->bs, &cylinders, &heads, &secs);
  2086 + translation = bdrv_get_translation_hint(s->bs);
2086 2087 if (cylinders != 0) {
2087 2088 s->cylinders = cylinders;
2088 2089 s->heads = heads;
... ... @@ -2093,6 +2094,7 @@ static void ide_init2(IDEState *ide_state,
2093 2094 /* if heads > 16, it means that a BIOS LBA
2094 2095 translation was active, so the default
2095 2096 hardware geometry is OK */
  2097 + lba_detected = 1;
2096 2098 goto default_geometry;
2097 2099 } else {
2098 2100 s->cylinders = cylinders;
... ... @@ -2100,7 +2102,6 @@ static void ide_init2(IDEState *ide_state,
2100 2102 s->sectors = secs;
2101 2103 /* disable any translation to be in sync with
2102 2104 the logical geometry */
2103   - translation = bdrv_get_translation_hint(s->bs);
2104 2105 if (translation == BIOS_ATA_TRANSLATION_AUTO) {
2105 2106 bdrv_set_translation_hint(s->bs,
2106 2107 BIOS_ATA_TRANSLATION_NONE);
... ... @@ -2117,6 +2118,15 @@ static void ide_init2(IDEState *ide_state,
2117 2118 s->cylinders = cylinders;
2118 2119 s->heads = 16;
2119 2120 s->sectors = 63;
  2121 + if ((lba_detected == 1) && (translation == BIOS_ATA_TRANSLATION_AUTO)) {
  2122 + if ((s->cylinders * s->heads) <= 131072) {
  2123 + bdrv_set_translation_hint(s->bs,
  2124 + BIOS_ATA_TRANSLATION_LARGE);
  2125 + } else {
  2126 + bdrv_set_translation_hint(s->bs,
  2127 + BIOS_ATA_TRANSLATION_LBA);
  2128 + }
  2129 + }
2120 2130 }
2121 2131 bdrv_set_geometry_hint(s->bs, s->cylinders, s->heads, s->sectors);
2122 2132 }
... ...
... ... @@ -616,9 +616,11 @@ void bdrv_flush(BlockDriverState *bs);
616 616 #define BDRV_TYPE_HD 0
617 617 #define BDRV_TYPE_CDROM 1
618 618 #define BDRV_TYPE_FLOPPY 2
619   -#define BIOS_ATA_TRANSLATION_AUTO 0
620   -#define BIOS_ATA_TRANSLATION_NONE 1
621   -#define BIOS_ATA_TRANSLATION_LBA 2
  619 +#define BIOS_ATA_TRANSLATION_AUTO 0
  620 +#define BIOS_ATA_TRANSLATION_NONE 1
  621 +#define BIOS_ATA_TRANSLATION_LBA 2
  622 +#define BIOS_ATA_TRANSLATION_LARGE 3
  623 +#define BIOS_ATA_TRANSLATION_RECHS 4
622 624  
623 625 void bdrv_set_geometry_hint(BlockDriverState *bs,
624 626 int cyls, int heads, int secs);
... ...