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.


added RAM based CD, updates to device registration
Jack Lange [Wed, 18 Mar 2009 21:33:45 +0000 (16:33 -0500)]
palacios/build/Makefile
palacios/include/devices/ide.h
palacios/src/devices/ide-types.h
palacios/src/devices/ide.c

index ebd751b..6d62c0b 100644 (file)
@@ -321,7 +321,7 @@ DEVICES_OBJS := \
        devices/pci.o \
        devices/para_net.o \
        devices/ide.o \
-
+       devices/ram_cd.o \
 
 #      devices/cdrom.o \
 #      devices/ramdisk.o \
index ee6f2c5..a5b6ea0 100644 (file)
 #include <palacios/vm_dev.h>
 
 
+typedef enum {IDE_DISK, IDE_CDROM, IDE_NONE} v3_ide_dev_type_t;
+
+struct v3_ide_cd_ops {
+    uint32_t (*get_capacity)(void * private_data);
+    // Reads always operate on 2048 byte blocks
+    int (*read_block)(uchar_t * buf, int offset, void * private_data);
+
+};
+
+
+struct v3_ide_hd_ops {
+    
+
+};
+
+
+int v3_ide_register_cdrom(struct vm_device * ide, 
+                         uint_t bus_num, 
+                         uint_t drive_num, 
+                         char * drive_name,
+                         struct v3_ide_cd_ops * ops, 
+                         void * private_data);
+
+int v3_ide_register_harddisk(struct vm_device * ide, 
+                            uint_t bus_num, 
+                            uint_t drive_num, 
+                            char * drive_name,
+                            struct v3_ide_hd_ops * ops, 
+                            void * private_data);
+
+
+
 struct vm_device * v3_create_ide();
 
 
index 4dbdc1d..f881157 100644 (file)
@@ -78,7 +78,7 @@ struct ide_ctrl_reg {
        uint8_t val;
        struct {
            uint_t rsvd0        : 1;
-           uint_t irq_enable   : 1;
+           uint_t irq_disable   : 1;
            uint_t soft_reset   : 1;
            uint_t rsvd1        : 5;
        } __attribute__((packed));
index d0adb63..87e10c3 100644 (file)
 #define SEC_ADDR_REG_PORT     0x377
 
 
-typedef enum {IDE_DISK, IDE_CDROM, IDE_NONE} ide_dev_type_t;
+
 static const char * ide_dev_type_strs[] = {"HARDDISK", "CDROM", "NONE"};
 
 
-static inline const char * device_type_to_str(ide_dev_type_t type) {
+static inline const char * device_type_to_str(v3_ide_dev_type_t type) {
     if (type > 2) {
        return NULL;
     }
@@ -65,9 +65,17 @@ static inline const char * device_type_to_str(ide_dev_type_t type) {
 struct ide_drive {
     // Command Registers
 
-    ide_dev_type_t drive_type;
+    v3_ide_dev_type_t drive_type;
+
+    union {
+       struct v3_ide_cd_ops * cd_ops;
+       struct v3_ide_hd_ops * hd_ops;
+    };
 
 
+    char model[41];
+    void * private_data;
+
     uint8_t sector_count;               // 0x1f2,0x172
     uint8_t sector_num;               // 0x1f3,0x173
     union {
@@ -162,7 +170,7 @@ static void channel_reset(struct ide_channel * channel) {
     // clear commands
     channel->command_reg = 0x00;
 
-    channel->ctrl_reg.irq_enable = 0;
+    channel->ctrl_reg.irq_disable = 0;
 }
 
 static void channel_reset_complete(struct ide_channel * channel) {
@@ -365,9 +373,11 @@ static void init_drive(struct ide_drive * drive) {
     drive->sector_num = 0x01;
     drive->cylinder = 0x0000;
 
-
     drive->drive_type = IDE_NONE;
 
+    memset(drive->model, 0, sizeof(drive->model));
+
+    drive->cd_ops = NULL;
 }
 
 static void init_channel(struct ide_channel * channel) {
@@ -482,3 +492,74 @@ struct vm_device *  v3_create_ide() {
 
     return device;
 }
+
+
+
+
+
+int v3_ide_register_cdrom(struct vm_device * ide_dev, 
+                         uint_t bus_num, 
+                         uint_t drive_num,
+                         char * dev_name, 
+                         struct v3_ide_cd_ops * ops, 
+                         void * private_data) {
+
+    struct ide_internal * ide  = (struct ide_internal *)(ide_dev->private_data);  
+    struct ide_channel * channel = NULL;
+    struct ide_drive * drive = NULL;
+
+    V3_ASSERT((bus_num >= 0) && (bus_num < 2));
+    V3_ASSERT((drive_num >= 0) && (drive_num < 2));
+
+    channel = &(ide->channels[bus_num]);
+    drive = &(channel->drives[drive_num]);
+    
+    if (drive->drive_type != IDE_NONE) {
+       PrintError("Device slot (bus=%d, drive=%d) already occupied\n", bus_num, drive_num);
+       return -1;
+    }
+
+    strncpy(drive->model, dev_name, sizeof(drive->model) - 1);
+
+    drive->drive_type = IDE_CDROM;
+
+    drive->cd_ops = ops;
+
+    drive->private_data = private_data;
+
+    return 0;
+}
+
+
+int v3_ide_register_harddisk(struct vm_device * ide_dev, 
+                            uint_t bus_num, 
+                            uint_t drive_num, 
+                            char * dev_name, 
+                            struct v3_ide_hd_ops * ops, 
+                            void * private_data) {
+
+    struct ide_internal * ide  = (struct ide_internal *)(ide_dev->private_data);  
+    struct ide_channel * channel = NULL;
+    struct ide_drive * drive = NULL;
+
+    V3_ASSERT((bus_num >= 0) && (bus_num < 2));
+    V3_ASSERT((drive_num >= 0) && (drive_num < 2));
+
+    channel = &(ide->channels[bus_num]);
+    drive = &(channel->drives[drive_num]);
+    
+    if (drive->drive_type != IDE_NONE) {
+       PrintError("Device slot (bus=%d, drive=%d) already occupied\n", bus_num, drive_num);
+       return -1;
+    }
+
+    strncpy(drive->model, dev_name, sizeof(drive->model) - 1);
+
+    drive->drive_type = IDE_DISK;
+
+    drive->hd_ops = ops;
+
+    drive->private_data = private_data;
+
+    return 0;
+}