From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EmewW-0007rh-NN for qemu-devel@nongnu.org; Wed, 14 Dec 2005 17:17:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EmewU-0007o7-Eb for qemu-devel@nongnu.org; Wed, 14 Dec 2005 17:17:47 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EmewU-0007ni-6n for qemu-devel@nongnu.org; Wed, 14 Dec 2005 17:17:46 -0500 Received: from [66.93.172.17] (helo=nevyn.them.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1Emeyc-0007Qa-Mf for qemu-devel@nongnu.org; Wed, 14 Dec 2005 17:19:58 -0500 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1Emevp-0005dI-AU for qemu-devel@nongnu.org; Wed, 14 Dec 2005 17:17:05 -0500 Date: Wed, 14 Dec 2005 17:17:05 -0500 From: Daniel Jacobowitz Message-ID: <20051214221705.GA21427@nevyn.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline Subject: [Qemu-devel] ARM ethernet fixes Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This is enough to let me use apt-get within qemu-system-arm :-) What it doesn't have, today, is a hard drive. I have some truly hideous qemu patches, and a Linux block driver that Paul wrote, that use ARM "semihosting" traps to simulate a block device using a host file. Ideally someone'll get around to emulating the Integrator/AP, which has a PCI bus, and then we can do it normally. -- Daniel Jacobowitz CodeSourcery, LLC --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="qemu-arm-ethernet.patch" Index: qemu/hw/smc91c111.c =================================================================== --- qemu.orig/hw/smc91c111.c 2005-12-13 19:31:38.000000000 -0800 +++ qemu/hw/smc91c111.c 2005-12-13 19:32:29.000000000 -0800 @@ -35,8 +35,10 @@ typedef struct { int tx_fifo[NUM_PACKETS]; int rx_fifo_len; int rx_fifo[NUM_PACKETS]; + int tx_fifo_done_len; + int tx_fifo_done[NUM_PACKETS]; /* Packet buffer memory. */ - uint8_t data[2048][NUM_PACKETS]; + uint8_t data[NUM_PACKETS][2048]; uint8_t int_level; uint8_t int_mask; uint8_t macaddr[6]; @@ -128,6 +130,18 @@ static void smc91c111_pop_rx_fifo(smc91c smc91c111_update(s); } +/* Remove an item from the TX completion FIFO. */ +static void smc91c111_pop_tx_fifo_done(smc91c111_state *s) +{ + int i; + + if (s->tx_fifo_done_len == 0) + return; + s->tx_fifo_done_len--; + for (i = 0; i < s->tx_fifo_done_len; i++) + s->tx_fifo_done[i] = s->tx_fifo_done[i + 1]; +} + /* Release the memory allocated to a packet. */ static void smc91c111_release_packet(smc91c111_state *s, int packet) { @@ -184,12 +198,15 @@ static void smc91c111_do_tx(smc91c111_st add_crc = 0; #endif if (s->ctr & CTR_AUTO_RELEASE) + /* Race? */ smc91c111_release_packet(s, packetnum); + else if (s->tx_fifo_done_len < NUM_PACKETS) + s->tx_fifo_done[s->tx_fifo_done_len++] = packetnum; qemu_send_packet(s->vc, p, len); } - s->tx_fifo_len = 0; if ((s->ctr & CTR_AUTO_RELEASE) == 0) s->int_level |= INT_TX; + s->tx_fifo_len = 0; smc91c111_update(s); } @@ -364,6 +381,8 @@ static void smc91c111_writeb(void *opaqu return; case 12: /* Interrupt ACK. */ s->int_level &= ~(value & 0xd6); + if (value & INT_TX) + smc91c111_pop_tx_fifo_done(s); smc91c111_update(s); return; case 13: /* Interrupt mask. */ @@ -473,10 +492,10 @@ static uint32_t smc91c111_readb(void *op case 3: /* Allocation Result. */ return s->tx_alloc; case 4: /* TX FIFO */ - if (s->tx_fifo_len == 0) + if (s->tx_fifo_done_len == 0) return 0x80; else - return s->tx_fifo[0]; + return s->tx_fifo_done[0]; case 5: /* RX FIFO */ if (s->rx_fifo_len == 0) return 0x80; --9jxsPFA5p3P2qPhR--