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.git] / palacios / src / devices / ramdisk.c
index d20fa88..495ffe8 100644 (file)
@@ -1,7 +1,39 @@
-/* (c) 2008, Zheng Cui <cuizheng@cs.unm.edu> */
-/* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
-/* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
-
+/* 
+ *
+ *   Copyright (C) 2002  MandrakeSoft S.A.
+ *
+ *     MandrakeSoft S.A.
+ *     43, rue d'Aboukir
+ *     75002 Paris - France
+ *     http://www.linux-mandrake.com/
+ *     http://www.mandrakesoft.com/
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU Lesser General Public
+ *   License as published by the Free Software Foundation; either
+ *   version 2 of the License, or (at your option) any later version.
+ *
+ *   This library is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *   Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ * Major modifications made for the V3VEE project
+ * 
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico.  You can find out more at 
+ * http://www.v3vee.org
+ * 
+ * Copyright (c) 2008, Zheng Cui <cuizheng@cs.unm.edu>
+ * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
+ * All rights reserved for original changes
+ * 
+ */
 
 
 #include <devices/ramdisk.h>
 #undef PrintDebug
 #define PrintDebug(_f, _a...)
 #endif
-                                                 
+
+
+
+
 
 /*
  * Data type definitions
 #define SEC_ADDR_REG_PORT     0x377
 
 
-
-
-
 #define PACKET_SIZE 12
 
 
 
-// FLAT MODE
-// Open a image. Returns non-negative if successful.
-//int open (const char* pathname);
-
-// Open an image with specific flags. Returns non-negative if successful.
-int rd_open (const char* pathname, int flags);
-
-// Close the image.
-void rd_close ();
-
-// Position ourselves. Return the resulting offset from the
-// beginning of the file.
-off_t rd_lseek (off_t offset, int whence);
-
-// Read count bytes to the buffer buf. Return the number of
-// bytes read (count).
-ssize_t rd_read (void* buf, size_t count);
-
-// Write count bytes from buf. Return the number of bytes
-// written (count).
-ssize_t rd_write (const void* buf, size_t count);
-
-
-
-
-
-/*
- * Debug facilities
- */
-
-#define ATA_DETECT                     0xf0 //0X3E8
-#define ATA_RESET                      0xf1 //0X3E9
-#define ATA_CMD_DATA_IN                0xf2 //0X3EA
-#define ATA_CMD_DATA_OUT               0xf3 //0X3EB
-#define ATA_CMD_PACKET                 0xf4 //0X3EC
-#define ATAPI_GET_SENSE                0xf5 //0X3ED
-#define ATAPI_IS_READY                 0xf6 //0X3EE
-#define ATAPI_IS_CDROM                 0xf7 //0X3EF
-
-#define CDEMU_INIT                     0xf8 //0X2E8
-#define CDEMU_ISACTIVE                 0xf9 //0X2E9
-#define CDEMU_EMULATED_DRIVE           0xfa //0X2EA
-#define CDROM_BOOT                     0xfb //0X2EB
-
-
-#define HARD_DRIVE_POST                0xfc //0X2EC
-
-
-#define ATA_DEVICE_NO                  0xfd //0X2ED
-#define ATA_DEVICE_TYPE                0xfe //0X2ED
-
-#define INT13_HARDDISK                 0xff //0x2ef
-#define INT13_CDROM                    0xe0 //0x2f8
-#define INT13_CDEMU                    0xe1 //0x2f9
-#define INT13_ELTORITO                 0xe2 //0x2fa
-#define INT13_DISKETTE_FUNCTION        0xe3 //0x2fb
-
-
-
-
 static const char cdrom_str[] = "CD-ROM";
 static const char harddisk_str[] = "HARDDISK";
 static const char none_str[] = "NONE";
@@ -349,6 +321,68 @@ static int check_bit_fields(struct controller_t * controller);
 
 
 
