palacios:
+ (cd $(PALACIOS_BUILD_DIR) && make $(DEBUG_SECTIONS))
+
+
+palacios-full:
(cd $(PALACIOS_BUILD_DIR) && make $(DEBUG_SECTIONS) world)
cp $(PALACIOS_BUILD_DIR)/libv3vee.a $(GEEKOS_BUILD_DIR)/palacios/
cp $(PALACIOS_BUILD_DIR)/../lib/xed/libxed.a $(GEEKOS_BUILD_DIR)/palacios/
cp $(PALACIOS_BUILD_DIR)/vm_kernel $(GEEKOS_BUILD_DIR)/palacios/
+ (cd $(GEEKOS_BUILD_DIR) && make)
+
+
+geekos-full:
+ cp $(PALACIOS_BUILD_DIR)/libv3vee.a $(GEEKOS_BUILD_DIR)/palacios/
+ cp $(PALACIOS_BUILD_DIR)/../lib/xed/libxed.a $(GEEKOS_BUILD_DIR)/palacios/
+ cp $(PALACIOS_BUILD_DIR)/vm_kernel $(GEEKOS_BUILD_DIR)/palacios/
(cd $(GEEKOS_BUILD_DIR) && make clean && make)
+world: palacios-full geekos-full
+
# make ready to boot over PXE
-geekos-pxe: geekos
+geekos-pxe:
cp $(GEEKOS_BUILD_DIR)/vmm.img /tftpboot/vmm.img
-geekos-run: geekos
+geekos-run:
$(QEMU) -m 1024 -serial file:serial.out -cdrom $(GUEST_ISO_DIR)/puppy.iso -fda $(GEEKOS_BUILD_DIR)/vmm.img
-geekos-iso: geekos
+geekos-iso:
cp $(GEEKOS_BUILD_DIR)/vmm.img iso/vmm.img
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o test.iso iso
#
#LWIP, ON -- used, OFF -- not used
#
-LWIP=ON
+LWIP=OFF
#
V3_LD_FLAGS := -L./palacios/
#V3_LIBS := -lxed -lv3vee
V3_LIBS := ./palacios/libxed.a ./palacios/libv3vee.a ./palacios/libxed.a ./palacios/libv3vee.a
-
+V3_OBJS := ./palacios/libxed.a ./palacios/libv3vee.a ./palacios/vm_kernel
endif
ifeq ($(LWIP),ON)
- LWIP_OBJS := lwip/*.o
+ LWIP_OBJS := lwip
CC_LWIP_OPTS := -I$(PROJECT_ROOT)/include/lwip -I$(PROJECT_ROOT)/include/lwip/ipv4 -I$(PROJECT_ROOT)/include/libc -DLWIP_DEBUG
else
LWIP_OBJS :=
all : $(ALL_TARGETS)
-force_lwip:
+lwip:
(cd ../src/lwip/build; make clean; make)
$(PAD) $@ 512
# The kernel executable and symbol map.
-geekos/kernel.exe : $(KERNEL_OBJS) $(COMMON_C_OBJS) force_lwip
+geekos/kernel.exe : $(KERNEL_OBJS) $(COMMON_C_OBJS) $(TCPSTACK_OBJS) $(V3_OBJS)
$(TARGET_LD) -o geekos/kernel.exe -Ttext $(KERNEL_BASE_ADDR) -e $(KERNEL_ENTRY) \
$(V3_LD_FLAGS) \
$(KERNEL_OBJS) $(COMMON_C_OBJS) $(TCPSTACK_OBJS) $(V3_LIBS) -b binary ./palacios/vm_kernel
int memSizeKB; /* number of KB, as reported by int 15h */
/*Zheng 08/02/2008*/
- unsigned long ramdisk_image; /*ramdisk load addr*/
+ void * ramdisk_image; /*ramdisk load addr*/
unsigned long ramdisk_size;
};
*/
struct Page* g_pageList;
-ulong_t g_ramdiskImage;
+void * g_ramdiskImage;
ulong_t s_ramdiskSize;
g_ramdiskImage = bootInfo->ramdisk_image;
s_ramdiskSize = bootInfo->ramdisk_size;
- ulong_t initrdAddr;
- ulong_t initrdEnd;
+ ulong_t initrdAddr = 0;
+ ulong_t initrdEnd = 0;
* Zheng 08/03/2008
* copy the ramdisk to this area
*/
-
- initrdAddr = vmmMemEnd;
- initrdEnd = Round_Up_To_Page(initrdAddr + s_ramdiskSize);
- PrintBoth("mem.c(%d) Move ramdisk(%dB) from %x to %x", __LINE__, s_ramdiskSize, g_ramdiskImage, initrdAddr);
- memcpy((ulong_t *)initrdAddr, (ulong_t *)g_ramdiskImage, s_ramdiskSize);
- PrintBoth(" done\n");
- PrintBoth("mem.c(%d) Set 0 to unused bytes in the last ramdisk page from %x to %x", __LINE__, initrdAddr+s_ramdiskSize, initrdEnd);
- memset((ulong_t *)initrdAddr + s_ramdiskSize, 0, initrdEnd - (initrdAddr + s_ramdiskSize));
- PrintBoth(" done\n");
-
+ if (s_ramdiskSize > 0) {
+ initrdAddr = vmmMemEnd;
+ initrdEnd = Round_Up_To_Page(initrdAddr + s_ramdiskSize);
+ PrintBoth("mem.c(%d) Move ramdisk(%dB) from %x to %x", __LINE__, s_ramdiskSize, g_ramdiskImage, initrdAddr);
+ memcpy((ulong_t *)initrdAddr, (ulong_t *)g_ramdiskImage, s_ramdiskSize);
+ PrintBoth(" done\n");
+ PrintBoth("mem.c(%d) Set 0 to unused bytes in the last ramdisk page from %x to %x", __LINE__, initrdAddr+s_ramdiskSize, initrdEnd);
+ memset((ulong_t *)initrdAddr + s_ramdiskSize, 0, initrdEnd - (initrdAddr + s_ramdiskSize));
+ PrintBoth(" done\n");
+ }
/*
/*
* Zheng 08/03/2008
*/
- vm_range_start = initrdEnd;
- vm_range_end = endOfMem;
-
+ if (s_ramdiskSize > 0) {
+ vm_range_start = initrdEnd;
+ vm_range_end = endOfMem;
+ }
Add_Page_Range(0, PAGE_SIZE, PAGE_UNUSED); // BIOS area
Add_Page_Range(PAGE_SIZE, PAGE_SIZE * 3, PAGE_ALLOCATED); // Intial kernel thread obj + stack
Add_Page_Range(pageListAddr, pageListEnd, PAGE_KERN); // Page List
Add_Page_Range(pageListEnd, vmmMemEnd, PAGE_AVAIL); // Available VMM memory
-#ifdef RAMDISK_BOOT
- /*
- * Zheng 08/03/2008
- */
- Add_Page_Range(vmmMemEnd, initrdEnd, PAGE_ALLOCATED); //Ramdisk memory area
- // Add_Page_Range(vmmMemEnd, endOfMem, PAGE_VM); // Memory allocated to the VM
- // Until we get a more intelligent memory allocator
- Add_Page_Range(initrdEnd, endOfMem, PAGE_AVAIL); // Memory allocated to the VM
-#else
- Add_Page_Range(vmmMemEnd, endOfMem, PAGE_AVAIL); // Memory allocated to the VM
-#endif
+
+ if (s_ramdiskSize > 0) {
+ /*
+ * Zheng 08/03/2008
+ */
+ Add_Page_Range(vmmMemEnd, initrdEnd, PAGE_ALLOCATED); //Ramdisk memory area
+ // Add_Page_Range(vmmMemEnd, endOfMem, PAGE_VM); // Memory allocated to the VM
+ // Until we get a more intelligent memory allocator
+ Add_Page_Range(initrdEnd, endOfMem, PAGE_AVAIL); // Memory allocated to the VM
+ } else {
+ Add_Page_Range(vmmMemEnd, endOfMem, PAGE_AVAIL); // Memory allocated to the VM
+ }
/* Initialize the kernel heap */
Init_Heap(heapAddr, KERNEL_HEAP_SIZE);
PrintBoth("%lx to %lx - PAGE LIST\n", pageListAddr, pageListEnd - 1);
PrintBoth("%lx to %x - FREE\n", pageListEnd, vmmMemEnd - 1);
-#ifdef RAMDISK_BOOT
- /*
- * Zheng 08/03/2008
- */
- PrintBoth("%lx to %x - RAMDISK\n", vmmMemEnd, initrdEnd - 1);
- PrintBoth("%lx to %x - GUEST_MEMORY (also free)\n", initrdEnd, endOfMem - 1);
-#else
- PrintBoth("%lx to %x - GUEST_MEMORY (also free)\n", vmmMemEnd, endOfMem - 1);
-#endif
+ if (s_ramdiskSize > 0) {
+ /*
+ * Zheng 08/03/2008
+ */
+ PrintBoth("%lx to %x - RAMDISK\n", vmmMemEnd, initrdEnd - 1);
+
+ PrintBoth("%lx to %x - GUEST_MEMORY (also free)\n", initrdEnd, endOfMem - 1);
+ } else {
+ PrintBoth("%lx to %x - GUEST_MEMORY (also free)\n", vmmMemEnd, endOfMem - 1);
+ }
+
}
/*
#include <geekos/net.h>
#include <geekos/socket.h>
#include <geekos/ne2k.h>
+
+#include <geekos/debug.h>
+
+#ifdef LWIP
#include <lwip/apps/ping.h>
#include <lwip/lwip/sockets.h>
#include <lwip/ipv4/lwip/ip_addr.h>
#include <lwip/sys.h>
#include <lwip/netifapi.h>
#include <lwip/tcpip.h>
+
#include <netif/etharp.h>
-#include <geekos/debug.h>
static void
ping_init();
}
+#endif
+
#if 0
void test_network() {
+extern void * g_ramdiskImage;
+extern ulong_t s_ramdiskSize;
+
+
#define SPEAKER_PORT 0x61
static inline void VM_Out_Byte(ushort_t port, uchar_t value)
*/
int RunVMM(struct Boot_Info * bootInfo) {
- void * config_data;
-
struct vmm_os_hooks os_hooks;
struct vmm_ctrl_ops vmm_ops;
struct guest_info * vm_info = 0;
-
+ struct v3_vm_config vm_config;
memset(&os_hooks, 0, sizeof(struct vmm_os_hooks));
memset(&vmm_ops, 0, sizeof(struct vmm_ctrl_ops));
+ memset(&vm_config, 0, sizeof(struct v3_vm_config));
os_hooks.print_debug = &SerialPrint;
extern char _binary___palacios_vm_kernel_start;
PrintBoth(" Guest Load Addr: 0x%x\n", &_binary___palacios_vm_kernel_start);
- config_data = &_binary___palacios_vm_kernel_start;
-
+ vm_config.vm_kernel = &_binary___palacios_vm_kernel_start;
+
+
+ if (g_ramdiskImage != NULL) {
+ vm_config.use_ramdisk = 1;
+ vm_config.ramdisk = g_ramdiskImage;
+ vm_config.ramdisk_size = s_ramdiskSize;
+ }
+
+
+
+
vm_info = (vmm_ops).allocate_guest();
PrintBoth("Allocated Guest\n");
- (vmm_ops).config_guest(vm_info, config_data);
+ (vmm_ops).config_guest(vm_info, &vm_config);
PrintBoth("Configured guest\n");
#ifndef __DEVICES_CDROM_H_
#define __DEVICES_CDROM_H_
+
+#ifdef __V3VEE__
+
#include <devices/ramdisk.h>
#include <devices/ide.h>
#include <palacios/vmm_types.h>
-struct cdrom_interface;
struct cdrom_ops {
-
- void (*init)(struct cdrom_interface *cdrom);
-
/*
* Load CD-ROM. Returns false if CD is not ready.
*/
- rd_bool (*insert_cdrom)(struct cdrom_interface *cdrom, char *dev /*= NULL*/);
+ rd_bool (*insert_cdrom)(void * private_data);
/*
* Logically eject the CD.
*/
- void (*eject_cdrom)(struct cdrom_interface *cdrom);
+ void (*eject_cdrom)(void * private_data);
/*
* Read CD TOC. Returns false if start track is out of bounds.
*/
- rd_bool (*read_toc)(struct cdrom_interface * cdrom, uint8_t * buf, int* length, rd_bool msf, int start_track);
+ rd_bool (*read_toc)(void * private_data, uchar_t * buf, int * length, rd_bool msf, int start_track);
/*
* Return CD-ROM capacity (in 2048 byte frames)
*/
- uint32_t (*capacity)(struct cdrom_interface *cdrom);
+ uint32_t (*capacity)(void * private_data);
/*
* Read a single block from the CD
*/
- void (*read_block)(struct cdrom_interface *cdrom, uint8_t* buf, int lba);
+ void (*read_block)(void * private_data, uchar_t * buf, int lba);
/*
* Start (spin up) the CD.
*/
- int (*start_cdrom)(struct cdrom_interface *cdrom);
+ int (*start_cdrom)(void * private_data);
+
+ void (*set_LBA)(void * private_data, uchar_t lba);
};
-struct cdrom_interface {
- struct cdrom_ops ops;
- ulong_t fd; //memory address
- ulong_t capacity_B;
- ulong_t head; //current position
+struct vm_device * v3_create_cdrom(struct vm_device * ramdisk_dev, void * ramdisk, uint_t ramdisk_size);
- uchar_t lba;
- char *path; //for ramdisk, NULL
- int using_file; //no
-};
-void init_cdrom(struct cdrom_interface *cdrom);
+#endif // !__V3VEE__
#endif
rd_bool ready;
rd_bool locked;
- struct cdrom_interface * cd;
+ struct cdrom_ops * cd;
uint32_t capacity;
int next_lba;
struct sense_info_t sense;
struct atapi_t atapi;
+ /* JRL */
+ void * private_data;
+
Bit8u model_no[41];
};
#endif
+#if 0
+
+// 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);
+
+
+#endif
#include <palacios/vmm_types.h>
#include <palacios/vm_dev.h>
+struct cdrom_ops;
-
-
+int v3_ramdisk_register_cdrom(struct vm_device * ide_dev, uint_t busID, uint_t driveID, struct cdrom_ops * cd, void * private_data);
struct vm_device * create_ramdisk(void);
};
+struct v3_vm_config {
+ void * vm_kernel;
+ int use_ramdisk;
+ void * ramdisk;
+ int ramdisk_size;
+};
+
+
+
/* This will contain Function pointers that control the VMs */
struct vmm_ctrl_ops {
struct guest_info *(*allocate_guest)();
- int (*config_guest)(struct guest_info * info, void * config_ptr);
+ int (*config_guest)(struct guest_info * info, struct v3_vm_config * config_ptr);
int (*init_guest)(struct guest_info * info);
int (*start_guest)(struct guest_info * info);
// int (*stop_vm)(uint_t vm_id);
+
+
void Init_V3(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
#ifdef __V3VEE__
#include <palacios/vm_guest.h>
+#include <palacios/vmm.h>
-
-#define MAGIC_CODE 0xf1e2d3c4
-
-struct layout_region {
- ulong_t length;
- ulong_t final_addr;
-};
-
-struct guest_mem_layout {
- ulong_t magic;
- ulong_t num_regions;
- struct layout_region regions[0];
-};
-
-
-
-int config_guest(struct guest_info * info, void * config_ptr);
-
-
-
+int config_guest(struct guest_info * info, struct v3_vm_config * config_ptr);
#endif // ! __V3VEE__
*/
#include <devices/cdrom.h>
+#include <devices/ide.h>
#include <palacios/vmm.h>
-#ifdef DEBUG_RAMDISK
-#define Ramdisk_Print_CD(_f, _a...) PrintTrace("cdrom.c(%d) "_f, __LINE__, ## _a)
-#else
-#define Ramdisk_Print_CD(_f, _a...)
+#ifndef DEBUG_RAMDISK
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
#endif
-ulong_t g_ramdiskImage;
-ulong_t s_ramdiskSize;
+struct cdrom_state {
+ uchar_t * image_addr; //memory address
+ ulong_t capacity_B;
+ ulong_t head; //current position
+
+ struct vm_device * ide_dev;
+
+ uchar_t lba;
+};
+
-static
-void cdrom_init(struct cdrom_interface * cdrom)
-{
- Ramdisk_Print_CD("[cdrom_init]\n");
- V3_ASSERT(g_ramdiskImage);
- cdrom->fd = g_ramdiskImage;
- PrintDebug("CDIMAGE located at: %x\n", cdrom->fd);
- cdrom->capacity_B = s_ramdiskSize;
- //FIXME:lba
- cdrom->lba = 1;
- return;
-}
/*
* Load CD-ROM. Returns false if CD is not ready.
*/
-static
-rd_bool cdrom_insert(struct cdrom_interface * cdrom, char *dev /*= NULL*/)
-{
- Ramdisk_Print_CD("[cdrom_insert]\n");
+static rd_bool cdrom_insert(void * private_data) {
+ PrintDebug("[cdrom_insert]\n");
return 1;
}
/*
* Logically eject the CD.
*/
-static
-void cdrom_eject(struct cdrom_interface *cdrom)
-{
- Ramdisk_Print_CD("[cdrom_eject]\n");
+static void cdrom_eject(void * private_data) {
+ PrintDebug("[cdrom_eject]\n");
return;
}
/*
* Read CD TOC. Returns false if start track is out of bounds.
*/
-static
-rd_bool cdrom_read_toc(struct cdrom_interface *cdrom, uint8_t* buf, int* length, rd_bool msf, int start_track)
+static rd_bool cdrom_read_toc(void * private_data, uint8_t* buf, int* length, rd_bool msf, int start_track)
{
- Ramdisk_Print_CD("[cdrom_read_toc]\n");
+ PrintDebug("[cdrom_read_toc]\n");
return 1;
}
/*
* Return CD-ROM capacity (in 2048 byte frames)
*/
-static
-uint32_t cdrom_capacity(struct cdrom_interface *cdrom)
-{
- Ramdisk_Print_CD("[cdrom_capacity] s_ramdiskSize = %d\n", cdrom->capacity_B);
+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);
+
if (cdrom->lba) {
if (cdrom->capacity_B % 2048) {
- Ramdisk_Print_CD("\t\t capacity in LBA is %d\n", cdrom->capacity_B/2048 + 1);
- return cdrom->capacity_B/2048 + 1;
+ PrintDebug("\t\t capacity in LBA is %d\n", (cdrom->capacity_B / 2048) + 1);
+ return (cdrom->capacity_B / 2048) + 1;
} else {
- Ramdisk_Print_CD("\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_B / 2048);
+ return cdrom->capacity_B / 2048;
}
} else {
+ PrintError("Unsupported CDROM mode in capacity query\n");
//FIXME CHS mode
return 0;
}
/*
* Read a single block from the CD
*/
-static
-void cdrom_read_block(struct cdrom_interface *cdrom, uint8_t* buf, int lba)// __attribute__(regparm(2));
-{
+static void cdrom_read_block(void * private_data, uint8_t * buf, int lba)/* __attribute__(regparm(2)); */ {
+ struct cdrom_state * cdrom = (struct cdrom_state *)private_data;
V3_ASSERT(lba != 0);
- Ramdisk_Print_CD("[cdrom_read_block] lba = %d (cdrom_image_start=%x)\n", lba, cdrom->fd);
- memcpy(buf, (uint8_t *)(cdrom->fd + lba * 2048), 2048);
+ 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");
- return;
+ return;
}
+static void set_LBA(void * private_data, uchar_t lba) {
+ struct cdrom_state * cdrom = (struct cdrom_state *)private_data;
+ cdrom->lba = lba;
+}
+
+
/*
* Start (spin up) the CD.
*/
-static
-int cdrom_start(struct cdrom_interface *cdrom)
-{
- Ramdisk_Print_CD("[cdrom_start]\n");
+static int cdrom_start(void * private_data) {
+ PrintDebug("[cdrom_start]\n");
return 1;
}
-void init_cdrom(struct cdrom_interface *cdrom)
-{
- V3_ASSERT(cdrom != NULL);
+static struct cdrom_ops cd_ops = {
+ .insert_cdrom = cdrom_insert,
+ .eject_cdrom = cdrom_eject,
+ .read_toc = cdrom_read_toc,
+ .capacity = cdrom_capacity,
+ .read_block = cdrom_read_block,
+ .start_cdrom = cdrom_start,
+ .set_LBA = set_LBA,
+};
+
+
+
+
+static int cdrom_device_init(struct vm_device * dev) {
+ struct cdrom_state * cdrom = (struct cdrom_state *)dev->private_data;
+ PrintDebug("[cdrom_init]\n");
+ PrintDebug("CDIMAGE located at: %x\n", cdrom->image_addr);
+
+ //FIXME:lba
+ cdrom->lba = 1;
+
+ v3_ramdisk_register_cdrom(cdrom->ide_dev, 1, 0, &cd_ops, cdrom);
+
+ return 0;
+}
+
+
+static int cdrom_device_deinit(struct vm_device * dev) {
+ return 0;
+}
+
+static struct vm_device_ops dev_ops = {
+ .init = cdrom_device_init,
+ .deinit = cdrom_device_deinit,
+ .reset = NULL,
+ .start = NULL,
+ .stop = NULL,
+};
+
+struct vm_device * v3_create_cdrom(struct vm_device * ramdisk_dev, void * ramdisk, uint_t ramdisk_size){
+ struct cdrom_state * cd = (struct cdrom_state *)V3_Malloc(sizeof(struct cdrom_state));
+ V3_ASSERT(cd != NULL);
+
+ memset(cd, 0, sizeof(struct cdrom_state));
+
+ cd->image_addr = (uchar_t *)ramdisk;
+ cd->capacity_B = ramdisk_size;
+ cd->ide_dev = ramdisk_dev;
- cdrom->ops.init = &cdrom_init;
- cdrom->ops.insert_cdrom = &cdrom_insert;
- cdrom->ops.eject_cdrom = &cdrom_eject;
- cdrom->ops.read_toc = &cdrom_read_toc;
- cdrom->ops.capacity = &cdrom_capacity;
- cdrom->ops.read_block = &cdrom_read_block;
- cdrom->ops.start_cdrom = &cdrom_start;
+ PrintDebug("Creating RamDISK CDROM\n");
- return;
+ struct vm_device * cd_dev = create_device("Ram Based CD", &dev_ops, cd);
+
+ return cd_dev;
}
#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
*/
+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;
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
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--;
}
default:
PrintError("\t\tneed translate command %2x\n", value);
- return -1;
+ //return -1;
+ /* JRL THIS NEEDS TO CHANGE */
+ return length;
}
return length;
}
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);
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);
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);
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);
switch (format) {
case 0:
- if (!(drive->cdrom.cd->ops.read_toc(drive->cdrom.cd, controller->buffer,
- &toc_length, msf, starting_track))) {
+ if (!(drive->cdrom.cd->read_toc(drive->private_data, controller->buffer,
+ &toc_length, msf, starting_track))) {
+ PrintDebug("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);
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;
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;
// 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);
#include <devices/nvram.h>
#include <devices/generic.h>
#include <devices/ramdisk.h>
+#include <devices/cdrom.h>
#define USE_GENERIC 1
-#define USE_RAMDISK 1
+
+#define MAGIC_CODE 0xf1e2d3c4
+
+
+
+struct layout_region {
+ ulong_t length;
+ ulong_t final_addr;
+};
+
+struct guest_mem_layout {
+ ulong_t magic;
+ ulong_t num_regions;
+ struct layout_region regions[0];
+};
+
}
*/
-int config_guest(struct guest_info * info, void * config_ptr) {
+int config_guest(struct guest_info * info, struct v3_vm_config * config_ptr) {
- struct guest_mem_layout * layout = (struct guest_mem_layout *)config_ptr;
+ struct guest_mem_layout * layout = (struct guest_mem_layout *)config_ptr->vm_kernel;
extern v3_cpu_arch_t v3_cpu_type;
void * region_start;
int i;
- int use_ramdisk = USE_RAMDISK;
+ int use_ramdisk = config_ptr->use_ramdisk;
int use_generic = USE_GENERIC;
{
struct vm_device * ramdisk = NULL;
+ struct vm_device * cdrom = NULL;
struct vm_device * nvram = create_nvram();
//struct vm_device * timer = create_timer();
struct vm_device * pic = create_pic();
struct vm_device * keyboard = create_keyboard();
struct vm_device * pit = create_pit();
+
//struct vm_device * serial = create_serial();
struct vm_device * generic = NULL;
- //Zheng 09/29/2008
+
+
if (use_ramdisk) {
PrintDebug("Creating Ramdisk\n");
ramdisk = create_ramdisk();
+ cdrom = v3_create_cdrom(ramdisk, config_ptr->ramdisk, config_ptr->ramdisk_size);
}
if (use_ramdisk) {
v3_attach_device(info, ramdisk);
+ v3_attach_device(info, cdrom);
}
if (use_generic) {