LSI53C895A, IDE HDD detection under SCO OpenServer 5.0.5
Hey again,
I realized that my patch was malformed (diffing the wrong way). Here it is again, hopefully in a usable format. Sorry for the confusion.
lsi53c895a.c.final renamed from lsi53c895a.c +22 -2
@@ -209,6 +209,7 @@ uint8_t mbox0; uint8_t mbox1; uint8_t dfifo; + uint8_t ctest2; uint8_t ctest3; uint8_t ctest4; uint8_t ctest5;
@@ -280,6 +281,7 @@ s->mbox0 = 0; s->mbox1 = 0; s->dfifo = 0; + s->ctest2 = 0; s->ctest3 = 0; s->ctest4 = 0; s->ctest5 = 0;
@@ -890,6 +892,7 @@ break; case PHASE_DI: s->waiting = 2; + s->current_dma_len = s->dbc; lsi_do_dma(s, 0); if (s->waiting) s->waiting = 3;
@@ -1279,7 +1282,7 @@ case 0x19: /* CTEST1 */ return 0; case 0x1a: /* CTEST2 */ - tmp = LSI_CTEST2_DACK | LSI_CTEST2_CM; + tmp = s->ctest2 | LSI_CTEST2_DACK | LSI_CTEST2_CM; if (s->istat0 & LSI_ISTAT0_SIGP) { s->istat0 &= ~LSI_ISTAT0_SIGP; tmp |= LSI_CTEST2_SIGP;
@@ -1327,6 +1330,8 @@ s->sist1 = 0; lsi_update_irq(s); return tmp; + case 0x46: /* MACNTL */ + return 0x0f; case 0x47: /* GPCNTL0 */ return 0x0f; case 0x48: /* STIME0 */
@@ -1440,6 +1445,9 @@ SCRIPTS register move instructions are. */ s->sfbr = val; break; + case 0x0a: case 0x0b: + /* Openserver writes to these readonly registers on startup */ + return; case 0x0c: case 0x0d: case 0x0e: case 0x0f: /* Linux writes to these readonly registers on startup. */ return;
@@ -1469,6 +1477,9 @@ case 0x17: /* MBOX1 */ s->mbox1 = val; break; + case 0x1a: /* CTEST2 */ + s->ctest2 = val & LSI_CTEST2_PCICIE; + break; case 0x1b: /* CTEST3 */ s->ctest3 = val & 0x0f; break;
@@ -1869,12 +1880,21 @@ return NULL; } + /* PCI Vendor ID (word) */ s->pci_dev.config[0x00] = 0x00; s->pci_dev.config[0x01] = 0x10; + /* PCI device ID (word) */ s->pci_dev.config[0x02] = 0x12; s->pci_dev.config[0x03] = 0x00; + /* PCI base class code */ s->pci_dev.config[0x0b] = 0x01; - s->pci_dev.config[0x3d] = 0x01; /* interrupt pin 1 */ + /* PCI subsystem ID */ + s->pci_dev.config[0x2e] = 0x00; + s->pci_dev.config[0x2f] = 0x10; + /* PCI latency timer = 255 */ + s->pci_dev.config[0x0d] = 0xff; + /* Interrupt pin 1 */ + s->pci_dev.config[0x3d] = 0x01; s->mmio_io_addr = cpu_register_io_memory(0, lsi_mmio_readfn, lsi_mmio_writefn, s);
Quoted 3 lines · Justin Chevrier
Hey again,
I realized that my patch was malformed (diffing the wrong way). Here it is again, hopefully in a usable format. Sorry for the confusion.
OK, I had a chance to test your patch - correctly, this time.
It gets a lot further into detection but on my 5.0.5 system still fails at:
lsi_scsi: SCRIPTS dsp=f20021ec opcode 88080000 arg f000ff53lsi_scsi: Call 0xf000ff53lsi_scsi: SCRIPTS dsp=f000ff53 opcode ff0720ff arg ff0720fflsi_scsi: Load reg 0x7 size 7 addr 0x000720ff = 00000000lsi_scsi: Write reg 7 = 00lsi_scsi: Write reg 8 = 00lsi_scsi: Write reg 9 = 00lsi_scsi: error: Unhandled writeb 0x9 = 0x0
... which looks like execution of a script from la-la land to me.
The dodgy value comes from here, a few operations earlier:
lsi_scsi: SCRIPTS dsp=f200256c opcode f1dc0004 arg 00000024lsi_scsi: Load reg 0xdc size 4 addr 0x00000024 = f000e987lsi_scsi: Write reg dc = 87lsi_scsi: Write reg dd = e9lsi_scsi: Write reg de = 00lsi_scsi: Write reg df = f0lsi_scsi: SCRIPTS dsp=f2002574 opcode f1640004 arg 00000000lsi_scsi: Load reg 0x64 size 4 addr 0x00000000 = f000ff53 <--**--lsi_scsi: Write reg 64 = 53lsi_scsi: Write reg 65 = fflsi_scsi: Write reg 66 = 00lsi_scsi: Write reg 67 = f0lsi_scsi: SCRIPTS dsp=f200257c opcode e0640004 arg 0101e080lsi_scsi: Store reg 0x64 size 4 addr 0x0101e080lsi_scsi: Read reg 64lsi_scsi: Read reg 65lsi_scsi: Read reg 66lsi_scsi: Read reg 67
That's tested with:
qemu \
-fda /archive/cdimages/SCO_5_0_5_LSI53C895A_BTLD_FLOPPY.img \
-cdrom /archive/cdimages/SCO_5_0_5.iso \
-drive file=/var/VMs/alder/alder.img,if=scsi,bus=0,unit=0 \
-boot d
where the disk image is a 4GB empty (sparse) file. The other two files have md5sums:
SCO_5_0_5_LSI53C895A_BTLD_FLOPPY.img:22c45122239892fefaf911caa8954bc9
SCO_5_0_5.iso:b2a13770f7e1b46aad4ff601a56f492c
The boot command line was "defbootstr link=slha". At the BTLD prompt "<return>28<return>2<return>" is entered.
I get the same result with:
qemu \
-no-fd-bootchk \
-fda /mnt/tmp/images/boot/install.img \
-fdb /archive/cdimages/SCO_5_0_5_LSI53C895A_BTLD_FLOPPY.img \
-drive file=/var/VMs/alder/alder.img,if=scsi,bus=0,unit=0 \
-boot a
and the boot string "defbootstr link=slha btld=fd(65)" . I enter "<return>26<return>2<return>" at the BTLD prompt, as the kernel hints.
/mnt/tmp/images/boot/install.img:5297c59e1cd7ba9d098bfa4a929dd28f
(from the OpenServer 5.0.5 CD media)
I'm currently testing with a patched qemu 0.9.1 from Ubuntu 8.10, though I'll test with HEAD shortly in case something else has changed; there was some fuzz required when applying the patch so something's clearly been altered either by Ubuntu patches to qemu 0.9.1 or by changes between 0.9.1 and the copy of HEAD you're working on.
--
Craig Ringer
Quoted 57 lines
OK, I had a chance to test your patch - correctly, this time.
It gets a lot further into detection but on my 5.0.5 system still fails at:
lsi_scsi: SCRIPTS dsp=f20021ec opcode 88080000 argf000ff53lsi_scsi: Call0xf000ff53lsi_scsi: SCRIPTS dsp=f000ff53 opcodeff0720ffargff0720fflsi_scsi: Load reg0x7size 7 addr0x000720ff= 00000000lsi_scsi: Write reg 7 = 00lsi_scsi: Write reg 8 = 00lsi_scsi: Write reg 9 = 00lsi_scsi: error: Unhandled writeb0x9=0x0... which looks like execution of a script from la-la land to me.
The dodgy value comes from here, a few operations earlier:
lsi_scsi: SCRIPTS dsp=f200256c opcodef1dc0004arg 00000024lsi_scsi: Load reg0xdcsize 4 addr0x00000024=f000e987lsi_scsi: Write reg dc = 87lsi_scsi: Write reg dd = e9lsi_scsi: Write reg de = 00lsi_scsi: Write reg df = f0lsi_scsi: SCRIPTS dsp=f2002574 opcodef1640004arg 00000000lsi_scsi: Load reg0x64size 4 addr0x00000000=f000ff53
<--**--lsi_scsi: Write reg 64 = 53lsi_scsi: Write reg 65 = fflsi_scsi: Write reg 66 = 00lsi_scsi: Write reg 67 = f0lsi_scsi: SCRIPTS dsp=f200257c opcodee0640004arg0101e080lsi_scsi: Store reg0x64size 4 addr0x0101e080lsi_scsi: Read reg 64lsi_scsi: Read reg 65lsi_scsi: Read reg 66lsi_scsi: Read reg 67That's tested with:
qemu \
-fda
/archive/cdimages/SCO_5_0_5_LSI53C895A_BTLD_FLOPPY.img \
-cdrom /archive/cdimages/SCO_5_0_5.iso \
-drive file=/var/VMs/alder/alder.img,if=scsi,bus=0,unit=0
\
-boot dwhere the disk image is a 4GB empty (sparse) file. The other two files have md5sums:
SCO_5_0_5_LSI53C895A_BTLD_FLOPPY.img:
22c45122239892fefaf911caa8954bc9
Quoted 7 lines
SCO_5_0_5.iso:
b2a13770f7e1b46aad4ff601a56f492cThe boot command line was "defbootstr link=slha".
At the BTLD prompt
"<return>28<return>2<return>" is
entered.
My md5sums match yours.
I used your exact command line and btld options (28 and 2) and it still worked on my end. At this point all I can think of is modifications done by Ubuntu, or it being qemu 0.9.10. It sounds like you're going to try again with a copy of HEAD anyway, hopefully it will work there!
Justin
Quoted 3 lines · Justin Chevrier
My md5sums match yours.
I used your exact command line and btld options (28 and 2) and it still worked on my end. At this point all I can think of is modifications done by Ubuntu, or it being qemu 0.9.10. It sounds like you're going to try again with a copy of HEAD anyway, hopefully it will work there!
It works with HEAD. Ubuntu don't seem to have patched anything in the LSI SCSI driver, so either it's an effect from elsewhere or (more likely) a fix in HEAD.
I don't see anything in the Ubuntu patches that looks like a likely candidate. The only significant change in the lsi driver between 0.9.1 and HEAD doesn't appear to be the cause, either, so it's presumably a fix somewhere else between 0.9.1 and HEAD. I'm not enthusiastic enough to go digging, since it works.
CD boot and installation fails after prompting for the CD-ROM ATA bus location. The first time I tested, oddly, it got a lot further - I was able to enter license codes, complete package selection and begin the installation proper before it failed. The error (from SCO's kernel) is:
PANIC: svirtophys - page not present
Some documentation I was able to turn up on this (for OpenServer 6 not OpenServer 5.05, but it should still be informative):
http://osr600doc.sco.com/man/html.D3oddi/phystokv.D3oddi.html
says:
If kvtophys( ) is given a virtual address that does not map to a physical address, the kernel panics with the following message:
svirtophys - Page not present
Booting with mem=1m-5m,128m-256m (hit upon after trying a few different values to play with the memory regions) seems to work around it. OpenServer isn't very good at reading the BIOS's memory mappings, and I wouldn't be too surprised if it was trying to access memory that wasn't mapped. mem=1m-10m,32m-128m also works, but mem=1m-15m,16m-64m doesn't. I'll dig a bit more later, but have continued testing to try to get a successful install.
Just before package selection, qemu prints some warning messages:
lsi_scsi: error: Unimplemented message 0x0c
but proceeds.
The installer then formats the disk. It didn't manage that before, it crashed after displaying the formatting progress bar but before doing any significant disk I/O.
The next issue I run into is after the root file system is formatted. SCO doesn't seem to be able to read the floppy drive when running the real SCO kernel; it fails to access it as /dev/fd0 (which it is) or as /dev/fd1 . This would also explain why I can't do a floppy installation. I haven't investigated yet, as I can skip BTLD installation, it just means I need to link the BTLD image into the kernel at boot time to init the machine.
If you skip copying the BTLD image to the root file system installation continues. However, it crashes at a variable point thereafter with errors suggesting that the newly created root file system must be corrupt. Another SCSI issue, presumably - hooray!
*tears at hair*
At least the errors about "lsi_scsi: error: Unimplemented message 0x0c" might provide a hint. I'll have a look, but thought I should let you know about the possibility of getting installation to proceed further by setting a memory mapping manually.
--
Craig Ringer
Quoted 1 line
lsi_scsi: error: Unimplemented message0x0c
Just a quick follow-up: I think the message 0x0c is:
SCSI Msg Bus Device Reset 0x0c
( based on
http://developer.apple.com/samplecode/SCSI_Async_Sample/listing22.html )
I guess I'll need to go diving into the debug output and SCRIPTS code again to find out where it's coming from and what the host is expecting it to do. It's not at all clear that the fact that this command isn't implemented is even the cause of the problem; it could be a bug somewhere else in the virtual LSI device or failure to emulate a bug/quirk in the real hardware that the SCO driver is relying on.
At least it's not real hardware. I'm now beginning to get the faintest inklings of why hardware designers/testers love FPGAs as much as they do.
--
Craig Ringer
Quoted 11 lines · Craig Ringer
CD boot and installation fails after prompting for the CD-ROM ATA bus
location. The first time I tested, oddly, it got a lot further - I was
able to enter license codes, complete package selection and begin the
installation proper before it failed. The error (from SCO's kernel) is:PANIC: svirtophys - page not present
I have seen the same thing. What I found is that you need to replace your disk image with a fresh one every time you try a fresh install. My guess is that the emulated controller is writing garbage to the drive, then the installer the next time through is reading this and thinking that the garbage is valid memory locations and is getting confused. I've been using the 'Upgrade' option to debug the error below to avoid having to do this every run through.
Quoted 6 lines
Just before package selection, qemu prints some warning messages:
lsi_scsi: error: Unimplemented message0x0cbut proceeds.
I'm looking into this now. I've tossed a basic implementation together, but the error messages continue to flood onto the installer's screen. It appears to be getting interrupts that it isn't expecting. After going through the debug log it looks like the installer pokes a bunch of LUNs and I think that it may not want interrupts for the LUNs that don't have a drive attached to them. This is just a guess though. I've got more testing to do.
At this point I'm not sure if this error has anything to do with the failure of installation. I hate error messages like this though (which wouldn't be there if we emulated correctly), so I'm going to try and fix this first and go from there.
Justin