1129198Scognet/* $NetBSD: db_disasm.c,v 1.4 2003/07/15 00:24:38 lukem Exp $ */ 2129198Scognet 3139735Simp/*- 4129198Scognet * Copyright (c) 1996 Mark Brinicombe. 5129198Scognet * Copyright (c) 1996 Brini. 6129198Scognet * 7129198Scognet * All rights reserved. 8129198Scognet * 9129198Scognet * Redistribution and use in source and binary forms, with or without 10129198Scognet * modification, are permitted provided that the following conditions 11129198Scognet * are met: 12129198Scognet * 1. Redistributions of source code must retain the above copyright 13129198Scognet * notice, this list of conditions and the following disclaimer. 14129198Scognet * 2. Redistributions in binary form must reproduce the above copyright 15129198Scognet * notice, this list of conditions and the following disclaimer in the 16129198Scognet * documentation and/or other materials provided with the distribution. 17129198Scognet * 3. All advertising materials mentioning features or use of this software 18129198Scognet * must display the following acknowledgement: 19129198Scognet * This product includes software developed by Brini. 20129198Scognet * 4. The name of the company nor the name of the author may be used to 21129198Scognet * endorse or promote products derived from this software without specific 22129198Scognet * prior written permission. 23129198Scognet * 24129198Scognet * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED 25129198Scognet * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26129198Scognet * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27129198Scognet * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28129198Scognet * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29129198Scognet * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30129198Scognet * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31129198Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32129198Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33129198Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34129198Scognet * SUCH DAMAGE. 35129198Scognet */ 36129198Scognet 37129198Scognet#include <sys/cdefs.h> 38129198Scognet__FBSDID("$FreeBSD$"); 39129198Scognet#include <sys/param.h> 40129198Scognet#include <machine/db_machdep.h> 41129198Scognet#include <ddb/ddb.h> 42129198Scognet#include <ddb/db_access.h> 43129198Scognet#include <ddb/db_sym.h> 44129198Scognet 45129198Scognet#include <machine/disassem.h> 46129198Scognet 47129198Scognet/* Glue code to interface db_disasm to the generic ARM disassembler */ 48129198Scognet 49129198Scognetstatic u_int db_disasm_read_word(u_int); 50129198Scognetstatic void db_disasm_printaddr(u_int); 51129198Scognet 52129198Scognetstatic const disasm_interface_t db_disasm_interface = { 53236991Simp db_disasm_read_word, 54129198Scognet db_disasm_printaddr, 55129198Scognet db_printf 56129198Scognet}; 57129198Scognet 58129198Scognetstatic u_int 59129198Scognetdb_disasm_read_word(u_int address) 60129198Scognet{ 61129198Scognet 62129198Scognet return db_get_value(address, 4, 0); 63129198Scognet} 64129198Scognet 65129198Scognetstatic void 66129198Scognetdb_disasm_printaddr(u_int address) 67129198Scognet{ 68129198Scognet 69129198Scognet db_printsym((db_addr_t)address, DB_STGY_ANY); 70129198Scognet} 71129198Scognet 72129198Scognetvm_offset_t 73129198Scognetdb_disasm(vm_offset_t loc, boolean_t altfmt) 74129198Scognet{ 75129198Scognet 76129198Scognet return disasm(&db_disasm_interface, loc, altfmt); 77129198Scognet} 78129198Scognet 79129198Scognet/* End of db_disasm.c */ 80