* [Qemu-devel] Implementation of BusLogic SCSI host adapter (BT-958)
@ 2016-08-31 13:48 Денис Дмитриев
2016-09-01 11:11 ` Paolo Bonzini
0 siblings, 1 reply; 7+ messages in thread
From: Денис Дмитриев @ 2016-08-31 13:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Pavel Dovgaluk, pbonzini
Hi,
I'm trying to implement a buslogic scsi adapter(BT-958) for qemu. I
realized the driver interaction with the ports through which the driver can
write / read commands and parameters for the adapter. The driver was able
to make an adapter sample procedure. The problem is that I do not
understand how to establish communication between the driver and adapter
for transferring mailboxes. I got the address of the mailboxes from the
driver. Then I calculated the start address of the desired mailbox (the
same address to which a driver recorded a mailbox). After that, I try to
read the data at this address using pci_dma_read function but no buffer
data after reading.
uint64_t buslogicReadOutgoingMailbox(BuslogicState *s, BUSLOGICTASKSTATE
*TaskState)
{
uint64_t GCMailbox;
Mailbox24 Mbx24;
Mbx24.uCmdState = 0;
PCIDevice *pci_dev = PCI_DEVICE(s);
if (s->fMbxIs24Bit)
{
//try to calculate mailbox address
GCMailbox = s->GCPhysAddrMailboxOutgoingBase +
(s->uMailboxOutgoingPositionCurrent * sizeof(Mailbox24));
//try to read mailbox
pci_dma_read(pci_dev, GCMailbox, &Mbx24, sizeof(Mailbox24));
//after that i have empty buffer
TaskState->MailboxGuest.u32PhysAddrCCB =
ADDR_TO_U32(Mbx24.aPhysAddrCCB);
TaskState->MailboxGuest.u.out.uActionCode = Mbx24.uCmdState;
}
else
{
GCMailbox = s->GCPhysAddrMailboxOutgoingBase +
(s->uMailboxOutgoingPositionCurrent * sizeof(Mailbox32));
pci_dma_read(pci_dev, GCMailbox, &TaskState->MailboxGuest,
sizeof(Mailbox32));
}
return GCMailbox;
}
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [Qemu-devel] Implementation of BusLogic SCSI host adapter (BT-958) 2016-08-31 13:48 [Qemu-devel] Implementation of BusLogic SCSI host adapter (BT-958) Денис Дмитриев @ 2016-09-01 11:11 ` Paolo Bonzini 2016-09-01 11:19 ` Peter Maydell 2016-09-01 13:17 ` Denis Dmitriev 0 siblings, 2 replies; 7+ messages in thread From: Paolo Bonzini @ 2016-09-01 11:11 UTC (permalink / raw) To: Денис Дмитриев, qemu-devel Cc: Pavel Dovgaluk On 31/08/2016 15:48, Денис Дмитриев wrote: > uint64_t buslogicReadOutgoingMailbox(BuslogicState *s, BUSLOGICTASKSTATE > *TaskState) > { > uint64_t GCMailbox; > Mailbox24 Mbx24; > Mbx24.uCmdState = 0; > PCIDevice *pci_dev = PCI_DEVICE(s); > if (s->fMbxIs24Bit) > { > //try to calculate mailbox address > GCMailbox = s->GCPhysAddrMailboxOutgoingBase + > (s->uMailboxOutgoingPositionCurrent * sizeof(Mailbox24)); > //try to read mailbox > pci_dma_read(pci_dev, GCMailbox, &Mbx24, sizeof(Mailbox24)); > //after that i have empty buffer > TaskState->MailboxGuest.u32PhysAddrCCB = > ADDR_TO_U32(Mbx24.aPhysAddrCCB); > TaskState->MailboxGuest.u.out.uActionCode = Mbx24.uCmdState; > } > else > { > GCMailbox = s->GCPhysAddrMailboxOutgoingBase + > (s->uMailboxOutgoingPositionCurrent * sizeof(Mailbox32)); > pci_dma_read(pci_dev, GCMailbox, &TaskState->MailboxGuest, > sizeof(Mailbox32)); > } > return GCMailbox; > } This seems okay, so I am afraid you'll have to debug it. :( That said, this looks very much like VirtualBox code. Do not use it if you want to contribute code to QEMU, because QEMU does not accept GPLv2-only code. We already had to rewrite the lsisas1068 device model instead of using the one that was contributed a few years ago. Paolo ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] Implementation of BusLogic SCSI host adapter (BT-958) 2016-09-01 11:11 ` Paolo Bonzini @ 2016-09-01 11:19 ` Peter Maydell 2016-09-01 12:59 ` Paolo Bonzini 2016-09-01 13:17 ` Denis Dmitriev 1 sibling, 1 reply; 7+ messages in thread From: Peter Maydell @ 2016-09-01 11:19 UTC (permalink / raw) To: Paolo Bonzini Cc: Денис Дмитриев, QEMU Developers, Pavel Dovgaluk On 1 September 2016 at 12:11, Paolo Bonzini <pbonzini@redhat.com> wrote: > That said, this looks very much like VirtualBox code. Do not use it if > you want to contribute code to QEMU, because QEMU does not accept > GPLv2-only code. I don't think this is the consensus view. We'd prefer v2-or-later, sure, but we haven't stopped taking v2-only code if that's all we have. thanks -- PMM ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] Implementation of BusLogic SCSI host adapter (BT-958) 2016-09-01 11:19 ` Peter Maydell @ 2016-09-01 12:59 ` Paolo Bonzini 2016-09-01 13:01 ` Peter Maydell 0 siblings, 1 reply; 7+ messages in thread From: Paolo Bonzini @ 2016-09-01 12:59 UTC (permalink / raw) To: Peter Maydell Cc: Денис Дмитриев, QEMU Developers, Pavel Dovgaluk On 01/09/2016 13:19, Peter Maydell wrote: > On 1 September 2016 at 12:11, Paolo Bonzini <pbonzini@redhat.com> wrote: >> That said, this looks very much like VirtualBox code. Do not use it if >> you want to contribute code to QEMU, because QEMU does not accept >> GPLv2-only code. > > I don't think this is the consensus view. We'd prefer v2-or-later, > sure, but we haven't stopped taking v2-only code if that's all > we have. Yes, I was simplifying a bit. LICENSE says: "As of July 2013, contributions under version 2 of the GNU General Public License (and no later version) are only accepted for the following files or directories: bsd-user/, linux-user/, hw/vfio/, hw/xen/xen_pt*". Paolo ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] Implementation of BusLogic SCSI host adapter (BT-958) 2016-09-01 12:59 ` Paolo Bonzini @ 2016-09-01 13:01 ` Peter Maydell 0 siblings, 0 replies; 7+ messages in thread From: Peter Maydell @ 2016-09-01 13:01 UTC (permalink / raw) To: Paolo Bonzini Cc: Денис Дмитриев, QEMU Developers, Pavel Dovgaluk On 1 September 2016 at 13:59, Paolo Bonzini <pbonzini@redhat.com> wrote: > On 01/09/2016 13:19, Peter Maydell wrote: >> On 1 September 2016 at 12:11, Paolo Bonzini <pbonzini@redhat.com> wrote: >>> That said, this looks very much like VirtualBox code. Do not use it if >>> you want to contribute code to QEMU, because QEMU does not accept >>> GPLv2-only code. >> >> I don't think this is the consensus view. We'd prefer v2-or-later, >> sure, but we haven't stopped taking v2-only code if that's all >> we have. > > Yes, I was simplifying a bit. LICENSE says: "As of July 2013, > contributions under version 2 of the GNU General Public License (and no > later version) are only accepted for the following files or directories: > bsd-user/, linux-user/, hw/vfio/, hw/xen/xen_pt*". I don't personally see the point in restricting to those directories. We are in practice never going be able to relicense to v2+ for the whole of QEMU. thanks -- PMM ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] Implementation of BusLogic SCSI host adapter (BT-958) 2016-09-01 11:11 ` Paolo Bonzini 2016-09-01 11:19 ` Peter Maydell @ 2016-09-01 13:17 ` Denis Dmitriev 2016-09-01 15:12 ` Paolo Bonzini 1 sibling, 1 reply; 7+ messages in thread From: Denis Dmitriev @ 2016-09-01 13:17 UTC (permalink / raw) To: Paolo Bonzini; +Cc: qemu-devel, Pavel Dovgaluk 2016-09-01 14:11 GMT+03:00 Paolo Bonzini <pbonzini@redhat.com>: > > > > On 31/08/2016 15:48, Денис Дмитриев wrote: > > uint64_t buslogicReadOutgoingMailbox(BuslogicState *s, BUSLOGICTASKSTATE > > *TaskState) > > { > > uint64_t GCMailbox; > > Mailbox24 Mbx24; > > Mbx24.uCmdState = 0; > > PCIDevice *pci_dev = PCI_DEVICE(s); > > if (s->fMbxIs24Bit) > > { > > //try to calculate mailbox address > > GCMailbox = s->GCPhysAddrMailboxOutgoingBase + > > (s->uMailboxOutgoingPositionCurrent * sizeof(Mailbox24)); > > //try to read mailbox > > pci_dma_read(pci_dev, GCMailbox, &Mbx24, sizeof(Mailbox24)); > > //after that i have empty buffer > > TaskState->MailboxGuest.u32PhysAddrCCB = > > ADDR_TO_U32(Mbx24.aPhysAddrCCB); > > TaskState->MailboxGuest.u.out.uActionCode = Mbx24.uCmdState; > > } > > else > > { > > GCMailbox = s->GCPhysAddrMailboxOutgoingBase + > > (s->uMailboxOutgoingPositionCurrent * sizeof(Mailbox32)); > > pci_dma_read(pci_dev, GCMailbox, &TaskState->MailboxGuest, > > sizeof(Mailbox32)); > > } > > return GCMailbox; > > } > > This seems okay, so I am afraid you'll have to debug it. :( I think that I am missing some initialization or something like that. To work with the registers I create a memory region, and associate it with the read and write handlers (as an example I used lsi53c895a.c). Maybe work with memory in which mailboxes are located must be built the same way? To me, it looks like I'm trying to get the data to the right place but I do not see them because there is something wrong with the mapping. The basis of the initialization function I took from lsi53c895a.c. Perhaps the root of evil in those lines, I commented out? If so, how can I understand what parameters should be passed in memory_region_init_io pci_register_bar and functions? void buslogic_scsi_realize(PCIDevice *dev, Error **errp) { BuslogicState *s = BUSLOGIC_BT958(dev); DeviceState *d = DEVICE(dev); uint8_t *pci_conf; pci_conf = dev->config; /* PCI latency timer = 255 */ pci_conf[PCI_LATENCY_TIMER] = 0xff; /* Interrupt pin A */ pci_conf[PCI_INTERRUPT_PIN] = 0x01; memory_region_init_io(&s->port_io, OBJECT(s), &bl_port_ops, s, "BusLogic", 0x4); // memory_region_init_io(&s->ram_io, OBJECT(s), &bl_ram_ops, s, // "BusLogic-ram", 0x2000); // memory_region_init_io(&s->io_io, OBJECT(s), &bl_io_ops, s, // "BusLogic-io", 256); pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->port_io); // pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_io); // pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io); QTAILQ_INIT(&s->queue); scsi_bus_new(&s->bus, sizeof(s->bus), d, &bl_scsi_info, NULL); if (!d->hotplugged) { scsi_bus_legacy_handle_cmdline(&s->bus, errp); } } -- Sincerely, Denis Dmitriev. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] Implementation of BusLogic SCSI host adapter (BT-958) 2016-09-01 13:17 ` Denis Dmitriev @ 2016-09-01 15:12 ` Paolo Bonzini 0 siblings, 0 replies; 7+ messages in thread From: Paolo Bonzini @ 2016-09-01 15:12 UTC (permalink / raw) To: Denis Dmitriev; +Cc: qemu-devel, Pavel Dovgaluk On 01/09/2016 15:17, Denis Dmitriev wrote: > > I think that I am missing some initialization or something like that. > To work with the registers I create a memory region, and associate it > with the read and write handlers (as an example I used lsi53c895a.c). > Maybe work with memory in which mailboxes are located must be built > the same way? No, it doesn't. > To me, it looks like I'm trying to get the data to the right place but > I do not see them because there is something wrong with the mapping. > The basis of the initialization function I took from lsi53c895a.c. > Perhaps the root of evil in those lines, I commented out? If so, how > can I understand what parameters should be passed in > memory_region_init_io pci_register_bar and functions? > > void buslogic_scsi_realize(PCIDevice *dev, Error **errp) > { > BuslogicState *s = BUSLOGIC_BT958(dev); > DeviceState *d = DEVICE(dev); > uint8_t *pci_conf; > > pci_conf = dev->config; > > /* PCI latency timer = 255 */ > pci_conf[PCI_LATENCY_TIMER] = 0xff; > /* Interrupt pin A */ > pci_conf[PCI_INTERRUPT_PIN] = 0x01; > > > > memory_region_init_io(&s->port_io, OBJECT(s), &bl_port_ops, s, > "BusLogic", 0x4); If the BT958 has a single BAR, that would be fine. But is the length (0x4) correct? Paolo > // memory_region_init_io(&s->ram_io, OBJECT(s), &bl_ram_ops, s, > // "BusLogic-ram", 0x2000); > // memory_region_init_io(&s->io_io, OBJECT(s), &bl_io_ops, s, > // "BusLogic-io", 256); > > pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->port_io); > // pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_io); > // pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io); > > QTAILQ_INIT(&s->queue); > > scsi_bus_new(&s->bus, sizeof(s->bus), d, &bl_scsi_info, NULL); > if (!d->hotplugged) { > scsi_bus_legacy_handle_cmdline(&s->bus, errp); > } ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-09-01 15:12 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-08-31 13:48 [Qemu-devel] Implementation of BusLogic SCSI host adapter (BT-958) Денис Дмитриев 2016-09-01 11:11 ` Paolo Bonzini 2016-09-01 11:19 ` Peter Maydell 2016-09-01 12:59 ` Paolo Bonzini 2016-09-01 13:01 ` Peter Maydell 2016-09-01 13:17 ` Denis Dmitriev 2016-09-01 15:12 ` Paolo Bonzini
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).