Skip to contentSkip to conversation

Add TPCI200 and IP-Octal 232 IndustryPack emulation

PATCH Superseded Alberto Garcia 6 participants 27 messages Aug 23, 2012 – Jan 7, 2013

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Add TPCI200 and IP-Octal 232 IndustryPack emulation

Hello,

I have been working on the emulation of the IP-Octal 232 IndustryPack module, a device that implements eight RS-232 serial ports.

IndustryPack modules are small boards that are attached to a carrier board, so in order to have a complete and working system I also wrote an emulation of the TEWS TPCI200 carrier, which is a PCI board to which up to 4 IndustryPack modules can be attached.

I have been using this virtual device to test and debug the ipoctal driver in the Linux kernel. I'm publishing the code now, the emulation is not 100% complete but it's fairly functional, and it can be used to easily implement more IndustryPack modules.

So the work consists on three parts:
- TPCI200, the bridge between PCI and IndustryPack.
- The IndustryPack bus.
- IP-Octal, the IndustryPack module.

Basic usage:

$ qemu -device tpci200 -device ipoctal

Each one of the serial ports in the ipoctal device can be redirected to a character device in the host using the functionality provided by QEMU. The 'serial0' to 'serial7' parameters can be used to specify each one of the redirections.

Suggestions, comments, etc, will be appreciated.

Alberto Garcia (2):
Add TEWS TPCI200 IndustryPack emulation
Add IP-Octal 232 IndustryPack emulation

 default-configs/pci.mak |    1 +
 hw/Makefile.objs        |    3 +
 hw/ipack.c              |  106 ++++++++
 hw/ipack.h              |   75 ++++++
 hw/ipoctal.c            |  662 +++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci_ids.h            |    3 +
 hw/tpci200.c            |  630 ++++++++++++++++++++++++++++++++++++++++++++
 7 ficheiros modificados, 1480 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/ipoctal.c
 create mode 100644 hw/tpci200.c
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/2 Add TEWS TPCI200 IndustryPack emulation

The TPCI200 is a PCI board that supports up to 4 IndustryPack modules.

A new bus type called 'IndustryPack' has been created so any compatible module can be attached to this board.

---
 default-configs/pci.mak |    1 +
 hw/Makefile.objs        |    3 +
 hw/ipack.c              |  106 ++++++++
 hw/ipack.h              |   75 ++++++
 hw/pci_ids.h            |    3 +
 hw/tpci200.c            |  630 +++++++++++++++++++++++++++++++++++++++++++++++
 6 ficheiros modificados, 818 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/tpci200.c
default-configs/pci.mak +1 -0
index 69e18f1..7753a4f 100644
@@ -19,3 +19,4 @@ CONFIG_IDE_PCI=y
 CONFIG_AHCI=y
 CONFIG_ESP=y
 CONFIG_ESP_PCI=y
+CONFIG_IPACK=y
hw/Makefile.objs +3 -0
index 7f57ed5..f4a3a9b 100644
@@ -99,6 +99,9 @@ hw-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 
 hw-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
+# IndustryPack
+hw-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+
 # PCI network cards
 hw-obj-$(CONFIG_NE2000_PCI) += ne2000.o
 hw-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
hw/ipack.c new file +106 -0

106 lines not on this page · raw message

hw/ipack.h new file +75 -0

75 lines not on this page · raw message

hw/pci_ids.h +3 -0
index 301bf1c..ef511f6 100644
@@ -128,3 +128,6 @@
 
 #define PCI_VENDOR_ID_NEC                0x1033
 #define PCI_DEVICE_ID_NEC_UPD720200      0x0194
+
+#define PCI_VENDOR_ID_TEWS               0x1498
+#define PCI_DEVICE_ID_TEWS_TPCI200       0x30C8
hw/tpci200.c new file +630 -0

630 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/2 Add IP-Octal 232 IndustryPack emulation

In reply to Alberto Garcia

The IP-Octal 232 is an IndustryPack module that implements eight RS-232 serial ports, each one of which can be redirected to a character device in the host.

---
 hw/Makefile.objs |    2 +-
 hw/ipoctal.c     |  662 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 ficheiros modificados, 663 adições(+), 1 eliminado(-)
 create mode 100644 hw/ipoctal.c