+int v3_ramdisk_register_cdrom(struct vm_device * dev, uint_t busID, uint_t driveID, struct cdrom_ops* cd, void * private_data) {
+  struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct channel_t * channel = &(ramdisk->channels[busID]);
+  struct drive_t * drive = &(channel->drives[driveID]);
+  struct controller_t * controller = &(drive->controller);
+
+
+  
+  if (drive->device_type != IDE_NONE) {
+    PrintError("Device already registered at this location\n");
+    return -1;
+  }
+
+
+  channel->irq =  15;
+
+  // Make model string
+  strncpy((char*)(drive->model_no), "V3VEE Ramdisk", 40);
+
+  while (strlen((char *)(drive->model_no)) < 40) {
+    strcat ((char*)(drive->model_no), " ");
+  }
+  
+  PrintDebug("CDROM on target %d/%d\n", busID, driveID);
+  
+  drive->device_type = IDE_CDROM;
+  drive->cdrom.locked = 0;
+  drive->sense.sense_key = SENSE_NONE;
+  drive->sense.asc = 0;
+  drive->sense.ascq = 0;
+  
+  drive->private_data = private_data;
+
+#ifdef DEBUG_RAMDISK
+  if (check_bit_fields(controller) == INTR_REASON_BIT_ERR) {
+    PrintDebug("interrupt reason: bit field error\n");
+    return INTR_REASON_BIT_ERR;
+  }
+#endif
+  
+  controller->sector_count = 0;
+
+  drive->cdrom.cd = cd;
+  
+  PrintDebug("\t\tCD on ata%d-%d: '%s'\n", 
+            busID, 
+            driveID, "");
+  
+  if(drive->cdrom.cd->insert_cdrom(drive->private_data)) {
+    PrintDebug("\t\tMedia present in CD-ROM drive\n");
+    drive->cdrom.ready = 1;
+    drive->cdrom.capacity = drive->cdrom.cd->capacity(drive->private_data);
+    PrintDebug("\t\tCDROM capacity is %d\n", drive->cdrom.capacity);
+  } else {                 
+    PrintDebug("\t\tCould not locate CD-ROM, continuing with media not present\n");
+    drive->cdrom.ready = 0;
+  }
+  
+  return 0;
+}
+
+
 static Bit32u rd_init_hardware(struct ramdisk_t *ramdisk) {
   uint_t channel_num; 
   uint_t device;
@@ -408,65 +442,6 @@ static Bit32u rd_init_hardware(struct ramdisk_t *ramdisk) {
         strcat ((char*)(drive->model_no), " ");
       }
 
-
-      
-      
-      if (channel_num == 1) {
-
-       channel->ioaddr1 = 0x170;
-       channel->ioaddr2 = 0x370;
-       channel->irq =  15;
-       channel->drive_select = 0;
-       
-       if (device == 0) {
-         // Make model string
-         strncpy((char*)(drive->model_no), "V3VEE Ramdisk", 40);
-         while (strlen((char *)(drive->model_no)) < 40) {
-           strcat ((char*)(drive->model_no), " ");
-         }
-         
-         PrintDebug("CDROM on target %d/%d\n", channel_num, device);
-         
-         drive->device_type = IDE_CDROM;
-         drive->cdrom.locked = 0;
-         drive->sense.sense_key = SENSE_NONE;
-         drive->sense.asc = 0;
-         drive->sense.ascq = 0;
-         
-#ifdef DEBUG_RAMDISK
-         if (check_bit_fields(controller) == INTR_REASON_BIT_ERR) {
-           PrintDebug("interrupt reason: bit field error\n");
-           return INTR_REASON_BIT_ERR;
-         }
-#endif
-         
-         controller->sector_count = 0;
-
-         // allocate low level driver
-         drive->cdrom.cd = (struct cdrom_interface *)V3_Malloc(sizeof(struct cdrom_interface));
-         PrintDebug("cd = %x\n", drive->cdrom.cd);
-         V3_ASSERT(drive->cdrom.cd != NULL);
-         
-         struct cdrom_interface * cdif = drive->cdrom.cd;
-         memset(cdif, 0, sizeof(struct cdrom_interface));
-         init_cdrom(cdif);
-         cdif->ops.init(cdif);
-
-         PrintDebug("\t\tCD on ata%d-%d: '%s'\n", 
-                    channel_num, 
-                    device, "");
-         
-         if((drive->cdrom.cd->ops).insert_cdrom(cdif, NULL)) {
-           PrintDebug("\t\tMedia present in CD-ROM drive\n");
-           drive->cdrom.ready = 1;
-           drive->cdrom.capacity = drive->cdrom.cd->ops.capacity(cdif);
-         } else {                  
-           PrintDebug("\t\tCould not locate CD-ROM, continuing with media not present\n");
-           drive->cdrom.ready = 0;
-         }
-         
-       }//if device = 0
-      }//if channel = 0
     }//for device
   }//for channel
 
