Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/arm Make all the disasm_interface_t arguments c...



details:   https://anonhg.NetBSD.org/src/rev/b8fe42d7a3a4
branches:  trunk
changeset: 502197:b8fe42d7a3a4
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Sat Jan 13 16:52:01 2001 +0000

description:
Make all the disasm_interface_t arguments const, thus allowing us to
allocate them statically in the text segment.  Do so for disassemble().

diffstat:

 sys/arch/arm/arm/disassem.c |  35 ++++++++++++++++++-----------------
 sys/arch/arm/arm/disassem.h |   4 ++--
 2 files changed, 20 insertions(+), 19 deletions(-)

diffs (115 lines):

diff -r 4f451f5089fe -r b8fe42d7a3a4 sys/arch/arm/arm/disassem.c
--- a/sys/arch/arm/arm/disassem.c       Sat Jan 13 16:44:25 2001 +0000
+++ b/sys/arch/arm/arm/disassem.c       Sat Jan 13 16:52:01 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disassem.c,v 1.7 2001/01/13 16:44:25 bjh21 Exp $       */
+/*     $NetBSD: disassem.c,v 1.8 2001/01/13 16:52:01 bjh21 Exp $       */
 
 /*
  * Copyright (c) 1996 Mark Brinicombe.
@@ -49,7 +49,7 @@
 
 #include <sys/param.h>
 
-__RCSID("$NetBSD: disassem.c,v 1.7 2001/01/13 16:44:25 bjh21 Exp $");
+__RCSID("$NetBSD: disassem.c,v 1.8 2001/01/13 16:52:01 bjh21 Exp $");
 
 #include <sys/systm.h>
 #include <arch/arm/arm/disassem.h>
@@ -244,15 +244,17 @@
 #define insn_fpaimm(x)         insn_fpaconstants[x & 0x07]
 
 /* Local prototypes */
-static void disasm_register_shift(disasm_interface_t *di, u_int insn);
-static void disasm_print_reglist(disasm_interface_t *di, u_int insn);
-static void disasm_insn_ldrstr(disasm_interface_t *di, u_int insn, u_int loc);
-static void disasm_insn_ldcstc(disasm_interface_t *di, u_int insn, u_int loc);
+static void disasm_register_shift(const disasm_interface_t *di, u_int insn);
+static void disasm_print_reglist(const disasm_interface_t *di, u_int insn);
+static void disasm_insn_ldrstr(const disasm_interface_t *di, u_int insn,
+    u_int loc);
+static void disasm_insn_ldcstc(const disasm_interface_t *di, u_int insn,
+    u_int loc);
 static u_int disassemble_readword(u_int address);
 static void disassemble_printaddr(u_int address);
 
 vm_offset_t
-disasm(disasm_interface_t *di, vm_offset_t loc, int altfmt)
+disasm(const disasm_interface_t *di, vm_offset_t loc, int altfmt)
 {
        struct arm32_insn *i_ptr = (struct arm32_insn *)&arm32_i;
 
@@ -481,7 +483,7 @@
 
 
 static void
-disasm_register_shift(disasm_interface_t *di, u_int insn)
+disasm_register_shift(const disasm_interface_t *di, u_int insn)
 {
        di->di_printf("r%d", (insn & 0x0f));
        if ((insn & 0x00000ff0) == 0)
@@ -500,7 +502,7 @@
 
 
 static void
-disasm_print_reglist(disasm_interface_t *di, u_int insn)
+disasm_print_reglist(const disasm_interface_t *di, u_int insn)
 {
        int loop;
        int start;
@@ -535,7 +537,7 @@
 }
 
 static void
-disasm_insn_ldrstr(disasm_interface_t *di, u_int insn, u_int loc)
+disasm_insn_ldrstr(const disasm_interface_t *di, u_int insn, u_int loc)
 {
        if ((((insn >> 16) & 0x0f) == 15) && ((insn & (1 << 21)) == 0)
            && ((insn & (1 << 24)) != 0) && ((insn & (1 << 25)) == 0)) {
@@ -561,7 +563,7 @@
 
 
 static void
-disasm_insn_ldcstc(disasm_interface_t *di, u_int insn, u_int loc)
+disasm_insn_ldcstc(const disasm_interface_t *di, u_int insn, u_int loc)
 {
        if (((insn >> 8) & 0xf) == 1)
                di->di_printf("f%d, ", (insn >> 12) & 0x07);
@@ -596,16 +598,15 @@
        printf("0x%08x", address);
 }
 
+static const disasm_interface_t disassemble_di = {
+       disassemble_readword, disassemble_printaddr, printf
+};
+
 void
 disassemble(u_int address)
 {
-       disasm_interface_t di;
 
-       di.di_readword = disassemble_readword;
-       di.di_printaddr = disassemble_printaddr;
-       di.di_printf = printf;
-
-       (void)disasm(&di, address, 0);
+       (void)disasm(&disassemble_di, address, 0);
 }
 
 /* End of disassem.c */
diff -r 4f451f5089fe -r b8fe42d7a3a4 sys/arch/arm/arm/disassem.h
--- a/sys/arch/arm/arm/disassem.h       Sat Jan 13 16:44:25 2001 +0000
+++ b/sys/arch/arm/arm/disassem.h       Sat Jan 13 16:52:01 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disassem.h,v 1.2 2001/01/13 16:44:26 bjh21 Exp $       */
+/*     $NetBSD: disassem.h,v 1.3 2001/01/13 16:52:01 bjh21 Exp $       */
 
 /*
  * Copyright (c) 1997 Mark Brinicombe.
@@ -44,5 +44,5 @@
 
 /* Prototypes for callable functions */
 
-vm_offset_t disasm(disasm_interface_t *, vm_offset_t, int);
+vm_offset_t disasm(const disasm_interface_t *, vm_offset_t, int);
 void disassemble(u_int);



Home | Main Index | Thread Index | Old Index