From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [6132] target-ppc: fix PowerMAC NVRAM emulation
Date: Fri, 26 Dec 2008 23:05:16 +0000 [thread overview]
Message-ID: <E1LGLk4-0005lT-Bl@cvs.savannah.gnu.org> (raw)
Revision: 6132
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6132
Author: aurel32
Date: 2008-12-26 23:05:15 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
target-ppc: fix PowerMAC NVRAM emulation
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Modified Paths:
--------------
trunk/hw/mac_nvram.c
Modified: trunk/hw/mac_nvram.c
===================================================================
--- trunk/hw/mac_nvram.c 2008-12-24 20:30:01 UTC (rev 6131)
+++ trunk/hw/mac_nvram.c 2008-12-26 23:05:15 UTC (rev 6132)
@@ -40,7 +40,7 @@
struct MacIONVRAMState {
target_phys_addr_t size;
int mem_index;
- uint8_t data[0x2000];
+ uint8_t *data;
};
/* Direct access to NVRAM */
@@ -49,7 +49,7 @@
MacIONVRAMState *s = opaque;
uint32_t ret;
- if (addr < 0x2000)
+ if (addr < s->size)
ret = s->data[addr];
else
ret = -1;
@@ -63,7 +63,7 @@
MacIONVRAMState *s = opaque;
NVR_DPRINTF("write addr %04x val %x\n", addr, val);
- if (addr < 0x2000)
+ if (addr < s->size)
s->data[addr] = val;
}
@@ -73,7 +73,7 @@
{
MacIONVRAMState *s = opaque;
- addr = (addr >> 4) & 0x1fff;
+ addr = (addr >> 4) & (s->size - 1);
s->data[addr] = value;
NVR_DPRINTF("writeb addr %04x val %x\n", (int)addr, value);
}
@@ -83,7 +83,7 @@
MacIONVRAMState *s = opaque;
uint32_t value;
- addr = (addr >> 4) & 0x1fff;
+ addr = (addr >> 4) & (s->size - 1);
value = s->data[addr];
NVR_DPRINTF("readb addr %04x val %x\n", (int)addr, value);
@@ -109,7 +109,13 @@
s = qemu_mallocz(sizeof(MacIONVRAMState));
if (!s)
return NULL;
+ s->data = qemu_mallocz(size);
+ if (!s->data) {
+ qemu_free(s);
+ return NULL;
+ }
s->size = size;
+
s->mem_index = cpu_register_io_memory(0, nvram_read, nvram_write, s);
*mem_index = s->mem_index;
@@ -121,7 +127,7 @@
MacIONVRAMState *s;
s = opaque;
- cpu_register_physical_memory(mem_base, s->size, s->mem_index);
+ cpu_register_physical_memory(mem_base, s->size << 4, s->mem_index);
}
/* Set up a system OpenBIOS NVRAM partition */
reply other threads:[~2008-12-26 23:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1LGLk4-0005lT-Bl@cvs.savannah.gnu.org \
--to=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).