hw/Makefile.objs +1 -1
index f4a3a9b..dfb3042 100644
@@ -100,7 +100,7 @@ hw-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 hw-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
 # IndustryPack
-hw-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+hw-obj-$(CONFIG_IPACK) += tpci200.o ipoctal.o ipack.o
 
 # PCI network cards
 hw-obj-$(CONFIG_NE2000_PCI) += ne2000.o
hw/ipoctal.c new file +662 -0

662 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#4 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Hi,

Am 31.08.2012 16:12, schrieb Alberto Garcia:

Quoted 1 line

Ping

We are currently in Hard Freeze, new devices will not get accepted before the release, and our review may focus on bug fixes.

http://wiki.qemu.org/Planning/1.2

I remember having had a brief look through your patches and they looked pretty good modeling- and style-wise for an initial submission. Don't know the hardware though and haven't tested the patches so far.

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#5 lore raw

[Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Quoted 2 lines · Andreas Färber

We are currently in Hard Freeze, new devices will not get accepted before the release, and our review may focus on bug fixes.

QEMU 1.2 has been released, so here's the new ping.

Patches here:

http://patchwork.ozlabs.org/patch/179657/
http://patchwork.ozlabs.org/patch/179658/

Description:

https://lists.gnu.org/archive/html/qemu-devel/2012-08/msg04173.html

Berto

#6 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

In reply to Andreas Färber
Quoted 11 lines · Andreas Färber
Quoted 1 line

Ping

We are currently in Hard Freeze, new devices will not get accepted before the release, and our review may focus on bug fixes.

http://wiki.qemu.org/Planning/1.2

I remember having had a brief look through your patches and they looked pretty good modeling- and style-wise for an initial submission. Don't know the hardware though and haven't tested the patches so far.

I wrote a small blog post about the work, including a bit more information on how to test it:

http://blogs.igalia.com/berto/2012/10/03/industrypack-qemu-and-linuxcon/

The patches are still available here:

http://patchwork.ozlabs.org/patch/179657/
http://patchwork.ozlabs.org/patch/179658/

Is there anything else I should do in order to have this reviewed, or should I contact someone else?

Thanks!

Berto

#7 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Il 05/10/2012 15:20, Alberto Garcia ha scritto:

Quoted 19 lines · Andreas Färber
Quoted 6 lines
Quoted 2 lines

Ping

We are currently in Hard Freeze, new devices will not get accepted before the release, and our review may focus on bug fixes.

Quoted 6 lines

http://wiki.qemu.org/Planning/1.2

I remember having had a brief look through your patches and they looked pretty good modeling- and style-wise for an initial submission. Don't know the hardware though and haven't tested the patches so far.

I wrote a small blog post about the work, including a bit more information on how to test it:

http://blogs.igalia.com/berto/2012/10/03/industrypack-qemu-and-linuxcon/

Quoted 7 lines

The patches are still available here:

http://patchwork.ozlabs.org/patch/179657/
http://patchwork.ozlabs.org/patch/179658/

Is there anything else I should do in order to have this reviewed, or should I contact someone else?

I think the patches are pretty good, thanks for the contribution! I'm adding another committer to the recipients. Blue, can you take a look?

Paolo

#8 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Quoted 25 lines · Paolo Bonzini

Il 05/10/2012 15:20, Alberto Garcia ha scritto:

Quoted 24 lines · Andreas Färber
Quoted 6 lines
Quoted 2 lines

Ping

We are currently in Hard Freeze, new devices will not get accepted before the release, and our review may focus on bug fixes.

Quoted 6 lines

http://wiki.qemu.org/Planning/1.2

I remember having had a brief look through your patches and they looked pretty good modeling- and style-wise for an initial submission. Don't know the hardware though and haven't tested the patches so far.

I wrote a small blog post about the work, including a bit more information on how to test it:

http://blogs.igalia.com/berto/2012/10/03/industrypack-qemu-and-linuxcon/

The patches are still available here:

http://patchwork.ozlabs.org/patch/179657/
http://patchwork.ozlabs.org/patch/179658/

Quoted 6 lines
Quoted 2 lines

Is there anything else I should do in order to have this reviewed, or should I contact someone else?

I think the patches are pretty good, thanks for the contribution! I'm adding another committer to the recipients. Blue, can you take a look?

I've got them in my testing queue right now.

Regards,

Anthony Liguori

Quoted 2 lines

Paolo

#17 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

In reply to Alberto Garcia

Am 05.10.2012 15:20, schrieb Alberto Garcia:

Quoted 14 lines · Andreas Färber
Quoted 6 lines
Quoted 2 lines

Ping

We are currently in Hard Freeze, new devices will not get accepted before the release, and our review may focus on bug fixes.

Quoted 6 lines

http://wiki.qemu.org/Planning/1.2

I remember having had a brief look through your patches and they looked pretty good modeling- and style-wise for an initial submission. Don't know the hardware though and haven't tested the patches so far.

Quoted 4 lines

I wrote a small blog post about the work, including a bit more information on how to test it:

http://blogs.igalia.com/berto/2012/10/03/industrypack-qemu-and-linuxcon/

Thanks for the illustrative blog post.

One thing caught my eye: Wouldn't it make more sense to call the device "ipoctal232"? Octal doesn't indicate of what there are eight. ;)

