Revision 9139046c hw/pc.c
b/hw/pc.c | ||
---|---|---|
216 | 216 |
return val; |
217 | 217 |
} |
218 | 218 |
|
219 |
static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd,
|
|
220 |
ISADevice *s)
|
|
219 |
static void cmos_init_hd(ISADevice *s, int type_ofs, int info_ofs,
|
|
220 |
int16_t cylinders, int8_t heads, int8_t sectors)
|
|
221 | 221 |
{ |
222 |
int cylinders, heads, sectors; |
|
223 |
bdrv_get_geometry_hint(hd, &cylinders, &heads, §ors); |
|
224 | 222 |
rtc_set_memory(s, type_ofs, 47); |
225 | 223 |
rtc_set_memory(s, info_ofs, cylinders); |
226 | 224 |
rtc_set_memory(s, info_ofs + 1, cylinders >> 8); |
... | ... | |
281 | 279 |
|
282 | 280 |
typedef struct pc_cmos_init_late_arg { |
283 | 281 |
ISADevice *rtc_state; |
284 |
BusState *idebus0, *idebus1;
|
|
282 |
BusState *idebus[2];
|
|
285 | 283 |
} pc_cmos_init_late_arg; |
286 | 284 |
|
287 | 285 |
static void pc_cmos_init_late(void *opaque) |
288 | 286 |
{ |
289 | 287 |
pc_cmos_init_late_arg *arg = opaque; |
290 | 288 |
ISADevice *s = arg->rtc_state; |
289 |
int16_t cylinders; |
|
290 |
int8_t heads, sectors; |
|
291 | 291 |
int val; |
292 |
BlockDriverState *hd_table[4]; |
|
293 | 292 |
int i; |
294 | 293 |
|
295 |
ide_get_bs(hd_table, arg->idebus0); |
|
296 |
ide_get_bs(hd_table + 2, arg->idebus1); |
|
297 |
|
|
298 |
rtc_set_memory(s, 0x12, (hd_table[0] ? 0xf0 : 0) | (hd_table[1] ? 0x0f : 0)); |
|
299 |
if (hd_table[0]) |
|
300 |
cmos_init_hd(0x19, 0x1b, hd_table[0], s); |
|
301 |
if (hd_table[1]) |
|
302 |
cmos_init_hd(0x1a, 0x24, hd_table[1], s); |
|
294 |
val = 0; |
|
295 |
if (ide_get_geometry(arg->idebus[0], 0, |
|
296 |
&cylinders, &heads, §ors) >= 0) { |
|
297 |
cmos_init_hd(s, 0x19, 0x1b, cylinders, heads, sectors); |
|
298 |
val |= 0xf0; |
|
299 |
} |
|
300 |
if (ide_get_geometry(arg->idebus[0], 1, |
|
301 |
&cylinders, &heads, §ors) >= 0) { |
|
302 |
cmos_init_hd(s, 0x1a, 0x24, cylinders, heads, sectors); |
|
303 |
val |= 0x0f; |
|
304 |
} |
|
305 |
rtc_set_memory(s, 0x12, val); |
|
303 | 306 |
|
304 | 307 |
val = 0; |
305 | 308 |
for (i = 0; i < 4; i++) { |
306 |
if (hd_table[i]) { |
|
307 |
int cylinders, heads, sectors, translation; |
|
308 |
/* NOTE: bdrv_get_geometry_hint() returns the physical |
|
309 |
geometry. It is always such that: 1 <= sects <= 63, 1 |
|
310 |
<= heads <= 16, 1 <= cylinders <= 16383. The BIOS |
|
311 |
geometry can be different if a translation is done. */ |
|
312 |
translation = bdrv_get_translation_hint(hd_table[i]); |
|
309 |
/* NOTE: ide_get_geometry() returns the physical |
|
310 |
geometry. It is always such that: 1 <= sects <= 63, 1 |
|
311 |
<= heads <= 16, 1 <= cylinders <= 16383. The BIOS |
|
312 |
geometry can be different if a translation is done. */ |
|
313 |
if (ide_get_geometry(arg->idebus[i / 2], i % 2, |
|
314 |
&cylinders, &heads, §ors) >= 0) { |
|
315 |
int translation = ide_get_bios_chs_trans(arg->idebus[i / 2], |
|
316 |
i % 2); |
|
313 | 317 |
if (translation == BIOS_ATA_TRANSLATION_AUTO) { |
314 |
bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, §ors); |
|
315 | 318 |
if (cylinders <= 1024 && heads <= 16 && sectors <= 63) { |
316 | 319 |
/* No translation. */ |
317 | 320 |
translation = 0; |
... | ... | |
411 | 414 |
|
412 | 415 |
/* hard drives */ |
413 | 416 |
arg.rtc_state = s; |
414 |
arg.idebus0 = idebus0;
|
|
415 |
arg.idebus1 = idebus1;
|
|
417 |
arg.idebus[0] = idebus0;
|
|
418 |
arg.idebus[1] = idebus1;
|
|
416 | 419 |
qemu_register_reset(pc_cmos_init_late, &arg); |
417 | 420 |
} |
418 | 421 |
|
Also available in: Unified diff