mirror of
https://git.proxmox.com/git/qemu
synced 2025-06-22 23:46:47 +00:00
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
This commit is contained in:
parent
6850dd945e
commit
4dbb0f5006
14
hw/ide.c
14
hw/ide.c
@ -2069,7 +2069,7 @@ static void ide_init2(IDEState *ide_state,
|
|||||||
{
|
{
|
||||||
IDEState *s;
|
IDEState *s;
|
||||||
static int drive_serial = 1;
|
static int drive_serial = 1;
|
||||||
int i, cylinders, heads, secs, translation;
|
int i, cylinders, heads, secs, translation, lba_detected = 0;
|
||||||
int64_t nb_sectors;
|
int64_t nb_sectors;
|
||||||
|
|
||||||
for(i = 0; i < 2; i++) {
|
for(i = 0; i < 2; i++) {
|
||||||
@ -2083,6 +2083,7 @@ static void ide_init2(IDEState *ide_state,
|
|||||||
s->nb_sectors = nb_sectors;
|
s->nb_sectors = nb_sectors;
|
||||||
/* if a geometry hint is available, use it */
|
/* if a geometry hint is available, use it */
|
||||||
bdrv_get_geometry_hint(s->bs, &cylinders, &heads, &secs);
|
bdrv_get_geometry_hint(s->bs, &cylinders, &heads, &secs);
|
||||||
|
translation = bdrv_get_translation_hint(s->bs);
|
||||||
if (cylinders != 0) {
|
if (cylinders != 0) {
|
||||||
s->cylinders = cylinders;
|
s->cylinders = cylinders;
|
||||||
s->heads = heads;
|
s->heads = heads;
|
||||||
@ -2093,6 +2094,7 @@ static void ide_init2(IDEState *ide_state,
|
|||||||
/* if heads > 16, it means that a BIOS LBA
|
/* if heads > 16, it means that a BIOS LBA
|
||||||
translation was active, so the default
|
translation was active, so the default
|
||||||
hardware geometry is OK */
|
hardware geometry is OK */
|
||||||
|
lba_detected = 1;
|
||||||
goto default_geometry;
|
goto default_geometry;
|
||||||
} else {
|
} else {
|
||||||
s->cylinders = cylinders;
|
s->cylinders = cylinders;
|
||||||
@ -2100,7 +2102,6 @@ static void ide_init2(IDEState *ide_state,
|
|||||||
s->sectors = secs;
|
s->sectors = secs;
|
||||||
/* disable any translation to be in sync with
|
/* disable any translation to be in sync with
|
||||||
the logical geometry */
|
the logical geometry */
|
||||||
translation = bdrv_get_translation_hint(s->bs);
|
|
||||||
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
|
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
|
||||||
bdrv_set_translation_hint(s->bs,
|
bdrv_set_translation_hint(s->bs,
|
||||||
BIOS_ATA_TRANSLATION_NONE);
|
BIOS_ATA_TRANSLATION_NONE);
|
||||||
@ -2117,6 +2118,15 @@ static void ide_init2(IDEState *ide_state,
|
|||||||
s->cylinders = cylinders;
|
s->cylinders = cylinders;
|
||||||
s->heads = 16;
|
s->heads = 16;
|
||||||
s->sectors = 63;
|
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);
|
bdrv_set_geometry_hint(s->bs, s->cylinders, s->heads, s->sectors);
|
||||||
}
|
}
|
||||||
|
8
vl.h
8
vl.h
@ -616,9 +616,11 @@ void bdrv_flush(BlockDriverState *bs);
|
|||||||
#define BDRV_TYPE_HD 0
|
#define BDRV_TYPE_HD 0
|
||||||
#define BDRV_TYPE_CDROM 1
|
#define BDRV_TYPE_CDROM 1
|
||||||
#define BDRV_TYPE_FLOPPY 2
|
#define BDRV_TYPE_FLOPPY 2
|
||||||
#define BIOS_ATA_TRANSLATION_AUTO 0
|
#define BIOS_ATA_TRANSLATION_AUTO 0
|
||||||
#define BIOS_ATA_TRANSLATION_NONE 1
|
#define BIOS_ATA_TRANSLATION_NONE 1
|
||||||
#define BIOS_ATA_TRANSLATION_LBA 2
|
#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,
|
void bdrv_set_geometry_hint(BlockDriverState *bs,
|
||||||
int cyls, int heads, int secs);
|
int cyls, int heads, int secs);
|
||||||
|
Loading…
Reference in New Issue
Block a user