Quoted 2 lines

Is there anything else I should do in order to have this reviewed, or should I contact someone else?

Paul and Peter are the ones with experience reviewing UARTs, I think.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#9 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

In reply to Paolo Bonzini
Quoted 22 lines · Paolo Bonzini

Il 05/10/2012 15:20, Alberto Garcia ha scritto:

Quoted 21 lines · Andreas Färber
Quoted 6 lines
Quoted 2 lines

Ping

We are currently in Hard Freeze, new devices will not get accepted before the release, and our review may focus on bug fixes.

Quoted 6 lines

http://wiki.qemu.org/Planning/1.2

I remember having had a brief look through your patches and they looked pretty good modeling- and style-wise for an initial submission. Don't know the hardware though and haven't tested the patches so far.

I wrote a small blog post about the work, including a bit more information on how to test it:

http://blogs.igalia.com/berto/2012/10/03/industrypack-qemu-and-linuxcon/

The patches are still available here:

Quoted 8 lines
Quoted 5 lines

http://patchwork.ozlabs.org/patch/179657/
http://patchwork.ozlabs.org/patch/179658/

Is there anything else I should do in order to have this reviewed, or should I contact someone else?

I think the patches are pretty good, thanks for the contribution! I'm adding another committer to the recipients. Blue, can you take a look?

Endianness looks buggy, there's no way to turn off big endian mode and DEVICE_NATIVE_ENDIAN should probably be DEVICE_LITTLE_ENDIAN.

Indentation of braces in switch cases looks strange.

Pointers to HW documentation and description how to test (or qtests) would be nice.

I'd suppose addressing devices in the bus could be implemented more efficiently with better use of memory API, now some of it is reimplemented. Maybe Avi can propose something?

Quoted 2 lines

Paolo

#10 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Quoted 1 line · Blue Swirl

Endianness looks buggy, there's no way to turn off big endian mode

I double checked the documentation and I think you're right, I can update the patch. Thanks for pointing it out.

Quoted 1 line

DEVICE_NATIVE_ENDIAN should probably be DEVICE_LITTLE_ENDIAN.

Where? In BAR0?

Quoted 1 line

Indentation of braces in switch cases looks strange.

I tried to follow the CODING_STYLE file, but I might have got it wrong, I can change that.

Quoted 2 lines

Pointers to HW documentation and description how to test (or qtests) would be nice.

The documentation is available online:

http://www.tews.com/Products/ArticleGroup/TPCI/TPCI200.html
http://www.mvme.com/manuals/IP-OCTAL-232_UM.pdf
http://www.alldatasheet.com/datasheet-pdf/pdf/19123/PHILIPS/SCC2698B.html

I'm not familiar with qtests, should I take a look at it?

In my blog post (see previous e-mail) there's a brief explanation on how to test it. I can provide with a compiled Linux kernel with the necessary drivers for the guest system if it helps.

A quick way to test it is to redirect one of the IP-Octal serial ports to a pty in the host and open minicom in both sides.

Quoted 3 lines

I'd suppose addressing devices in the bus could be implemented more efficiently with better use of memory API, now some of it is reimplemented. Maybe Avi can propose something?

I'm open to suggestions.

And answering Andreas, yes, the device could be renamed as 'ipoctal232' :)

Thanks,

Berto

#11 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

In reply to Blue Swirl
Quoted 4 lines · Blue Swirl

