summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2012-11-01 18:11:18 -0400
committerJerome Glisse <jglisse@redhat.com>2012-11-01 18:11:18 -0400
commited4aec6661009eb800f8a30277fa9d547ae7b28e (patch)
tree8e2c3170dfd9d73f03afe02e71739d841d87aed7
parentecac0eab7e47c0f32363d63b64bd45df0e878437 (diff)
add new query program and ignore domain when annoting ib
-rw-r--r--Makefile8
-rw-r--r--rdb.c12
-rw-r--r--rdb.h1
-rw-r--r--rdb_annotateib.c6
-rw-r--r--rdb_queryregname.c65
5 files changed, 88 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 4a67313..864ca46 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,9 @@ CFLAGS = -I . -g -O0 -Wall -std=c99 -D_BSD_SOURCE
SAN_C = rdb_sanitize.c rdb.c
SAN_O = $(SAN_C:.c=.o)
+QUE_C = rdb_queryregname.c rdb.c
+QUE_O = $(QUE_C:.c=.o)
+
RD_C = rdb_read.c rdb.c
RD_O = $(RD_C:.c=.o)
@@ -42,7 +45,7 @@ ANN4_O = $(ANN4_C:.c=.o)
TARGETS = rdb_sanitize rdb_read rdb_preg rdb_build rdb_anotate rdb_build2 \
rdb_update rdb_annotateib rdb_cmpib rdb_annotateib2 rdb_header \
- rdb_missingreg rdb_analyze
+ rdb_missingreg rdb_analyze rdb_queryregname
##### RULES #####
.SUFFIXES:
@@ -94,6 +97,9 @@ rdb_cmpib: $(ICM_O)
rdb_missingreg: $(ANN4_O)
$(CC) -o $@ $(ANN4_O)
+rdb_queryregname: $(QUE_O)
+ $(CC) -o $@ $(QUE_O)
+
clean:
rm -f $(TARGETS)
rm -f *.o
diff --git a/rdb.c b/rdb.c
index d912144..0e487b6 100644
--- a/rdb.c
+++ b/rdb.c
@@ -455,6 +455,18 @@ const struct rdb_reg *rdb_find_reg(struct rdb *rdb, unsigned domain, unsigned of
return NULL;
}
+const struct rdb_reg *rdb_find_reg_any_domain(struct rdb *rdb, unsigned offset)
+{
+ struct rdb_reg *reg;
+
+ LIST_FOR_EACH_ENTRY (reg, &rdb->regs, list) {
+ if (reg->offset == offset) {
+ return reg;
+ }
+ }
+ return NULL;
+}
+
void rdb_init(struct rdb *rdb)
{
list_init_head(&rdb->blocks);
diff --git a/rdb.h b/rdb.h
index 9f2f680..0681f6c 100644
--- a/rdb.h
+++ b/rdb.h
@@ -114,5 +114,6 @@ void rdb_init(struct rdb *rdb);
int rdb_read(struct rdb *rdb, FILE *file);
void rdb_write(FILE *file, struct rdb *rdb);
const struct rdb_reg *rdb_find_reg(struct rdb *rdb, unsigned domain, unsigned offset);
+const struct rdb_reg *rdb_find_reg_any_domain(struct rdb *rdb, unsigned offset);
#endif
diff --git a/rdb_annotateib.c b/rdb_annotateib.c
index 5ab38e5..a0b42bf 100644
--- a/rdb_annotateib.c
+++ b/rdb_annotateib.c
@@ -78,7 +78,7 @@ void annotate(struct rdb *rdb, FILE *file)
offset = (value << 2) + 0x8000;
printf("%s // CFG_OFFSET 0x%08x\n", line, offset);
} else {
- reg = rdb_find_reg(rdb, 0, offset);
+ reg = rdb_find_reg_any_domain(rdb, offset);
if (reg) {
printf("%s // 0x%08x %s\n", line, offset, reg->name);
} else {
@@ -92,7 +92,7 @@ void annotate(struct rdb *rdb, FILE *file)
offset = (value << 2) + 0x28000;
printf("%s // CTX_OFFSET 0x%08x\n", line, offset);
} else {
- reg = rdb_find_reg(rdb, 0, offset);
+ reg = rdb_find_reg_any_domain(rdb, offset);
if (reg) {
printf("%s // 0x%08x %s\n", line, offset, reg->name);
} else {
@@ -108,7 +108,7 @@ void annotate(struct rdb *rdb, FILE *file)
break;
case 0:
default:
- reg = rdb_find_reg(rdb, 0, offset);
+ reg = rdb_find_reg_any_domain(rdb, offset);
if (reg) {
printf("%s // 0x%08x %s\n", line, offset, reg->name);
} else {
diff --git a/rdb_queryregname.c b/rdb_queryregname.c
new file mode 100644
index 0000000..57fa229
--- /dev/null
+++ b/rdb_queryregname.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * author: Jerome Glisse
+ */
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "rdb.h"
+
+int main(int argc, char *argv[])
+{
+ struct rdb rdb;
+ const struct rdb_reg *reg;
+ FILE *file;
+ unsigned offset;
+
+ if (argc != 3) {
+ printf("usage %s rdb ibfile\n", argv[0]);
+ return -1;
+ }
+
+ offset = strtoul(argv[2], NULL, 0);
+ file = fopen(argv[1], "r");
+ if (file == NULL) {
+ fprintf(stderr, "failed reading %s\n", argv[1]);
+ return -1;
+ }
+ rdb_init(&rdb);
+ if (rdb_read(&rdb, file)) {
+ fprintf(stderr, "failed reading %s\n", argv[1]);
+ return -1;
+ }
+ fclose(file);
+
+ reg = rdb_find_reg(&rdb, 0, offset);
+ if (reg) {
+ printf("0x%08x %s\n", offset, reg->name);
+ } else {
+ printf("0x%08x ??\n", offset);
+ }
+}