I did some experimenting with this lsi driver. Here are some findings:
- It's enough to replace nvram.resource.kmod and add nvrom.txt from the pegasos2 version to Kicklayout to be able to set nvram options with this file. Adding lsi53c8xx_override=0012 and lsi53c8xx_verbose=1 makes the driver happy with QEMU's card and print dome debug logs.
- The AmigaOS driver only sets bus master bit but does not enable memory regions and BBoot did not enable it either. The peagsos2.rom firmware does so that's why it did not work with BBoot. I'll fix that when it would work otherwise.
- The scsi-hd is detected but when trying to talk to it it fails after some error. The next command after the error seems to be missing something the card expects so maybe it's due to incorrect error handling in the AmigaOS driver or some behaviour of the card that's not emulated and the AmigaOS driver relies on.
I get these logs during detecting the card which seems to finish successfully:
lsi53c8xx.device 53.20 (24.9.2014)
[lsi53c8xx/dev_init] Adjusted pci_prodid to 0012
[lsi53c8xx/dev_init] Found chip #0
[lsi53c8xx/ide_initchip] Waiting for devices to spin up..
[lsi53c8xx/init_port] ---> Port 0
[lsi53c8xx/scsi_scan] Scanning SCSI bus...
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=6
lsi_do_dma DMA addr=0x19b000 len=254
lsi_do_status Get status len=1 status=0
lsi_do_msgin Message in len=1 1
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=6
lsi_do_status Get status len=1 status=2
lsi_do_msgin Message in len=1 1
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=6
lsi_do_dma DMA addr=0x19907c len=14
lsi_do_status Get status len=1 status=0
lsi_do_msgin Message in len=1 1
[lsi53c8xx/execute_cmd] Request_sense sense key 6 ASC 29 ASCQ 0
[lsi53c8xx/execute_cmd] Target 0 not ready, retry 0
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=6
lsi_do_status Get status len=1 status=0
lsi_do_msgin Message in len=1 1
Device 0: (0:0) Vendor: QEMU Prod.: QEMU HARDDISK Rev: 2.5+
Type: Hard Disk
[lsi53c8xx/execute_script] ID: 1 Selection Timeout
[lsi53c8xx/execute_script] ID: 2 Selection Timeout
[lsi53c8xx/execute_script] ID: 3 Selection Timeout
[lsi53c8xx/execute_script] ID: 4 Selection Timeout
[lsi53c8xx/execute_script] ID: 5 Selection Timeout
[lsi53c8xx/execute_script] ID: 6 Selection Timeout
[lsi53c8xx/execute_script] ID: 7 Selection Timeout
[lsi53c8xx/execute_script] ID: 8 Selection Timeout
[lsi53c8xx/execute_script] ID: 9 Selection Timeout
[lsi53c8xx/execute_script] ID: A Selection Timeout
[lsi53c8xx/execute_script] ID: B Selection Timeout
[lsi53c8xx/execute_script] ID: C Selection Timeout
[lsi53c8xx/execute_script] ID: D Selection Timeout
[lsi53c8xx/execute_script] ID: E Selection Timeout
[lsi53c8xx/execute_script] ID: F Selection Timeout
[lsi53c8xx/init_port] 1 device(s) on port
[lsi53c8xx/init_port] Starting 'lsi53c8xx.device - chip 0 port 0' task
[lsi53c8xx/int_install_handler] Installing handler for irq 25
[lsi53c8xx/init_unit] Trying to configure unit 0
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=10
lsi_do_dma DMA addr=0x23a0000 len=8
lsi_do_status Get status len=1 status=0
lsi_do_msgin Message in len=1 1
[lsi53c8xx/init_unit] Unit configured, flags $0301
[lsi53c8xx/init_port] Port 0 task started
[lsi53c8xx/dev_init] All done
Then later when trying to access the device:
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=6
lsi_do_dma DMA addr=0x23a0000 len=8
lsi_do_status Get status len=1 status=0
lsi_do_msgin Message in len=1 1
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=10
lsi_do_msgin Message in len=1 2
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=10
lsi_do_msgin Message in len=1 3
[lsi53c8xx/scsi_print_error] SCSI Error: Target 0 LUN 0 Command 28
CCB: 28 00 00 00 00 01 00 00 01 00 (len = 10)
Cntrl: Script Error
Sense: SK 0 (No Sense) ASC 0 ASCQ 0
Status: Good
lsi_do_msgin Message in len=1 3
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=10
qemu-system-ppc: ../hw/scsi/lsi53c895a.c:866: lsi_do_command: Assertion `s->current == NULL' failed.
I don't know what the failed command is, would need to look up in some SCSI docs.
It tries to detect up to 15 devices so maybe even more than 7 could be attached to this controller. The options to attach a scsi disk in QEMU is:
-device lsi53c895a -drive if=none,id=shd,format=raw,file=disk.img -device scsi-hd,drive=shd
but it won't work currently, only added it here because @smarkusg had a more complex command above which can be simplified as above.
Using scsi-cd instead of scsi-hd the error does not happen but eventually gets the same error after some more communication with the scsi-cd:
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=6
lsi_do_dma DMA addr=0x23a0000 len=8
lsi_do_status Get status len=1 status=0
lsi_do_msgin Message in len=1 1
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=6
lsi_do_status Get status len=1 status=0
lsi_do_msgin Message in len=1 1
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=10
lsi_do_msgin Message in len=1 2
[lsi53c8xx/find_unit] unitnum 16 invalid (!chip)
[lsi53c8xx/find_unit] unitnum 17 invalid (!chip)
...
[lsi53c8xx/find_unit] unitnum 62 invalid (!chip)
[lsi53c8xx/find_unit] unitnum 63 invalid (!chip)
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=6
lsi_do_status Get status len=1 status=0
lsi_do_msgin Message in len=1 2
[DOS] NOTE: Kernel debug level detected as 1
lsi_do_msgin Message in len=1 2
lsi_do_msgout MSG out len=1
lsi_do_msgout_select Select LUN 0
lsi_do_command Send command len=6
qemu-system-ppc: ../hw/scsi/lsi53c895a.c:866: lsi_do_command: Assertion `s->current == NULL' failed.
Edited by balaton on 2024/3/2 19:35:14