I'd suppose addressing devices in the bus could be implemented more efficiently with better use of memory API, now some of it is reimplemented. Maybe Avi can propose something?

Luckily the low-order bits are used for offsets, and the high-order bits are used for selecting the sub-device.

So you could easily have

 struct IPackDevice {
     DeviceState qdev;
     int32_t slot;
     /* IRQ objects for the IndustryPack INT0# and INT1# */
     qemu_irq *irq;
     MemoryRegion io_space;
     MemoryRegion id_space;
     MemoryRegion int_space;
     MemoryRegion mem8_space;  /* for las3 */
     MemoryRegion mem16_space; /* for las2 */

};

The PCI device would then just map each space (with memory_region_add_subregion()) into las1/las2/las3 such that the high bits select the device/space. The low bits would automatically become the offset into the space.

Signature · 1 line
error compiling committee.c: too many arguments to function
#12 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Quoted 21 lines · Avi Kivity
Quoted 4 lines · Blue Swirl

I'd suppose addressing devices in the bus could be implemented more efficiently with better use of memory API, now some of it is reimplemented. Maybe Avi can propose something?

Luckily the low-order bits are used for offsets, and the high-order bits are used for selecting the sub-device.

So you could easily have

 struct IPackDevice {
     DeviceState qdev;
     int32_t slot;
     /* IRQ objects for the IndustryPack INT0# and INT1# */
     qemu_irq *irq;
     MemoryRegion io_space;
     MemoryRegion id_space;
     MemoryRegion int_space;
     MemoryRegion mem8_space;  /* for las3 */
     MemoryRegion mem16_space; /* for las2 */
Quoted 6 lines

};

The PCI device would then just map each space (with memory_region_add_subregion()) into las1/las2/las3 such that the high bits select the device/space. The low bits would automatically become the offset into the space.

Note: you can easily verify that the mapping is correct with 'info mtree'. You should see something like:

pci:
...

xxxxxxxx-xxxxxxxx las1
xxxxxxxx-xxxxxxxxx ip0-io
xxxxxxxx-xxxxxxxxx ip0-id
xxxxxxxx-xxxxxxxxx ip0-int
xxxxxxxx-xxxxxxxxx ip1-io
xxxxxxxx-xxxxxxxxx ip1-id
xxxxxxxx-xxxxxxxxx ip1-int
xxxxxxxx-xxxxxxxx las2
xxxxxxxx-xxxxxxxx ip0-mem16
xxxxxxxx-xxxxxxxx ip1-mem16

with the addresses relative to the pci address space.

Signature · 1 line
error compiling committee.c: too many arguments to function
#13 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Quoted 14 lines · Avi Kivity
Quoted 12 lines

So you could easily have

 struct IPackDevice {
     DeviceState qdev;
     int32_t slot;
     /* IRQ objects for the IndustryPack INT0# and INT1# */
     qemu_irq *irq;
     MemoryRegion io_space;
     MemoryRegion id_space;
     MemoryRegion int_space;
     MemoryRegion mem8_space;  /* for las3 */
     MemoryRegion mem16_space; /* for las2 */
Quoted 2 lines

};

Quoted 2 lines

Note: you can easily verify that the mapping is correct with 'info mtree'. You should see something like:

I got the idea, it sounds like a better solution, I'll try to rework the patch with all the proposed changes and post it again, thanks!

Berto

#14 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

In reply to Avi Kivity
Quoted 15 lines · Avi Kivity

Luckily the low-order bits are used for offsets, and the high-order bits are used for selecting the sub-device.

So you could easily have

 struct IPackDevice {
     DeviceState qdev;
     int32_t slot;
     /* IRQ objects for the IndustryPack INT0# and INT1# */
     qemu_irq *irq;
     MemoryRegion io_space;
     MemoryRegion id_space;
     MemoryRegion int_space;
     MemoryRegion mem8_space;  /* for las3 */
     MemoryRegion mem16_space; /* for las2 */
Quoted 6 lines

};

The PCI device would then just map each space (with memory_region_add_subregion()) into las1/las2/las3 such that the high bits select the device/space. The low bits would automatically become the offset into the space.

Hey, I finally found some time to look into this, the problem that I see is that the PCI carrier doesn't just map each space into its local address spaces, in addition to that:

