9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] patch for working LSI 53c895a in kvm-16 QEMU
@ 2007-04-01 21:37 Paweł Lasek
  2007-04-04 12:40 ` [9fans] " Paweł Lasek
  0 siblings, 1 reply; 2+ messages in thread
From: Paweł Lasek @ 2007-04-01 21:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1480 bytes --]

This is a I found some time ago using google, unfortunately I don't
remember original author. I had rewritten the patch (original file for
some reason was malformed) and changed device id of emulated
controller to match the one found in my plan9.iso.

However, I only tested (and written it) using modified qemu sources
from kvm-16 distribution, so I don't if it works with stock qemu-0.9.

The patch is very simple, it only supports hard drives and doesn't
have a SCSI BIOS (There's sign for preparing a better one in qemu
code), however, it works and i have a functional installation using
emulated 2GB scsi hd with floppy boot. The only thing is that 9pcf
kernel from somewhere around february stops when starting rc, using an
old (ca. 2005?) kernel solved it. 9pccd works flawlessly.

I think there was some speedup compared to emulated IDE, however,
Plan9 installation in qemu (I don't count my test install on old pc,
as it was with old iso) for some reason is still veeeryy slow. I think
it's userspace problem, since most of the time there's _no_ disk
activity at all during "copydist". Since IO works fine for everything
other than installer, I am very confused. I had the same 'slow
install' problem every time I had installed Plan9 (That includes pc
with i440bx and ATA33 7200rpm drive, netbsd-xen0 with lsi53c895 and
7200 SCSI hd and many tries under both VMWare and Qemu).

Now, off to change terminal into cpu server....

-- 
Paul Lasek

[-- Attachment #2: add-scsi --]
[-- Type: application/octet-stream, Size: 6171 bytes --]

diff -r 99d002ddd735 hw/lsi53c895a.c
--- a/hw/lsi53c895a.c	Sat Mar 31 21:01:18 2007 +0200
+++ b/hw/lsi53c895a.c	Sat Mar 31 22:32:19 2007 +0200
@@ -149,8 +149,6 @@ do { fprintf(stderr, "lsi_scsi: error: "
 #define PHASE_MI          7
 #define PHASE_MASK        7
 
-/* The HBA is ID 7, so for simplicitly limit to 7 devices.  */
-#define LSI_MAX_DEVS      7
 
 /* Maximum length of MSG IN data.  */
 #define LSI_MAX_MSGIN_LEN 8
@@ -1837,7 +1835,7 @@ void *lsi_scsi_init(PCIBus *bus, int dev
 
     s->pci_dev.config[0x00] = 0x00;
     s->pci_dev.config[0x01] = 0x10;
-    s->pci_dev.config[0x02] = 0x12;
+    s->pci_dev.config[0x02] = 0x0c;
     s->pci_dev.config[0x03] = 0x00;
     s->pci_dev.config[0x0b] = 0x01;
     s->pci_dev.config[0x3d] = 0x01; /* interrupt pin 1 */
diff -r 99d002ddd735 hw/pc.c
--- a/hw/pc.c	Sat Mar 31 21:01:18 2007 +0200
+++ b/hw/pc.c	Sat Mar 31 21:59:32 2007 +0200
@@ -766,7 +766,18 @@ static void pc_init1(int ram_size, int v
         lsi_scsi_attach(scsi, bdrv, -1);
     }
 #endif
-}
+    if (pci_enabled) {
+	void *scsi;
+	
+	scsi = lsi_scsi_init(pci_bus, -1);
+        for (i = 0; i < LSI_MAX_DEVS; i++) {
+            if (bs_table[i + MAX_DISKS])
+                lsi_scsi_attach(scsi, bs_table[i + MAX_DISKS], -1);
+        }
+    }
+}
+
+
 
 static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
                         DisplayState *ds, const char **fd_filename, 
@@ -805,3 +816,4 @@ QEMUMachine isapc_machine = {
     "ISA-only PC",
     pc_init_isa,
 };
+
diff -r 99d002ddd735 vl.c
--- a/vl.c	Sat Mar 31 21:01:18 2007 +0200
+++ b/vl.c	Sat Mar 31 21:49:28 2007 +0200
@@ -125,7 +125,7 @@ IOPortWriteFunc *ioport_write_table[3][M
 IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];
 /* Note: bs_table[MAX_DISKS] is a dummy block driver if none available
    to store the VM snapshots */
-BlockDriverState *bs_table[MAX_DISKS + 1], *fd_table[MAX_FD];
+BlockDriverState *bs_table[MAX_DISKS + LSI_MAX_DEVS + 1], *fd_table[MAX_FD];
 /* point to the block driver where the snapshots are managed */
 BlockDriverState *bs_snapshots;
 int vga_ram_size;
@@ -6309,6 +6309,7 @@ void help(void)
            "-fda/-fdb file  use 'file' as floppy disk 0/1 image\n"
            "-hda/-hdb file  use 'file' as IDE hard disk 0/1 image\n"
            "-hdc/-hdd file  use 'file' as IDE hard disk 2/3 image\n"
+	   "-sda ... -sdg   use 'file' as SCSI hard disk 0-7\n"
            "-cdrom file     use 'file' as IDE cdrom image (cdrom is ide1 master)\n"
            "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n"
            "-snapshot       write to temporary files instead of disk image files\n"
@@ -6450,6 +6451,13 @@ enum {
     QEMU_OPTION_hdb,
     QEMU_OPTION_hdc,
     QEMU_OPTION_hdd,
+    QEMU_OPTION_sda,
+    QEMU_OPTION_sdb,
+    QEMU_OPTION_sdc,
+    QEMU_OPTION_sdd,
+    QEMU_OPTION_sde,
+    QEMU_OPTION_sdf,
+    QEMU_OPTION_sdg,
     QEMU_OPTION_cdrom,
     QEMU_OPTION_boot,
     QEMU_OPTION_snapshot,
@@ -6530,6 +6538,13 @@ const QEMUOption qemu_options[] = {
     { "hdc", HAS_ARG, QEMU_OPTION_hdc },
     { "hdd", HAS_ARG, QEMU_OPTION_hdd },
     { "cdrom", HAS_ARG, QEMU_OPTION_cdrom },
+    { "sda", HAS_ARG, QEMU_OPTION_sda },
+    { "sdb", HAS_ARG, QEMU_OPTION_sdb },
+    { "sdc", HAS_ARG, QEMU_OPTION_sdc },
+    { "sdd", HAS_ARG, QEMU_OPTION_sdd },
+    { "sde", HAS_ARG, QEMU_OPTION_sde },
+    { "sdf", HAS_ARG, QEMU_OPTION_sdf },
+    { "sdg", HAS_ARG, QEMU_OPTION_sdg },   
     { "boot", HAS_ARG, QEMU_OPTION_boot },
     { "snapshot", 0, QEMU_OPTION_snapshot },
 #ifdef TARGET_I386
@@ -6828,6 +6843,7 @@ int main(int argc, char **argv)
     int i, cdrom_index;
     int snapshot, linux_boot;
     const char *initrd_filename;
+    const char *sd_filename[LSI_MAX_DEVS];
     const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD];
     const char *kernel_filename, *kernel_cmdline;
     DisplayState *ds = &display_state;
@@ -6891,6 +6907,8 @@ int main(int argc, char **argv)
         fd_filename[i] = NULL;
     for(i = 0; i < MAX_DISKS; i++)
         hd_filename[i] = NULL;
+    for(i = 0; i < LSI_MAX_DEVS; i++)
+	sd_filename[i] = NULL;
     ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
     vga_ram_size = VGA_RAM_SIZE;
     bios_size = BIOS_SIZE;
@@ -6997,6 +7015,15 @@ int main(int argc, char **argv)
                         cdrom_index = -1;
                 }
                 break;
+	    case QEMU_OPTION_sda:
+	    case QEMU_OPTION_sdb:
+	    case QEMU_OPTION_sdc:
+	    case QEMU_OPTION_sdd:
+	    case QEMU_OPTION_sde:
+	    case QEMU_OPTION_sdf:
+	    case QEMU_OPTION_sdg:
+		sd_filename[popt->index - QEMU_OPTION_sda] = optarg;
+		break;
             case QEMU_OPTION_snapshot:
                 snapshot = 1;
                 break;
@@ -7509,8 +7536,25 @@ int main(int argc, char **argv)
                 bdrv_set_translation_hint(bs_table[i], translation);
             }
         }
-    }
-
+    }	
+
+    for( i = 0; i < LSI_MAX_DEVS; i++) {
+        int ret;
+       if (sd_filename[i]) {
+           if (!bs_table[i + MAX_DISKS]) {
+               char buf[64];
+               snprintf(buf, sizeof(buf), "sd%c", i + 'a');
+               bs_table[i + MAX_DISKS] = bdrv_new(buf);
+           }
+           ret = bdrv_open(bs_table[i + MAX_DISKS], sd_filename[i], 0);
+           if (ret < 0) {
+               fprintf(stderr, "qemu: could not open hard disk image '%s'\n",
+                       sd_filename[i]);
+               exit(1);
+           }
+       }
+    }
+	
     /* we always create at least one floppy disk */
     fd_table[0] = bdrv_new("fda");
     bdrv_set_type_hint(fd_table[0], BDRV_TYPE_FLOPPY);
diff -r 99d002ddd735 vl.h
--- a/vl.h	Sat Mar 31 21:01:18 2007 +0200
+++ b/vl.h	Sat Mar 31 21:34:34 2007 +0200
@@ -943,9 +943,10 @@ extern uint8_t _translate_keycode(const 
 extern uint8_t _translate_keycode(const int key);
 
 /* ide.c */
+#define LSI_MAX_DEVS 7
 #define MAX_DISKS 4
 
-extern BlockDriverState *bs_table[MAX_DISKS + 1];
+extern BlockDriverState *bs_table[MAX_DISKS + LSI_MAX_DEVS + 1];
 
 void isa_ide_init(int iobase, int iobase2, int irq,
                   BlockDriverState *hd0, BlockDriverState *hd1);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [9fans] Re: patch for working LSI 53c895a in kvm-16 QEMU
  2007-04-01 21:37 [9fans] patch for working LSI 53c895a in kvm-16 QEMU Paweł Lasek
@ 2007-04-04 12:40 ` Paweł Lasek
  0 siblings, 0 replies; 2+ messages in thread
From: Paweł Lasek @ 2007-04-04 12:40 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[cut]

I have tested the patch for the last few days, should be stable
although I haven't checked it under heavy load. Maybe somebody could
provide a SCSI BIOS from 53c895a? Maybe it would allow to enable
booting from simulated SCSI, at least in unofficial way.

Since I only have an Adaptec 7950 I cannot use it's BIOS and I doubt
my chances in writing device driver w/ QEMU emulation for it :-)

-- 
Paul Lasek


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-04-04 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-01 21:37 [9fans] patch for working LSI 53c895a in kvm-16 QEMU Paweł Lasek
2007-04-04 12:40 ` [9fans] " Paweł Lasek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).