#include <palacios/vmm.h>
#include <devices/cdrom.h>
#include <devices/ide.h>
-
+#include <devices/pci.h>
#ifndef TRACE_RAMDISK
#undef PrintTrace
#ifdef DEBUG_RAMDISK
static void rd_print_state(struct ramdisk_t *ramdisk);
-static int check_bit_fields(struct controller_t * controller);
#endif
drive->private_data = private_data;
-
-#ifdef DEBUG_RAMDISK
- if (check_bit_fields(controller) == INTR_REASON_BIT_ERR) {
- PrintError("interrupt reason: bit field error\n");
- return INTR_REASON_BIT_ERR;
- }
-#endif
-
controller->sector_count = 0;
drive->cdrom.cd = cd;
strcat ((char*)(drive->model_no), " ");
}
- }//for device
- }//for channel
+ }
+ }
#ifdef DEBUG_RAMDISK
rd_print_state(ramdisk);
case 0xec: // IDENTIFY DEVICE
case 0xa1:
{
-
-
controller->status.busy = 0;
controller->status.drive_ready = 1;
controller->status.write_fault = 0;
controller->status.seek_complete = 1;
controller->status.corrected_data = 0;
controller->status.err = 0;
-
+
/*
value32 = controller->buffer[index];
index++;
if (controller->buffer_index >= 512) {
controller->status.drq = 0;
}
-
+
return length;
}
case 0xa0: //send packet cmd
}
case 0x42: // read sub-channel
{
- //bool msf = get_packet_field(channel,1, 1, 1);
- bool sub_q = get_packet_field(channel,2, 6, 1);
- //uint8_t data_format = get_packet_byte(channel,3);
- //uint8_t track_number = get_packet_byte(channel,6);
- uint16_t alloc_length = get_packet_word(channel,7);
+ //bool msf = get_packet_field(channel, 1, 1, 1);
+ bool sub_q = get_packet_field(channel, 2, 6, 1);
+ //uint8_t data_format = get_packet_byte(channel, 3);
+ //uint8_t track_number = get_packet_byte(channel, 6);
+ uint16_t alloc_length = get_packet_word(channel, 7);
/*
drive->id_drive[i] = 0;
}
- for (i = 0; i < strlen(firmware)/2; i++) {
+ for (i = 0; i < strlen(firmware) / 2; i++) {
drive->id_drive[23 + i] = ((firmware[i * 2] << 8) |
(firmware[(i * 2) + 1]));
}
drive->id_drive[27 + i] = ((drive->model_no[i * 2] << 8) |
(drive->model_no[(i * 2) + 1]));
}
+
V3_ASSERT((27 + i) == 47);
drive->id_drive[47] = 0;
drive->id_drive[i] = 0;
}
- // now convert the id_drive array (native 256 word format) to
- // the controller buffer (512 bytes)
- Bit16u temp16;
- for (i = 0; i <= 255; i++) {
- temp16 = drive->id_drive[i];
- controller->buffer[i * 2] = temp16 & 0x00ff;
- controller->buffer[i * 2 + 1] = temp16 >> 8;
- }
return;
}
}
+/*
+static void init_pci(struct ramdisk_t * ramdisk) {
+struct v3_pci_bar bars[6];
+ struct pci_device * pci_dev;
+ int i;
+
+ for (i = 0; i < 6; i++) {
+ bars[i].type = PCI_BAR_NONE;
+ bars[i].mem_hook = 0;
+ bars[i].num_pages = 0;
+ bars[i].bar_update = NULL;
+ }
+
+ bars[4].type = PCI_BAR_MEM32;
+ bars[4].mem_hook = 0;
+ bars[4].num_pages = 1;
+ bars[4].bar_update = NULL;
+
+ pci_dev = v3_pci_register_device(ramdisk->pci, PCI_STD_DEVICE, 0, "IDE", -1, bars, NULL, NULL, NULL, NULL);
+
+
+ pci_dev->config_header.vendor_id = 0x8086;
+ pci_dev->config_header.device_id = 0x2421;
+
+
+}
+ */
static int ramdisk_init_device(struct vm_device *dev) {
struct ramdisk_t *ramdisk= (struct ramdisk_t *)dev->private_data;
+
+
return 0;
}
-struct vm_device * v3_create_ramdisk()
+struct vm_device * v3_create_ramdisk(struct vm_device * pci)
{
struct ramdisk_t *ramdisk;
ramdisk = (struct ramdisk_t *)V3_Malloc(sizeof(struct ramdisk_t));
V3_ASSERT(ramdisk != NULL);
+ // ramdisk->pci = pci;
+
PrintDebug("[create_ramdisk]\n");
struct vm_device * device = v3_create_device("RAMDISK", &dev_ops, ramdisk);
+
+
return device;
}
}
-
-
-static int check_bit_fields(struct controller_t * controller) {
- //Check bit fields
- controller->sector_count = 0;
- controller->interrupt_reason.c_d = 1;
- if (controller->sector_count != 0x01) {
- return INTR_REASON_BIT_ERR;
- }
-
- controller->sector_count = 0;
- controller->interrupt_reason.i_o = 1;
- if (controller->sector_count != 0x02) {
- return INTR_REASON_BIT_ERR;
- }
-
- controller->sector_count = 0;
- controller->interrupt_reason.rel = 1;
- if (controller->sector_count != 0x04) {
- return INTR_REASON_BIT_ERR;
- }
-
- controller->sector_count = 0;
- controller->interrupt_reason.tag = 3;
- if (controller->sector_count != 0x18) {
- return INTR_REASON_BIT_ERR;
- }
-
- return 0;
-}
-
#endif