1) it changes the data and addresses according to the endianness configuration in the local configuration registers (PCI BAR0). See adjust_addr()/adjust_value() and page 20 of the user manual.

http://www.tews.com/Products/ArticleGroup/TPCI/TPCI200.html

2) read accesses to the local address space 1 are also used to acknowledge interrupts (manual page 33 and tpci200_read_las1()).

On a related note, I was wondering whether it would be simpler to get rid of tpci200_cfg_ops and replace the current implementation of the local configuration registers with something like this:

memory_region_init_ram_ptr(&s->mmio, "tpci200_mmio", 128, s->local_cfg); memory_region_init_alias(&s->io, "tpci200_io", &s->mmio, 0, 128); pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio);
pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io);

(s->local_cfg would contain the config registers data)

But it doesn't seem to work.

Berto

#15 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Quoted 28 lines · Alberto Garcia
Quoted 15 lines · Avi Kivity

Luckily the low-order bits are used for offsets, and the high-order bits are used for selecting the sub-device.

So you could easily have

 struct IPackDevice {
     DeviceState qdev;
     int32_t slot;
     /* IRQ objects for the IndustryPack INT0# and INT1# */
     qemu_irq *irq;
     MemoryRegion io_space;
     MemoryRegion id_space;
     MemoryRegion int_space;
     MemoryRegion mem8_space;  /* for las3 */
     MemoryRegion mem16_space; /* for las2 */
Quoted 6 lines

};

The PCI device would then just map each space (with memory_region_add_subregion()) into las1/las2/las3 such that the high bits select the device/space. The low bits would automatically become the offset into the space.

Hey, I finally found some time to look into this, the problem that I see is that the PCI carrier doesn't just map each space into its local address spaces, in addition to that:

Quoted 5 lines

1) it changes the data and addresses according to the endianness configuration in the local configuration registers (PCI BAR0). See adjust_addr()/adjust_value() and page 20 of the user manual.

http://www.tews.com/Products/ArticleGroup/TPCI/TPCI200.html

This is supported (albeit not cleanly) by the memory API. There is the MemoryRegionOps::endianess attribute, you can have a mem16_be_space and mem16_le_space; use memory_region_add_subregion()/memory_region_del_subregion() to map le_space or be_space as needed to the BAR.

Quoted 4 lines

2) read accesses to the local address space 1 are also used to acknowledge interrupts (manual page 33 and tpci200_read_las1()).

You can map a small subregion over those addresses. What is the value read? does it need to go to the int space and read it, or is it some fixed value?

Quoted 6 lines

On a related note, I was wondering whether it would be simpler to get rid of tpci200_cfg_ops and replace the current implementation of the local configuration registers with something like this:

Quoted 8 lines

memory_region_init_ram_ptr(&s->mmio, "tpci200_mmio", 128, s->local_cfg); memory_region_init_alias(&s->io, "tpci200_io", &s->mmio, 0, 128); pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio);
pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io);

(s->local_cfg would contain the config registers data)

But it doesn't seem to work.

This is supposed to work. What does 'info mtree' show? What happens if you grow the size up to a page size? Do both BARs fail, or just the IO BAR?

Signature · 1 line
error compiling committee.c: too many arguments to function
#16 lore raw

Re: [Qemu-devel] Ping [PATCH 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Quoted 9 lines · Avi Kivity
Quoted 9 lines

Hey, I finally found some time to look into this, the problem that I see is that the PCI carrier doesn't just map each space into its local address spaces, in addition to that:

1) it changes the data and addresses according to the endianness configuration in the local configuration registers (PCI BAR0). See adjust_addr()/adjust_value() and page 20 of the user manual.

Quoted 7 lines
Quoted 1 line

http://www.tews.com/Products/ArticleGroup/TPCI/TPCI200.html

This is supported (albeit not cleanly) by the memory API. There is the MemoryRegionOps::endianess attribute, you can have a mem16_be_space and mem16_le_space; use memory_region_add_subregion()/memory_region_del_subregion() to map le_space or be_space as needed to the BAR.

I'm not sure if that will work in this case. From the TPCI200 manual:

"Changing Local Space 0, 1 or 2 to Big Endian mode results in swapped
data lines of the local bus:

A 32 bit access is separated by the PCI9030 into two local 16 bit accesses. Byte lane 0 and 1 are swapped, and byte lane 2 and 3 are swapped.

