qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] mipsnet incorrect device ID fix
@ 2008-02-22  0:46 Vijay Kumar
  2008-03-13  1:09 ` Aurelien Jarno
  0 siblings, 1 reply; 4+ messages in thread
From: Vijay Kumar @ 2008-02-22  0:46 UTC (permalink / raw)
  To: qemu-devel

The mipsnet device returns wrong values for device ID, since it returns 
the contents of the pointer rather that the contents of the device ID 
string. Also the contents of the string is returned such that the order 
is host endianess dependent. The patch fixes both these issues.

Signed-off-by: Vijay Kumar B. <vijaykumar@bravegnu.org>

--- qemu-orig/hw/mipsnet.c	2007-12-27 11:18:52.000000000 +0530
+++ qemu-mod/hw/mipsnet.c	2008-02-20 20:23:44.000000000 +0530
@@ -101,6 +101,19 @@
      mipsnet_update_irq(s);
  }

+static uint32_t bytes_to_int32(const unsigned char *arr)
+{
+    int i;
+    uint32_t ret = 0;
+    int nbytes = sizeof(int32_t);
+
+    for (i = 0; i < nbytes; i++) {
+	ret = ret << 8 | arr[nbytes - 1 - i];
+    }
+
+    return ret;
+}
+
  static uint32_t mipsnet_ioport_read(void *opaque, uint32_t addr)
  {
      MIPSnetState *s = opaque;
@@ -110,10 +123,10 @@
      addr &= 0x3f;
      switch (addr) {
      case MIPSNET_DEV_ID:
-	ret = *((uint32_t *)&devid);
+	ret = bytes_to_int32(devid);
          break;
      case MIPSNET_DEV_ID + 4:
-	ret = *((uint32_t *)(&devid + 4));
+	ret = bytes_to_int32(devid + 4);
          break;
      case MIPSNET_BUSY:
  	ret = s->busy;

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-03-13  1:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-22  0:46 [Qemu-devel] [PATCH] mipsnet incorrect device ID fix Vijay Kumar
2008-03-13  1:09 ` Aurelien Jarno
2008-03-13  1:18   ` Paul Brook
2008-03-13  1:54     ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).