Updated PATCH: hw/rtl8139.c for Sparc (BigEndian) Hosts
Apologies to the list. I forgot to separate out the patches in a more appropriate manner.
Patch 1: qemu-rtl8139-bigend.diff
This fixes the big-endian problem with the hw/rtl8139.c on a Sparc host.
Patch 2: qemu-rtl8139-impv-debug.difff
This is an improved macro for debugging. This patch layers on the first patch.
The above two patches were coded by Igor Kovalenko ([email protected])
Patch 3: qemu-rtl8139-extra-debug.diff
This just adds a lot of debugging that was used to isolate the problem with the big-endian problem, and layers on the first two patches.
Ben
hw/rtl8139.c renamed from hw/rtl8139.c.ORIG +5 -2
@@ -1192,7 +1192,10 @@ s->eeprom.contents[1 ] =0x10ec ; s->eeprom.contents[2 ] =0x8139 ;#endif -memcpy (&s->eeprom.contents[7 ], s->macaddr,6 ); + + s->eeprom.contents[7 ] = s->macaddr[0 ] | s->macaddr[1 ] <<8 ; + s->eeprom.contents[8 ] = s->macaddr[2 ] | s->macaddr[3 ] <<8 ; + s->eeprom.contents[9 ] = s->macaddr[4 ] | s->macaddr[5 ] <<8 ;/* mark all status registers as owned by host */ for (i =0 ; i <4 ; ++i)
@@ -2455,7 +2458,7 @@ {DEBUG_PRINT (("RTL8139: TxAddr write offset=0x%x val=0x%08x\n" , txAddrOffset, val)); - s->TxAddr[txAddrOffset/4 ] =le32_to_cpu (val); + s->TxAddr[txAddrOffset/4 ] = val; }static uint32_t rtl8139_TxAddr_read (RTL8139State *s,uint32_t txAddrOffset)
hw/rtl8139.c renamed from hw/rtl8139.c.ORIG +71 -5
334 lines not on this page · raw message
hw/rtl8139.c renamed from hw/rtl8139.c.ORIG +3 -1
@@ -73,7 +73,9 @@ ( ( input ) & ( size - 1 ) )#if defined (DEBUG_RTL8139 ) -# define DEBUG_PRINT (x) do { printf x ; } while (0) +#include <stdarg.h> +# define DEBUG_PRINT_VA (fmt, ...) do { printf ( "rtl8139.c:%d:%s: " fmt, __LINE__, __FUNCTION__, ## __VA_ARGS__ ); } while (0) +# define DEBUG_PRINT (x) do { DEBUG_PRINT_VA x ; } while (0)#else # define DEBUG_PRINT (x)#endif
Quoted 7 lines · Ben Taylor
Patch 1: qemu-rtl8139-bigend.diff
This fixes the big-endian problem with the
hw/rtl8139.con a Sparc host.
I updated the patch to remove one extra le32 conversion found in rtl8139_TxAddr_read
which is called from i/o read callback.
Signature · 2 lines
Kind regards, Igor V. Kovalenko
rtl8139.c renamed from rtl8139.c.old +6 -3
@@ -1194,7 +1194,10 @@ s->eeprom.contents[1 ] =0x10ec ; s->eeprom.contents[2 ] =0x8139 ;#endif -memcpy (&s->eeprom.contents[7 ], s->macaddr,6 ); + + s->eeprom.contents[7 ] = s->macaddr[0 ] | s->macaddr[1 ] <<8 ; + s->eeprom.contents[8 ] = s->macaddr[2 ] | s->macaddr[3 ] <<8 ; + s->eeprom.contents[9 ] = s->macaddr[4 ] | s->macaddr[5 ] <<8 ;/* mark all status registers as owned by host */ for (i =0 ; i <4 ; ++i)
@@ -2457,12 +2460,12 @@ {DEBUG_PRINT (("RTL8139: TxAddr write offset=0x%x val=0x%08x\n" , txAddrOffset, val)); - s->TxAddr[txAddrOffset/4 ] =le32_to_cpu (val); + s->TxAddr[txAddrOffset/4 ] = val; }static uint32_t rtl8139_TxAddr_read (RTL8139State *s,uint32_t txAddrOffset) { -uint32_t ret =cpu_to_le32 (s->TxAddr[txAddrOffset/4 ]); +uint32_t ret = s->TxAddr[txAddrOffset/4 ];DEBUG_PRINT (("RTL8139: TxAddr read offset=0x%x val=0x%08x\n" , txAddrOffset, ret));