During 16 bit access, the upper and lower bytes are displayed in reverse order.

During 8 bit access odd and even addresses are swapped. To access Address 0x00, the Address 0x01 must be used. An access to Address 0x01 is done by Address 0x00."

32 bit access does not worry me in this case, since it's not used in any local space, but how about 8 bit access? Is the "FIXME: big-endian support" in access_with_adjusted_size() related to this?

Quoted 7 lines
Quoted 3 lines

2) read accesses to the local address space 1 are also used to acknowledge interrupts (manual page 33 and tpci200_read_las1()).

You can map a small subregion over those addresses. What is the value read? does it need to go to the int space and read it, or is it some fixed value?

It needs to go to the int space.

Quoted 6 lines
Quoted 4 lines

memory_region_init_ram_ptr(&s->mmio, "tpci200_mmio", 128, s->local_cfg); memory_region_init_alias(&s->io, "tpci200_io", &s->mmio, 0, 128); pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio);
pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io);

This is supposed to work. What does 'info mtree' show?

pci
0000000000000000-7ffffffffffffffe (prio 0, RW): pci [...]
00000000fb022000-00000000fb02207f (prio 1, RW): tpci200_mmio 00000000fb023000-00000000fb0230ff (prio 1, RW): tpci200_las0 00000000fb024000-00000000fb0243ff (prio 1, RW): tpci200_las1
[...]

tpci200_mmio
00000000fb022000-00000000fb02207f (prio 1, RW): tpci200_mmio

I also tried to debug a bit read accesses to that memory region to see what was going on. For example, when the kernel driver tries to read the config register at PCI BAR0 + 0x2C the call ends up here:

subpage_ram_read (opaque=0x0, addr=0x2C, size=4)

I don't know the internals of the memory handling in QEMU but that call doesn't look right, and the returned valued is indeed wrong.

Quoted 1 line

What happens if you grow the size up to a page size?

So I changed the size to 4K and got this:

kvm_set_phys_mem: error registering slot: Invalid argument Aborted

If I run qemu without -enable-kvm then it appears to work fine (not with the 128 bytes memory region, though).

Quoted 1 line

Do both BARs fail, or just the IO BAR?

I think the kernel driver doesn't use the IO BAR at all, so all my tests are with BAR0.

Berto

#18 lore raw

v2 cover Add TPCI200 and IP-Octal 232 IndustryPack emulation

In reply to Alberto Garcia

Hello again,

I'm sending the new version of my TPCI200 and IP-Octal 232 patches, here's the original submission for reference:

https://lists.gnu.org/archive/html/qemu-devel/2012-08/msg04173.html

It's been a while since I posted the previous patches. I was on holidays for quite some time, plus the trip to the KVM Forum where I could have the chance to meet some of you in person :)

Then came the v1.3 code freeze, so I was making a few changes to both devices since then. These are the changes from the previous version:

* Rebased against the current master. ipoctal renamed to
* ipoctal232. Big-endian mode can now be disabled (tpci200).
* Implemented the RxFIFO (ipoctal232). Simplified the Tx code
* (ipoctal232). Removed the timer (ipoctal232). Rewrote the IRQ
* code (both devices). A few minor bugfixes. Coding style fixes.

The Linux driver is available in the latest mainline kernel (tested with v3.7-rc6).

I also devoted quite some time to testing the code (and fixing a few bugs in the kernel driver along the way). The device has 8 serial ports, I tried them with minicom, pppd, etc and everything seems to work fine.

I also tried attaching 4 instances of ipoctal232 to the tpci200 bridge -32 serial ports in total- and using all of them at the same time and there was nothing unexpected.

As a last thing, I also tried to reorganize the memory addressing using Avi's suggestions but I couldn't come up with a solution to the problems that I described back then. Here's the original thread for reference:

https://lists.gnu.org/archive/html/qemu-devel/2012-10/msg01117.html

I think that's all, if there's any questions please let me know.

Thanks,

Alberto Garcia (2):
Add TEWS TPCI200 IndustryPack emulation
Add GE IP-Octal 232 IndustryPack emulation

 default-configs/pci.mak |    1 +
 hw/Makefile.objs        |    3 +
 hw/ipack.c              |  106 ++++++++
 hw/ipack.h              |   75 ++++++
 hw/ipoctal.c            |  613 +++++++++++++++++++++++++++++++++++++++++++
 hw/pci_ids.h            |    3 +
 hw/tpci200.c            |  667 +++++++++++++++++++++++++++++++++++++++++++++++
 7 ficheiros modificados, 1468 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/ipoctal.c
 create mode 100644 hw/tpci200.c