@@ -516,7 +491,7 @@ static int read_data_port(ushort_t port, void * dst, uint_t length, struct vm_de
   PrintDebug("[read_data_handler] IO Read at 0x%x, on drive %d/%d (current_cmd = 0x%02x)\n", 
             port, 
             get_channel_no(ramdisk, channel),
-            get_drive_no(channel, drive),
+            get_drive_no(channel, drive), 
             controller->current_command);
 
   switch (controller->current_command) {
@@ -581,15 +556,14 @@ static int read_data_port(ushort_t port, void * dst, uint_t length, struct vm_de
        case 0x28: // read (10)
        case 0xa8: // read (12)
          {
-           struct cdrom_interface * cdif = drive->cdrom.cd;
-           
+    
            if (!(drive->cdrom.ready)) {
              PrintError("\t\tRead with CDROM not ready\n");
              return -1;
            } 
            
-           drive->cdrom.cd->ops.read_block(cdif, controller->buffer,
-                                           drive->cdrom.next_lba);
+           drive->cdrom.cd->read_block(drive->private_data, controller->buffer,
+                                       drive->cdrom.next_lba);
            drive->cdrom.next_lba++;
            drive->cdrom.remaining_blocks--;
            
@@ -711,9 +685,13 @@ static int write_data_port(ushort_t port, void * src, uint_t length, struct vm_d
   drive = get_selected_drive(channel);
   controller = &(drive->controller);
 
+
   PrintDebug("[write_data_handler] IO write at 0x%x, current_cmd = 0x%02x\n", 
-            port, controller->current_command);
-  
+            port, controller->current_command);
+
+
+  //PrintDebug("[write_data_handler]\n");
   switch (controller->current_command) {
   case 0x30: // WRITE SECTORS
     PrintError("\t\tneed to implement 0x30(write sector) to port 0x%x\n", port);
@@ -733,6 +711,9 @@ static int write_data_port(ushort_t port, void * src, uint_t length, struct vm_d
 
     return -1;
   }
+
+
+  return -1;
 }
 
 
@@ -748,10 +729,7 @@ static int read_status_port(ushort_t port, void * dst, uint_t length, struct vm_
   struct controller_t * controller = NULL;
 
 
-  if (length != 1) {
-    PrintError("Invalid Status port read length: %d (port=%d)\n", length, port);
-    return -1;
-  }
+
 
   if (is_primary_port(ramdisk, port)) {
     channel = &(ramdisk->channels[0]);
@@ -765,6 +743,7 @@ static int read_status_port(ushort_t port, void * dst, uint_t length, struct vm_
   drive = get_selected_drive(channel);
   controller = &(drive->controller);
 
   PrintDebug("[read_status_handler] IO read at 0x%x, on drive %d/%d\n", 
             port, get_channel_no(ramdisk, channel), 
             channel->drive_select);
@@ -784,7 +763,8 @@ static int read_status_port(ushort_t port, void * dst, uint_t length, struct vm_
                   (controller->status.corrected_data << 2)  |
                   (controller->status.index_pulse << 1)     |
                   (controller->status.err) );
-   
+
+
     memcpy(dst, &val, length);
 
     controller->status.index_pulse_count++;
@@ -800,6 +780,8 @@ static int read_status_port(ushort_t port, void * dst, uint_t length, struct vm_
     rd_lower_irq(dev, channel->irq);
   }
   
+  PrintDebug("\t\tRead STATUS = 0x%x\n", *(uchar_t *)dst);
+
   return length;
   
 }
@@ -894,7 +876,9 @@ static int write_cmd_port(ushort_t port, void * src, uint_t length, struct vm_de
     }
   default:
     PrintError("\t\tneed translate command %2x\n", value);
-    return -1;
+    //return -1;
+    /* JRL THIS NEEDS TO CHANGE */
+    return length;
 
   }
   return length;
@@ -940,6 +924,11 @@ static int write_ctrl_port(ushort_t port, void * src, uint_t length, struct vm_d
   
   prev_control_reset = controller->control.reset;
 
+
+  if (value & 0x04) {
+    PrintDebug("RESET Signaled\n");
+  }
+
   master_drive->controller.control.reset         = value & 0x04;
   slave_drive->controller.control.reset         = value & 0x04;
 
@@ -1076,6 +1065,8 @@ static int read_general_port(ushort_t port, void * dst, uint_t length, struct vm
       
       controller->status.err = 0;
       
+      PrintDebug("\t\tRead FEATURES = 0x%x\n", val);
+
       *(uchar_t *)dst = val;
       return length;
       
@@ -1086,7 +1077,7 @@ static int read_general_port(ushort_t port, void * dst, uint_t length, struct vm
   case SEC_SECT_CNT_PORT:  // hard disk sector count / interrupt reason 0x1f2
     {
       uchar_t val = (drive->device_type == IDE_NONE) ? 0 : controller->sector_count;
-
+      PrintDebug("\t\tRead SECTOR COUNT = 0x%x\n", val);
       *(uchar_t *)dst = val;
       return length;
 
@@ -1094,9 +1085,11 @@ static int read_general_port(ushort_t port, void * dst, uint_t length, struct vm
     }
   case PRI_SECT_ADDR1_PORT:
   case SEC_SECT_ADDR1_PORT: // sector number 0x1f3
-    {
+    { 
       uchar_t val = (drive->device_type == IDE_NONE) ? 0 : controller->sector_no;
 
+      PrintDebug("\t\tRead SECTOR ADDR1 = 0x%x\n", val);
+
       *(uchar_t *)dst = val;
       return length;
 
@@ -1111,6 +1104,8 @@ static int read_general_port(ushort_t port, void * dst, uint_t length, struct vm
       // to detect the disks.... minix2 for example
       uchar_t val = (num_drives_on_channel(channel) == 0) ? 0 : (controller->cylinder_no & 0x00ff);
 
+      PrintDebug("\t\tRead SECTOR ADDR2 = 0x%x\n", val);
+
       *(uchar_t *)dst = val;
       return length;
 
@@ -1125,6 +1120,8 @@ static int read_general_port(ushort_t port, void * dst, uint_t length, struct vm
       // to detect the disks.... minix2 for example
       uchar_t val = (num_drives_on_channel(channel) == 0) ? 0 : (controller->cylinder_no >> 8);
 
+      PrintDebug("\t\tRead SECTOR ADDR3 = 0x%x\n", val);
+
       *(uchar_t *)dst = val;
       return length;
 
@@ -1146,6 +1143,7 @@ static int read_general_port(ushort_t port, void * dst, uint_t length, struct vm
                     (channel->drive_select << 4)      |
                     (controller->head_no << 0));
       
+      PrintDebug("\t\tRead DRIVE SELECT = 0x%x\n", val);
       *(uchar_t *)dst = val;
       return length;
 
@@ -1198,7 +1196,7 @@ static int write_general_port(ushort_t port, void * src, uint_t length, struct v
 
 
   PrintDebug("[write_general_handler] IO write to port %x (val=0x%02x), channel = %d\n", 
-            port,  value, get_channel_no(ramdisk, channel));
+            port, value, get_channel_no(ramdisk, channel));
 
   switch (port) {
 
@@ -1257,9 +1255,15 @@ static int write_general_port(ushort_t port, void * src, uint_t length, struct v
       }
 
       write_lba_mode(channel, (value >> 6) & 1);
-      drive->cdrom.cd->lba = (value >> 6) & 1;
-      
+
+
+
+      if (drive->cdrom.cd) {
+       PrintDebug("\t\tSetting LBA on CDROM: %d\n", (value >> 6) & 1);
+       drive->cdrom.cd->set_LBA(drive->private_data, (value >> 6) & 1);
+      }
       
+
       channel->drive_select = (value >> 4) & 0x01;
       drive = get_selected_drive(channel);
 
@@ -1327,7 +1331,7 @@ static void rd_lower_irq(struct vm_device *dev, Bit32u irq)  // __attribute__(re
 
 
 int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * channel, ushort_t value) {
-  //struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
   struct drive_t * drive = get_selected_drive(channel);
   struct controller_t * controller = &(drive->controller);
 
@@ -1407,7 +1411,7 @@ int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * chann
          rd_raise_interrupt(dev, channel);
        } else if (!LoEj && Start) { // start (spin up) the disc
          
-         drive->cdrom.cd->ops.start_cdrom(drive->cdrom.cd);
+         drive->cdrom.cd->start_cdrom(drive->private_data);
          
          PrintError("FIXME: ATAPI start disc not reading TOC\n");
          rd_atapi_cmd_nop(dev, channel);
@@ -1417,7 +1421,7 @@ int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * chann
          
          if (drive->cdrom.ready) {
            
-           drive->cdrom.cd->ops.eject_cdrom(drive->cdrom.cd);
+           drive->cdrom.cd->eject_cdrom(drive->private_data);
            
            drive->cdrom.ready = 0;
            //bx_options.atadevice[channel][SLAVE_SELECTED(channel)].Ostatus->set(EJECTED);
@@ -1695,7 +1699,7 @@ int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * chann
     case 0x43: // read toc
       { 
        if (drive->cdrom.ready) {
-         int toc_length;  
+         int toc_length = 0;  
          bool msf = (controller->buffer[1] >> 1) & 1;
          uint8_t starting_track = controller->buffer[6];
          
@@ -1703,24 +1707,33 @@ int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * chann
          
          uint8_t format = (controller->buffer[9] >> 6);
          int i;
+
+         PrintDebug("Reading CDROM TOC: Format=%d (byte count=%d) (toc length:%d)\n", 
+                    format, controller->byte_count, toc_length);
+
          switch (format) {
          case 0:
-           
-           if (!(drive->cdrom.cd->ops.read_toc(drive->cdrom.cd, controller->buffer,
-                                               &toc_length, msf, starting_track))) {
-             rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST,
-                                ASC_INV_FIELD_IN_CMD_PACKET);
-             rd_raise_interrupt(dev, channel);
-           } else {
+           {
+             if (!(drive->cdrom.cd->read_toc(drive->private_data, controller->buffer,
+                                             &toc_length, msf, starting_track))) {
+               PrintError("CDROM: Reading Table of Contents Failed\n");
+               rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST,
+                                  ASC_INV_FIELD_IN_CMD_PACKET);
+               rd_raise_interrupt(dev, channel);
+               break;
+             }
+
              if (rd_init_send_atapi_command(dev, channel, atapi_command, toc_length, alloc_length, false) == -1) {
                return -1;
              }
-             rd_ready_to_send_atapi(dev, channel);
+
+             rd_ready_to_send_atapi(dev, channel);    
+
+             break;
            }
-           break;
-           
          case 1:
            // multi session stuff. we ignore this and emulate a single session only
+
            if (rd_init_send_atapi_command(dev, channel, atapi_command, 12, alloc_length, false) == -1) {
              return -1;
            }
@@ -1747,7 +1760,7 @@ int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * chann
          rd_raise_interrupt(dev, channel);
        }
        break;
-      }  
+      }
     case 0x28: // read (10)
     case 0xa8: // read (12)
       { 
@@ -1762,6 +1775,8 @@ int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * chann
        uint32_t lba = rd_read_32bit(controller->buffer + 2);
        
        if (!(drive->cdrom.ready)) {
+         PrintError("CDROM Error: Not Ready (ATA%d/%d)\n", 
+                    get_channel_no(ramdisk, channel), get_drive_no(channel, drive));
          rd_atapi_cmd_error(dev, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
          rd_raise_interrupt(dev, channel);
          break;
@@ -1770,11 +1785,15 @@ int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * chann
        if (transfer_length == 0) {
          rd_atapi_cmd_nop(dev, channel);
          rd_raise_interrupt(dev, channel);
-         PrintDebug("\t\tREAD(%d) with transfer length 0, ok\n", (atapi_command == 0x28) ? 10 : 12);
+         PrintError("READ(%d) with transfer length 0, ok\n", 
+                    (atapi_command == 0x28) ? 10 : 12);
          break;
        }
        
        if (lba + transfer_length > drive->cdrom.capacity) {
+         PrintError("CDROM Error: Capacity exceeded [capacity=%d] (ATA%d/%d)\n",
+                    drive->cdrom.capacity,
+                    get_channel_no(ramdisk, channel), get_drive_no(channel, drive));
          rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST, ASC_LOGICAL_BLOCK_OOR);
          rd_raise_interrupt(dev, channel);
          break;
@@ -1787,8 +1806,10 @@ int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * chann
        // handle command
        if (rd_init_send_atapi_command(dev, channel, atapi_command, transfer_length * 2048,
                                       transfer_length * 2048, true) == -1) {
+         PrintError("CDROM Error: Atapi command send error\n");
          return -1;
        }
+
        drive->cdrom.remaining_blocks = transfer_length;
        drive->cdrom.next_lba = lba;
        rd_ready_to_send_atapi(dev, channel);
@@ -1904,6 +1925,8 @@ int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * chann
       break;
     }
   }
+       
+             
   return 0;
 }
 
@@ -1928,9 +1951,9 @@ int rd_init_send_atapi_command(struct vm_device * dev, struct channel_t * channe
       !(alloc_length <= controller->byte_count)) {
       
     PrintDebug("\t\tOdd byte count (0x%04x) to ATAPI command 0x%02x, using 0x%x\n", 
-                 controller->byte_count, 
-                 command, 
-                 controller->byte_count - 1);
+              controller->byte_count, 
+              command, 
+              controller->byte_count - 1);
     
     controller->byte_count -= 1;
   }
@@ -1987,9 +2010,9 @@ int rd_init_send_atapi_command(struct vm_device * dev, struct channel_t * channe
 
 
 
- void rd_ready_to_send_atapi(struct vm_device * dev, struct channel_t * channel) {
+void rd_ready_to_send_atapi(struct vm_device * dev, struct channel_t * channel) {
   PrintDebug("[rd_ready_to_send_atapi]\n");
-
+  
   rd_raise_interrupt(dev, channel);
 }
 
@@ -2470,119 +2493,7 @@ static void rd_print_state(struct ramdisk_t * ramdisk) {
   return;
 }
 
-#if 0
-static void trace_info(ushort_t port, void *src, uint_t length) {
 
-  switch(port){
-
-  case 0x3e8:
-    if (length == 1 && *((uchar_t*) src) == ATA_DETECT)
-      PrintDebug("ata_detect()\n");
-    break;
-
-  case 0x3e9:
-    if (length == 1 && *((uchar_t*) src) == ATA_RESET)
-      PrintDebug("ata_reset()\n");
-    break;
-
-  case 0x3ea:
-    if (length == 1 && *((uchar_t*) src) == ATA_CMD_DATA_IN)
-      PrintDebug("ata_cmd_data_in()\n");
-    break;
-
-  case 0x3eb:
-    if (length == 1 && *((uchar_t*) src) == ATA_CMD_DATA_OUT)
-      PrintDebug("ata_cmd_data_out()\n");
-    break;
-
-  case 0x3ec:
-    if (length == 1 && *((uchar_t*) src) == ATA_CMD_PACKET)
-      PrintDebug("ata_cmd_packet()\n");
-    break;
-
-  case 0x3ed:
-    if (length == 1 && *((uchar_t*) src) == ATAPI_GET_SENSE)
-      PrintDebug("atapi_get_sense()\n");
-    break;
-
-  case 0x3ee:
-    if (length == 1 && *((uchar_t*) src) == ATAPI_IS_READY)
-      PrintDebug("atapi_is_ready()\n");
-    break;
-
-  case 0x3ef:
-    if (length == 1 && *((uchar_t*) src) == ATAPI_IS_CDROM)
-      PrintDebug("atapi_is_cdrom()\n");
-    break;
-
-
-  case 0x2e8:
-    if (length == 1 && *((uchar_t*) src) == CDEMU_INIT)
-      PrintDebug("cdemu_init()\n");
-    break;
-
-  case 0x2e9:
-    if (length == 1 && *((uchar_t*) src) == CDEMU_ISACTIVE)
-      PrintDebug("cdemu_isactive()\n");
-    break;
-
-  case 0x2ea:
-    if (length == 1 && *((uchar_t*) src) == CDEMU_EMULATED_DRIVE)
-      PrintDebug("cdemu_emulated_drive()\n");
-    break;
-
-  case 0x2eb:
-    if (length == 1 && *((uchar_t*) src) == CDROM_BOOT)
-      PrintDebug("cdrom_boot()\n");
-    break;
-
-  case 0x2ec:
-    if (length == 1 && *((uchar_t*) src) == HARD_DRIVE_POST)
-      PrintDebug("ata_hard_drive_post()\n");
-    break;
-
-  case 0x2ed:
-    if (length == 1)
-      PrintDebug("ata_device_no(%d)\n", *((uchar_t*) src));
-    break;
-
-  case 0x2ee:
-    if (length == 1)
-      PrintDebug("ata_device_type(%d)\n", *((uchar_t*) src));
-    break;
-
-  case 0x2ef:
-    if (length == 1 && *((uchar_t*) src) == INT13_HARDDISK)
-      PrintDebug("int13_harddrive()\n");
-    break;
-
-  case 0x2f8:
-    if (length == 1 && *((uchar_t*) src) == INT13_CDROM)
-      PrintDebug("int13_cdrom()\n");
-    break;
-
-  case 0x2f9:
-    if (length == 1 && *((uchar_t*) src) == INT13_CDEMU)
-      PrintDebug("int13_cdemu()\n");
-    break;
-
-  case 0x2fa:
-    if (length == 1 && *((uchar_t*) src) == INT13_ELTORITO)
-      PrintDebug("int13_eltorito()\n");
-    break;
-
-  case 0x2fb:
-    if (length == 1 && *((uchar_t*) src) == INT13_DISKETTE_FUNCTION)
-      PrintDebug("int13_diskette_function()\n");
-    break;
-
-
-  default:
-    break;
-  }
-}
-
-#endif
 
 static int check_bit_fields(struct controller_t * controller) {
   //Check bit fields