aboutsummaryrefslogtreecommitdiffstats
path: root/hw/goldfish_memlog.c
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:32 -0800
commit8b23a6c7e1aee255004dd19098d4c2462b61b849 (patch)
tree7a4d682ba51f0ff0364c5ca2509f515bdaf96de9 /hw/goldfish_memlog.c
parentf721e3ac031f892af46f255a47d7f54a91317b30 (diff)
downloadexternal_qemu-8b23a6c7e1aee255004dd19098d4c2462b61b849.zip
external_qemu-8b23a6c7e1aee255004dd19098d4c2462b61b849.tar.gz
external_qemu-8b23a6c7e1aee255004dd19098d4c2462b61b849.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'hw/goldfish_memlog.c')
-rw-r--r--hw/goldfish_memlog.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/hw/goldfish_memlog.c b/hw/goldfish_memlog.c
new file mode 100644
index 0000000..98fcffc
--- /dev/null
+++ b/hw/goldfish_memlog.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 2007-2008 The Android Open Source Project
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+*/
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "qemu_file.h"
+#include "goldfish_device.h"
+#include "audio/audio.h"
+
+extern void dprint(const char* fmt, ...);
+
+int fd = -1;
+
+static uint32_t memlog_read(void *opaque, target_phys_addr_t offset)
+{
+ struct goldfish_device *dev = opaque;
+ offset -= dev->base;
+
+ return 0;
+}
+
+unsigned info[8];
+
+static void memlog_write(void *opaque, target_phys_addr_t offset, uint32_t val)
+{
+ char buf[128];
+ struct goldfish_device *dev = opaque;
+ offset -= dev->base;
+
+ info[offset / 4] = val;
+
+ if (offset == 0) {
+ /* write PID and VADDR to logfile */
+ sprintf(buf,"%08x %08x\n", info[0], info[1]);
+ write(fd, buf, strlen(buf));
+ }
+}
+
+
+static CPUReadMemoryFunc *memlog_readfn[] = {
+ memlog_read,
+ memlog_read,
+ memlog_read
+};
+
+static CPUWriteMemoryFunc *memlog_writefn[] = {
+ memlog_write,
+ memlog_write,
+ memlog_write
+};
+
+struct goldfish_device memlog_dev;
+
+void goldfish_memlog_init(uint32_t base)
+{
+ struct goldfish_device *dev = &memlog_dev;
+
+ dev->name = "goldfish_memlog";
+ dev->id = 0;
+ dev->base = base;
+ dev->size = 0x1000;
+ dev->irq_count = 0;
+
+ fd = open("mem.log", /* O_CREAT | */ O_TRUNC | O_WRONLY, 0644);
+
+ goldfish_device_add(dev, memlog_readfn, memlog_writefn, dev);
+}
+