Signature · 1 line
1.7.10.4
#20 lore raw

PATCH v2 2/2 Add GE IP-Octal 232 IndustryPack emulation

The GE IP-Octal 232 is an IndustryPack module that implements eight RS-232 serial ports, each one of which can be redirected to a character device in the host.

---
 hw/Makefile.objs |    2 +-
 hw/ipoctal.c     |  613 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 ficheiros modificados, 614 adições(+), 1 eliminado(-)
 create mode 100644 hw/ipoctal.c
hw/Makefile.objs +1 -1
index 2ce5ec0..b43a67e 100644
@@ -105,7 +105,7 @@ common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
 # IndustryPack
-common-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+common-obj-$(CONFIG_IPACK) += tpci200.o ipoctal.o ipack.o
 
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
hw/ipoctal.c new file +613 -0

613 lines not on this page · raw message

#19 lore raw

PATCH v2 1/2 Add TEWS TPCI200 IndustryPack emulation

In reply to Alberto Garcia

The TPCI200 is a PCI board that supports up to 4 IndustryPack modules.

A new bus type called 'IndustryPack' has been created so any compatible module can be attached to this board.

---
 default-configs/pci.mak |    1 +
 hw/Makefile.objs        |    3 +
 hw/ipack.c              |  106 ++++++++
 hw/ipack.h              |   75 ++++++
 hw/pci_ids.h            |    3 +
 hw/tpci200.c            |  667 +++++++++++++++++++++++++++++++++++++++++++++++
 6 ficheiros modificados, 855 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/tpci200.c
default-configs/pci.mak +1 -0
index ae9d1eb..ee2d18d 100644
@@ -21,3 +21,4 @@ CONFIG_ESP=y
 CONFIG_ESP_PCI=y
 CONFIG_SERIAL=y
 CONFIG_SERIAL_PCI=y
+CONFIG_IPACK=y
hw/Makefile.objs +3 -0
index d581d8d..2ce5ec0 100644
@@ -104,6 +104,9 @@ common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 
 common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
+# IndustryPack
+common-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
 common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
hw/ipack.c new file +106 -0

106 lines not on this page · raw message

hw/ipack.h new file +75 -0

75 lines not on this page · raw message

hw/pci_ids.h +3 -0
index 5df7245..38d6af5 100644
@@ -145,3 +145,6 @@
 
 #define PCI_VENDOR_ID_NEC                0x1033
 #define PCI_DEVICE_ID_NEC_UPD720200      0x0194
+
+#define PCI_VENDOR_ID_TEWS               0x1498
+#define PCI_DEVICE_ID_TEWS_TPCI200       0x30C8
hw/tpci200.c new file +667 -0

667 lines not on this page · raw message

#21 lore raw
In reply to Alberto Garcia

Hello Alberto,

Am 05.12.2012 14:16, schrieb Alberto Garcia:

Quoted 4 lines

Hello again,

I'm sending the new version of my TPCI200 and IP-Octal 232 patches,

[snip]

You may want to resend v2 as inline patches - Thunderbird for instance doesn't allow to quote / comment on attachments.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#22 lore raw

v3 cover Add TPCI200 and IP-Octal 232 IndustryPack emulation

In reply to Alberto Garcia

As requested by Andreas, I'm sending them again as inline patches.

I also changed the name of the VMStateDescription struct from ipoctal to ipoctal232. Otherwise they're the same.

Regards,

Alberto Garcia (2):
Add TEWS TPCI200 IndustryPack emulation
Add GE IP-Octal 232 IndustryPack emulation

 default-configs/pci.mak |    1 +
 hw/Makefile.objs        |    3 +
 hw/ipack.c              |  106 ++++++++
 hw/ipack.h              |   75 ++++++
 hw/ipoctal.c            |  613 +++++++++++++++++++++++++++++++++++++++++++
 hw/pci_ids.h            |    3 +
 hw/tpci200.c            |  667 +++++++++++++++++++++++++++++++++++++++++++++++
 7 ficheiros modificados, 1468 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/ipoctal.c
 create mode 100644 hw/tpci200.c
