{
IDEState *s;
static int drive_serial = 1;
- int i, cylinders, heads, secs, translation;
+ int i, cylinders, heads, secs, translation, lba_detected = 0;
int64_t nb_sectors;
for(i = 0; i < 2; i++) {
s->nb_sectors = nb_sectors;
/* if a geometry hint is available, use it */
bdrv_get_geometry_hint(s->bs, &cylinders, &heads, &secs);
+ translation = bdrv_get_translation_hint(s->bs);
if (cylinders != 0) {
s->cylinders = cylinders;
s->heads = heads;
/* if heads > 16, it means that a BIOS LBA
translation was active, so the default
hardware geometry is OK */
+ lba_detected = 1;
goto default_geometry;
} else {
s->cylinders = cylinders;
s->sectors = secs;
/* disable any translation to be in sync with
the logical geometry */
- translation = bdrv_get_translation_hint(s->bs);
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_set_translation_hint(s->bs,
BIOS_ATA_TRANSLATION_NONE);
s->cylinders = cylinders;
s->heads = 16;
s->sectors = 63;
+ if ((lba_detected == 1) && (translation == BIOS_ATA_TRANSLATION_AUTO)) {
+ if ((s->cylinders * s->heads) <= 131072) {
+ bdrv_set_translation_hint(s->bs,
+ BIOS_ATA_TRANSLATION_LARGE);
+ } else {
+ bdrv_set_translation_hint(s->bs,
+ BIOS_ATA_TRANSLATION_LBA);
+ }
+ }
}
bdrv_set_geometry_hint(s->bs, s->cylinders, s->heads, s->sectors);
}
#define BDRV_TYPE_HD 0
#define BDRV_TYPE_CDROM 1
#define BDRV_TYPE_FLOPPY 2
-#define BIOS_ATA_TRANSLATION_AUTO 0
-#define BIOS_ATA_TRANSLATION_NONE 1
-#define BIOS_ATA_TRANSLATION_LBA 2
+#define BIOS_ATA_TRANSLATION_AUTO 0
+#define BIOS_ATA_TRANSLATION_NONE 1
+#define BIOS_ATA_TRANSLATION_LBA 2
+#define BIOS_ATA_TRANSLATION_LARGE 3
+#define BIOS_ATA_TRANSLATION_RECHS 4
void bdrv_set_geometry_hint(BlockDriverState *bs,
int cyls, int heads, int secs);