X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fram_hd.c;h=3bce4fcfdb32926b21a54a392aeacb121024f7a0;hp=1094a3191691bd54086c16837df89fd1b782b45b;hb=326a9425e1dc7a9f7afafe2951b55f35d9ff2422;hpb=639901d32ea8c5144ce9bb8f44bc6efa81a947a0 diff --git a/palacios/src/devices/ram_hd.c b/palacios/src/devices/ram_hd.c index 1094a31..3bce4fc 100644 --- a/palacios/src/devices/ram_hd.c +++ b/palacios/src/devices/ram_hd.c @@ -39,7 +39,7 @@ struct hd_state { }; -// HDs always read 2048 byte blocks... ? +// HDs always read 512 byte blocks... ? static int hd_read(uint8_t * buf, int sector_count, uint64_t lba, void * private_data) { struct vm_device * hd_dev = (struct vm_device *)private_data; struct hd_state * hd = (struct hd_state *)(hd_dev->private_data); @@ -50,7 +50,17 @@ static int hd_read(uint8_t * buf, int sector_count, uint64_t lba, void * privat memcpy(buf, (uint8_t *)(hd->disk_image + offset), length); + return 0; +} + + +static int hd_write(uint8_t * buf, int sector_count, uint64_t lba, void * private_data) { + struct vm_device * hd_dev = (struct vm_device *)private_data; + struct hd_state * hd = (struct hd_state *)(hd_dev->private_data); + int offset = lba * IDE_SECTOR_SIZE; + int length = sector_count * IDE_SECTOR_SIZE; + memcpy((uint8_t *)(hd->disk_image + offset), buf, length); return 0; } @@ -66,6 +76,7 @@ static uint64_t hd_get_capacity(void * private_data) { static struct v3_ide_hd_ops hd_ops = { .read = hd_read, + .write = hd_write, .get_capacity = hd_get_capacity, };