Revision 46d4767d hw/pc.c

b/hw/pc.c
217 217
    val = 0;
218 218
    for (i = 0; i < 4; i++) {
219 219
        if (hd_table[i]) {
220
            int cylinders, heads, sectors;
221
            uint8_t translation;
222
            /* NOTE: bdrv_get_geometry_hint() returns the geometry
223
               that the hard disk returns. It is always such that: 1 <=
224
               sects <= 63, 1 <= heads <= 16, 1 <= cylinders <=
225
               16383. The BIOS geometry can be different. */
226
            bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, &sectors);
227
            if (cylinders <= 1024 && heads <= 16 && sectors <= 63) {
228
                /* No translation. */
229
                translation = 0;
220
            int cylinders, heads, sectors, translation;
221
            /* NOTE: bdrv_get_geometry_hint() returns the physical
222
                geometry.  It is always such that: 1 <= sects <= 63, 1
223
                <= heads <= 16, 1 <= cylinders <= 16383. The BIOS
224
                geometry can be different if a translation is done. */
225
            translation = bdrv_get_translation_hint(hd_table[i]);
226
            if (translation == BIOS_ATA_TRANSLATION_AUTO) {
227
                bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, &sectors);
228
                if (cylinders <= 1024 && heads <= 16 && sectors <= 63) {
229
                    /* No translation. */
230
                    translation = 0;
231
                } else {
232
                    /* LBA translation. */
233
                    translation = 1;
234
                }
230 235
            } else {
231
                /* LBA translation. */
232
                translation = 1;
236
                translation--;
233 237
            }
234 238
            val |= translation << (i * 2);
235 239
        }

Also available in: Unified diff