[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/5] [ioemu]: fix declaration after statement
ISO C90 forbids mixed declarations and code. ioemu is compiled with -Wdeclaration-after-statement, so this produces a warning. Moved the declerations to the beginning of a new block. -- Andre Przywara AMD-Operating System Research Center (OSRC), Dresden, Germany Tel: +49 351 277-84917 ----to satisfy European Law for business letters: AMD Saxony Limited Liability Company & Co. KG, Wilschdorfer Landstr. 101, 01109 Dresden, Germany Register Court Dresden: HRA 4896, General Partner authorized to represent: AMD Saxony LLC (Wilmington, Delaware, US) General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy diff -r 0f0d67f29ccb tools/ioemu/hw/es1370.c --- a/tools/ioemu/hw/es1370.c Fri Dec 21 23:58:29 2007 +0100 +++ b/tools/ioemu/hw/es1370.c Tue Jan 08 14:48:38 2008 +0100 @@ -516,9 +516,10 @@ IO_WRITE_PROTO (es1370_writew) IO_WRITE_PROTO (es1370_writew) { ES1370State *s = opaque; - addr = es1370_fixup (s, addr); uint32_t shift, mask; struct chan *d = &s->chan[0]; + + addr = es1370_fixup (s, addr); switch (addr) { case ES1370_REG_CODEC: diff -r 0f0d67f29ccb tools/ioemu/hw/rtl8139.c --- a/tools/ioemu/hw/rtl8139.c Fri Dec 21 23:58:29 2007 +0100 +++ b/tools/ioemu/hw/rtl8139.c Tue Jan 08 14:48:38 2008 +0100 @@ -867,6 +867,7 @@ static void rtl8139_do_receive(void *opa } else if (buf[0] & 0x01) { /* multicast */ + int mcast_idx; if (!(s->RxConfig & AcceptMulticast)) { DEBUG_PRINT((">>> RTL8139: multicast packet rejected\n")); @@ -877,7 +878,7 @@ static void rtl8139_do_receive(void *opa return; } - int mcast_idx = compute_mcast_idx(buf); + mcast_idx = compute_mcast_idx(buf); if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))) { @@ -941,6 +942,12 @@ static void rtl8139_do_receive(void *opa if (rtl8139_cp_receiver_enabled(s)) { + int descriptor; + uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI; + uint32_t rx_space; + target_phys_addr_t rx_addr; + target_phys_addr_t cplus_rx_ring_desc; + DEBUG_PRINT(("RTL8139: in C+ Rx mode ================\n")); /* begin C+ receiver mode */ @@ -958,8 +965,7 @@ static void rtl8139_do_receive(void *opa /* w2 low 32bit of Rx buffer ptr */ /* w3 high 32bit of Rx buffer ptr */ - int descriptor = s->currCPlusRxDesc; - target_phys_addr_t cplus_rx_ring_desc; + descriptor = s->currCPlusRxDesc; cplus_rx_ring_desc = rtl8139_addr64(s->RxRingAddrLO, s->RxRingAddrHI); cplus_rx_ring_desc += 16 * descriptor; @@ -967,7 +973,6 @@ static void rtl8139_do_receive(void *opa DEBUG_PRINT(("RTL8139: +++ C+ mode reading RX descriptor %d from host memory at %08x %08x = %016" PRIx64 "\n", descriptor, s->RxRingAddrHI, s->RxRingAddrLO, (uint64_t)cplus_rx_ring_desc)); - uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI; cpu_physical_memory_read(cplus_rx_ring_desc, (uint8_t *)&val, 4); rxdw0 = le32_to_cpu(val); @@ -997,7 +1002,7 @@ static void rtl8139_do_receive(void *opa return; } - uint32_t rx_space = rxdw0 & CP_RX_BUFFER_SIZE_MASK; + rx_space = rxdw0 & CP_RX_BUFFER_SIZE_MASK; /* TODO: scatter the packet over available receive ring descriptors space */ @@ -1017,7 +1022,7 @@ static void rtl8139_do_receive(void *opa return; } - target_phys_addr_t rx_addr = rtl8139_addr64(rxbufLO, rxbufHI); + rx_addr = rtl8139_addr64(rxbufLO, rxbufHI); /* receive/copy to target memory */ cpu_physical_memory_write( rx_addr, buf, size ); @@ -1104,10 +1109,13 @@ static void rtl8139_do_receive(void *opa } else { + int avail; + uint32_t val; + DEBUG_PRINT(("RTL8139: in ring Rx mode ================\n")); /* begin ring receiver mode */ - int avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize); + avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize); /* if receiver buffer is empty then avail == 0 */ @@ -1127,7 +1135,7 @@ static void rtl8139_do_receive(void *opa packet_header |= (((size+4) << 16) & 0xffff0000); /* write header */ - uint32_t val = cpu_to_le32(packet_header); + val = cpu_to_le32(packet_header); rtl8139_write_buffer(s, (uint8_t *)&val, 4); @@ -1463,12 +1471,13 @@ int rtl8139_config_writeable(RTL8139Stat static void rtl8139_BasicModeCtrl_write(RTL8139State *s, uint32_t val) { + uint32_t mask; val &= 0xffff; DEBUG_PRINT(("RTL8139: BasicModeCtrl register write(w) val=0x%04x\n", val)); /* mask unwriteable bits */ - uint32 mask = 0x4cff; + mask = 0x4cff; if (1 || !rtl8139_config_writeable(s)) { @@ -1515,6 +1524,8 @@ static uint32_t rtl8139_BasicModeStatus_ static void rtl8139_Cfg9346_write(RTL8139State *s, uint32_t val) { + uint32_t opmode, eeprom_val; + val &= 0xff; DEBUG_PRINT(("RTL8139: Cfg9346 write val=0x%02x\n", val)); @@ -1522,8 +1533,8 @@ static void rtl8139_Cfg9346_write(RTL813 /* mask unwriteable bits */ val = SET_MASKED(val, 0x31, s->Cfg9346); - uint32_t opmode = val & 0xc0; - uint32_t eeprom_val = val & 0xf; + opmode = val & 0xc0; + eeprom_val = val & 0xf; if (opmode == 0x80) { /* eeprom access */ @@ -1699,9 +1710,11 @@ static void rtl8139_TxConfig_write(RTL81 static void rtl8139_TxConfig_writeb(RTL8139State *s, uint32_t val) { + uint32_t tc; + DEBUG_PRINT(("RTL8139C TxConfig via write(b) val=0x%02x\n", val)); - uint32_t tc = s->TxConfig; + tc = s->TxConfig; tc &= 0xFFFFFF00; tc |= (val & 0x000000FF); rtl8139_TxConfig_write(s, tc); @@ -1761,6 +1774,9 @@ static void rtl8139_transfer_frame(RTL81 static int rtl8139_transmit_one(RTL8139State *s, int descriptor) { + int txsize; + uint8_t txbuffer[0x2000]; + if (!rtl8139_transmitter_enabled(s)) { DEBUG_PRINT(("RTL8139: +++ cannot transmit from descriptor %d: transmitter disabled\n", @@ -1777,8 +1793,7 @@ static int rtl8139_transmit_one(RTL8139S DEBUG_PRINT(("RTL8139: +++ transmitting from descriptor %d\n", descriptor)); - int txsize = s->TxStatus[descriptor] & 0x1fff; - uint8_t txbuffer[0x2000]; + txsize = s->TxStatus[descriptor] & 0x1fff; DEBUG_PRINT(("RTL8139: +++ transmit reading %d bytes from host memory at 0x%08x\n", txsize, s->TxAddr[descriptor])); @@ -1889,6 +1904,12 @@ static uint16_t ip_checksum(void *data, static int rtl8139_cplus_transmit_one(RTL8139State *s) { + int descriptor; + target_phys_addr_t cplus_tx_ring_desc; + uint32_t val, txdw0,txdw1,txbufLO,txbufHI; + int txsize; + target_phys_addr_t tx_addr; + if (!rtl8139_transmitter_enabled(s)) { DEBUG_PRINT(("RTL8139: +++ C+ mode: transmitter disabled\n")); @@ -1901,10 +1922,9 @@ static int rtl8139_cplus_transmit_one(RT return 0 ; } - int descriptor = s->currCPlusTxDesc; - - target_phys_addr_t cplus_tx_ring_desc = - rtl8139_addr64(s->TxAddr[0], s->TxAddr[1]); + descriptor = s->currCPlusTxDesc; + + cplus_tx_ring_desc = rtl8139_addr64(s->TxAddr[0], s->TxAddr[1]); /* Normal priority ring */ cplus_tx_ring_desc += 16 * descriptor; @@ -1912,7 +1932,6 @@ static int rtl8139_cplus_transmit_one(RT DEBUG_PRINT(("RTL8139: +++ C+ mode reading TX descriptor %d from host memory at %08x0x%08x = 0x%8lx\n", descriptor, s->TxAddr[1], s->TxAddr[0], cplus_tx_ring_desc)); - uint32_t val, txdw0,txdw1,txbufLO,txbufHI; cpu_physical_memory_read(cplus_tx_ring_desc, (uint8_t *)&val, 4); txdw0 = le32_to_cpu(val); @@ -1985,8 +2004,8 @@ static int rtl8139_cplus_transmit_one(RT s->cplus_txbuffer_offset = 0; } - int txsize = txdw0 & CP_TX_BUFFER_SIZE_MASK; - target_phys_addr_t tx_addr = rtl8139_addr64(txbufLO, txbufHI); + txsize = txdw0 & CP_TX_BUFFER_SIZE_MASK; + tx_addr = rtl8139_addr64(txbufLO, txbufHI); /* make sure we have enough space to assemble the packet */ if (!s->cplus_txbuffer) @@ -2058,13 +2077,16 @@ static int rtl8139_cplus_transmit_one(RT /* Now decide if descriptor being processed is holding the last segment of packet */ if (txdw0 & CP_TX_LS) { + uint8_t *saved_buffer; + int saved_size, saved_buffer_len; + DEBUG_PRINT(("RTL8139: +++ C+ Tx mode : descriptor %d is last segment descriptor\n", descriptor)); /* can transfer fully assembled packet */ - uint8_t *saved_buffer = s->cplus_txbuffer; - int saved_size = s->cplus_txbuffer_offset; - int saved_buffer_len = s->cplus_txbuffer_len; + saved_buffer = s->cplus_txbuffer; + saved_size = s->cplus_txbuffer_offset; + saved_buffer_len = s->cplus_txbuffer_len; /* reset the card space to protect from recursive call */ s->cplus_txbuffer = NULL; @@ -2073,6 +2095,13 @@ static int rtl8139_cplus_transmit_one(RT if (txdw0 & (CP_TX_IPCS | CP_TX_UDPCS | CP_TX_TCPCS | CP_TX_LGSEN)) { + int hlen, proto; + uint8_t ip_protocol; + uint16_t ip_data_len; + uint8_t *eth_payload_data; + size_t eth_payload_len; + ip_header *ip; + DEBUG_PRINT(("RTL8139: +++ C+ mode offloaded task checksum\n")); #define ETH_P_IP 0x0800 /* Internet Protocol packet */ @@ -2080,15 +2109,15 @@ static int rtl8139_cplus_transmit_one(RT #define ETH_MTU 1500 /* ip packet header */ - ip_header *ip = 0; - int hlen = 0; - uint8_t ip_protocol = 0; - uint16_t ip_data_len = 0; - - uint8_t *eth_payload_data = 0; - size_t eth_payload_len = 0; - - int proto = be16_to_cpu(*(uint16_t *)(saved_buffer + 12)); + ip = 0; + hlen = 0; + ip_protocol = 0; + ip_data_len = 0; + + eth_payload_data = 0; + eth_payload_len = 0; + + proto = be16_to_cpu(*(uint16_t *)(saved_buffer + 12)); if (proto == ETH_P_IP) { DEBUG_PRINT(("RTL8139: +++ C+ mode has IP packet\n")); @@ -2129,33 +2158,38 @@ static int rtl8139_cplus_transmit_one(RT if ((txdw0 & CP_TX_LGSEN) && ip_protocol == IP_PROTO_TCP) { + int tcp_send_offset; + int send_count; + /* maximum IP header length is 60 bytes */ + uint8_t saved_ip_header[60]; + uint8_t *data_to_checksum; + int tcp_hlen, tcp_data_len, tcp_chunk_size, is_last_frame; + tcp_header *p_tcp_hdr; + #if defined (DEBUG_RTL8139) int large_send_mss = (txdw0 >> 16) & CP_TC_LGSEN_MSS_MASK; #endif DEBUG_PRINT(("RTL8139: +++ C+ mode offloaded task TSO MTU=%d IP data %d frame data %d specified MSS=%d\n", ETH_MTU, ip_data_len, saved_size - ETH_HLEN, large_send_mss)); - int tcp_send_offset = 0; - int send_count = 0; - - /* maximum IP header length is 60 bytes */ - uint8_t saved_ip_header[60]; + tcp_send_offset = 0; + send_count = 0; /* save IP header template; data area is used in tcp checksum calculation */ memcpy(saved_ip_header, eth_payload_data, hlen); /* a placeholder for checksum calculation routine in tcp case */ - uint8_t *data_to_checksum = eth_payload_data + hlen - 12; + data_to_checksum = eth_payload_data + hlen - 12; // size_t data_to_checksum_len = eth_payload_len - hlen + 12; /* pointer to TCP header */ - tcp_header *p_tcp_hdr = (tcp_header*)(eth_payload_data + hlen); - - int tcp_hlen = TCP_HEADER_DATA_OFFSET(p_tcp_hdr); + p_tcp_hdr = (tcp_header*)(eth_payload_data + hlen); + + tcp_hlen = TCP_HEADER_DATA_OFFSET(p_tcp_hdr); /* ETH_MTU = ip header len + tcp header len + payload */ - int tcp_data_len = ip_data_len - tcp_hlen; - int tcp_chunk_size = ETH_MTU - hlen - tcp_hlen; + tcp_data_len = ip_data_len - tcp_hlen; + tcp_chunk_size = ETH_MTU - hlen - tcp_hlen; DEBUG_PRINT(("RTL8139: +++ C+ mode TSO IP data len %d TCP hlen %d TCP data len %d TCP chunk size %d\n", ip_data_len, tcp_hlen, tcp_data_len, tcp_chunk_size)); @@ -2163,10 +2197,13 @@ static int rtl8139_cplus_transmit_one(RT /* note the cycle below overwrites IP header data, but restores it from saved_ip_header before sending packet */ - int is_last_frame = 0; + is_last_frame = 0; for (tcp_send_offset = 0; tcp_send_offset < tcp_data_len; tcp_send_offset += tcp_chunk_size) { + ip_pseudo_header *p_tcpip_hdr; + int tcp_checksum; + int tso_send_size; uint16_t chunk_size = tcp_chunk_size; /* check if this is the last frame */ @@ -2196,14 +2233,14 @@ static int rtl8139_cplus_transmit_one(RT } /* recalculate TCP checksum */ - ip_pseudo_header *p_tcpip_hdr = (ip_pseudo_header *)data_to_checksum; + p_tcpip_hdr = (ip_pseudo_header *)data_to_checksum; p_tcpip_hdr->zeros = 0; p_tcpip_hdr->ip_proto = IP_PROTO_TCP; p_tcpip_hdr->ip_payload = cpu_to_be16(tcp_hlen + chunk_size); p_tcp_hdr->th_sum = 0; - int tcp_checksum = ip_checksum(data_to_checksum, tcp_hlen + chunk_size + 12); + tcp_checksum = ip_checksum(data_to_checksum, tcp_hlen + chunk_size + 12); DEBUG_PRINT(("RTL8139: +++ C+ mode TSO TCP checksum %04x\n", tcp_checksum)); p_tcp_hdr->th_sum = tcp_checksum; @@ -2221,7 +2258,7 @@ static int rtl8139_cplus_transmit_one(RT ip->ip_sum = ip_checksum(eth_payload_data, hlen); DEBUG_PRINT(("RTL8139: +++ C+ mode TSO IP header len=%d checksum=%04x\n", hlen, ip->ip_sum)); - int tso_send_size = ETH_HLEN + hlen + tcp_hlen + chunk_size; + tso_send_size = ETH_HLEN + hlen + tcp_hlen + chunk_size; DEBUG_PRINT(("RTL8139: +++ C+ mode TSO transferring packet size %d\n", tso_send_size)); rtl8139_transfer_frame(s, saved_buffer, tso_send_size, 0); @@ -2235,13 +2272,14 @@ static int rtl8139_cplus_transmit_one(RT } else if (txdw0 & (CP_TX_TCPCS|CP_TX_UDPCS)) { - DEBUG_PRINT(("RTL8139: +++ C+ mode need TCP or UDP checksum\n")); - /* maximum IP header length is 60 bytes */ uint8_t saved_ip_header[60]; + uint8_t *data_to_checksum; + DEBUG_PRINT(("RTL8139: +++ C+ mode need TCP or UDP checksum\n")); + memcpy(saved_ip_header, eth_payload_data, hlen); - uint8_t *data_to_checksum = eth_payload_data + hlen - 12; + data_to_checksum = eth_payload_data + hlen - 12; // size_t data_to_checksum_len = eth_payload_len - hlen + 12; /* add 4 TCP pseudoheader fields */ @@ -2250,36 +2288,44 @@ static int rtl8139_cplus_transmit_one(RT if ((txdw0 & CP_TX_TCPCS) && ip_protocol == IP_PROTO_TCP) { + ip_pseudo_header *p_tcpip_hdr; + tcp_header* p_tcp_hdr; + int tcp_checksum; + DEBUG_PRINT(("RTL8139: +++ C+ mode calculating TCP checksum for packet with %d bytes data\n", ip_data_len)); - ip_pseudo_header *p_tcpip_hdr = (ip_pseudo_header *)data_to_checksum; + p_tcpip_hdr = (ip_pseudo_header *)data_to_checksum; p_tcpip_hdr->zeros = 0; p_tcpip_hdr->ip_proto = IP_PROTO_TCP; p_tcpip_hdr->ip_payload = cpu_to_be16(ip_data_len); - tcp_header* p_tcp_hdr = (tcp_header *) (data_to_checksum+12); + p_tcp_hdr = (tcp_header *) (data_to_checksum+12); p_tcp_hdr->th_sum = 0; - int tcp_checksum = ip_checksum(data_to_checksum, ip_data_len + 12); + tcp_checksum = ip_checksum(data_to_checksum, ip_data_len + 12); DEBUG_PRINT(("RTL8139: +++ C+ mode TCP checksum %04x\n", tcp_checksum)); p_tcp_hdr->th_sum = tcp_checksum; } else if ((txdw0 & CP_TX_UDPCS) && ip_protocol == IP_PROTO_UDP) { + ip_pseudo_header *p_udpip_hdr; + udp_header *p_udp_hdr; + int udp_checksum; + DEBUG_PRINT(("RTL8139: +++ C+ mode calculating UDP checksum for packet with %d bytes data\n", ip_data_len)); - ip_pseudo_header *p_udpip_hdr = (ip_pseudo_header *)data_to_checksum; + p_udpip_hdr = (ip_pseudo_header *)data_to_checksum; p_udpip_hdr->zeros = 0; p_udpip_hdr->ip_proto = IP_PROTO_UDP; p_udpip_hdr->ip_payload = cpu_to_be16(ip_data_len); - udp_header *p_udp_hdr = (udp_header *) (data_to_checksum+12); + p_udp_hdr = (udp_header *) (data_to_checksum+12); p_udp_hdr->uh_sum = 0; - int udp_checksum = ip_checksum(data_to_checksum, ip_data_len + 12); + udp_checksum = ip_checksum(data_to_checksum, ip_data_len + 12); DEBUG_PRINT(("RTL8139: +++ C+ mode UDP checksum %04x\n", udp_checksum)); p_udp_hdr->uh_sum = udp_checksum; @@ -2538,6 +2584,7 @@ static uint32_t rtl8139_IntrMask_read(RT static void rtl8139_IntrStatus_write(RTL8139State *s, uint32_t val) { + uint16_t newStatus; DEBUG_PRINT(("RTL8139: IntrStatus write(w) val=0x%04x\n", val)); #if 0 @@ -2547,7 +2594,7 @@ static void rtl8139_IntrStatus_write(RTL return; #else - uint16_t newStatus = s->IntrStatus & ~val; + newStatus = s->IntrStatus & ~val; /* mask unwriteable bits */ newStatus = SET_MASKED(newStatus, 0x1e00, s->IntrStatus); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |