summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2022-04-13 13:26:33 +0200
committerGerd Hoffmann <kraxel@redhat.com>2022-04-22 14:52:30 +0200
commitaf0c41e620b90e9a7df522f3a4898d11d3ded912 (patch)
tree2e147c9adcd6e25c201d655d80b0a35184697b7c
parent59f531cffb9c7fdbabf5f8f8e4655cafc6549f09 (diff)
downloadamtterm-af0c41e620b90e9a7df522f3a4898d11d3ded912.tar.gz
ider: chunked transport
-rw-r--r--ider.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/ider.c b/ider.c
index fe209bd..7f69bc6 100644
--- a/ider.c
+++ b/ider.c
@@ -52,7 +52,7 @@ static int ider_data_to_host(struct redir *r, unsigned char device,
}
if (completed) {
msg.output.mask = mask | IDER_INTERRUPT_MASK;
- msg.output.sector_count = IDER_INTERRUPT_CD | IDER_INTERRUPT_CD;
+ msg.output.sector_count = IDER_INTERRUPT_CD | IDER_INTERRUPT_IO;
msg.output.drive_select = device;
msg.output.status = IDER_STATUS_DRDY | IDER_STATUS_DSC;
}
@@ -94,17 +94,34 @@ static int ider_packet_sense(struct redir *r,
static int ider_read_data(struct redir *r, unsigned char device, bool use_dma,
unsigned long lba, unsigned int count)
{
- off_t mmap_offset = lba << r->lba_shift;
- size_t mmap_len = count << r->lba_shift;
+ off_t mmap_offset = (off_t)lba << r->lba_shift;
+ size_t mmap_len = (size_t)count << r->lba_shift;
unsigned char *lba_ptr =
(unsigned char *)r->mmap_buf + mmap_offset;
+ size_t chunk_size = 0x2000;
+ bool last_lba = false;
+ int ret = 0;
if (!count)
return ider_packet_sense(r, device, 0x00, 0x00, 0x00);
if (mmap_offset >= r->mmap_size)
return ider_packet_sense(r, device, 0x05, 0x21, 0x00);
- return ider_data_to_host(r, device, lba_ptr, mmap_len, true, use_dma);
+ while (mmap_len) {
+ if (mmap_len <= chunk_size) {
+ chunk_size = mmap_len;
+ last_lba = true;
+ }
+ ret = ider_data_to_host(r, device, lba_ptr, chunk_size,
+ last_lba, use_dma);
+ if (ret < 0)
+ break;
+ if (last_lba)
+ break;
+ lba_ptr += chunk_size;
+ mmap_len -= chunk_size;
+ }
+ return ret;
}
unsigned char ider_mode_page_01_floppy[] = {