Discussion:
[edk2] Unaligned I/O ?
Gerd Hoffmann
2012-11-08 20:53:03 UTC
Permalink
Hi,

Is there some way to do _unaligned_ I/O?

Background:

I'm trying to extend the ovmf video driver, so it isn't limited to the
cirrus gfx card but can handle the other vga cards emulated by qemu/kvm
too. The easiest way to get this going is to use the bochs display
interface directly for modesetting.

The problem with that approach is that the data register for the bochs
dispi interface is a 16bit register at a uneven address (0x01CF to be
exact). There seems to be no easy way to do that ...

And, no, splitting that into two 8-byte accesses doesn't cut it, it must
be an outw instruction.

Hints anyone?

thanks,
Gerd

PS: wip patch attached for reference
Andrew Fish
2012-11-08 21:02:48 UTC
Permalink
I can't think of a good way....
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/MdePkg/Library/BaseIoLibIntrinsic/ will ASSERT on misaligned access.

So you can turn off all ASSERT() and DEBUG() macros when you build your module, or you could build versions of the library functions that support unaligned access.

Andrew Fish
Post by Gerd Hoffmann
Hi,
Is there some way to do _unaligned_ I/O?
I'm trying to extend the ovmf video driver, so it isn't limited to the
cirrus gfx card but can handle the other vga cards emulated by qemu/kvm
too. The easiest way to get this going is to use the bochs display
interface directly for modesetting.
The problem with that approach is that the data register for the bochs
dispi interface is a 16bit register at a uneven address (0x01CF to be
exact). There seems to be no easy way to do that ...
And, no, splitting that into two 8-byte accesses doesn't cut it, it must
be an outw instruction.
Hints anyone?
thanks,
Gerd
PS: wip patch attached for reference
<0001-wip-QemuVideo-add-qemu-standard-vga-support.patch>------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_nov_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Jordan Justen
2012-11-08 21:23:27 UTC
Permalink
Post by Gerd Hoffmann
Is there some way to do _unaligned_ I/O?
Seems like you're going to need to:
* Pull IoRead/Write16 from MdePkg/Library/BaseIoLibIntrinsic into the driver.
* Rename to UnalignedIoRead/Write16 and remove the alignment assert
* Read the BAR to get the address
* Use UnalignedIoRead/Write16

-Jordan
Post by Gerd Hoffmann
I'm trying to extend the ovmf video driver, so it isn't limited to the
cirrus gfx card but can handle the other vga cards emulated by qemu/kvm
too. The easiest way to get this going is to use the bochs display
interface directly for modesetting.
The problem with that approach is that the data register for the bochs
dispi interface is a 16bit register at a uneven address (0x01CF to be
exact). There seems to be no easy way to do that ...
And, no, splitting that into two 8-byte accesses doesn't cut it, it must
be an outw instruction.
Hints anyone?
thanks,
Gerd
PS: wip patch attached for reference
Gerd Hoffmann
2012-11-08 22:17:05 UTC
Permalink
Post by Jordan Justen
* Pull IoRead/Write16 from MdePkg/Library/BaseIoLibIntrinsic into the driver.
* Rename to UnalignedIoRead/Write16 and remove the alignment assert
* Read the BAR to get the address
* Use UnalignedIoRead/Write16
Whoa, straight to the lowest level. But works fine. Adds gcc
dependency though. Incremental patch attached FYI.

thanks,
Gerd
Paolo Bonzini
2012-11-09 23:30:56 UTC
Permalink
Post by Gerd Hoffmann
Post by Jordan Justen
* Pull IoRead/Write16 from MdePkg/Library/BaseIoLibIntrinsic into the driver.
* Rename to UnalignedIoRead/Write16 and remove the alignment assert
* Read the BAR to get the address
* Use UnalignedIoRead/Write16
Whoa, straight to the lowest level. But works fine. Adds gcc
dependency though. Incremental patch attached FYI.
Can you just mandate a newer QEMU for this device, and use the saner BAR
you added, that doesn't require unaligned accesses?

Paolo
Gerd Hoffmann
2012-11-12 09:54:54 UTC
Permalink
Post by Paolo Bonzini
Post by Gerd Hoffmann
Post by Jordan Justen
* Pull IoRead/Write16 from MdePkg/Library/BaseIoLibIntrinsic into the driver.
* Rename to UnalignedIoRead/Write16 and remove the alignment assert
* Read the BAR to get the address
* Use UnalignedIoRead/Write16
Whoa, straight to the lowest level. But works fine. Adds gcc
dependency though. Incremental patch attached FYI.
Can you just mandate a newer QEMU for this device, and use the saner BAR
you added, that doesn't require unaligned accesses?
That works for the standard vga card, but not the other vga cards we
have (vmware, qxl).

Nevertheless fixing this on the qemu side is an option, just need to
mirror the bochs dispi data register on a aligned address. qemu already
uses another address for !x86 archs exactly because of the alignment issue.

cheers,
Gerd

Loading...