From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nz7DD-0000P5-0U for qemu-devel@nongnu.org; Tue, 06 Apr 2010 07:44:55 -0400 Received: from [140.186.70.92] (port=35046 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nz7DA-0000Ow-DB for qemu-devel@nongnu.org; Tue, 06 Apr 2010 07:44:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nz7D8-0000Hq-MI for qemu-devel@nongnu.org; Tue, 06 Apr 2010 07:44:52 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:50867) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nz7D8-0000Gz-Ar for qemu-devel@nongnu.org; Tue, 06 Apr 2010 07:44:50 -0400 From: Stefan Weil Date: Tue, 6 Apr 2010 13:44:01 +0200 Message-Id: <1270554249-24861-2-git-send-email-weil@mail.berlios.de> In-Reply-To: <1270554249-24861-1-git-send-email-weil@mail.berlios.de> References: <1270554249-24861-1-git-send-email-weil@mail.berlios.de> Subject: [Qemu-devel] [PATCH 1/9] eepro100: Don't allow writing SCBStatus List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers Cc: "Michael S. Tsirkin" SCBStatus is readonly, but most drivers which were derived from the old Linux eepro100.c do a word write to this address when they want to acknowledge interrupts. So we have to mask these writes here. The patch also removes old unused code for status read / write. Signed-off-by: Stefan Weil --- hw/eepro100.c | 49 +++++-------------------------------------------- 1 files changed, 5 insertions(+), 44 deletions(-) diff --git a/hw/eepro100.c b/hw/eepro100.c index 7db6fb5..0415132 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -237,10 +237,6 @@ typedef struct { /* Statistical counters. Also used for wake-up packet (i82559). */ eepro100_stats_t statistics; -#if 0 - uint16_t status; -#endif - /* Configuration bytes. */ uint8_t configuration[22]; @@ -693,21 +689,6 @@ static char *regname(uint32_t addr) } #endif /* DEBUG_EEPRO100 */ -#if 0 -static uint16_t eepro100_read_status(EEPRO100State * s) -{ - uint16_t val = s->status; - TRACE(OTHER, logout("val=0x%04x\n", val)); - return val; -} - -static void eepro100_write_status(EEPRO100State * s, uint16_t val) -{ - TRACE(OTHER, logout("val=0x%04x\n", val)); - s->status = val; -} -#endif - /***************************************************************************** * * Command emulation. @@ -1364,15 +1345,7 @@ static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr) switch (addr) { case SCBStatus: -#if 0 - val = eepro100_read_status(s); -#endif - TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val)); - break; case SCBAck: -#if 0 - val = eepro100_read_status(s); -#endif TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val)); break; case SCBCmd: @@ -1415,9 +1388,6 @@ static uint16_t eepro100_read2(EEPRO100State * s, uint32_t addr) switch (addr) { case SCBStatus: -#if 0 - val = eepro100_read_status(s); -#endif case SCBCmd: TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val)); break; @@ -1441,9 +1411,6 @@ static uint32_t eepro100_read4(EEPRO100State * s, uint32_t addr) switch (addr) { case SCBStatus: -#if 0 - val = eepro100_read_status(s); -#endif TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val)); break; case SCBPointer: @@ -1468,7 +1435,8 @@ static uint32_t eepro100_read4(EEPRO100State * s, uint32_t addr) static void eepro100_write1(EEPRO100State * s, uint32_t addr, uint8_t val) { - if (addr <= sizeof(s->mem) - sizeof(val)) { + /* SCBStatus is readonly. */ + if (addr > SCBStatus && addr <= sizeof(s->mem) - sizeof(val)) { memcpy(&s->mem[addr], &val, sizeof(val)); } @@ -1476,9 +1444,6 @@ static void eepro100_write1(EEPRO100State * s, uint32_t addr, uint8_t val) switch (addr) { case SCBStatus: -#if 0 - eepro100_write_status(s, val); -#endif break; case SCBAck: eepro100_acknowledge(s); @@ -1510,7 +1475,8 @@ static void eepro100_write1(EEPRO100State * s, uint32_t addr, uint8_t val) static void eepro100_write2(EEPRO100State * s, uint32_t addr, uint16_t val) { - if (addr <= sizeof(s->mem) - sizeof(val)) { + /* SCBStatus is readonly. */ + if (addr > SCBStatus && addr <= sizeof(s->mem) - sizeof(val)) { memcpy(&s->mem[addr], &val, sizeof(val)); } @@ -1518,9 +1484,7 @@ static void eepro100_write2(EEPRO100State * s, uint32_t addr, uint16_t val) switch (addr) { case SCBStatus: -#if 0 - eepro100_write_status(s, val); -#endif + s->mem[SCBAck] = (val >> 8); eepro100_acknowledge(s); break; case SCBCmd: @@ -1908,9 +1872,6 @@ static const VMStateDescription vmstate_eepro100 = { VMSTATE_UINT32(statistics.fc_rcv_unsupported, EEPRO100State), VMSTATE_UINT16(statistics.xmt_tco_frames, EEPRO100State), VMSTATE_UINT16(statistics.rcv_tco_frames, EEPRO100State), -#if 0 - VMSTATE_UINT16(status, EEPRO100State), -#endif /* Configuration bytes. */ VMSTATE_BUFFER(configuration, EEPRO100State), VMSTATE_END_OF_LIST() -- 1.7.0