Signature · 1 line
1.7.10.4
#23 lore raw

PATCH v3 1/2 Add TEWS TPCI200 IndustryPack emulation

The TPCI200 is a PCI board that supports up to 4 IndustryPack modules.

A new bus type called 'IndustryPack' has been created so any compatible module can be attached to this board.

---
 default-configs/pci.mak |    1 +
 hw/Makefile.objs        |    3 +
 hw/ipack.c              |  106 ++++++++
 hw/ipack.h              |   75 ++++++
 hw/pci_ids.h            |    3 +
 hw/tpci200.c            |  667 +++++++++++++++++++++++++++++++++++++++++++++++
 6 ficheiros modificados, 855 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/tpci200.c
default-configs/pci.mak +1 -0
index ae9d1eb..ee2d18d 100644
@@ -21,3 +21,4 @@ CONFIG_ESP=y
 CONFIG_ESP_PCI=y
 CONFIG_SERIAL=y
 CONFIG_SERIAL_PCI=y
+CONFIG_IPACK=y
hw/Makefile.objs +3 -0
index d581d8d..2ce5ec0 100644
@@ -104,6 +104,9 @@ common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 
 common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
+# IndustryPack
+common-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
 common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
hw/ipack.c new file +106 -0

106 lines not on this page · raw message

hw/ipack.h new file +75 -0

75 lines not on this page · raw message

hw/pci_ids.h +3 -0
index 5df7245..38d6af5 100644
@@ -145,3 +145,6 @@
 
 #define PCI_VENDOR_ID_NEC                0x1033
 #define PCI_DEVICE_ID_NEC_UPD720200      0x0194
+
+#define PCI_VENDOR_ID_TEWS               0x1498
+#define PCI_DEVICE_ID_TEWS_TPCI200       0x30C8
hw/tpci200.c new file +667 -0

667 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#24 lore raw

PATCH v3 2/2 Add GE IP-Octal 232 IndustryPack emulation

In reply to Alberto Garcia

The GE IP-Octal 232 is an IndustryPack module that implements eight RS-232 serial ports, each one of which can be redirected to a character device in the host.

---
 hw/Makefile.objs |    2 +-
 hw/ipoctal.c     |  613 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 ficheiros modificados, 614 adições(+), 1 eliminado(-)
 create mode 100644 hw/ipoctal.c
hw/Makefile.objs +1 -1
index 2ce5ec0..b43a67e 100644
@@ -105,7 +105,7 @@ common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
 # IndustryPack
-common-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+common-obj-$(CONFIG_IPACK) += tpci200.o ipoctal.o ipack.o
 
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
hw/ipoctal.c new file +613 -0

613 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#25 lore raw

Re: [Qemu-devel] Ping [PATCH v3 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

In reply to Alberto Garcia

Ping,

Here's a QEMU image (124 MB) of a Debian system with the tpci200 and ipoctal drivers, in case you want to try them out:

http://dl.dropbox.com/u/1667385/qemu-ipoctal.qcow2

The root password is just 'root'.

The patches for QEMU are here:

http://patchwork.ozlabs.org/patch/203892/
http://patchwork.ozlabs.org/patch/203896/

And you need to run it with these options:

-device tpci200 -device ipoctal232,serialX=DEV

where X is a channel number (from 0 to 7) and DEV a host character device (e.g. "pty").

Regards,

Berto

#26 lore raw

Re: [Qemu-devel] Ping [PATCH v3 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

Quoted 4 lines · Alberto Garcia

Ping,

Here's a QEMU image (124 MB) of a Debian system with the tpci200 and ipoctal drivers, in case you want to try them out:

Please rebase and top-post. Don't send the new series as a response to a previous thread.

Regards,

Anthony Liguori

Quoted 20 lines

http://dl.dropbox.com/u/1667385/qemu-ipoctal.qcow2

The root password is just 'root'.

The patches for QEMU are here:

http://patchwork.ozlabs.org/patch/203892/
http://patchwork.ozlabs.org/patch/203896/

And you need to run it with these options:

-device tpci200 -device ipoctal232,serialX=DEV

where X is a channel number (from 0 to 7) and DEV a host character device (e.g. "pty").

Regards,

Berto