Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


fixed toc_length initialization bug
[palacios-OLD.git] / palacios / src / devices / cdrom.c
index e77c280..40ed98c 100644 (file)
@@ -18,6 +18,8 @@
  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
  */
 
+
+
 #include <devices/cdrom.h>
 #include <devices/ide.h>
 #include <palacios/vmm.h>
@@ -31,7 +33,7 @@
 
 struct cdrom_state {
   uchar_t * image_addr; //memory address
-  ulong_t capacity_B;
+  ulong_t capacity_in_bytes;
   ulong_t head; //current position
 
   struct vm_device * ide_dev;
@@ -64,6 +66,7 @@ static void cdrom_eject(void * private_data) {
  */
 static rd_bool cdrom_read_toc(void * private_data, uint8_t* buf, int* length, rd_bool msf, int start_track)
 {
+  *length = 4;
   PrintDebug("[cdrom_read_toc]\n");
   return 1;
 }
@@ -74,15 +77,15 @@ static rd_bool cdrom_read_toc(void * private_data, uint8_t* buf, int* length, rd
 static uint32_t cdrom_capacity(void * private_data) {
   struct cdrom_state * cdrom = (struct cdrom_state *)private_data;
 
-  PrintDebug("[cdrom_capacity] s_ramdiskSize = %d\n", cdrom->capacity_B);
+  PrintDebug("[cdrom_capacity] s_ramdiskSize = %d\n", cdrom->capacity_in_bytes);
 
   if (cdrom->lba) {
-    if (cdrom->capacity_B % 2048) {
-      PrintDebug("\t\t capacity in LBA is %d\n", (cdrom->capacity_B / 2048) + 1);
-      return (cdrom->capacity_B / 2048) + 1;
+    if (cdrom->capacity_in_bytes % 2048) {
+      PrintDebug("\t\t capacity in LBA is %d\n", (cdrom->capacity_in_bytes / 2048) + 1);
+      return (cdrom->capacity_in_bytes / 2048) + 1;
     } else {
-      PrintDebug("\t\t capacity in LBA is %d\n", cdrom->capacity_B / 2048);
-      return cdrom->capacity_B / 2048;
+      PrintDebug("\t\t capacity in LBA is %d\n", cdrom->capacity_in_bytes / 2048);
+      return cdrom->capacity_in_bytes / 2048;
     }
   } else {
     PrintError("Unsupported CDROM mode in capacity query\n");
@@ -101,7 +104,7 @@ static void cdrom_read_block(void * private_data, uint8_t * buf, int lba)/* __at
   
   PrintDebug("[cdrom_read_block] lba = %d (cdrom_image_start=%x)\n", lba, cdrom->image_addr);
   memcpy(buf, (uchar_t *)(cdrom->image_addr + lba * 2048), 2048);
-  PrintDebug("Returning from read block\n");
+  //PrintDebug("Returning from read block\n");
   return;
 }
 
@@ -166,7 +169,7 @@ struct vm_device *  v3_create_cdrom(struct vm_device * ramdisk_dev, void * ramdi
   memset(cd, 0, sizeof(struct cdrom_state));
 
   cd->image_addr = (uchar_t *)ramdisk;
-  cd->capacity_B = ramdisk_size;
+  cd->capacity_in_bytes = ramdisk_size;
   cd->ide_dev = ramdisk_dev;
   
   PrintDebug("Creating RamDISK CDROM\n");