#endif
+#define SECTOR_SIZE 512
+
#define BLK_CAPACITY_PORT 20
#define BLK_MAX_SIZE_PORT 28
#define BLK_MAX_SEG_PORT 32
int ret = -1;
PrintDebug("Reading Disk\n");
- ret = blk_state->ops->read(buf, *sector, len, (void *)(blk_state->backend_data));
- *sector += len;
+ ret = blk_state->ops->read(buf, (*sector) * SECTOR_SIZE, len, (void *)(blk_state->backend_data));
+ *sector += (len / SECTOR_SIZE);
return ret;
}
int ret = -1;
PrintDebug("Writing Disk\n");
- ret = blk_state->ops->write(buf, *sector, len, (void *)(blk_state->backend_data));
- *sector += len;
+ ret = blk_state->ops->write(buf, (*sector) * SECTOR_SIZE, len, (void *)(blk_state->backend_data));
+ *sector += (len / SECTOR_SIZE);
return ret;
}
blk_state->ops = ops;
blk_state->backend_data = private_data;
- blk_state->block_cfg.capacity = ops->get_capacity(private_data);
+ blk_state->block_cfg.capacity = ops->get_capacity(private_data) / SECTOR_SIZE;
- PrintDebug("Virtio Capacity = %d -- 0x%p\n", (int)(virtio->block_cfg.capacity),
- (void *)(addr_t)(virtio->block_cfg.capacity));
+ PrintDebug("Virtio Capacity = %d -- 0x%p\n", (int)(blk_state->block_cfg.capacity),
+ (void *)(addr_t)(blk_state->block_cfg.capacity));
return 0;
}