Revision e162cfb0 hw/ide.c
b/hw/ide.c | ||
---|---|---|
817 | 817 |
} |
818 | 818 |
} |
819 | 819 |
|
820 |
static void ide_rw_error(IDEState *s) { |
|
821 |
ide_abort_command(s); |
|
822 |
ide_set_irq(s); |
|
823 |
} |
|
824 |
|
|
820 | 825 |
static void ide_sector_read(IDEState *s) |
821 | 826 |
{ |
822 | 827 |
int64_t sector_num; |
... | ... | |
836 | 841 |
if (n > s->req_nb_sectors) |
837 | 842 |
n = s->req_nb_sectors; |
838 | 843 |
ret = bdrv_read(s->bs, sector_num, s->io_buffer, n); |
844 |
if (ret != 0) { |
|
845 |
ide_rw_error(s); |
|
846 |
return; |
|
847 |
} |
|
839 | 848 |
ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_read); |
840 | 849 |
ide_set_irq(s); |
841 | 850 |
ide_set_sector(s, sector_num + n); |
... | ... | |
843 | 852 |
} |
844 | 853 |
} |
845 | 854 |
|
855 |
static void ide_dma_error(IDEState *s) |
|
856 |
{ |
|
857 |
ide_transfer_stop(s); |
|
858 |
s->error = ABRT_ERR; |
|
859 |
s->status = READY_STAT | ERR_STAT; |
|
860 |
ide_set_irq(s); |
|
861 |
} |
|
862 |
|
|
846 | 863 |
/* return 0 if buffer completed */ |
847 | 864 |
static int dma_buf_rw(BMDMAState *bm, int is_write) |
848 | 865 |
{ |
... | ... | |
891 | 908 |
return 1; |
892 | 909 |
} |
893 | 910 |
|
894 |
/* XXX: handle errors */ |
|
895 | 911 |
static void ide_read_dma_cb(void *opaque, int ret) |
896 | 912 |
{ |
897 | 913 |
BMDMAState *bm = opaque; |
... | ... | |
899 | 915 |
int n; |
900 | 916 |
int64_t sector_num; |
901 | 917 |
|
918 |
if (ret < 0) { |
|
919 |
ide_dma_error(s); |
|
920 |
return; |
|
921 |
} |
|
922 |
|
|
902 | 923 |
n = s->io_buffer_size >> 9; |
903 | 924 |
sector_num = ide_get_sector(s); |
904 | 925 |
if (n > 0) { |
... | ... | |
963 | 984 |
if (n > s->req_nb_sectors) |
964 | 985 |
n = s->req_nb_sectors; |
965 | 986 |
ret = bdrv_write(s->bs, sector_num, s->io_buffer, n); |
987 |
if (ret != 0) { |
|
988 |
ide_rw_error(s); |
|
989 |
return; |
|
990 |
} |
|
991 |
|
|
966 | 992 |
s->nsector -= n; |
967 | 993 |
if (s->nsector == 0) { |
968 | 994 |
/* no more sectors to write */ |
... | ... | |
992 | 1018 |
} |
993 | 1019 |
} |
994 | 1020 |
|
995 |
/* XXX: handle errors */ |
|
996 | 1021 |
static void ide_write_dma_cb(void *opaque, int ret) |
997 | 1022 |
{ |
998 | 1023 |
BMDMAState *bm = opaque; |
... | ... | |
1000 | 1025 |
int n; |
1001 | 1026 |
int64_t sector_num; |
1002 | 1027 |
|
1028 |
if (ret < 0) { |
|
1029 |
ide_dma_error(s); |
|
1030 |
return; |
|
1031 |
} |
|
1032 |
|
|
1003 | 1033 |
n = s->io_buffer_size >> 9; |
1004 | 1034 |
sector_num = ide_get_sector(s); |
1005 | 1035 |
if (n > 0) { |
Also available in: Unified diff