Revision 2c406b8f hw/rtl8139.c
b/hw/rtl8139.c | ||
---|---|---|
47 | 47 |
* Darwin) |
48 | 48 |
*/ |
49 | 49 |
|
50 |
/* For crc32 */ |
|
51 |
#include <zlib.h> |
|
52 |
|
|
50 | 53 |
#include "hw.h" |
51 | 54 |
#include "pci.h" |
52 | 55 |
#include "qemu-timer.h" |
... | ... | |
62 | 65 |
/* debug RTL8139 card C+ mode only */ |
63 | 66 |
//#define DEBUG_RTL8139CP 1 |
64 | 67 |
|
65 |
/* Calculate CRCs properly on Rx packets */ |
|
66 |
#define RTL8139_CALCULATE_RXCRC 1 |
|
67 |
|
|
68 |
#if defined(RTL8139_CALCULATE_RXCRC) |
|
69 |
/* For crc32 */ |
|
70 |
#include <zlib.h> |
|
71 |
#endif |
|
72 |
|
|
73 | 68 |
#define SET_MASKED(input, mask, curr) \ |
74 | 69 |
( ( (input) & ~(mask) ) | ( (curr) & (mask) ) ) |
75 | 70 |
|
... | ... | |
1030 | 1025 |
} |
1031 | 1026 |
|
1032 | 1027 |
/* write checksum */ |
1033 |
#if defined (RTL8139_CALCULATE_RXCRC) |
|
1034 | 1028 |
val = cpu_to_le32(crc32(0, buf, size)); |
1035 |
#else |
|
1036 |
val = 0; |
|
1037 |
#endif |
|
1038 | 1029 |
cpu_physical_memory_write( rx_addr+size, (uint8_t *)&val, 4); |
1039 | 1030 |
|
1040 | 1031 |
/* first segment of received packet flag */ |
... | ... | |
1136 | 1127 |
rtl8139_write_buffer(s, buf, size); |
1137 | 1128 |
|
1138 | 1129 |
/* write checksum */ |
1139 |
#if defined (RTL8139_CALCULATE_RXCRC) |
|
1140 | 1130 |
val = cpu_to_le32(crc32(0, buf, size)); |
1141 |
#else |
|
1142 |
val = 0; |
|
1143 |
#endif |
|
1144 |
|
|
1145 | 1131 |
rtl8139_write_buffer(s, (uint8_t *)&val, 4); |
1146 | 1132 |
|
1147 | 1133 |
/* correct buffer write pointer */ |
Also available in: Unified diff