2 * QEMU LSI53C895A SCSI Host Bus Adapter emulation
4 * Copyright (c) 2006 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licensed under the LGPL.
11 * LSI53C810 emulation is incorrect, in the sense that it supports
12 * features added in later evolutions. This should not be a problem,
13 * as well-behaved operating systems will not try to use them.
16 #include "qemu/osdep.h"
19 #include "hw/pci/pci_device.h"
20 #include "hw/scsi/scsi.h"
21 #include "migration/vmstate.h"
22 #include "sysemu/dma.h"
24 #include "qemu/module.h"
26 #include "qom/object.h"
28 static const char *names
[] = {
29 "SCNTL0", "SCNTL1", "SCNTL2", "SCNTL3", "SCID", "SXFER", "SDID", "GPREG",
30 "SFBR", "SOCL", "SSID", "SBCL", "DSTAT", "SSTAT0", "SSTAT1", "SSTAT2",
31 "DSA0", "DSA1", "DSA2", "DSA3", "ISTAT", "0x15", "0x16", "0x17",
32 "CTEST0", "CTEST1", "CTEST2", "CTEST3", "TEMP0", "TEMP1", "TEMP2", "TEMP3",
33 "DFIFO", "CTEST4", "CTEST5", "CTEST6", "DBC0", "DBC1", "DBC2", "DCMD",
34 "DNAD0", "DNAD1", "DNAD2", "DNAD3", "DSP0", "DSP1", "DSP2", "DSP3",
35 "DSPS0", "DSPS1", "DSPS2", "DSPS3", "SCRATCHA0", "SCRATCHA1", "SCRATCHA2", "SCRATCHA3",
36 "DMODE", "DIEN", "SBR", "DCNTL", "ADDER0", "ADDER1", "ADDER2", "ADDER3",
37 "SIEN0", "SIEN1", "SIST0", "SIST1", "SLPAR", "0x45", "MACNTL", "GPCNTL",
38 "STIME0", "STIME1", "RESPID", "0x4b", "STEST0", "STEST1", "STEST2", "STEST3",
39 "SIDL", "0x51", "0x52", "0x53", "SODL", "0x55", "0x56", "0x57",
40 "SBDL", "0x59", "0x5a", "0x5b", "SCRATCHB0", "SCRATCHB1", "SCRATCHB2", "SCRATCHB3",
43 #define LSI_MAX_DEVS 7
45 #define LSI_SCNTL0_TRG 0x01
46 #define LSI_SCNTL0_AAP 0x02
47 #define LSI_SCNTL0_EPC 0x08
48 #define LSI_SCNTL0_WATN 0x10
49 #define LSI_SCNTL0_START 0x20
51 #define LSI_SCNTL1_SST 0x01
52 #define LSI_SCNTL1_IARB 0x02
53 #define LSI_SCNTL1_AESP 0x04
54 #define LSI_SCNTL1_RST 0x08
55 #define LSI_SCNTL1_CON 0x10
56 #define LSI_SCNTL1_DHP 0x20
57 #define LSI_SCNTL1_ADB 0x40
58 #define LSI_SCNTL1_EXC 0x80
60 #define LSI_SCNTL2_WSR 0x01
61 #define LSI_SCNTL2_VUE0 0x02
62 #define LSI_SCNTL2_VUE1 0x04
63 #define LSI_SCNTL2_WSS 0x08
64 #define LSI_SCNTL2_SLPHBEN 0x10
65 #define LSI_SCNTL2_SLPMD 0x20
66 #define LSI_SCNTL2_CHM 0x40
67 #define LSI_SCNTL2_SDU 0x80
69 #define LSI_ISTAT0_DIP 0x01
70 #define LSI_ISTAT0_SIP 0x02
71 #define LSI_ISTAT0_INTF 0x04
72 #define LSI_ISTAT0_CON 0x08
73 #define LSI_ISTAT0_SEM 0x10
74 #define LSI_ISTAT0_SIGP 0x20
75 #define LSI_ISTAT0_SRST 0x40
76 #define LSI_ISTAT0_ABRT 0x80
78 #define LSI_ISTAT1_SI 0x01
79 #define LSI_ISTAT1_SRUN 0x02
80 #define LSI_ISTAT1_FLSH 0x04
82 #define LSI_SSTAT0_SDP0 0x01
83 #define LSI_SSTAT0_RST 0x02
84 #define LSI_SSTAT0_WOA 0x04
85 #define LSI_SSTAT0_LOA 0x08
86 #define LSI_SSTAT0_AIP 0x10
87 #define LSI_SSTAT0_OLF 0x20
88 #define LSI_SSTAT0_ORF 0x40
89 #define LSI_SSTAT0_ILF 0x80
91 #define LSI_SIST0_PAR 0x01
92 #define LSI_SIST0_RST 0x02
93 #define LSI_SIST0_UDC 0x04
94 #define LSI_SIST0_SGE 0x08
95 #define LSI_SIST0_RSL 0x10
96 #define LSI_SIST0_SEL 0x20
97 #define LSI_SIST0_CMP 0x40
98 #define LSI_SIST0_MA 0x80
100 #define LSI_SIST1_HTH 0x01
101 #define LSI_SIST1_GEN 0x02
102 #define LSI_SIST1_STO 0x04
103 #define LSI_SIST1_SBMC 0x10
105 #define LSI_SOCL_IO 0x01
106 #define LSI_SOCL_CD 0x02
107 #define LSI_SOCL_MSG 0x04
108 #define LSI_SOCL_ATN 0x08
109 #define LSI_SOCL_SEL 0x10
110 #define LSI_SOCL_BSY 0x20
111 #define LSI_SOCL_ACK 0x40
112 #define LSI_SOCL_REQ 0x80
114 #define LSI_DSTAT_IID 0x01
115 #define LSI_DSTAT_SIR 0x04
116 #define LSI_DSTAT_SSI 0x08
117 #define LSI_DSTAT_ABRT 0x10
118 #define LSI_DSTAT_BF 0x20
119 #define LSI_DSTAT_MDPE 0x40
120 #define LSI_DSTAT_DFE 0x80
122 #define LSI_DCNTL_COM 0x01
123 #define LSI_DCNTL_IRQD 0x02
124 #define LSI_DCNTL_STD 0x04
125 #define LSI_DCNTL_IRQM 0x08
126 #define LSI_DCNTL_SSM 0x10
127 #define LSI_DCNTL_PFEN 0x20
128 #define LSI_DCNTL_PFF 0x40
129 #define LSI_DCNTL_CLSE 0x80
131 #define LSI_DMODE_MAN 0x01
132 #define LSI_DMODE_BOF 0x02
133 #define LSI_DMODE_ERMP 0x04
134 #define LSI_DMODE_ERL 0x08
135 #define LSI_DMODE_DIOM 0x10
136 #define LSI_DMODE_SIOM 0x20
138 #define LSI_CTEST2_DACK 0x01
139 #define LSI_CTEST2_DREQ 0x02
140 #define LSI_CTEST2_TEOP 0x04
141 #define LSI_CTEST2_PCICIE 0x08
142 #define LSI_CTEST2_CM 0x10
143 #define LSI_CTEST2_CIO 0x20
144 #define LSI_CTEST2_SIGP 0x40
145 #define LSI_CTEST2_DDIR 0x80
147 #define LSI_CTEST5_BL2 0x04
148 #define LSI_CTEST5_DDIR 0x08
149 #define LSI_CTEST5_MASR 0x10
150 #define LSI_CTEST5_DFSN 0x20
151 #define LSI_CTEST5_BBCK 0x40
152 #define LSI_CTEST5_ADCK 0x80
154 #define LSI_CCNTL0_DILS 0x01
155 #define LSI_CCNTL0_DISFC 0x10
156 #define LSI_CCNTL0_ENNDJ 0x20
157 #define LSI_CCNTL0_PMJCTL 0x40
158 #define LSI_CCNTL0_ENPMJ 0x80
160 #define LSI_CCNTL1_EN64DBMV 0x01
161 #define LSI_CCNTL1_EN64TIBMV 0x02
162 #define LSI_CCNTL1_64TIMOD 0x04
163 #define LSI_CCNTL1_DDAC 0x08
164 #define LSI_CCNTL1_ZMOD 0x80
166 #define LSI_SBCL_ATN 0x08
167 #define LSI_SBCL_BSY 0x20
168 #define LSI_SBCL_ACK 0x40
169 #define LSI_SBCL_REQ 0x80
171 /* Enable Response to Reselection */
172 #define LSI_SCID_RRE 0x60
174 #define LSI_CCNTL1_40BIT (LSI_CCNTL1_EN64TIBMV|LSI_CCNTL1_64TIMOD)
184 /* Maximum length of MSG IN data. */
185 #define LSI_MAX_MSGIN_LEN 8
187 /* Flag set if this is a tagged command. */
188 #define LSI_TAG_VALID (1 << 16)
190 /* Maximum instructions to process. */
191 #define LSI_MAX_INSN 500
193 typedef struct lsi_request
{
200 QTAILQ_ENTRY(lsi_request
) next
;
204 LSI_NOWAIT
, /* SCRIPTS are running or stopped */
205 LSI_WAIT_RESELECT
, /* Wait Reselect instruction has been issued */
206 LSI_DMA_SCRIPTS
, /* processing DMA from lsi_execute_script */
207 LSI_DMA_IN_PROGRESS
, /* DMA operation is in progress */
208 LSI_WAIT_SCRIPTS
, /* SCRIPTS stopped because of instruction count limit */
212 LSI_MSG_ACTION_COMMAND
= 0,
213 LSI_MSG_ACTION_DISCONNECT
= 1,
214 LSI_MSG_ACTION_DOUT
= 2,
215 LSI_MSG_ACTION_DIN
= 3,
220 PCIDevice parent_obj
;
224 MemoryRegion mmio_io
;
227 AddressSpace pci_io_as
;
228 QEMUTimer
*scripts_timer
;
230 int carry
; /* ??? Should this be in a visible register somewhere? */
234 uint8_t msg
[LSI_MAX_MSGIN_LEN
];
238 /* The tag is a combination of the device ID and the SCSI tag. */
240 int command_complete
;
241 QTAILQ_HEAD(, lsi_request
) queue
;
242 lsi_request
*current
;
304 uint32_t scratch
[18]; /* SCRATCHA-SCRATCHR */
308 uint8_t script_ram
[2048 * sizeof(uint32_t)];
311 #define TYPE_LSI53C810 "lsi53c810"
312 #define TYPE_LSI53C895A "lsi53c895a"
314 OBJECT_DECLARE_SIMPLE_TYPE(LSIState
, LSI53C895A
)
316 static const char *scsi_phases
[] = {
327 static const char *scsi_phase_name(int phase
)
329 return scsi_phases
[phase
& PHASE_MASK
];
332 static inline int lsi_irq_on_rsl(LSIState
*s
)
334 return (s
->sien0
& LSI_SIST0_RSL
) && (s
->scid
& LSI_SCID_RRE
);
337 static lsi_request
*get_pending_req(LSIState
*s
)
341 QTAILQ_FOREACH(p
, &s
->queue
, next
) {
349 static void lsi_soft_reset(LSIState
*s
)
354 s
->msg_action
= LSI_MSG_ACTION_COMMAND
;
356 s
->waiting
= LSI_NOWAIT
;
361 memset(s
->scratch
, 0, sizeof(s
->scratch
));
374 s
->ctest2
= LSI_CTEST2_DACK
;
418 assert(QTAILQ_EMPTY(&s
->queue
));
420 timer_del(s
->scripts_timer
);
423 static int lsi_dma_40bit(LSIState
*s
)
425 if ((s
->ccntl1
& LSI_CCNTL1_40BIT
) == LSI_CCNTL1_40BIT
)
430 static int lsi_dma_ti64bit(LSIState
*s
)
432 if ((s
->ccntl1
& LSI_CCNTL1_EN64TIBMV
) == LSI_CCNTL1_EN64TIBMV
)
437 static int lsi_dma_64bit(LSIState
*s
)
439 if ((s
->ccntl1
& LSI_CCNTL1_EN64DBMV
) == LSI_CCNTL1_EN64DBMV
)
444 static uint8_t lsi_reg_readb(LSIState
*s
, int offset
);
445 static void lsi_reg_writeb(LSIState
*s
, int offset
, uint8_t val
);
446 static void lsi_execute_script(LSIState
*s
);
447 static void lsi_reselect(LSIState
*s
, lsi_request
*p
);
449 static inline void lsi_mem_read(LSIState
*s
, dma_addr_t addr
,
450 void *buf
, dma_addr_t len
)
452 if (s
->dmode
& LSI_DMODE_SIOM
) {
453 address_space_read(&s
->pci_io_as
, addr
, MEMTXATTRS_UNSPECIFIED
,
456 pci_dma_read(PCI_DEVICE(s
), addr
, buf
, len
);
460 static inline void lsi_mem_write(LSIState
*s
, dma_addr_t addr
,
461 const void *buf
, dma_addr_t len
)
463 if (s
->dmode
& LSI_DMODE_DIOM
) {
464 address_space_write(&s
->pci_io_as
, addr
, MEMTXATTRS_UNSPECIFIED
,
467 pci_dma_write(PCI_DEVICE(s
), addr
, buf
, len
);
471 static inline uint32_t read_dword(LSIState
*s
, uint32_t addr
)
475 pci_dma_read(PCI_DEVICE(s
), addr
, &buf
, 4);
476 return cpu_to_le32(buf
);
479 static void lsi_stop_script(LSIState
*s
)
481 s
->istat1
&= ~LSI_ISTAT1_SRUN
;
484 static void lsi_set_irq(LSIState
*s
, int level
)
486 PCIDevice
*d
= PCI_DEVICE(s
);
489 qemu_set_irq(s
->ext_irq
, level
);
491 pci_set_irq(d
, level
);
495 static void lsi_update_irq(LSIState
*s
)
498 static int last_level
;
500 /* It's unclear whether the DIP/SIP bits should be cleared when the
501 Interrupt Status Registers are cleared or when istat0 is read.
502 We currently do the formwer, which seems to work. */
505 if (s
->dstat
& s
->dien
)
507 s
->istat0
|= LSI_ISTAT0_DIP
;
509 s
->istat0
&= ~LSI_ISTAT0_DIP
;
512 if (s
->sist0
|| s
->sist1
) {
513 if ((s
->sist0
& s
->sien0
) || (s
->sist1
& s
->sien1
))
515 s
->istat0
|= LSI_ISTAT0_SIP
;
517 s
->istat0
&= ~LSI_ISTAT0_SIP
;
519 if (s
->istat0
& LSI_ISTAT0_INTF
)
522 if (level
!= last_level
) {
523 trace_lsi_update_irq(level
, s
->dstat
, s
->sist1
, s
->sist0
);
526 lsi_set_irq(s
, level
);
528 if (!s
->current
&& !level
&& lsi_irq_on_rsl(s
) && !(s
->scntl1
& LSI_SCNTL1_CON
)) {
531 trace_lsi_update_irq_disconnected();
532 p
= get_pending_req(s
);
539 /* Stop SCRIPTS execution and raise a SCSI interrupt. */
540 static void lsi_script_scsi_interrupt(LSIState
*s
, int stat0
, int stat1
)
545 trace_lsi_script_scsi_interrupt(stat1
, stat0
, s
->sist1
, s
->sist0
);
548 /* Stop processor on fatal or unmasked interrupt. As a special hack
549 we don't stop processing when raising STO. Instead continue
550 execution and stop at the next insn that accesses the SCSI bus. */
551 mask0
= s
->sien0
| ~(LSI_SIST0_CMP
| LSI_SIST0_SEL
| LSI_SIST0_RSL
);
552 mask1
= s
->sien1
| ~(LSI_SIST1_GEN
| LSI_SIST1_HTH
);
553 mask1
&= ~LSI_SIST1_STO
;
554 if (s
->sist0
& mask0
|| s
->sist1
& mask1
) {
560 /* Stop SCRIPTS execution and raise a DMA interrupt. */
561 static void lsi_script_dma_interrupt(LSIState
*s
, int stat
)
563 trace_lsi_script_dma_interrupt(stat
, s
->dstat
);
569 static inline void lsi_set_phase(LSIState
*s
, int phase
)
571 s
->sbcl
&= ~PHASE_MASK
;
572 s
->sbcl
|= phase
| LSI_SBCL_REQ
;
573 s
->sstat1
= (s
->sstat1
& ~PHASE_MASK
) | phase
;
576 static int lsi_bad_phase(LSIState
*s
, int out
, int new_phase
)
579 /* Trigger a phase mismatch. */
580 if (s
->ccntl0
& LSI_CCNTL0_ENPMJ
) {
581 if ((s
->ccntl0
& LSI_CCNTL0_PMJCTL
)) {
582 s
->dsp
= out
? s
->pmjad1
: s
->pmjad2
;
584 s
->dsp
= (s
->scntl2
& LSI_SCNTL2_WSR
? s
->pmjad2
: s
->pmjad1
);
586 trace_lsi_bad_phase_jump(s
->dsp
);
588 trace_lsi_bad_phase_interrupt();
589 lsi_script_scsi_interrupt(s
, LSI_SIST0_MA
, 0);
593 lsi_set_phase(s
, new_phase
);
598 /* Resume SCRIPTS execution after a DMA operation. */
599 static void lsi_resume_script(LSIState
*s
)
601 if (s
->waiting
!= 2) {
602 s
->waiting
= LSI_NOWAIT
;
603 lsi_execute_script(s
);
605 s
->waiting
= LSI_NOWAIT
;
609 static void lsi_disconnect(LSIState
*s
)
611 s
->scntl1
&= ~LSI_SCNTL1_CON
;
612 s
->sstat1
&= ~PHASE_MASK
;
616 static void lsi_bad_selection(LSIState
*s
, uint32_t id
)
618 trace_lsi_bad_selection(id
);
619 lsi_script_scsi_interrupt(s
, 0, LSI_SIST1_STO
);
623 /* Initiate a SCSI layer data transfer. */
624 static void lsi_do_dma(LSIState
*s
, int out
)
630 if (!s
->current
|| !s
->current
->dma_len
) {
631 /* Wait until data is available. */
632 trace_lsi_do_dma_unavailable();
636 dev
= s
->current
->req
->dev
;
640 if (count
> s
->current
->dma_len
)
641 count
= s
->current
->dma_len
;
644 /* both 40 and Table Indirect 64-bit DMAs store upper bits in dnad64 */
645 if (lsi_dma_40bit(s
) || lsi_dma_ti64bit(s
))
646 addr
|= ((uint64_t)s
->dnad64
<< 32);
648 addr
|= ((uint64_t)s
->dbms
<< 32);
650 addr
|= ((uint64_t)s
->sbms
<< 32);
652 trace_lsi_do_dma(addr
, count
);
656 if (s
->current
->dma_buf
== NULL
) {
657 s
->current
->dma_buf
= scsi_req_get_buf(s
->current
->req
);
659 /* ??? Set SFBR to first data byte. */
661 lsi_mem_read(s
, addr
, s
->current
->dma_buf
, count
);
663 lsi_mem_write(s
, addr
, s
->current
->dma_buf
, count
);
665 s
->current
->dma_len
-= count
;
666 if (s
->current
->dma_len
== 0) {
667 s
->current
->dma_buf
= NULL
;
668 scsi_req_continue(s
->current
->req
);
670 s
->current
->dma_buf
+= count
;
671 lsi_resume_script(s
);
676 /* Add a command to the queue. */
677 static void lsi_queue_command(LSIState
*s
)
679 lsi_request
*p
= s
->current
;
681 trace_lsi_queue_command(p
->tag
);
682 assert(s
->current
!= NULL
);
683 assert(s
->current
->dma_len
== 0);
684 QTAILQ_INSERT_TAIL(&s
->queue
, s
->current
, next
);
688 p
->out
= (s
->sstat1
& PHASE_MASK
) == PHASE_DO
;
691 /* Queue a byte for a MSG IN phase. */
692 static void lsi_add_msg_byte(LSIState
*s
, uint8_t data
)
694 if (s
->msg_len
>= LSI_MAX_MSGIN_LEN
) {
695 trace_lsi_add_msg_byte_error();
697 trace_lsi_add_msg_byte(data
);
698 s
->msg
[s
->msg_len
++] = data
;
702 /* Perform reselection to continue a command. */
703 static void lsi_reselect(LSIState
*s
, lsi_request
*p
)
707 assert(s
->current
== NULL
);
708 QTAILQ_REMOVE(&s
->queue
, p
, next
);
711 id
= (p
->tag
>> 8) & 0xf;
713 /* LSI53C700 Family Compatibility, see LSI53C895A 4-73 */
714 if (!(s
->dcntl
& LSI_DCNTL_COM
)) {
715 s
->sfbr
= 1 << (id
& 0x7);
717 trace_lsi_reselect(id
);
718 s
->scntl1
|= LSI_SCNTL1_CON
;
719 lsi_set_phase(s
, PHASE_MI
);
720 s
->msg_action
= p
->out
? LSI_MSG_ACTION_DOUT
: LSI_MSG_ACTION_DIN
;
721 s
->current
->dma_len
= p
->pending
;
722 lsi_add_msg_byte(s
, 0x80);
723 if (s
->current
->tag
& LSI_TAG_VALID
) {
724 lsi_add_msg_byte(s
, 0x20);
725 lsi_add_msg_byte(s
, p
->tag
& 0xff);
728 if (lsi_irq_on_rsl(s
)) {
729 lsi_script_scsi_interrupt(s
, LSI_SIST0_RSL
, 0);
733 static lsi_request
*lsi_find_by_tag(LSIState
*s
, uint32_t tag
)
737 QTAILQ_FOREACH(p
, &s
->queue
, next
) {
746 static void lsi_request_free(LSIState
*s
, lsi_request
*p
)
748 if (p
== s
->current
) {
751 QTAILQ_REMOVE(&s
->queue
, p
, next
);
756 static void lsi_request_cancelled(SCSIRequest
*req
)
758 LSIState
*s
= LSI53C895A(req
->bus
->qbus
.parent
);
759 lsi_request
*p
= req
->hba_private
;
761 req
->hba_private
= NULL
;
762 lsi_request_free(s
, p
);
766 /* Record that data is available for a queued command. Returns zero if
767 the device was reselected, nonzero if the IO is deferred. */
768 static int lsi_queue_req(LSIState
*s
, SCSIRequest
*req
, uint32_t len
)
770 lsi_request
*p
= req
->hba_private
;
773 trace_lsi_queue_req_error(p
);
776 /* Reselect if waiting for it, or if reselection triggers an IRQ
778 Since no interrupt stacking is implemented in the emulation, it
779 is also required that there are no pending interrupts waiting
780 for service from the device driver. */
781 if (s
->waiting
== LSI_WAIT_RESELECT
||
782 (lsi_irq_on_rsl(s
) && !(s
->scntl1
& LSI_SCNTL1_CON
) &&
783 !(s
->istat0
& (LSI_ISTAT0_SIP
| LSI_ISTAT0_DIP
)))) {
784 /* Reselect device. */
788 trace_lsi_queue_req(p
->tag
);
794 /* Callback to indicate that the SCSI layer has completed a command. */
795 static void lsi_command_complete(SCSIRequest
*req
, size_t resid
)
797 LSIState
*s
= LSI53C895A(req
->bus
->qbus
.parent
);
800 out
= (s
->sstat1
& PHASE_MASK
) == PHASE_DO
;
801 trace_lsi_command_complete(req
->status
);
802 s
->status
= req
->status
;
803 s
->command_complete
= 2;
804 if (s
->waiting
&& s
->dbc
!= 0) {
805 /* Raise phase mismatch for short transfers. */
806 stop
= lsi_bad_phase(s
, out
, PHASE_ST
);
811 lsi_set_phase(s
, PHASE_ST
);
814 if (req
->hba_private
== s
->current
) {
815 req
->hba_private
= NULL
;
816 lsi_request_free(s
, s
->current
);
820 lsi_resume_script(s
);
824 /* Callback to indicate that the SCSI layer has completed a transfer. */
825 static void lsi_transfer_data(SCSIRequest
*req
, uint32_t len
)
827 LSIState
*s
= LSI53C895A(req
->bus
->qbus
.parent
);
830 assert(req
->hba_private
);
831 if (s
->waiting
== LSI_WAIT_RESELECT
|| req
->hba_private
!= s
->current
||
832 (lsi_irq_on_rsl(s
) && !(s
->scntl1
& LSI_SCNTL1_CON
))) {
833 if (lsi_queue_req(s
, req
, len
)) {
838 out
= (s
->sstat1
& PHASE_MASK
) == PHASE_DO
;
840 /* host adapter (re)connected */
841 trace_lsi_transfer_data(req
->tag
, len
);
842 s
->current
->dma_len
= len
;
843 s
->command_complete
= 1;
845 if (s
->waiting
== LSI_WAIT_RESELECT
|| s
->dbc
== 0) {
846 lsi_resume_script(s
);
853 static void lsi_do_command(LSIState
*s
)
860 trace_lsi_do_command(s
->dbc
);
863 pci_dma_read(PCI_DEVICE(s
), s
->dnad
, buf
, s
->dbc
);
865 s
->command_complete
= 0;
867 id
= (s
->select_tag
>> 8) & 0xf;
868 dev
= scsi_device_find(&s
->bus
, 0, id
, s
->current_lun
);
870 lsi_bad_selection(s
, id
);
874 assert(s
->current
== NULL
);
875 s
->current
= g_new0(lsi_request
, 1);
876 s
->current
->tag
= s
->select_tag
;
877 s
->current
->req
= scsi_req_new(dev
, s
->current
->tag
, s
->current_lun
, buf
,
880 n
= scsi_req_enqueue(s
->current
->req
);
883 lsi_set_phase(s
, PHASE_DI
);
885 lsi_set_phase(s
, PHASE_DO
);
887 scsi_req_continue(s
->current
->req
);
889 if (!s
->command_complete
) {
891 /* Command did not complete immediately so disconnect. */
892 lsi_add_msg_byte(s
, 2); /* SAVE DATA POINTER */
893 lsi_add_msg_byte(s
, 4); /* DISCONNECT */
895 lsi_set_phase(s
, PHASE_MI
);
896 s
->msg_action
= LSI_MSG_ACTION_DISCONNECT
;
897 lsi_queue_command(s
);
899 /* wait command complete */
900 lsi_set_phase(s
, PHASE_DI
);
905 static void lsi_do_status(LSIState
*s
)
908 trace_lsi_do_status(s
->dbc
, s
->status
);
910 trace_lsi_do_status_error();
915 pci_dma_write(PCI_DEVICE(s
), s
->dnad
, &status
, 1);
916 lsi_set_phase(s
, PHASE_MI
);
917 s
->msg_action
= LSI_MSG_ACTION_DISCONNECT
;
918 lsi_add_msg_byte(s
, 0); /* COMMAND COMPLETE */
921 static void lsi_do_msgin(LSIState
*s
)
924 trace_lsi_do_msgin(s
->dbc
, s
->msg_len
);
927 assert(len
> 0 && len
<= LSI_MAX_MSGIN_LEN
);
932 pci_dma_write(PCI_DEVICE(s
), s
->dnad
, s
->msg
, len
);
933 /* Linux drivers rely on the last byte being in the SIDL. */
934 s
->sidl
= s
->msg
[len
- 1];
937 memmove(s
->msg
, s
->msg
+ len
, s
->msg_len
);
942 /* ??? Check if ATN (not yet implemented) is asserted and maybe
943 switch to PHASE_MO. */
944 switch (s
->msg_action
) {
945 case LSI_MSG_ACTION_COMMAND
:
946 lsi_set_phase(s
, PHASE_CMD
);
948 case LSI_MSG_ACTION_DISCONNECT
:
951 case LSI_MSG_ACTION_DOUT
:
952 lsi_set_phase(s
, PHASE_DO
);
954 case LSI_MSG_ACTION_DIN
:
955 lsi_set_phase(s
, PHASE_DI
);
963 /* Read the next byte during a MSGOUT phase. */
964 static uint8_t lsi_get_msgbyte(LSIState
*s
)
967 pci_dma_read(PCI_DEVICE(s
), s
->dnad
, &data
, 1);
973 /* Skip the next n bytes during a MSGOUT phase. */
974 static void lsi_skip_msgbytes(LSIState
*s
, unsigned int n
)
980 static void lsi_do_msgout(LSIState
*s
)
984 uint32_t current_tag
;
985 lsi_request
*current_req
, *p
, *p_next
;
988 current_tag
= s
->current
->tag
;
989 current_req
= s
->current
;
991 current_tag
= s
->select_tag
;
992 current_req
= lsi_find_by_tag(s
, current_tag
);
995 trace_lsi_do_msgout(s
->dbc
);
997 msg
= lsi_get_msgbyte(s
);
1002 trace_lsi_do_msgout_disconnect();
1006 trace_lsi_do_msgout_noop();
1007 lsi_set_phase(s
, PHASE_CMD
);
1010 len
= lsi_get_msgbyte(s
);
1011 msg
= lsi_get_msgbyte(s
);
1012 (void)len
; /* avoid a warning about unused variable*/
1013 trace_lsi_do_msgout_extended(msg
, len
);
1016 trace_lsi_do_msgout_ignored("SDTR");
1017 lsi_skip_msgbytes(s
, 2);
1020 trace_lsi_do_msgout_ignored("WDTR");
1021 lsi_skip_msgbytes(s
, 1);
1024 trace_lsi_do_msgout_ignored("PPR");
1025 lsi_skip_msgbytes(s
, 5);
1031 case 0x20: /* SIMPLE queue */
1032 s
->select_tag
|= lsi_get_msgbyte(s
) | LSI_TAG_VALID
;
1033 trace_lsi_do_msgout_simplequeue(s
->select_tag
& 0xff);
1035 case 0x21: /* HEAD of queue */
1036 qemu_log_mask(LOG_UNIMP
, "lsi_scsi: HEAD queue not implemented\n");
1037 s
->select_tag
|= lsi_get_msgbyte(s
) | LSI_TAG_VALID
;
1039 case 0x22: /* ORDERED queue */
1040 qemu_log_mask(LOG_UNIMP
,
1041 "lsi_scsi: ORDERED queue not implemented\n");
1042 s
->select_tag
|= lsi_get_msgbyte(s
) | LSI_TAG_VALID
;
1045 /* The ABORT TAG message clears the current I/O process only. */
1046 trace_lsi_do_msgout_abort(current_tag
);
1047 if (current_req
&& current_req
->req
) {
1048 scsi_req_cancel(current_req
->req
);
1056 /* The ABORT message clears all I/O processes for the selecting
1057 initiator on the specified logical unit of the target. */
1059 trace_lsi_do_msgout_abort(current_tag
);
1061 /* The CLEAR QUEUE message clears all I/O processes for all
1062 initiators on the specified logical unit of the target. */
1064 trace_lsi_do_msgout_clearqueue(current_tag
);
1066 /* The BUS DEVICE RESET message clears all I/O processes for all
1067 initiators on all logical units of the target. */
1069 trace_lsi_do_msgout_busdevicereset(current_tag
);
1072 /* clear the current I/O process */
1074 scsi_req_cancel(s
->current
->req
);
1078 /* As the current implemented devices scsi_disk and scsi_generic
1079 only support one LUN, we don't need to keep track of LUNs.
1080 Clearing I/O processes for other initiators could be possible
1081 for scsi_generic by sending a SG_SCSI_RESET to the /dev/sgX
1082 device, but this is currently not implemented (and seems not
1083 to be really necessary). So let's simply clear all queued
1084 commands for the current device: */
1085 QTAILQ_FOREACH_SAFE(p
, &s
->queue
, next
, p_next
) {
1086 if ((p
->tag
& 0x0000ff00) == (current_tag
& 0x0000ff00)) {
1087 scsi_req_cancel(p
->req
);
1094 if ((msg
& 0x80) == 0) {
1097 s
->current_lun
= msg
& 7;
1098 trace_lsi_do_msgout_select(s
->current_lun
);
1099 lsi_set_phase(s
, PHASE_CMD
);
1105 qemu_log_mask(LOG_UNIMP
, "Unimplemented message 0x%02x\n", msg
);
1106 lsi_set_phase(s
, PHASE_MI
);
1107 lsi_add_msg_byte(s
, 7); /* MESSAGE REJECT */
1108 s
->msg_action
= LSI_MSG_ACTION_COMMAND
;
1111 #define LSI_BUF_SIZE 4096
1112 static void lsi_memcpy(LSIState
*s
, uint32_t dest
, uint32_t src
, int count
)
1115 uint8_t buf
[LSI_BUF_SIZE
];
1117 trace_lsi_memcpy(dest
, src
, count
);
1119 n
= (count
> LSI_BUF_SIZE
) ? LSI_BUF_SIZE
: count
;
1120 lsi_mem_read(s
, src
, buf
, n
);
1121 lsi_mem_write(s
, dest
, buf
, n
);
1128 static void lsi_wait_reselect(LSIState
*s
)
1132 trace_lsi_wait_reselect();
1137 p
= get_pending_req(s
);
1141 if (s
->current
== NULL
) {
1142 s
->waiting
= LSI_WAIT_RESELECT
;
1146 static void lsi_scripts_timer_start(LSIState
*s
)
1148 trace_lsi_scripts_timer_start();
1149 timer_mod(s
->scripts_timer
, qemu_clock_get_us(QEMU_CLOCK_VIRTUAL
) + 500);
1152 static void lsi_execute_script(LSIState
*s
)
1154 PCIDevice
*pci_dev
= PCI_DEVICE(s
);
1156 uint32_t addr
, addr_high
;
1158 int insn_processed
= 0;
1159 static int reentrancy_level
;
1161 if (s
->waiting
== LSI_WAIT_SCRIPTS
) {
1162 timer_del(s
->scripts_timer
);
1163 s
->waiting
= LSI_NOWAIT
;
1168 s
->istat1
|= LSI_ISTAT1_SRUN
;
1171 * Some windows drivers make the device spin waiting for a memory location
1172 * to change. If we have executed more than LSI_MAX_INSN instructions then
1173 * assume this is the case and start a timer. Until the timer fires, the
1174 * host CPU has a chance to run and change the memory location.
1176 * Another issue (CVE-2023-0330) can occur if the script is programmed to
1177 * trigger itself again and again. Avoid this problem by stopping after
1178 * being called multiple times in a reentrant way (8 is an arbitrary value
1179 * which should be enough for all valid use cases).
1181 if (++insn_processed
> LSI_MAX_INSN
|| reentrancy_level
> 8) {
1182 s
->waiting
= LSI_WAIT_SCRIPTS
;
1183 lsi_scripts_timer_start(s
);
1187 insn
= read_dword(s
, s
->dsp
);
1189 /* If we receive an empty opcode increment the DSP by 4 bytes
1190 instead of 8 and execute the next opcode at that location */
1194 addr
= read_dword(s
, s
->dsp
+ 4);
1196 trace_lsi_execute_script(s
->dsp
, insn
, addr
);
1198 s
->dcmd
= insn
>> 24;
1200 switch (insn
>> 30) {
1201 case 0: /* Block move. */
1202 if (s
->sist1
& LSI_SIST1_STO
) {
1203 trace_lsi_execute_script_blockmove_delayed();
1207 s
->dbc
= insn
& 0xffffff;
1211 if (insn
& (1 << 29)) {
1212 /* Indirect addressing. */
1213 addr
= read_dword(s
, addr
);
1214 } else if (insn
& (1 << 28)) {
1217 /* Table indirect addressing. */
1219 /* 32-bit Table indirect */
1220 offset
= sextract32(addr
, 0, 24);
1221 pci_dma_read(pci_dev
, s
->dsa
+ offset
, buf
, 8);
1222 /* byte count is stored in bits 0:23 only */
1223 s
->dbc
= cpu_to_le32(buf
[0]) & 0xffffff;
1225 addr
= cpu_to_le32(buf
[1]);
1227 /* 40-bit DMA, upper addr bits [39:32] stored in first DWORD of
1228 * table, bits [31:24] */
1229 if (lsi_dma_40bit(s
))
1230 addr_high
= cpu_to_le32(buf
[0]) >> 24;
1231 else if (lsi_dma_ti64bit(s
)) {
1232 int selector
= (cpu_to_le32(buf
[0]) >> 24) & 0x1f;
1235 /* offset index into scratch registers since
1236 * TI64 mode can use registers C to R */
1237 addr_high
= s
->scratch
[2 + selector
];
1240 addr_high
= s
->mmrs
;
1243 addr_high
= s
->mmws
;
1252 addr_high
= s
->sbms
;
1255 addr_high
= s
->dbms
;
1258 qemu_log_mask(LOG_GUEST_ERROR
,
1259 "lsi_scsi: Illegal selector specified (0x%x > 0x15) "
1260 "for 64-bit DMA block move", selector
);
1264 } else if (lsi_dma_64bit(s
)) {
1265 /* fetch a 3rd dword if 64-bit direct move is enabled and
1266 only if we're not doing table indirect or indirect addressing */
1267 s
->dbms
= read_dword(s
, s
->dsp
);
1269 s
->ia
= s
->dsp
- 12;
1271 if ((s
->sstat1
& PHASE_MASK
) != ((insn
>> 24) & 7)) {
1272 trace_lsi_execute_script_blockmove_badphase(
1273 scsi_phase_name(s
->sstat1
),
1274 scsi_phase_name(insn
>> 24));
1275 lsi_script_scsi_interrupt(s
, LSI_SIST0_MA
, 0);
1279 s
->dnad64
= addr_high
;
1280 switch (s
->sstat1
& 0x7) {
1282 s
->waiting
= LSI_DMA_SCRIPTS
;
1285 s
->waiting
= LSI_DMA_IN_PROGRESS
;
1288 s
->waiting
= LSI_DMA_SCRIPTS
;
1291 s
->waiting
= LSI_DMA_IN_PROGRESS
;
1306 qemu_log_mask(LOG_UNIMP
, "lsi_scsi: Unimplemented phase %s\n",
1307 scsi_phase_name(s
->sstat1
));
1309 s
->dfifo
= s
->dbc
& 0xff;
1310 s
->ctest5
= (s
->ctest5
& 0xfc) | ((s
->dbc
>> 8) & 3);
1313 s
->ua
= addr
+ s
->dbc
;
1316 case 1: /* IO or Read/Write instruction. */
1317 opcode
= (insn
>> 27) & 7;
1321 if (insn
& (1 << 25)) {
1322 id
= read_dword(s
, s
->dsa
+ sextract32(insn
, 0, 24));
1326 id
= (id
>> 16) & 0xf;
1327 if (insn
& (1 << 26)) {
1328 addr
= s
->dsp
+ sextract32(addr
, 0, 24);
1332 case 0: /* Select */
1334 if (s
->scntl1
& LSI_SCNTL1_CON
) {
1335 trace_lsi_execute_script_io_alreadyreselected();
1339 s
->sstat0
|= LSI_SSTAT0_WOA
;
1340 s
->scntl1
&= ~LSI_SCNTL1_IARB
;
1341 if (!scsi_device_find(&s
->bus
, 0, id
, 0)) {
1342 lsi_bad_selection(s
, id
);
1345 trace_lsi_execute_script_io_selected(id
,
1346 insn
& (1 << 3) ? " ATN" : "");
1347 /* ??? Linux drivers complain when this is set. Maybe
1348 it only applies in low-level mode (unimplemented).
1349 lsi_script_scsi_interrupt(s, LSI_SIST0_CMP, 0); */
1350 s
->select_tag
= id
<< 8;
1351 s
->scntl1
|= LSI_SCNTL1_CON
;
1352 if (insn
& (1 << 3)) {
1353 s
->socl
|= LSI_SOCL_ATN
;
1354 s
->sbcl
|= LSI_SBCL_ATN
;
1356 s
->sbcl
|= LSI_SBCL_BSY
;
1357 lsi_set_phase(s
, PHASE_MO
);
1358 s
->waiting
= LSI_NOWAIT
;
1360 case 1: /* Disconnect */
1361 trace_lsi_execute_script_io_disconnect();
1362 s
->scntl1
&= ~LSI_SCNTL1_CON
;
1363 /* FIXME: this is not entirely correct; the target need not ask
1364 * for reselection until it has to send data, while here we force a
1365 * reselection as soon as the bus is free. The correct flow would
1366 * reselect before lsi_transfer_data and disconnect as soon as
1370 lsi_request
*p
= get_pending_req(s
);
1376 case 2: /* Wait Reselect */
1377 if (s
->istat0
& LSI_ISTAT0_SIGP
) {
1379 } else if (!lsi_irq_on_rsl(s
)) {
1380 lsi_wait_reselect(s
);
1384 trace_lsi_execute_script_io_set(
1385 insn
& (1 << 3) ? " ATN" : "",
1386 insn
& (1 << 6) ? " ACK" : "",
1387 insn
& (1 << 9) ? " TM" : "",
1388 insn
& (1 << 10) ? " CC" : "");
1389 if (insn
& (1 << 3)) {
1390 s
->socl
|= LSI_SOCL_ATN
;
1391 s
->sbcl
|= LSI_SBCL_ATN
;
1392 lsi_set_phase(s
, PHASE_MO
);
1395 if (insn
& (1 << 6)) {
1396 s
->sbcl
|= LSI_SBCL_ACK
;
1399 if (insn
& (1 << 9)) {
1400 qemu_log_mask(LOG_UNIMP
,
1401 "lsi_scsi: Target mode not implemented\n");
1403 if (insn
& (1 << 10))
1407 trace_lsi_execute_script_io_clear(
1408 insn
& (1 << 3) ? " ATN" : "",
1409 insn
& (1 << 6) ? " ACK" : "",
1410 insn
& (1 << 9) ? " TM" : "",
1411 insn
& (1 << 10) ? " CC" : "");
1412 if (insn
& (1 << 3)) {
1413 s
->socl
&= ~LSI_SOCL_ATN
;
1414 s
->sbcl
&= ~LSI_SBCL_ATN
;
1417 if (insn
& (1 << 6)) {
1418 s
->sbcl
&= ~LSI_SBCL_ACK
;
1421 if (insn
& (1 << 10))
1432 static const char *opcode_names
[3] =
1433 {"Write", "Read", "Read-Modify-Write"};
1434 static const char *operator_names
[8] =
1435 {"MOV", "SHL", "OR", "XOR", "AND", "SHR", "ADD", "ADC"};
1437 reg
= ((insn
>> 16) & 0x7f) | (insn
& 0x80);
1438 data8
= (insn
>> 8) & 0xff;
1439 opcode
= (insn
>> 27) & 7;
1440 operator = (insn
>> 24) & 7;
1441 trace_lsi_execute_script_io_opcode(
1442 opcode_names
[opcode
- 5], reg
,
1443 operator_names
[operator], data8
, s
->sfbr
,
1444 (insn
& (1 << 23)) ? " SFBR" : "");
1447 case 5: /* From SFBR */
1451 case 6: /* To SFBR */
1453 op0
= lsi_reg_readb(s
, reg
);
1456 case 7: /* Read-modify-write */
1458 op0
= lsi_reg_readb(s
, reg
);
1459 if (insn
& (1 << 23)) {
1471 case 1: /* Shift left */
1473 op0
= (op0
<< 1) | s
->carry
;
1487 op0
= (op0
>> 1) | (s
->carry
<< 7);
1492 s
->carry
= op0
< op1
;
1495 op0
+= op1
+ s
->carry
;
1497 s
->carry
= op0
<= op1
;
1499 s
->carry
= op0
< op1
;
1504 case 5: /* From SFBR */
1505 case 7: /* Read-modify-write */
1506 lsi_reg_writeb(s
, reg
, op0
);
1508 case 6: /* To SFBR */
1515 case 2: /* Transfer Control. */
1520 if ((insn
& 0x002e0000) == 0) {
1521 trace_lsi_execute_script_tc_nop();
1524 if (s
->sist1
& LSI_SIST1_STO
) {
1525 trace_lsi_execute_script_tc_delayedselect_timeout();
1529 cond
= jmp
= (insn
& (1 << 19)) != 0;
1530 if (cond
== jmp
&& (insn
& (1 << 21))) {
1531 trace_lsi_execute_script_tc_compc(s
->carry
== jmp
);
1532 cond
= s
->carry
!= 0;
1534 if (cond
== jmp
&& (insn
& (1 << 17))) {
1535 trace_lsi_execute_script_tc_compp(scsi_phase_name(s
->sstat1
),
1536 jmp
? '=' : '!', scsi_phase_name(insn
>> 24));
1537 cond
= (s
->sstat1
& PHASE_MASK
) == ((insn
>> 24) & 7);
1539 if (cond
== jmp
&& (insn
& (1 << 18))) {
1542 mask
= (~insn
>> 8) & 0xff;
1543 trace_lsi_execute_script_tc_compd(
1544 s
->sfbr
, mask
, jmp
? '=' : '!', insn
& mask
);
1545 cond
= (s
->sfbr
& mask
) == (insn
& mask
);
1548 if (insn
& (1 << 23)) {
1549 /* Relative address. */
1550 addr
= s
->dsp
+ sextract32(addr
, 0, 24);
1552 switch ((insn
>> 27) & 7) {
1554 trace_lsi_execute_script_tc_jump(addr
);
1559 trace_lsi_execute_script_tc_call(addr
);
1563 case 2: /* Return */
1564 trace_lsi_execute_script_tc_return(s
->temp
);
1567 case 3: /* Interrupt */
1568 trace_lsi_execute_script_tc_interrupt(s
->dsps
);
1569 if ((insn
& (1 << 20)) != 0) {
1570 s
->istat0
|= LSI_ISTAT0_INTF
;
1573 lsi_script_dma_interrupt(s
, LSI_DSTAT_SIR
);
1577 trace_lsi_execute_script_tc_illegal();
1578 lsi_script_dma_interrupt(s
, LSI_DSTAT_IID
);
1582 trace_lsi_execute_script_tc_cc_failed();
1588 if ((insn
& (1 << 29)) == 0) {
1591 /* ??? The docs imply the destination address is loaded into
1592 the TEMP register. However the Linux drivers rely on
1593 the value being presrved. */
1594 dest
= read_dword(s
, s
->dsp
);
1596 lsi_memcpy(s
, dest
, addr
, insn
& 0xffffff);
1603 if (insn
& (1 << 28)) {
1604 addr
= s
->dsa
+ sextract32(addr
, 0, 24);
1607 reg
= (insn
>> 16) & 0xff;
1608 if (insn
& (1 << 24)) {
1609 pci_dma_read(pci_dev
, addr
, data
, n
);
1610 trace_lsi_execute_script_mm_load(reg
, n
, addr
, *(int *)data
);
1611 for (i
= 0; i
< n
; i
++) {
1612 lsi_reg_writeb(s
, reg
+ i
, data
[i
]);
1615 trace_lsi_execute_script_mm_store(reg
, n
, addr
);
1616 for (i
= 0; i
< n
; i
++) {
1617 data
[i
] = lsi_reg_readb(s
, reg
+ i
);
1619 pci_dma_write(pci_dev
, addr
, data
, n
);
1623 if (s
->istat1
& LSI_ISTAT1_SRUN
&& s
->waiting
== LSI_NOWAIT
) {
1624 if (s
->dcntl
& LSI_DCNTL_SSM
) {
1625 lsi_script_dma_interrupt(s
, LSI_DSTAT_SSI
);
1630 trace_lsi_execute_script_stop();
1635 static uint8_t lsi_reg_readb(LSIState
*s
, int offset
)
1639 #define CASE_GET_REG24(name, addr) \
1640 case addr: ret = s->name & 0xff; break; \
1641 case addr + 1: ret = (s->name >> 8) & 0xff; break; \
1642 case addr + 2: ret = (s->name >> 16) & 0xff; break;
1644 #define CASE_GET_REG32(name, addr) \
1645 case addr: ret = s->name & 0xff; break; \
1646 case addr + 1: ret = (s->name >> 8) & 0xff; break; \
1647 case addr + 2: ret = (s->name >> 16) & 0xff; break; \
1648 case addr + 3: ret = (s->name >> 24) & 0xff; break;
1651 case 0x00: /* SCNTL0 */
1654 case 0x01: /* SCNTL1 */
1657 case 0x02: /* SCNTL2 */
1660 case 0x03: /* SCNTL3 */
1663 case 0x04: /* SCID */
1666 case 0x05: /* SXFER */
1669 case 0x06: /* SDID */
1672 case 0x07: /* GPREG0 */
1675 case 0x08: /* Revision ID */
1678 case 0x09: /* SOCL */
1681 case 0xa: /* SSID */
1684 case 0xb: /* SBCL */
1687 case 0xc: /* DSTAT */
1688 ret
= s
->dstat
| LSI_DSTAT_DFE
;
1689 if ((s
->istat0
& LSI_ISTAT0_INTF
) == 0)
1693 case 0x0d: /* SSTAT0 */
1696 case 0x0e: /* SSTAT1 */
1699 case 0x0f: /* SSTAT2 */
1700 ret
= s
->scntl1
& LSI_SCNTL1_CON
? 0 : 2;
1702 CASE_GET_REG32(dsa
, 0x10)
1703 case 0x14: /* ISTAT0 */
1706 case 0x15: /* ISTAT1 */
1709 case 0x16: /* MBOX0 */
1712 case 0x17: /* MBOX1 */
1715 case 0x18: /* CTEST0 */
1718 case 0x19: /* CTEST1 */
1721 case 0x1a: /* CTEST2 */
1722 ret
= s
->ctest2
| LSI_CTEST2_DACK
| LSI_CTEST2_CM
;
1723 if (s
->istat0
& LSI_ISTAT0_SIGP
) {
1724 s
->istat0
&= ~LSI_ISTAT0_SIGP
;
1725 ret
|= LSI_CTEST2_SIGP
;
1728 case 0x1b: /* CTEST3 */
1731 CASE_GET_REG32(temp
, 0x1c)
1732 case 0x20: /* DFIFO */
1735 case 0x21: /* CTEST4 */
1738 case 0x22: /* CTEST5 */
1741 case 0x23: /* CTEST6 */
1744 CASE_GET_REG24(dbc
, 0x24)
1745 case 0x27: /* DCMD */
1748 CASE_GET_REG32(dnad
, 0x28)
1749 CASE_GET_REG32(dsp
, 0x2c)
1750 CASE_GET_REG32(dsps
, 0x30)
1751 CASE_GET_REG32(scratch
[0], 0x34)
1752 case 0x38: /* DMODE */
1755 case 0x39: /* DIEN */
1758 case 0x3a: /* SBR */
1761 case 0x3b: /* DCNTL */
1764 /* ADDER Output (Debug of relative jump address) */
1765 CASE_GET_REG32(adder
, 0x3c)
1766 case 0x40: /* SIEN0 */
1769 case 0x41: /* SIEN1 */
1772 case 0x42: /* SIST0 */
1777 case 0x43: /* SIST1 */
1782 case 0x46: /* MACNTL */
1785 case 0x47: /* GPCNTL0 */
1788 case 0x48: /* STIME0 */
1791 case 0x4a: /* RESPID0 */
1794 case 0x4b: /* RESPID1 */
1797 case 0x4d: /* STEST1 */
1800 case 0x4e: /* STEST2 */
1803 case 0x4f: /* STEST3 */
1806 case 0x50: /* SIDL */
1807 /* This is needed by the linux drivers. We currently only update it
1808 during the MSG IN phase. */
1811 case 0x52: /* STEST4 */
1814 case 0x56: /* CCNTL0 */
1817 case 0x57: /* CCNTL1 */
1820 case 0x58: /* SBDL */
1821 /* Some drivers peek at the data bus during the MSG IN phase. */
1822 if ((s
->sstat1
& PHASE_MASK
) == PHASE_MI
) {
1823 assert(s
->msg_len
> 0);
1828 case 0x59: /* SBDL high */
1831 CASE_GET_REG32(mmrs
, 0xa0)
1832 CASE_GET_REG32(mmws
, 0xa4)
1833 CASE_GET_REG32(sfs
, 0xa8)
1834 CASE_GET_REG32(drs
, 0xac)
1835 CASE_GET_REG32(sbms
, 0xb0)
1836 CASE_GET_REG32(dbms
, 0xb4)
1837 CASE_GET_REG32(dnad64
, 0xb8)
1838 CASE_GET_REG32(pmjad1
, 0xc0)
1839 CASE_GET_REG32(pmjad2
, 0xc4)
1840 CASE_GET_REG32(rbc
, 0xc8)
1841 CASE_GET_REG32(ua
, 0xcc)
1842 CASE_GET_REG32(ia
, 0xd4)
1843 CASE_GET_REG32(sbc
, 0xd8)
1844 CASE_GET_REG32(csbc
, 0xdc)
1849 n
= (offset
- 0x58) >> 2;
1850 shift
= (offset
& 3) * 8;
1851 ret
= (s
->scratch
[n
] >> shift
) & 0xff;
1856 qemu_log_mask(LOG_GUEST_ERROR
,
1857 "lsi_scsi: invalid read from reg %s %x\n",
1858 offset
< ARRAY_SIZE(names
) ? names
[offset
] : "???",
1864 #undef CASE_GET_REG24
1865 #undef CASE_GET_REG32
1867 trace_lsi_reg_read(offset
< ARRAY_SIZE(names
) ? names
[offset
] : "???",
1873 static void lsi_reg_writeb(LSIState
*s
, int offset
, uint8_t val
)
1875 #define CASE_SET_REG24(name, addr) \
1876 case addr : s->name &= 0xffffff00; s->name |= val; break; \
1877 case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \
1878 case addr + 2: s->name &= 0xff00ffff; s->name |= val << 16; break;
1880 #define CASE_SET_REG32(name, addr) \
1881 case addr : s->name &= 0xffffff00; s->name |= val; break; \
1882 case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \
1883 case addr + 2: s->name &= 0xff00ffff; s->name |= val << 16; break; \
1884 case addr + 3: s->name &= 0x00ffffff; s->name |= val << 24; break;
1886 trace_lsi_reg_write(offset
< ARRAY_SIZE(names
) ? names
[offset
] : "???",
1890 case 0x00: /* SCNTL0 */
1892 if (val
& LSI_SCNTL0_START
) {
1893 qemu_log_mask(LOG_UNIMP
,
1894 "lsi_scsi: Start sequence not implemented\n");
1897 case 0x01: /* SCNTL1 */
1898 s
->scntl1
= val
& ~LSI_SCNTL1_SST
;
1899 if (val
& LSI_SCNTL1_IARB
) {
1900 qemu_log_mask(LOG_UNIMP
,
1901 "lsi_scsi: Immediate Arbritration not implemented\n");
1903 if (val
& LSI_SCNTL1_RST
) {
1904 if (!(s
->sstat0
& LSI_SSTAT0_RST
)) {
1905 bus_cold_reset(BUS(&s
->bus
));
1906 s
->sstat0
|= LSI_SSTAT0_RST
;
1907 lsi_script_scsi_interrupt(s
, LSI_SIST0_RST
, 0);
1910 s
->sstat0
&= ~LSI_SSTAT0_RST
;
1913 case 0x02: /* SCNTL2 */
1914 val
&= ~(LSI_SCNTL2_WSR
| LSI_SCNTL2_WSS
);
1917 case 0x03: /* SCNTL3 */
1920 case 0x04: /* SCID */
1923 case 0x05: /* SXFER */
1926 case 0x06: /* SDID */
1927 if ((s
->ssid
& 0x80) && (val
& 0xf) != (s
->ssid
& 0xf)) {
1928 qemu_log_mask(LOG_GUEST_ERROR
,
1929 "lsi_scsi: Destination ID does not match SSID\n");
1931 s
->sdid
= val
& 0xf;
1933 case 0x07: /* GPREG0 */
1935 case 0x08: /* SFBR */
1936 /* The CPU is not allowed to write to this register. However the
1937 SCRIPTS register move instructions are. */
1940 case 0x0a: case 0x0b:
1941 /* Openserver writes to these readonly registers on startup */
1943 case 0x0c: case 0x0d: case 0x0e: case 0x0f:
1944 /* Linux writes to these readonly registers on startup. */
1946 CASE_SET_REG32(dsa
, 0x10)
1947 case 0x14: /* ISTAT0 */
1948 s
->istat0
= (s
->istat0
& 0x0f) | (val
& 0xf0);
1949 if (val
& LSI_ISTAT0_ABRT
) {
1950 lsi_script_dma_interrupt(s
, LSI_DSTAT_ABRT
);
1952 if (val
& LSI_ISTAT0_INTF
) {
1953 s
->istat0
&= ~LSI_ISTAT0_INTF
;
1956 if (s
->waiting
== LSI_WAIT_RESELECT
&& val
& LSI_ISTAT0_SIGP
) {
1958 s
->waiting
= LSI_NOWAIT
;
1960 lsi_execute_script(s
);
1962 if (val
& LSI_ISTAT0_SRST
) {
1963 device_cold_reset(DEVICE(s
));
1966 case 0x16: /* MBOX0 */
1969 case 0x17: /* MBOX1 */
1972 case 0x18: /* CTEST0 */
1975 case 0x1a: /* CTEST2 */
1976 s
->ctest2
= val
& LSI_CTEST2_PCICIE
;
1978 case 0x1b: /* CTEST3 */
1979 s
->ctest3
= val
& 0x0f;
1981 CASE_SET_REG32(temp
, 0x1c)
1982 case 0x21: /* CTEST4 */
1984 qemu_log_mask(LOG_UNIMP
,
1985 "lsi_scsi: Unimplemented CTEST4-FBL 0x%x\n", val
);
1989 case 0x22: /* CTEST5 */
1990 if (val
& (LSI_CTEST5_ADCK
| LSI_CTEST5_BBCK
)) {
1991 qemu_log_mask(LOG_UNIMP
,
1992 "lsi_scsi: CTEST5 DMA increment not implemented\n");
1996 CASE_SET_REG24(dbc
, 0x24)
1997 CASE_SET_REG32(dnad
, 0x28)
1998 case 0x2c: /* DSP[0:7] */
1999 s
->dsp
&= 0xffffff00;
2002 case 0x2d: /* DSP[8:15] */
2003 s
->dsp
&= 0xffff00ff;
2006 case 0x2e: /* DSP[16:23] */
2007 s
->dsp
&= 0xff00ffff;
2008 s
->dsp
|= val
<< 16;
2010 case 0x2f: /* DSP[24:31] */
2011 s
->dsp
&= 0x00ffffff;
2012 s
->dsp
|= val
<< 24;
2014 * FIXME: if s->waiting != LSI_NOWAIT, this will only execute one
2015 * instruction. Is this correct?
2017 if ((s
->dmode
& LSI_DMODE_MAN
) == 0
2018 && (s
->istat1
& LSI_ISTAT1_SRUN
) == 0)
2019 lsi_execute_script(s
);
2021 CASE_SET_REG32(dsps
, 0x30)
2022 CASE_SET_REG32(scratch
[0], 0x34)
2023 case 0x38: /* DMODE */
2026 case 0x39: /* DIEN */
2030 case 0x3a: /* SBR */
2033 case 0x3b: /* DCNTL */
2034 s
->dcntl
= val
& ~(LSI_DCNTL_PFF
| LSI_DCNTL_STD
);
2036 * FIXME: if s->waiting != LSI_NOWAIT, this will only execute one
2037 * instruction. Is this correct?
2039 if ((val
& LSI_DCNTL_STD
) && (s
->istat1
& LSI_ISTAT1_SRUN
) == 0)
2040 lsi_execute_script(s
);
2042 case 0x40: /* SIEN0 */
2046 case 0x41: /* SIEN1 */
2050 case 0x47: /* GPCNTL0 */
2052 case 0x48: /* STIME0 */
2055 case 0x49: /* STIME1 */
2057 qemu_log_mask(LOG_UNIMP
,
2058 "lsi_scsi: General purpose timer not implemented\n");
2059 /* ??? Raising the interrupt immediately seems to be sufficient
2060 to keep the FreeBSD driver happy. */
2061 lsi_script_scsi_interrupt(s
, 0, LSI_SIST1_GEN
);
2064 case 0x4a: /* RESPID0 */
2067 case 0x4b: /* RESPID1 */
2070 case 0x4d: /* STEST1 */
2073 case 0x4e: /* STEST2 */
2075 qemu_log_mask(LOG_UNIMP
,
2076 "lsi_scsi: Low level mode not implemented\n");
2080 case 0x4f: /* STEST3 */
2082 qemu_log_mask(LOG_UNIMP
,
2083 "lsi_scsi: SCSI FIFO test mode not implemented\n");
2087 case 0x56: /* CCNTL0 */
2090 case 0x57: /* CCNTL1 */
2093 CASE_SET_REG32(mmrs
, 0xa0)
2094 CASE_SET_REG32(mmws
, 0xa4)
2095 CASE_SET_REG32(sfs
, 0xa8)
2096 CASE_SET_REG32(drs
, 0xac)
2097 CASE_SET_REG32(sbms
, 0xb0)
2098 CASE_SET_REG32(dbms
, 0xb4)
2099 CASE_SET_REG32(dnad64
, 0xb8)
2100 CASE_SET_REG32(pmjad1
, 0xc0)
2101 CASE_SET_REG32(pmjad2
, 0xc4)
2102 CASE_SET_REG32(rbc
, 0xc8)
2103 CASE_SET_REG32(ua
, 0xcc)
2104 CASE_SET_REG32(ia
, 0xd4)
2105 CASE_SET_REG32(sbc
, 0xd8)
2106 CASE_SET_REG32(csbc
, 0xdc)
2108 if (offset
>= 0x5c && offset
< 0xa0) {
2111 n
= (offset
- 0x58) >> 2;
2112 shift
= (offset
& 3) * 8;
2113 s
->scratch
[n
] = deposit32(s
->scratch
[n
], shift
, 8, val
);
2115 qemu_log_mask(LOG_GUEST_ERROR
,
2116 "lsi_scsi: invalid write to reg %s %x (0x%02x)\n",
2117 offset
< ARRAY_SIZE(names
) ? names
[offset
] : "???",
2121 #undef CASE_SET_REG24
2122 #undef CASE_SET_REG32
2125 static void lsi_mmio_write(void *opaque
, hwaddr addr
,
2126 uint64_t val
, unsigned size
)
2128 LSIState
*s
= opaque
;
2130 lsi_reg_writeb(s
, addr
& 0xff, val
);
2133 static uint64_t lsi_mmio_read(void *opaque
, hwaddr addr
,
2136 LSIState
*s
= opaque
;
2137 return lsi_reg_readb(s
, addr
& 0xff);
2140 static const MemoryRegionOps lsi_mmio_ops
= {
2141 .read
= lsi_mmio_read
,
2142 .write
= lsi_mmio_write
,
2143 .endianness
= DEVICE_LITTLE_ENDIAN
,
2145 .min_access_size
= 1,
2146 .max_access_size
= 1,
2150 static void lsi_ram_write(void *opaque
, hwaddr addr
,
2151 uint64_t val
, unsigned size
)
2153 LSIState
*s
= opaque
;
2154 stn_le_p(s
->script_ram
+ addr
, size
, val
);
2157 static uint64_t lsi_ram_read(void *opaque
, hwaddr addr
,
2160 LSIState
*s
= opaque
;
2161 return ldn_le_p(s
->script_ram
+ addr
, size
);
2164 static const MemoryRegionOps lsi_ram_ops
= {
2165 .read
= lsi_ram_read
,
2166 .write
= lsi_ram_write
,
2167 .endianness
= DEVICE_LITTLE_ENDIAN
,
2170 static uint64_t lsi_io_read(void *opaque
, hwaddr addr
,
2173 LSIState
*s
= opaque
;
2174 return lsi_reg_readb(s
, addr
& 0xff);
2177 static void lsi_io_write(void *opaque
, hwaddr addr
,
2178 uint64_t val
, unsigned size
)
2180 LSIState
*s
= opaque
;
2181 lsi_reg_writeb(s
, addr
& 0xff, val
);
2184 static const MemoryRegionOps lsi_io_ops
= {
2185 .read
= lsi_io_read
,
2186 .write
= lsi_io_write
,
2187 .endianness
= DEVICE_LITTLE_ENDIAN
,
2189 .min_access_size
= 1,
2190 .max_access_size
= 1,
2194 static void lsi_scsi_reset(DeviceState
*dev
)
2196 LSIState
*s
= LSI53C895A(dev
);
2201 static int lsi_pre_save(void *opaque
)
2203 LSIState
*s
= opaque
;
2206 assert(s
->current
->dma_buf
== NULL
);
2207 assert(s
->current
->dma_len
== 0);
2209 assert(QTAILQ_EMPTY(&s
->queue
));
2214 static int lsi_post_load(void *opaque
, int version_id
)
2216 LSIState
*s
= opaque
;
2218 if (s
->msg_len
< 0 || s
->msg_len
> LSI_MAX_MSGIN_LEN
) {
2222 if (s
->waiting
== LSI_WAIT_SCRIPTS
) {
2223 lsi_scripts_timer_start(s
);
2228 static const VMStateDescription vmstate_lsi_scsi
= {
2231 .minimum_version_id
= 0,
2232 .pre_save
= lsi_pre_save
,
2233 .post_load
= lsi_post_load
,
2234 .fields
= (const VMStateField
[]) {
2235 VMSTATE_PCI_DEVICE(parent_obj
, LSIState
),
2237 VMSTATE_INT32(carry
, LSIState
),
2238 VMSTATE_INT32(status
, LSIState
),
2239 VMSTATE_INT32(msg_action
, LSIState
),
2240 VMSTATE_INT32(msg_len
, LSIState
),
2241 VMSTATE_BUFFER(msg
, LSIState
),
2242 VMSTATE_INT32(waiting
, LSIState
),
2244 VMSTATE_UINT32(dsa
, LSIState
),
2245 VMSTATE_UINT32(temp
, LSIState
),
2246 VMSTATE_UINT32(dnad
, LSIState
),
2247 VMSTATE_UINT32(dbc
, LSIState
),
2248 VMSTATE_UINT8(istat0
, LSIState
),
2249 VMSTATE_UINT8(istat1
, LSIState
),
2250 VMSTATE_UINT8(dcmd
, LSIState
),
2251 VMSTATE_UINT8(dstat
, LSIState
),
2252 VMSTATE_UINT8(dien
, LSIState
),
2253 VMSTATE_UINT8(sist0
, LSIState
),
2254 VMSTATE_UINT8(sist1
, LSIState
),
2255 VMSTATE_UINT8(sien0
, LSIState
),
2256 VMSTATE_UINT8(sien1
, LSIState
),
2257 VMSTATE_UINT8(mbox0
, LSIState
),
2258 VMSTATE_UINT8(mbox1
, LSIState
),
2259 VMSTATE_UINT8(dfifo
, LSIState
),
2260 VMSTATE_UINT8(ctest2
, LSIState
),
2261 VMSTATE_UINT8(ctest3
, LSIState
),
2262 VMSTATE_UINT8(ctest4
, LSIState
),
2263 VMSTATE_UINT8(ctest5
, LSIState
),
2264 VMSTATE_UINT8(ccntl0
, LSIState
),
2265 VMSTATE_UINT8(ccntl1
, LSIState
),
2266 VMSTATE_UINT32(dsp
, LSIState
),
2267 VMSTATE_UINT32(dsps
, LSIState
),
2268 VMSTATE_UINT8(dmode
, LSIState
),
2269 VMSTATE_UINT8(dcntl
, LSIState
),
2270 VMSTATE_UINT8(scntl0
, LSIState
),
2271 VMSTATE_UINT8(scntl1
, LSIState
),
2272 VMSTATE_UINT8(scntl2
, LSIState
),
2273 VMSTATE_UINT8(scntl3
, LSIState
),
2274 VMSTATE_UINT8(sstat0
, LSIState
),
2275 VMSTATE_UINT8(sstat1
, LSIState
),
2276 VMSTATE_UINT8(scid
, LSIState
),
2277 VMSTATE_UINT8(sxfer
, LSIState
),
2278 VMSTATE_UINT8(socl
, LSIState
),
2279 VMSTATE_UINT8(sdid
, LSIState
),
2280 VMSTATE_UINT8(ssid
, LSIState
),
2281 VMSTATE_UINT8(sfbr
, LSIState
),
2282 VMSTATE_UINT8(stest1
, LSIState
),
2283 VMSTATE_UINT8(stest2
, LSIState
),
2284 VMSTATE_UINT8(stest3
, LSIState
),
2285 VMSTATE_UINT8(sidl
, LSIState
),
2286 VMSTATE_UINT8(stime0
, LSIState
),
2287 VMSTATE_UINT8(respid0
, LSIState
),
2288 VMSTATE_UINT8(respid1
, LSIState
),
2289 VMSTATE_UINT8_V(sbcl
, LSIState
, 1),
2290 VMSTATE_UINT32(mmrs
, LSIState
),
2291 VMSTATE_UINT32(mmws
, LSIState
),
2292 VMSTATE_UINT32(sfs
, LSIState
),
2293 VMSTATE_UINT32(drs
, LSIState
),
2294 VMSTATE_UINT32(sbms
, LSIState
),
2295 VMSTATE_UINT32(dbms
, LSIState
),
2296 VMSTATE_UINT32(dnad64
, LSIState
),
2297 VMSTATE_UINT32(pmjad1
, LSIState
),
2298 VMSTATE_UINT32(pmjad2
, LSIState
),
2299 VMSTATE_UINT32(rbc
, LSIState
),
2300 VMSTATE_UINT32(ua
, LSIState
),
2301 VMSTATE_UINT32(ia
, LSIState
),
2302 VMSTATE_UINT32(sbc
, LSIState
),
2303 VMSTATE_UINT32(csbc
, LSIState
),
2304 VMSTATE_BUFFER_UNSAFE(scratch
, LSIState
, 0, 18 * sizeof(uint32_t)),
2305 VMSTATE_UINT8(sbr
, LSIState
),
2307 VMSTATE_BUFFER_UNSAFE(script_ram
, LSIState
, 0, 8192),
2308 VMSTATE_END_OF_LIST()
2312 static const struct SCSIBusInfo lsi_scsi_info
= {
2314 .max_target
= LSI_MAX_DEVS
,
2315 .max_lun
= 0, /* LUN support is buggy */
2317 .transfer_data
= lsi_transfer_data
,
2318 .complete
= lsi_command_complete
,
2319 .cancel
= lsi_request_cancelled
2322 static void scripts_timer_cb(void *opaque
)
2324 LSIState
*s
= opaque
;
2326 trace_lsi_scripts_timer_triggered();
2327 s
->waiting
= LSI_NOWAIT
;
2328 lsi_execute_script(s
);
2331 static void lsi_scsi_realize(PCIDevice
*dev
, Error
**errp
)
2333 LSIState
*s
= LSI53C895A(dev
);
2334 DeviceState
*d
= DEVICE(dev
);
2337 pci_conf
= dev
->config
;
2339 /* PCI latency timer = 255 */
2340 pci_conf
[PCI_LATENCY_TIMER
] = 0xff;
2341 /* Interrupt pin A */
2342 pci_conf
[PCI_INTERRUPT_PIN
] = 0x01;
2344 memory_region_init_io(&s
->mmio_io
, OBJECT(s
), &lsi_mmio_ops
, s
,
2346 memory_region_init_io(&s
->ram_io
, OBJECT(s
), &lsi_ram_ops
, s
,
2348 memory_region_init_io(&s
->io_io
, OBJECT(s
), &lsi_io_ops
, s
,
2350 s
->scripts_timer
= timer_new_us(QEMU_CLOCK_VIRTUAL
, scripts_timer_cb
, s
);
2353 * Since we use the address-space API to interact with ram_io, disable the
2354 * re-entrancy guard.
2356 s
->ram_io
.disable_reentrancy_guard
= true;
2357 s
->mmio_io
.disable_reentrancy_guard
= true;
2359 address_space_init(&s
->pci_io_as
, pci_address_space_io(dev
), "lsi-pci-io");
2360 qdev_init_gpio_out(d
, &s
->ext_irq
, 1);
2362 pci_register_bar(dev
, 0, PCI_BASE_ADDRESS_SPACE_IO
, &s
->io_io
);
2363 pci_register_bar(dev
, 1, PCI_BASE_ADDRESS_SPACE_MEMORY
, &s
->mmio_io
);
2364 pci_register_bar(dev
, 2, PCI_BASE_ADDRESS_SPACE_MEMORY
, &s
->ram_io
);
2365 QTAILQ_INIT(&s
->queue
);
2367 scsi_bus_init(&s
->bus
, sizeof(s
->bus
), d
, &lsi_scsi_info
);
2370 static void lsi_scsi_exit(PCIDevice
*dev
)
2372 LSIState
*s
= LSI53C895A(dev
);
2374 address_space_destroy(&s
->pci_io_as
);
2375 timer_del(s
->scripts_timer
);
2378 static void lsi_class_init(ObjectClass
*klass
, void *data
)
2380 DeviceClass
*dc
= DEVICE_CLASS(klass
);
2381 PCIDeviceClass
*k
= PCI_DEVICE_CLASS(klass
);
2383 k
->realize
= lsi_scsi_realize
;
2384 k
->exit
= lsi_scsi_exit
;
2385 k
->vendor_id
= PCI_VENDOR_ID_LSI_LOGIC
;
2386 k
->device_id
= PCI_DEVICE_ID_LSI_53C895A
;
2387 k
->class_id
= PCI_CLASS_STORAGE_SCSI
;
2388 k
->subsystem_id
= 0x1000;
2389 dc
->reset
= lsi_scsi_reset
;
2390 dc
->vmsd
= &vmstate_lsi_scsi
;
2391 set_bit(DEVICE_CATEGORY_STORAGE
, dc
->categories
);
2394 static const TypeInfo lsi_info
= {
2395 .name
= TYPE_LSI53C895A
,
2396 .parent
= TYPE_PCI_DEVICE
,
2397 .instance_size
= sizeof(LSIState
),
2398 .class_init
= lsi_class_init
,
2399 .interfaces
= (InterfaceInfo
[]) {
2400 { INTERFACE_CONVENTIONAL_PCI_DEVICE
},
2405 static void lsi53c810_class_init(ObjectClass
*klass
, void *data
)
2407 PCIDeviceClass
*k
= PCI_DEVICE_CLASS(klass
);
2409 k
->device_id
= PCI_DEVICE_ID_LSI_53C810
;
2412 static const TypeInfo lsi53c810_info
= {
2413 .name
= TYPE_LSI53C810
,
2414 .parent
= TYPE_LSI53C895A
,
2415 .class_init
= lsi53c810_class_init
,
2418 static void lsi53c895a_register_types(void)
2420 type_register_static(&lsi_info
);
2421 type_register_static(&lsi53c810_info
);
2424 type_init(lsi53c895a_register_types
)
2426 void lsi53c8xx_handle_legacy_cmdline(DeviceState
*lsi_dev
)
2428 LSIState
*s
= LSI53C895A(lsi_dev
);
2430 scsi_bus_legacy_handle_cmdline(&s
->bus
);