Lines Matching full:s

332 static inline int lsi_irq_on_rsl(LSIState *s)  in lsi_irq_on_rsl()  argument
334 return (s->sien0 & LSI_SIST0_RSL) && (s->scid & LSI_SCID_RRE); in lsi_irq_on_rsl()
337 static lsi_request *get_pending_req(LSIState *s) in get_pending_req() argument
341 QTAILQ_FOREACH(p, &s->queue, next) { in get_pending_req()
349 static void lsi_soft_reset(LSIState *s) in lsi_soft_reset() argument
352 s->carry = 0; in lsi_soft_reset()
354 s->msg_action = LSI_MSG_ACTION_COMMAND; in lsi_soft_reset()
355 s->msg_len = 0; in lsi_soft_reset()
356 s->waiting = LSI_NOWAIT; in lsi_soft_reset()
357 s->dsa = 0; in lsi_soft_reset()
358 s->dnad = 0; in lsi_soft_reset()
359 s->dbc = 0; in lsi_soft_reset()
360 s->temp = 0; in lsi_soft_reset()
361 memset(s->scratch, 0, sizeof(s->scratch)); in lsi_soft_reset()
362 s->istat0 = 0; in lsi_soft_reset()
363 s->istat1 = 0; in lsi_soft_reset()
364 s->dcmd = 0x40; in lsi_soft_reset()
365 s->dstat = 0; in lsi_soft_reset()
366 s->dien = 0; in lsi_soft_reset()
367 s->sist0 = 0; in lsi_soft_reset()
368 s->sist1 = 0; in lsi_soft_reset()
369 s->sien0 = 0; in lsi_soft_reset()
370 s->sien1 = 0; in lsi_soft_reset()
371 s->mbox0 = 0; in lsi_soft_reset()
372 s->mbox1 = 0; in lsi_soft_reset()
373 s->dfifo = 0; in lsi_soft_reset()
374 s->ctest2 = LSI_CTEST2_DACK; in lsi_soft_reset()
375 s->ctest3 = 0; in lsi_soft_reset()
376 s->ctest4 = 0; in lsi_soft_reset()
377 s->ctest5 = 0; in lsi_soft_reset()
378 s->ccntl0 = 0; in lsi_soft_reset()
379 s->ccntl1 = 0; in lsi_soft_reset()
380 s->dsp = 0; in lsi_soft_reset()
381 s->dsps = 0; in lsi_soft_reset()
382 s->dmode = 0; in lsi_soft_reset()
383 s->dcntl = 0; in lsi_soft_reset()
384 s->scntl0 = 0xc0; in lsi_soft_reset()
385 s->scntl1 = 0; in lsi_soft_reset()
386 s->scntl2 = 0; in lsi_soft_reset()
387 s->scntl3 = 0; in lsi_soft_reset()
388 s->sstat0 = 0; in lsi_soft_reset()
389 s->sstat1 = 0; in lsi_soft_reset()
390 s->scid = 7; in lsi_soft_reset()
391 s->sxfer = 0; in lsi_soft_reset()
392 s->socl = 0; in lsi_soft_reset()
393 s->sdid = 0; in lsi_soft_reset()
394 s->ssid = 0; in lsi_soft_reset()
395 s->sbcl = 0; in lsi_soft_reset()
396 s->stest1 = 0; in lsi_soft_reset()
397 s->stest2 = 0; in lsi_soft_reset()
398 s->stest3 = 0; in lsi_soft_reset()
399 s->sidl = 0; in lsi_soft_reset()
400 s->stime0 = 0; in lsi_soft_reset()
401 s->respid0 = 0x80; in lsi_soft_reset()
402 s->respid1 = 0; in lsi_soft_reset()
403 s->mmrs = 0; in lsi_soft_reset()
404 s->mmws = 0; in lsi_soft_reset()
405 s->sfs = 0; in lsi_soft_reset()
406 s->drs = 0; in lsi_soft_reset()
407 s->sbms = 0; in lsi_soft_reset()
408 s->dbms = 0; in lsi_soft_reset()
409 s->dnad64 = 0; in lsi_soft_reset()
410 s->pmjad1 = 0; in lsi_soft_reset()
411 s->pmjad2 = 0; in lsi_soft_reset()
412 s->rbc = 0; in lsi_soft_reset()
413 s->ua = 0; in lsi_soft_reset()
414 s->ia = 0; in lsi_soft_reset()
415 s->sbc = 0; in lsi_soft_reset()
416 s->csbc = 0; in lsi_soft_reset()
417 s->sbr = 0; in lsi_soft_reset()
418 assert(QTAILQ_EMPTY(&s->queue)); in lsi_soft_reset()
419 assert(!s->current); in lsi_soft_reset()
420 timer_del(s->scripts_timer); in lsi_soft_reset()
423 static int lsi_dma_40bit(LSIState *s) in lsi_dma_40bit() argument
425 if ((s->ccntl1 & LSI_CCNTL1_40BIT) == LSI_CCNTL1_40BIT) in lsi_dma_40bit()
430 static int lsi_dma_ti64bit(LSIState *s) in lsi_dma_ti64bit() argument
432 if ((s->ccntl1 & LSI_CCNTL1_EN64TIBMV) == LSI_CCNTL1_EN64TIBMV) in lsi_dma_ti64bit()
437 static int lsi_dma_64bit(LSIState *s) in lsi_dma_64bit() argument
439 if ((s->ccntl1 & LSI_CCNTL1_EN64DBMV) == LSI_CCNTL1_EN64DBMV) in lsi_dma_64bit()
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, in lsi_mem_read() argument
452 if (s->dmode & LSI_DMODE_SIOM) { in lsi_mem_read()
453 address_space_read(&s->pci_io_as, addr, MEMTXATTRS_UNSPECIFIED, in lsi_mem_read()
456 pci_dma_read(PCI_DEVICE(s), addr, buf, len); in lsi_mem_read()
460 static inline void lsi_mem_write(LSIState *s, dma_addr_t addr, in lsi_mem_write() argument
463 if (s->dmode & LSI_DMODE_DIOM) { in lsi_mem_write()
464 address_space_write(&s->pci_io_as, addr, MEMTXATTRS_UNSPECIFIED, in lsi_mem_write()
467 pci_dma_write(PCI_DEVICE(s), addr, buf, len); in lsi_mem_write()
471 static inline uint32_t read_dword(LSIState *s, uint32_t addr) in read_dword() argument
475 pci_dma_read(PCI_DEVICE(s), addr, &buf, 4); in read_dword()
479 static void lsi_stop_script(LSIState *s) in lsi_stop_script() argument
481 s->istat1 &= ~LSI_ISTAT1_SRUN; in lsi_stop_script()
484 static void lsi_set_irq(LSIState *s, int level) in lsi_set_irq() argument
486 PCIDevice *d = PCI_DEVICE(s); in lsi_set_irq()
488 if (s->ext_irq) { in lsi_set_irq()
489 qemu_set_irq(s->ext_irq, level); in lsi_set_irq()
495 static void lsi_update_irq(LSIState *s) in lsi_update_irq() argument
500 /* It's unclear whether the DIP/SIP bits should be cleared when the in lsi_update_irq()
504 if (s->dstat) { in lsi_update_irq()
505 if (s->dstat & s->dien) in lsi_update_irq()
507 s->istat0 |= LSI_ISTAT0_DIP; in lsi_update_irq()
509 s->istat0 &= ~LSI_ISTAT0_DIP; in lsi_update_irq()
512 if (s->sist0 || s->sist1) { in lsi_update_irq()
513 if ((s->sist0 & s->sien0) || (s->sist1 & s->sien1)) in lsi_update_irq()
515 s->istat0 |= LSI_ISTAT0_SIP; in lsi_update_irq()
517 s->istat0 &= ~LSI_ISTAT0_SIP; in lsi_update_irq()
519 if (s->istat0 & LSI_ISTAT0_INTF) in lsi_update_irq()
523 trace_lsi_update_irq(level, s->dstat, s->sist1, s->sist0); in lsi_update_irq()
526 lsi_set_irq(s, level); in lsi_update_irq()
528 if (!s->current && !level && lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON)) { in lsi_update_irq()
532 p = get_pending_req(s); in lsi_update_irq()
534 lsi_reselect(s, p); in lsi_update_irq()
540 static void lsi_script_scsi_interrupt(LSIState *s, int stat0, int stat1) in lsi_script_scsi_interrupt() argument
545 trace_lsi_script_scsi_interrupt(stat1, stat0, s->sist1, s->sist0); in lsi_script_scsi_interrupt()
546 s->sist0 |= stat0; in lsi_script_scsi_interrupt()
547 s->sist1 |= stat1; in lsi_script_scsi_interrupt()
551 mask0 = s->sien0 | ~(LSI_SIST0_CMP | LSI_SIST0_SEL | LSI_SIST0_RSL); in lsi_script_scsi_interrupt()
552 mask1 = s->sien1 | ~(LSI_SIST1_GEN | LSI_SIST1_HTH); in lsi_script_scsi_interrupt()
554 if (s->sist0 & mask0 || s->sist1 & mask1) { in lsi_script_scsi_interrupt()
555 lsi_stop_script(s); in lsi_script_scsi_interrupt()
557 lsi_update_irq(s); in lsi_script_scsi_interrupt()
561 static void lsi_script_dma_interrupt(LSIState *s, int stat) in lsi_script_dma_interrupt() argument
563 trace_lsi_script_dma_interrupt(stat, s->dstat); in lsi_script_dma_interrupt()
564 s->dstat |= stat; in lsi_script_dma_interrupt()
565 lsi_update_irq(s); in lsi_script_dma_interrupt()
566 lsi_stop_script(s); in lsi_script_dma_interrupt()
569 static inline void lsi_set_phase(LSIState *s, int phase) in lsi_set_phase() argument
571 s->sbcl &= ~PHASE_MASK; in lsi_set_phase()
572 s->sbcl |= phase | LSI_SBCL_REQ; in lsi_set_phase()
573 s->sstat1 = (s->sstat1 & ~PHASE_MASK) | phase; in lsi_set_phase()
576 static int lsi_bad_phase(LSIState *s, int out, int new_phase) in lsi_bad_phase() argument
580 if (s->ccntl0 & LSI_CCNTL0_ENPMJ) { in lsi_bad_phase()
581 if ((s->ccntl0 & LSI_CCNTL0_PMJCTL)) { in lsi_bad_phase()
582 s->dsp = out ? s->pmjad1 : s->pmjad2; in lsi_bad_phase()
584 s->dsp = (s->scntl2 & LSI_SCNTL2_WSR ? s->pmjad2 : s->pmjad1); in lsi_bad_phase()
586 trace_lsi_bad_phase_jump(s->dsp); in lsi_bad_phase()
589 lsi_script_scsi_interrupt(s, LSI_SIST0_MA, 0); in lsi_bad_phase()
590 lsi_stop_script(s); in lsi_bad_phase()
593 lsi_set_phase(s, new_phase); in lsi_bad_phase()
599 static void lsi_resume_script(LSIState *s) in lsi_resume_script() argument
601 if (s->waiting != 2) { in lsi_resume_script()
602 s->waiting = LSI_NOWAIT; in lsi_resume_script()
603 lsi_execute_script(s); in lsi_resume_script()
605 s->waiting = LSI_NOWAIT; in lsi_resume_script()
609 static void lsi_disconnect(LSIState *s) in lsi_disconnect() argument
611 s->scntl1 &= ~LSI_SCNTL1_CON; in lsi_disconnect()
612 s->sstat1 &= ~PHASE_MASK; in lsi_disconnect()
613 s->sbcl = 0; in lsi_disconnect()
616 static void lsi_bad_selection(LSIState *s, uint32_t id) in lsi_bad_selection() argument
619 lsi_script_scsi_interrupt(s, 0, LSI_SIST1_STO); in lsi_bad_selection()
620 lsi_disconnect(s); in lsi_bad_selection()
624 static void lsi_do_dma(LSIState *s, int out) in lsi_do_dma() argument
630 if (!s->current || !s->current->dma_len) { in lsi_do_dma()
636 dev = s->current->req->dev; in lsi_do_dma()
639 count = s->dbc; in lsi_do_dma()
640 if (count > s->current->dma_len) in lsi_do_dma()
641 count = s->current->dma_len; in lsi_do_dma()
643 addr = s->dnad; in lsi_do_dma()
645 if (lsi_dma_40bit(s) || lsi_dma_ti64bit(s)) in lsi_do_dma()
646 addr |= ((uint64_t)s->dnad64 << 32); in lsi_do_dma()
647 else if (s->dbms) in lsi_do_dma()
648 addr |= ((uint64_t)s->dbms << 32); in lsi_do_dma()
649 else if (s->sbms) in lsi_do_dma()
650 addr |= ((uint64_t)s->sbms << 32); in lsi_do_dma()
653 s->csbc += count; in lsi_do_dma()
654 s->dnad += count; in lsi_do_dma()
655 s->dbc -= count; in lsi_do_dma()
656 if (s->current->dma_buf == NULL) { in lsi_do_dma()
657 s->current->dma_buf = scsi_req_get_buf(s->current->req); in lsi_do_dma()
661 lsi_mem_read(s, addr, s->current->dma_buf, count); in lsi_do_dma()
663 lsi_mem_write(s, addr, s->current->dma_buf, count); in lsi_do_dma()
665 s->current->dma_len -= count; in lsi_do_dma()
666 if (s->current->dma_len == 0) { in lsi_do_dma()
667 s->current->dma_buf = NULL; in lsi_do_dma()
668 scsi_req_continue(s->current->req); in lsi_do_dma()
670 s->current->dma_buf += count; in lsi_do_dma()
671 lsi_resume_script(s); in lsi_do_dma()
677 static void lsi_queue_command(LSIState *s) in lsi_queue_command() argument
679 lsi_request *p = s->current; in lsi_queue_command()
682 assert(s->current != NULL); in lsi_queue_command()
683 assert(s->current->dma_len == 0); in lsi_queue_command()
684 QTAILQ_INSERT_TAIL(&s->queue, s->current, next); in lsi_queue_command()
685 s->current = NULL; in lsi_queue_command()
688 p->out = (s->sstat1 & PHASE_MASK) == PHASE_DO; in lsi_queue_command()
692 static void lsi_add_msg_byte(LSIState *s, uint8_t data) in lsi_add_msg_byte() argument
694 if (s->msg_len >= LSI_MAX_MSGIN_LEN) { in lsi_add_msg_byte()
698 s->msg[s->msg_len++] = data; in lsi_add_msg_byte()
703 static void lsi_reselect(LSIState *s, lsi_request *p) in lsi_reselect() argument
707 assert(s->current == NULL); in lsi_reselect()
708 QTAILQ_REMOVE(&s->queue, p, next); in lsi_reselect()
709 s->current = p; in lsi_reselect()
712 s->ssid = id | 0x80; in lsi_reselect()
714 if (!(s->dcntl & LSI_DCNTL_COM)) { in lsi_reselect()
715 s->sfbr = 1 << (id & 0x7); in lsi_reselect()
718 s->scntl1 |= LSI_SCNTL1_CON; in lsi_reselect()
719 lsi_set_phase(s, PHASE_MI); in lsi_reselect()
720 s->msg_action = p->out ? LSI_MSG_ACTION_DOUT : LSI_MSG_ACTION_DIN; in lsi_reselect()
721 s->current->dma_len = p->pending; in lsi_reselect()
722 lsi_add_msg_byte(s, 0x80); in lsi_reselect()
723 if (s->current->tag & LSI_TAG_VALID) { in lsi_reselect()
724 lsi_add_msg_byte(s, 0x20); in lsi_reselect()
725 lsi_add_msg_byte(s, p->tag & 0xff); in lsi_reselect()
728 if (lsi_irq_on_rsl(s)) { in lsi_reselect()
729 lsi_script_scsi_interrupt(s, LSI_SIST0_RSL, 0); in lsi_reselect()
733 static lsi_request *lsi_find_by_tag(LSIState *s, uint32_t tag) in lsi_find_by_tag() argument
737 QTAILQ_FOREACH(p, &s->queue, next) { in lsi_find_by_tag()
746 static void lsi_request_free(LSIState *s, lsi_request *p) in lsi_request_free() argument
748 if (p == s->current) { in lsi_request_free()
749 s->current = NULL; in lsi_request_free()
751 QTAILQ_REMOVE(&s->queue, p, next); in lsi_request_free()
758 LSIState *s = LSI53C895A(req->bus->qbus.parent); in lsi_request_cancelled() local
762 lsi_request_free(s, p); in lsi_request_cancelled()
768 static int lsi_queue_req(LSIState *s, SCSIRequest *req, uint32_t len) in lsi_queue_req() argument
781 if (s->waiting == LSI_WAIT_RESELECT || in lsi_queue_req()
782 (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON) && in lsi_queue_req()
783 !(s->istat0 & (LSI_ISTAT0_SIP | LSI_ISTAT0_DIP)))) { in lsi_queue_req()
785 lsi_reselect(s, p); in lsi_queue_req()
797 LSIState *s = LSI53C895A(req->bus->qbus.parent); in lsi_command_complete() local
800 out = (s->sstat1 & PHASE_MASK) == PHASE_DO; in lsi_command_complete()
802 s->status = req->status; in lsi_command_complete()
803 s->command_complete = 2; in lsi_command_complete()
804 if (s->waiting && s->dbc != 0) { in lsi_command_complete()
806 stop = lsi_bad_phase(s, out, PHASE_ST); in lsi_command_complete()
808 s->waiting = 0; in lsi_command_complete()
811 lsi_set_phase(s, PHASE_ST); in lsi_command_complete()
814 if (req->hba_private == s->current) { in lsi_command_complete()
816 lsi_request_free(s, s->current); in lsi_command_complete()
820 lsi_resume_script(s); in lsi_command_complete()
827 LSIState *s = LSI53C895A(req->bus->qbus.parent); in lsi_transfer_data() local
831 if (s->waiting == LSI_WAIT_RESELECT || req->hba_private != s->current || in lsi_transfer_data()
832 (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) { in lsi_transfer_data()
833 if (lsi_queue_req(s, req, len)) { in lsi_transfer_data()
838 out = (s->sstat1 & PHASE_MASK) == PHASE_DO; in lsi_transfer_data()
842 s->current->dma_len = len; in lsi_transfer_data()
843 s->command_complete = 1; in lsi_transfer_data()
844 if (s->waiting) { in lsi_transfer_data()
845 if (s->waiting == LSI_WAIT_RESELECT || s->dbc == 0) { in lsi_transfer_data()
846 lsi_resume_script(s); in lsi_transfer_data()
848 lsi_do_dma(s, out); in lsi_transfer_data()
853 static void lsi_do_command(LSIState *s) in lsi_do_command() argument
860 trace_lsi_do_command(s->dbc); in lsi_do_command()
861 if (s->dbc > 16) in lsi_do_command()
862 s->dbc = 16; in lsi_do_command()
863 pci_dma_read(PCI_DEVICE(s), s->dnad, buf, s->dbc); in lsi_do_command()
864 s->sfbr = buf[0]; in lsi_do_command()
865 s->command_complete = 0; in lsi_do_command()
867 id = (s->select_tag >> 8) & 0xf; in lsi_do_command()
868 dev = scsi_device_find(&s->bus, 0, id, s->current_lun); in lsi_do_command()
870 lsi_bad_selection(s, id); in lsi_do_command()
874 assert(s->current == NULL); in lsi_do_command()
875 s->current = g_new0(lsi_request, 1); in lsi_do_command()
876 s->current->tag = s->select_tag; in lsi_do_command()
877 s->current->req = scsi_req_new(dev, s->current->tag, s->current_lun, buf, in lsi_do_command()
878 s->dbc, s->current); in lsi_do_command()
880 n = scsi_req_enqueue(s->current->req); in lsi_do_command()
883 lsi_set_phase(s, PHASE_DI); in lsi_do_command()
885 lsi_set_phase(s, PHASE_DO); in lsi_do_command()
887 scsi_req_continue(s->current->req); in lsi_do_command()
889 if (!s->command_complete) { in lsi_do_command()
892 lsi_add_msg_byte(s, 2); /* SAVE DATA POINTER */ in lsi_do_command()
893 lsi_add_msg_byte(s, 4); /* DISCONNECT */ in lsi_do_command()
895 lsi_set_phase(s, PHASE_MI); in lsi_do_command()
896 s->msg_action = LSI_MSG_ACTION_DISCONNECT; in lsi_do_command()
897 lsi_queue_command(s); in lsi_do_command()
900 lsi_set_phase(s, PHASE_DI); in lsi_do_command()
905 static void lsi_do_status(LSIState *s) in lsi_do_status() argument
908 trace_lsi_do_status(s->dbc, s->status); in lsi_do_status()
909 if (s->dbc != 1) { in lsi_do_status()
912 s->dbc = 1; in lsi_do_status()
913 status = s->status; in lsi_do_status()
914 s->sfbr = status; in lsi_do_status()
915 pci_dma_write(PCI_DEVICE(s), s->dnad, &status, 1); in lsi_do_status()
916 lsi_set_phase(s, PHASE_MI); in lsi_do_status()
917 s->msg_action = LSI_MSG_ACTION_DISCONNECT; in lsi_do_status()
918 lsi_add_msg_byte(s, 0); /* COMMAND COMPLETE */ in lsi_do_status()
921 static void lsi_do_msgin(LSIState *s) in lsi_do_msgin() argument
924 trace_lsi_do_msgin(s->dbc, s->msg_len); in lsi_do_msgin()
925 s->sfbr = s->msg[0]; in lsi_do_msgin()
926 len = s->msg_len; in lsi_do_msgin()
928 if (len > s->dbc) in lsi_do_msgin()
929 len = s->dbc; in lsi_do_msgin()
932 pci_dma_write(PCI_DEVICE(s), s->dnad, s->msg, len); in lsi_do_msgin()
934 s->sidl = s->msg[len - 1]; in lsi_do_msgin()
935 s->msg_len -= len; in lsi_do_msgin()
936 if (s->msg_len) { in lsi_do_msgin()
937 memmove(s->msg, s->msg + len, s->msg_len); in lsi_do_msgin()
941 if (!s->msg_len) { in lsi_do_msgin()
944 switch (s->msg_action) { in lsi_do_msgin()
946 lsi_set_phase(s, PHASE_CMD); in lsi_do_msgin()
949 lsi_disconnect(s); in lsi_do_msgin()
952 lsi_set_phase(s, PHASE_DO); in lsi_do_msgin()
955 lsi_set_phase(s, PHASE_DI); in lsi_do_msgin()
964 static uint8_t lsi_get_msgbyte(LSIState *s) in lsi_get_msgbyte() argument
967 pci_dma_read(PCI_DEVICE(s), s->dnad, &data, 1); in lsi_get_msgbyte()
968 s->dnad++; in lsi_get_msgbyte()
969 s->dbc--; in lsi_get_msgbyte()
974 static void lsi_skip_msgbytes(LSIState *s, unsigned int n) in lsi_skip_msgbytes() argument
976 s->dnad += n; in lsi_skip_msgbytes()
977 s->dbc -= n; in lsi_skip_msgbytes()
980 static void lsi_do_msgout(LSIState *s) in lsi_do_msgout() argument
987 if (s->current) { in lsi_do_msgout()
988 current_tag = s->current->tag; in lsi_do_msgout()
989 current_req = s->current; in lsi_do_msgout()
991 current_tag = s->select_tag; in lsi_do_msgout()
992 current_req = lsi_find_by_tag(s, current_tag); in lsi_do_msgout()
995 trace_lsi_do_msgout(s->dbc); in lsi_do_msgout()
996 while (s->dbc) { in lsi_do_msgout()
997 msg = lsi_get_msgbyte(s); in lsi_do_msgout()
998 s->sfbr = msg; in lsi_do_msgout()
1003 lsi_disconnect(s); in lsi_do_msgout()
1007 lsi_set_phase(s, PHASE_CMD); in lsi_do_msgout()
1010 len = lsi_get_msgbyte(s); in lsi_do_msgout()
1011 msg = lsi_get_msgbyte(s); in lsi_do_msgout()
1017 lsi_skip_msgbytes(s, 2); in lsi_do_msgout()
1021 lsi_skip_msgbytes(s, 1); in lsi_do_msgout()
1025 lsi_skip_msgbytes(s, 5); in lsi_do_msgout()
1032 s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID; in lsi_do_msgout()
1033 trace_lsi_do_msgout_simplequeue(s->select_tag & 0xff); in lsi_do_msgout()
1037 s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID; in lsi_do_msgout()
1042 s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID; in lsi_do_msgout()
1051 lsi_disconnect(s); in lsi_do_msgout()
1073 if (s->current) { in lsi_do_msgout()
1074 scsi_req_cancel(s->current->req); in lsi_do_msgout()
1083 to be really necessary). So let's simply clear all queued in lsi_do_msgout()
1085 QTAILQ_FOREACH_SAFE(p, &s->queue, next, p_next) { in lsi_do_msgout()
1091 lsi_disconnect(s); in lsi_do_msgout()
1097 s->current_lun = msg & 7; in lsi_do_msgout()
1098 trace_lsi_do_msgout_select(s->current_lun); in lsi_do_msgout()
1099 lsi_set_phase(s, PHASE_CMD); in lsi_do_msgout()
1106 lsi_set_phase(s, PHASE_MI); in lsi_do_msgout()
1107 lsi_add_msg_byte(s, 7); /* MESSAGE REJECT */ in lsi_do_msgout()
1108 s->msg_action = LSI_MSG_ACTION_COMMAND; in lsi_do_msgout()
1112 static void lsi_memcpy(LSIState *s, uint32_t dest, uint32_t src, int count) in lsi_memcpy() argument
1120 lsi_mem_read(s, src, buf, n); in lsi_memcpy()
1121 lsi_mem_write(s, dest, buf, n); in lsi_memcpy()
1128 static void lsi_wait_reselect(LSIState *s) in lsi_wait_reselect() argument
1134 if (s->current) { in lsi_wait_reselect()
1137 p = get_pending_req(s); in lsi_wait_reselect()
1139 lsi_reselect(s, p); in lsi_wait_reselect()
1141 if (s->current == NULL) { in lsi_wait_reselect()
1142 s->waiting = LSI_WAIT_RESELECT; in lsi_wait_reselect()
1146 static void lsi_scripts_timer_start(LSIState *s) in lsi_scripts_timer_start() argument
1149 timer_mod(s->scripts_timer, qemu_clock_get_us(QEMU_CLOCK_VIRTUAL) + 500); in lsi_scripts_timer_start()
1152 static void lsi_execute_script(LSIState *s) in lsi_execute_script() argument
1154 PCIDevice *pci_dev = PCI_DEVICE(s); in lsi_execute_script()
1161 if (s->waiting == LSI_WAIT_SCRIPTS) { in lsi_execute_script()
1162 timer_del(s->scripts_timer); in lsi_execute_script()
1163 s->waiting = LSI_NOWAIT; in lsi_execute_script()
1168 s->istat1 |= LSI_ISTAT1_SRUN; in lsi_execute_script()
1182 s->waiting = LSI_WAIT_SCRIPTS; in lsi_execute_script()
1183 lsi_scripts_timer_start(s); in lsi_execute_script()
1187 insn = read_dword(s, s->dsp); in lsi_execute_script()
1191 s->dsp += 4; in lsi_execute_script()
1194 addr = read_dword(s, s->dsp + 4); in lsi_execute_script()
1196 trace_lsi_execute_script(s->dsp, insn, addr); in lsi_execute_script()
1197 s->dsps = addr; in lsi_execute_script()
1198 s->dcmd = insn >> 24; in lsi_execute_script()
1199 s->dsp += 8; in lsi_execute_script()
1202 if (s->sist1 & LSI_SIST1_STO) { in lsi_execute_script()
1204 lsi_stop_script(s); in lsi_execute_script()
1207 s->dbc = insn & 0xffffff; in lsi_execute_script()
1208 s->rbc = s->dbc; in lsi_execute_script()
1210 s->ia = s->dsp - 8; in lsi_execute_script()
1213 addr = read_dword(s, addr); in lsi_execute_script()
1221 pci_dma_read(pci_dev, s->dsa + offset, buf, 8); in lsi_execute_script()
1223 s->dbc = cpu_to_le32(buf[0]) & 0xffffff; in lsi_execute_script()
1224 s->rbc = s->dbc; in lsi_execute_script()
1229 if (lsi_dma_40bit(s)) in lsi_execute_script()
1231 else if (lsi_dma_ti64bit(s)) { in lsi_execute_script()
1237 addr_high = s->scratch[2 + selector]; in lsi_execute_script()
1240 addr_high = s->mmrs; in lsi_execute_script()
1243 addr_high = s->mmws; in lsi_execute_script()
1246 addr_high = s->sfs; in lsi_execute_script()
1249 addr_high = s->drs; in lsi_execute_script()
1252 addr_high = s->sbms; in lsi_execute_script()
1255 addr_high = s->dbms; in lsi_execute_script()
1264 } else if (lsi_dma_64bit(s)) { in lsi_execute_script()
1267 s->dbms = read_dword(s, s->dsp); in lsi_execute_script()
1268 s->dsp += 4; in lsi_execute_script()
1269 s->ia = s->dsp - 12; in lsi_execute_script()
1271 if ((s->sstat1 & PHASE_MASK) != ((insn >> 24) & 7)) { in lsi_execute_script()
1273 scsi_phase_name(s->sstat1), in lsi_execute_script()
1275 lsi_script_scsi_interrupt(s, LSI_SIST0_MA, 0); in lsi_execute_script()
1278 s->dnad = addr; in lsi_execute_script()
1279 s->dnad64 = addr_high; in lsi_execute_script()
1280 switch (s->sstat1 & 0x7) { in lsi_execute_script()
1282 s->waiting = LSI_DMA_SCRIPTS; in lsi_execute_script()
1283 lsi_do_dma(s, 1); in lsi_execute_script()
1284 if (s->waiting) in lsi_execute_script()
1285 s->waiting = LSI_DMA_IN_PROGRESS; in lsi_execute_script()
1288 s->waiting = LSI_DMA_SCRIPTS; in lsi_execute_script()
1289 lsi_do_dma(s, 0); in lsi_execute_script()
1290 if (s->waiting) in lsi_execute_script()
1291 s->waiting = LSI_DMA_IN_PROGRESS; in lsi_execute_script()
1294 lsi_do_command(s); in lsi_execute_script()
1297 lsi_do_status(s); in lsi_execute_script()
1300 lsi_do_msgout(s); in lsi_execute_script()
1303 lsi_do_msgin(s); in lsi_execute_script()
1306 qemu_log_mask(LOG_UNIMP, "lsi_scsi: Unimplemented phase %s\n", in lsi_execute_script()
1307 scsi_phase_name(s->sstat1)); in lsi_execute_script()
1309 s->dfifo = s->dbc & 0xff; in lsi_execute_script()
1310 s->ctest5 = (s->ctest5 & 0xfc) | ((s->dbc >> 8) & 3); in lsi_execute_script()
1311 s->sbc = s->dbc; in lsi_execute_script()
1312 s->rbc -= s->dbc; in lsi_execute_script()
1313 s->ua = addr + s->dbc; in lsi_execute_script()
1322 id = read_dword(s, s->dsa + sextract32(insn, 0, 24)); in lsi_execute_script()
1328 addr = s->dsp + sextract32(addr, 0, 24); in lsi_execute_script()
1330 s->dnad = addr; in lsi_execute_script()
1333 s->sdid = id; in lsi_execute_script()
1334 if (s->scntl1 & LSI_SCNTL1_CON) { in lsi_execute_script()
1336 s->dsp = s->dnad; in lsi_execute_script()
1339 s->sstat0 |= LSI_SSTAT0_WOA; in lsi_execute_script()
1340 s->scntl1 &= ~LSI_SCNTL1_IARB; in lsi_execute_script()
1341 if (!scsi_device_find(&s->bus, 0, id, 0)) { in lsi_execute_script()
1342 lsi_bad_selection(s, id); in lsi_execute_script()
1349 lsi_script_scsi_interrupt(s, LSI_SIST0_CMP, 0); */ in lsi_execute_script()
1350 s->select_tag = id << 8; in lsi_execute_script()
1351 s->scntl1 |= LSI_SCNTL1_CON; in lsi_execute_script()
1353 s->socl |= LSI_SOCL_ATN; in lsi_execute_script()
1354 s->sbcl |= LSI_SBCL_ATN; in lsi_execute_script()
1356 s->sbcl |= LSI_SBCL_BSY; in lsi_execute_script()
1357 lsi_set_phase(s, PHASE_MO); in lsi_execute_script()
1358 s->waiting = LSI_NOWAIT; in lsi_execute_script()
1362 s->scntl1 &= ~LSI_SCNTL1_CON; in lsi_execute_script()
1369 if (!s->current) { in lsi_execute_script()
1370 lsi_request *p = get_pending_req(s); in lsi_execute_script()
1372 lsi_reselect(s, p); in lsi_execute_script()
1377 if (s->istat0 & LSI_ISTAT0_SIGP) { in lsi_execute_script()
1378 s->dsp = s->dnad; in lsi_execute_script()
1379 } else if (!lsi_irq_on_rsl(s)) { in lsi_execute_script()
1380 lsi_wait_reselect(s); in lsi_execute_script()
1390 s->socl |= LSI_SOCL_ATN; in lsi_execute_script()
1391 s->sbcl |= LSI_SBCL_ATN; in lsi_execute_script()
1392 lsi_set_phase(s, PHASE_MO); in lsi_execute_script()
1396 s->sbcl |= LSI_SBCL_ACK; in lsi_execute_script()
1404 s->carry = 1; in lsi_execute_script()
1413 s->socl &= ~LSI_SOCL_ATN; in lsi_execute_script()
1414 s->sbcl &= ~LSI_SBCL_ATN; in lsi_execute_script()
1418 s->sbcl &= ~LSI_SBCL_ACK; in lsi_execute_script()
1422 s->carry = 0; in lsi_execute_script()
1443 operator_names[operator], data8, s->sfbr, in lsi_execute_script()
1448 op0 = s->sfbr; in lsi_execute_script()
1453 op0 = lsi_reg_readb(s, reg); in lsi_execute_script()
1458 op0 = lsi_reg_readb(s, reg); in lsi_execute_script()
1460 op1 = s->sfbr; in lsi_execute_script()
1473 op0 = (op0 << 1) | s->carry; in lsi_execute_script()
1474 s->carry = op1; in lsi_execute_script()
1487 op0 = (op0 >> 1) | (s->carry << 7); in lsi_execute_script()
1488 s->carry = op1; in lsi_execute_script()
1492 s->carry = op0 < op1; in lsi_execute_script()
1495 op0 += op1 + s->carry; in lsi_execute_script()
1496 if (s->carry) in lsi_execute_script()
1497 s->carry = op0 <= op1; in lsi_execute_script()
1499 s->carry = op0 < op1; in lsi_execute_script()
1506 lsi_reg_writeb(s, reg, op0); in lsi_execute_script()
1509 s->sfbr = op0; in lsi_execute_script()
1524 if (s->sist1 & LSI_SIST1_STO) { in lsi_execute_script()
1526 lsi_stop_script(s); in lsi_execute_script()
1531 trace_lsi_execute_script_tc_compc(s->carry == jmp); in lsi_execute_script()
1532 cond = s->carry != 0; in lsi_execute_script()
1535 trace_lsi_execute_script_tc_compp(scsi_phase_name(s->sstat1), in lsi_execute_script()
1537 cond = (s->sstat1 & PHASE_MASK) == ((insn >> 24) & 7); in lsi_execute_script()
1544 s->sfbr, mask, jmp ? '=' : '!', insn & mask); in lsi_execute_script()
1545 cond = (s->sfbr & mask) == (insn & mask); in lsi_execute_script()
1550 addr = s->dsp + sextract32(addr, 0, 24); in lsi_execute_script()
1555 s->adder = addr; in lsi_execute_script()
1556 s->dsp = addr; in lsi_execute_script()
1560 s->temp = s->dsp; in lsi_execute_script()
1561 s->dsp = addr; in lsi_execute_script()
1564 trace_lsi_execute_script_tc_return(s->temp); in lsi_execute_script()
1565 s->dsp = s->temp; in lsi_execute_script()
1568 trace_lsi_execute_script_tc_interrupt(s->dsps); in lsi_execute_script()
1570 s->istat0 |= LSI_ISTAT0_INTF; in lsi_execute_script()
1571 lsi_update_irq(s); in lsi_execute_script()
1573 lsi_script_dma_interrupt(s, LSI_DSTAT_SIR); in lsi_execute_script()
1578 lsi_script_dma_interrupt(s, LSI_DSTAT_IID); in lsi_execute_script()
1594 dest = read_dword(s, s->dsp); in lsi_execute_script()
1595 s->dsp += 4; in lsi_execute_script()
1596 lsi_memcpy(s, dest, addr, insn & 0xffffff); in lsi_execute_script()
1604 addr = s->dsa + sextract32(addr, 0, 24); in lsi_execute_script()
1612 lsi_reg_writeb(s, reg + i, data[i]); in lsi_execute_script()
1617 data[i] = lsi_reg_readb(s, reg + i); in lsi_execute_script()
1623 if (s->istat1 & LSI_ISTAT1_SRUN && s->waiting == LSI_NOWAIT) { in lsi_execute_script()
1624 if (s->dcntl & LSI_DCNTL_SSM) { in lsi_execute_script()
1625 lsi_script_dma_interrupt(s, LSI_DSTAT_SSI); in lsi_execute_script()
1635 static uint8_t lsi_reg_readb(LSIState *s, int offset) in lsi_reg_readb() argument
1640 case addr: ret = s->name & 0xff; break; \ in lsi_reg_readb()
1641 case addr + 1: ret = (s->name >> 8) & 0xff; break; \ in lsi_reg_readb()
1642 case addr + 2: ret = (s->name >> 16) & 0xff; break; in lsi_reg_readb()
1645 case addr: ret = s->name & 0xff; break; \ in lsi_reg_readb()
1646 case addr + 1: ret = (s->name >> 8) & 0xff; break; \ in lsi_reg_readb()
1647 case addr + 2: ret = (s->name >> 16) & 0xff; break; \ in lsi_reg_readb()
1648 case addr + 3: ret = (s->name >> 24) & 0xff; break; in lsi_reg_readb()
1652 ret = s->scntl0; in lsi_reg_readb()
1655 ret = s->scntl1; in lsi_reg_readb()
1658 ret = s->scntl2; in lsi_reg_readb()
1661 ret = s->scntl3; in lsi_reg_readb()
1664 ret = s->scid; in lsi_reg_readb()
1667 ret = s->sxfer; in lsi_reg_readb()
1670 ret = s->sdid; in lsi_reg_readb()
1679 ret = s->socl; in lsi_reg_readb()
1682 ret = s->ssid; in lsi_reg_readb()
1685 ret = s->sbcl; in lsi_reg_readb()
1688 ret = s->dstat | LSI_DSTAT_DFE; in lsi_reg_readb()
1689 if ((s->istat0 & LSI_ISTAT0_INTF) == 0) in lsi_reg_readb()
1690 s->dstat = 0; in lsi_reg_readb()
1691 lsi_update_irq(s); in lsi_reg_readb()
1694 ret = s->sstat0; in lsi_reg_readb()
1697 ret = s->sstat1; in lsi_reg_readb()
1700 ret = s->scntl1 & LSI_SCNTL1_CON ? 0 : 2; in lsi_reg_readb()
1704 ret = s->istat0; in lsi_reg_readb()
1707 ret = s->istat1; in lsi_reg_readb()
1710 ret = s->mbox0; in lsi_reg_readb()
1713 ret = s->mbox1; in lsi_reg_readb()
1722 ret = s->ctest2 | LSI_CTEST2_DACK | LSI_CTEST2_CM; in lsi_reg_readb()
1723 if (s->istat0 & LSI_ISTAT0_SIGP) { in lsi_reg_readb()
1724 s->istat0 &= ~LSI_ISTAT0_SIGP; in lsi_reg_readb()
1729 ret = s->ctest3; in lsi_reg_readb()
1733 ret = s->dfifo; in lsi_reg_readb()
1736 ret = s->ctest4; in lsi_reg_readb()
1739 ret = s->ctest5; in lsi_reg_readb()
1746 ret = s->dcmd; in lsi_reg_readb()
1753 ret = s->dmode; in lsi_reg_readb()
1756 ret = s->dien; in lsi_reg_readb()
1759 ret = s->sbr; in lsi_reg_readb()
1762 ret = s->dcntl; in lsi_reg_readb()
1767 ret = s->sien0; in lsi_reg_readb()
1770 ret = s->sien1; in lsi_reg_readb()
1773 ret = s->sist0; in lsi_reg_readb()
1774 s->sist0 = 0; in lsi_reg_readb()
1775 lsi_update_irq(s); in lsi_reg_readb()
1778 ret = s->sist1; in lsi_reg_readb()
1779 s->sist1 = 0; in lsi_reg_readb()
1780 lsi_update_irq(s); in lsi_reg_readb()
1789 ret = s->stime0; in lsi_reg_readb()
1792 ret = s->respid0; in lsi_reg_readb()
1795 ret = s->respid1; in lsi_reg_readb()
1798 ret = s->stest1; in lsi_reg_readb()
1801 ret = s->stest2; in lsi_reg_readb()
1804 ret = s->stest3; in lsi_reg_readb()
1809 ret = s->sidl; in lsi_reg_readb()
1815 ret = s->ccntl0; in lsi_reg_readb()
1818 ret = s->ccntl1; in lsi_reg_readb()
1822 if ((s->sstat1 & PHASE_MASK) == PHASE_MI) { in lsi_reg_readb()
1823 assert(s->msg_len > 0); in lsi_reg_readb()
1824 return s->msg[0]; in lsi_reg_readb()
1851 ret = (s->scratch[n] >> shift) & 0xff; in lsi_reg_readb()
1857 "lsi_scsi: invalid read from reg %s %x\n", in lsi_reg_readb()
1873 static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val) in lsi_reg_writeb() argument
1876 case addr : s->name &= 0xffffff00; s->name |= val; break; \ in lsi_reg_writeb()
1877 case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \ in lsi_reg_writeb()
1878 case addr + 2: s->name &= 0xff00ffff; s->name |= val << 16; break; in lsi_reg_writeb()
1881 case addr : s->name &= 0xffffff00; s->name |= val; break; \ in lsi_reg_writeb()
1882 case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \ in lsi_reg_writeb()
1883 case addr + 2: s->name &= 0xff00ffff; s->name |= val << 16; break; \ in lsi_reg_writeb()
1884 case addr + 3: s->name &= 0x00ffffff; s->name |= val << 24; break; in lsi_reg_writeb()
1891 s->scntl0 = val; in lsi_reg_writeb()
1898 s->scntl1 = val & ~LSI_SCNTL1_SST; in lsi_reg_writeb()
1904 if (!(s->sstat0 & LSI_SSTAT0_RST)) { in lsi_reg_writeb()
1905 bus_cold_reset(BUS(&s->bus)); in lsi_reg_writeb()
1906 s->sstat0 |= LSI_SSTAT0_RST; in lsi_reg_writeb()
1907 lsi_script_scsi_interrupt(s, LSI_SIST0_RST, 0); in lsi_reg_writeb()
1910 s->sstat0 &= ~LSI_SSTAT0_RST; in lsi_reg_writeb()
1915 s->scntl2 = val; in lsi_reg_writeb()
1918 s->scntl3 = val; in lsi_reg_writeb()
1921 s->scid = val; in lsi_reg_writeb()
1924 s->sxfer = val; in lsi_reg_writeb()
1927 if ((s->ssid & 0x80) && (val & 0xf) != (s->ssid & 0xf)) { in lsi_reg_writeb()
1931 s->sdid = val & 0xf; in lsi_reg_writeb()
1938 s->sfbr = val; in lsi_reg_writeb()
1948 s->istat0 = (s->istat0 & 0x0f) | (val & 0xf0); in lsi_reg_writeb()
1950 lsi_script_dma_interrupt(s, LSI_DSTAT_ABRT); in lsi_reg_writeb()
1953 s->istat0 &= ~LSI_ISTAT0_INTF; in lsi_reg_writeb()
1954 lsi_update_irq(s); in lsi_reg_writeb()
1956 if (s->waiting == LSI_WAIT_RESELECT && val & LSI_ISTAT0_SIGP) { in lsi_reg_writeb()
1958 s->waiting = LSI_NOWAIT; in lsi_reg_writeb()
1959 s->dsp = s->dnad; in lsi_reg_writeb()
1960 lsi_execute_script(s); in lsi_reg_writeb()
1963 device_cold_reset(DEVICE(s)); in lsi_reg_writeb()
1967 s->mbox0 = val; in lsi_reg_writeb()
1970 s->mbox1 = val; in lsi_reg_writeb()
1976 s->ctest2 = val & LSI_CTEST2_PCICIE; in lsi_reg_writeb()
1979 s->ctest3 = val & 0x0f; in lsi_reg_writeb()
1987 s->ctest4 = val; in lsi_reg_writeb()
1994 s->ctest5 = val; in lsi_reg_writeb()
1999 s->dsp &= 0xffffff00; in lsi_reg_writeb()
2000 s->dsp |= val; in lsi_reg_writeb()
2003 s->dsp &= 0xffff00ff; in lsi_reg_writeb()
2004 s->dsp |= val << 8; in lsi_reg_writeb()
2007 s->dsp &= 0xff00ffff; in lsi_reg_writeb()
2008 s->dsp |= val << 16; in lsi_reg_writeb()
2011 s->dsp &= 0x00ffffff; in lsi_reg_writeb()
2012 s->dsp |= val << 24; in lsi_reg_writeb()
2014 * FIXME: if s->waiting != LSI_NOWAIT, this will only execute one in lsi_reg_writeb()
2017 if ((s->dmode & LSI_DMODE_MAN) == 0 in lsi_reg_writeb()
2018 && (s->istat1 & LSI_ISTAT1_SRUN) == 0) in lsi_reg_writeb()
2019 lsi_execute_script(s); in lsi_reg_writeb()
2024 s->dmode = val; in lsi_reg_writeb()
2027 s->dien = val; in lsi_reg_writeb()
2028 lsi_update_irq(s); in lsi_reg_writeb()
2031 s->sbr = val; in lsi_reg_writeb()
2034 s->dcntl = val & ~(LSI_DCNTL_PFF | LSI_DCNTL_STD); in lsi_reg_writeb()
2036 * FIXME: if s->waiting != LSI_NOWAIT, this will only execute one in lsi_reg_writeb()
2039 if ((val & LSI_DCNTL_STD) && (s->istat1 & LSI_ISTAT1_SRUN) == 0) in lsi_reg_writeb()
2040 lsi_execute_script(s); in lsi_reg_writeb()
2043 s->sien0 = val; in lsi_reg_writeb()
2044 lsi_update_irq(s); in lsi_reg_writeb()
2047 s->sien1 = val; in lsi_reg_writeb()
2048 lsi_update_irq(s); in lsi_reg_writeb()
2053 s->stime0 = val; in lsi_reg_writeb()
2061 lsi_script_scsi_interrupt(s, 0, LSI_SIST1_GEN); in lsi_reg_writeb()
2065 s->respid0 = val; in lsi_reg_writeb()
2068 s->respid1 = val; in lsi_reg_writeb()
2071 s->stest1 = val; in lsi_reg_writeb()
2078 s->stest2 = val; in lsi_reg_writeb()
2085 s->stest3 = val; in lsi_reg_writeb()
2088 s->ccntl0 = val; in lsi_reg_writeb()
2091 s->ccntl1 = val; in lsi_reg_writeb()
2113 s->scratch[n] = deposit32(s->scratch[n], shift, 8, val); in lsi_reg_writeb()
2116 "lsi_scsi: invalid write to reg %s %x (0x%02x)\n", in lsi_reg_writeb()
2128 LSIState *s = opaque; in lsi_mmio_write() local
2130 lsi_reg_writeb(s, addr & 0xff, val); in lsi_mmio_write()
2136 LSIState *s = opaque; in lsi_mmio_read() local
2137 return lsi_reg_readb(s, addr & 0xff); in lsi_mmio_read()
2153 LSIState *s = opaque; in lsi_ram_write() local
2154 stn_le_p(s->script_ram + addr, size, val); in lsi_ram_write()
2160 LSIState *s = opaque; in lsi_ram_read() local
2161 return ldn_le_p(s->script_ram + addr, size); in lsi_ram_read()
2173 LSIState *s = opaque; in lsi_io_read() local
2174 return lsi_reg_readb(s, addr & 0xff); in lsi_io_read()
2180 LSIState *s = opaque; in lsi_io_write() local
2181 lsi_reg_writeb(s, addr & 0xff, val); in lsi_io_write()
2196 LSIState *s = LSI53C895A(dev); in lsi_scsi_reset() local
2198 lsi_soft_reset(s); in lsi_scsi_reset()
2203 LSIState *s = opaque; in lsi_pre_save() local
2205 if (s->current) { in lsi_pre_save()
2206 assert(s->current->dma_buf == NULL); in lsi_pre_save()
2207 assert(s->current->dma_len == 0); in lsi_pre_save()
2209 assert(QTAILQ_EMPTY(&s->queue)); in lsi_pre_save()
2216 LSIState *s = opaque; in lsi_post_load() local
2218 if (s->msg_len < 0 || s->msg_len > LSI_MAX_MSGIN_LEN) { in lsi_post_load()
2222 if (s->waiting == LSI_WAIT_SCRIPTS) { in lsi_post_load()
2223 lsi_scripts_timer_start(s); in lsi_post_load()
2324 LSIState *s = opaque; in scripts_timer_cb() local
2327 s->waiting = LSI_NOWAIT; in scripts_timer_cb()
2328 lsi_execute_script(s); in scripts_timer_cb()
2333 LSIState *s = LSI53C895A(dev); in lsi_scsi_realize() local
2344 memory_region_init_io(&s->mmio_io, OBJECT(s), &lsi_mmio_ops, s, in lsi_scsi_realize()
2346 memory_region_init_io(&s->ram_io, OBJECT(s), &lsi_ram_ops, s, in lsi_scsi_realize()
2348 memory_region_init_io(&s->io_io, OBJECT(s), &lsi_io_ops, s, in lsi_scsi_realize()
2350 s->scripts_timer = timer_new_us(QEMU_CLOCK_VIRTUAL, scripts_timer_cb, s); in lsi_scsi_realize()
2356 s->ram_io.disable_reentrancy_guard = true; in lsi_scsi_realize()
2357 s->mmio_io.disable_reentrancy_guard = true; in lsi_scsi_realize()
2359 address_space_init(&s->pci_io_as, pci_address_space_io(dev), "lsi-pci-io"); in lsi_scsi_realize()
2360 qdev_init_gpio_out(d, &s->ext_irq, 1); in lsi_scsi_realize()
2362 pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io_io); in lsi_scsi_realize()
2363 pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_io); in lsi_scsi_realize()
2364 pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io); in lsi_scsi_realize()
2365 QTAILQ_INIT(&s->queue); in lsi_scsi_realize()
2367 scsi_bus_init(&s->bus, sizeof(s->bus), d, &lsi_scsi_info); in lsi_scsi_realize()
2372 LSIState *s = LSI53C895A(dev); in lsi_scsi_exit() local
2374 address_space_destroy(&s->pci_io_as); in lsi_scsi_exit()
2375 timer_del(s->scripts_timer); in lsi_scsi_exit()
2428 LSIState *s = LSI53C895A(lsi_dev); in type_init() local
2430 scsi_bus_legacy_handle_cmdline(&s->bus); in type_init()