xfree86 use byte access for dword write which will lead to corruption if some MMIO can't support byte access
xserver use an x86 emulator instead of calling VBIOS directly. But I find something wrong when it runs on an test chip. After traced xserver code I have found the root cause. Our VBIOS will access some 32-bit registers through memory mapped IO, but x86emu will translate this into 4 byte-write operations, which would cause an exception.
static void
write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
{
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
if (OFF(addr + 3) > 2) {
V_ADDR_WL(addr, val);
}
#endif
V_ADDR_WB(addr, val);
V_ADDR_WB(addr + 1, val >> 8);
V_ADDR_WB(addr + 2, val >> 16);
V_ADDR_WB(addr + 3, val >> 24);
}
The function write_w also has similar problem. The #if is also very strange and it seems that the author just wants to write a dword directly for little endian case, but misses return command, so the dword will be written twice.