1282078Szbb/*-
2282078Szbb * Copyright (c) 2015 The FreeBSD Foundation
3282078Szbb * All rights reserved.
4282078Szbb *
5282078Szbb * This software was developed by Semihalf under
6282078Szbb * the sponsorship of the FreeBSD Foundation.
7282078Szbb *
8282078Szbb * Redistribution and use in source and binary forms, with or without
9282078Szbb * modification, are permitted provided that the following conditions
10282078Szbb * are met:
11282078Szbb * 1. Redistributions of source code must retain the above copyright
12282078Szbb *    notice, this list of conditions and the following disclaimer.
13282078Szbb * 2. Redistributions in binary form must reproduce the above copyright
14282078Szbb *    notice, this list of conditions and the following disclaimer in the
15282078Szbb *    documentation and/or other materials provided with the distribution.
16282078Szbb *
17282078Szbb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18282078Szbb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19282078Szbb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20282078Szbb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21282078Szbb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22282078Szbb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23282078Szbb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24282078Szbb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25282078Szbb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26282078Szbb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27282078Szbb * SUCH DAMAGE.
28282078Szbb */
29282078Szbb
30282078Szbb#include <sys/cdefs.h>
31282078Szbb__FBSDID("$FreeBSD$");
32282078Szbb#include <sys/param.h>
33282078Szbb#include <ddb/ddb.h>
34295038Swma#include <ddb/db_access.h>
35295038Swma#include <ddb/db_sym.h>
36282078Szbb
37295038Swma#include <machine/disassem.h>
38295038Swma
39295038Swmastatic u_int db_disasm_read_word(vm_offset_t);
40295038Swmastatic void db_disasm_printaddr(vm_offset_t);
41295038Swma
42295038Swma/* Glue code to interface db_disasm to the generic ARM disassembler */
43295038Swmastatic const struct disasm_interface db_disasm_interface = {
44295432Sandrew	.di_readword = db_disasm_read_word,
45295432Sandrew	.di_printaddr = db_disasm_printaddr,
46295432Sandrew	.di_printf = db_printf,
47295038Swma};
48295038Swma
49295038Swmastatic u_int
50295038Swmadb_disasm_read_word(vm_offset_t address)
51295038Swma{
52295038Swma
53295038Swma	return (db_get_value(address, INSN_SIZE, 0));
54295038Swma}
55295038Swma
56295038Swmastatic void
57295038Swmadb_disasm_printaddr(vm_offset_t address)
58295038Swma{
59295038Swma
60295038Swma	db_printsym((db_addr_t)address, DB_STGY_ANY);
61295038Swma}
62295038Swma
63282078Szbbvm_offset_t
64283248Spfgdb_disasm(vm_offset_t loc, bool altfmt)
65282078Szbb{
66295038Swma
67295038Swma	return (disasm(&db_disasm_interface, loc, altfmt));
68282078Szbb}
69282078Szbb
70282078Szbb/* End of db_disasm.c */
71