| 368 | } |
| 369 | |
| 370 | static void ide_sector_read(IDEState *s) |
| 371 | { |
| 372 | int64_t sector_num; |
| 373 | int ret, n; |
| 374 | |
| 375 | sector_num = ide_get_sector(s); |
| 376 | n = s->nsector; |
| 377 | if (n == 0) |
| 378 | n = 256; |
| 379 | if (n > s->req_nb_sectors) |
| 380 | n = s->req_nb_sectors; |
| 381 | #if defined(DEBUG_IDE) |
| 382 | printf("read sector=%" PRId64 " count=%d\n", sector_num, n); |
| 383 | #endif |
| 384 | s->io_nb_sectors = n; |
| 385 | ret = s->bs->read_async(s->bs, sector_num, s->io_buffer, n, |
| 386 | ide_sector_read_cb, s); |
| 387 | if (ret < 0) { |
| 388 | /* error */ |
| 389 | ide_abort_command(s); |
| 390 | ide_set_irq(s); |
| 391 | } else if (ret == 0) { |
| 392 | /* synchronous case (needed for performance) */ |
| 393 | ide_sector_read_cb(s, 0); |
| 394 | } else { |
| 395 | /* async case */ |
| 396 | s->status = READY_STAT | SEEK_STAT | BUSY_STAT; |
| 397 | s->error = 0; /* not needed by IDE spec, but needed by Windows */ |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | static void ide_sector_read_cb(void *opaque, int ret) |
| 402 | { |
no test coverage detected