xref: /freebsd/sys/arm/arm/db_disasm.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
16fc729afSOlivier Houchard /*	$NetBSD: db_disasm.c,v 1.4 2003/07/15 00:24:38 lukem Exp $	*/
26fc729afSOlivier Houchard 
3d8315c79SWarner Losh /*-
4*af3dc4a7SPedro F. Giffuni  * SPDX-License-Identifier: BSD-4-Clause
5*af3dc4a7SPedro F. Giffuni  *
66fc729afSOlivier Houchard  * Copyright (c) 1996 Mark Brinicombe.
76fc729afSOlivier Houchard  * Copyright (c) 1996 Brini.
86fc729afSOlivier Houchard  *
96fc729afSOlivier Houchard  * All rights reserved.
106fc729afSOlivier Houchard  *
116fc729afSOlivier Houchard  * Redistribution and use in source and binary forms, with or without
126fc729afSOlivier Houchard  * modification, are permitted provided that the following conditions
136fc729afSOlivier Houchard  * are met:
146fc729afSOlivier Houchard  * 1. Redistributions of source code must retain the above copyright
156fc729afSOlivier Houchard  *    notice, this list of conditions and the following disclaimer.
166fc729afSOlivier Houchard  * 2. Redistributions in binary form must reproduce the above copyright
176fc729afSOlivier Houchard  *    notice, this list of conditions and the following disclaimer in the
186fc729afSOlivier Houchard  *    documentation and/or other materials provided with the distribution.
196fc729afSOlivier Houchard  * 3. All advertising materials mentioning features or use of this software
206fc729afSOlivier Houchard  *    must display the following acknowledgement:
216fc729afSOlivier Houchard  *	This product includes software developed by Brini.
226fc729afSOlivier Houchard  * 4. The name of the company nor the name of the author may be used to
236fc729afSOlivier Houchard  *    endorse or promote products derived from this software without specific
246fc729afSOlivier Houchard  *    prior written permission.
256fc729afSOlivier Houchard  *
266fc729afSOlivier Houchard  * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
276fc729afSOlivier Houchard  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
286fc729afSOlivier Houchard  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
296fc729afSOlivier Houchard  * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
306fc729afSOlivier Houchard  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
316fc729afSOlivier Houchard  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
326fc729afSOlivier Houchard  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
336fc729afSOlivier Houchard  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
346fc729afSOlivier Houchard  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
356fc729afSOlivier Houchard  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
366fc729afSOlivier Houchard  * SUCH DAMAGE.
376fc729afSOlivier Houchard  */
386fc729afSOlivier Houchard 
396fc729afSOlivier Houchard #include <sys/param.h>
406fc729afSOlivier Houchard #include <machine/db_machdep.h>
416fc729afSOlivier Houchard #include <ddb/ddb.h>
426fc729afSOlivier Houchard #include <ddb/db_access.h>
436fc729afSOlivier Houchard #include <ddb/db_sym.h>
446fc729afSOlivier Houchard 
456fc729afSOlivier Houchard #include <machine/disassem.h>
466fc729afSOlivier Houchard 
476fc729afSOlivier Houchard /* Glue code to interface db_disasm to the generic ARM disassembler */
486fc729afSOlivier Houchard 
496fc729afSOlivier Houchard static u_int db_disasm_read_word(u_int);
506fc729afSOlivier Houchard static void db_disasm_printaddr(u_int);
516fc729afSOlivier Houchard 
526fc729afSOlivier Houchard static const disasm_interface_t db_disasm_interface = {
536fc729afSOlivier Houchard 	db_disasm_read_word,
546fc729afSOlivier Houchard 	db_disasm_printaddr,
556fc729afSOlivier Houchard        	db_printf
566fc729afSOlivier Houchard };
576fc729afSOlivier Houchard 
586fc729afSOlivier Houchard static u_int
db_disasm_read_word(u_int address)596fc729afSOlivier Houchard db_disasm_read_word(u_int address)
606fc729afSOlivier Houchard {
616fc729afSOlivier Houchard 
626fc729afSOlivier Houchard 	return db_get_value(address, 4, 0);
636fc729afSOlivier Houchard }
646fc729afSOlivier Houchard 
656fc729afSOlivier Houchard static void
db_disasm_printaddr(u_int address)666fc729afSOlivier Houchard db_disasm_printaddr(u_int address)
676fc729afSOlivier Houchard {
686fc729afSOlivier Houchard 
696fc729afSOlivier Houchard 	db_printsym((db_addr_t)address, DB_STGY_ANY);
706fc729afSOlivier Houchard }
716fc729afSOlivier Houchard 
726fc729afSOlivier Houchard vm_offset_t
db_disasm(vm_offset_t loc,bool altfmt)73cd508278SPedro F. Giffuni db_disasm(vm_offset_t loc, bool altfmt)
746fc729afSOlivier Houchard {
756fc729afSOlivier Houchard 
766fc729afSOlivier Houchard 	return disasm(&db_disasm_interface, loc, altfmt);
776fc729afSOlivier Houchard }
786fc729afSOlivier Houchard 
796fc729afSOlivier Houchard /* End of db_disasm.c */
80