1 /* Calypso TPU debugger, displays and decodes TPU instruction RAM */
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <osmocore/msgb.h>
29 /* TPU disassembler begin */
31 static const char *tpu_instr_name[] = {
42 static const char *tpu_addr_name[0x1f] = {
54 [0x10] = "DSP_INT_PG",
55 [0x11] = "GAUGING_EN",
58 static uint8_t tpu_reg_cache[0x1f];
59 static uint16_t tpu_qbit;
61 static void tpu_show_instr(uint16_t tpu)
63 uint16_t instr = tpu >> 13;
64 uint16_t param = tpu & 0x1fff;
65 uint16_t addr, data, bitlen;
70 printf("\t %04u %04x %s ", tpu_qbit, tpu, tpu_instr_name[instr]);
91 tpu_reg_cache[addr] = data;
92 printf("%10s=0x%04x ", tpu_addr_name[addr], data);
95 bitlen = (data & 0x1f) + 1;
96 printf("DEV_IDX=%u, BITLEN=%u ", data >> 5, bitlen);
98 tsp_data = tpu_reg_cache[4];
99 printf(" TSP_DATA=0x%02x ", tsp_data);
100 } else if (bitlen <= 16) {
101 tsp_data = tpu_reg_cache[3];
102 tsp_data |= tpu_reg_cache[4] << 8;
103 printf(" TSP_DATA=0x%04x ", tsp_data);
104 } else if (bitlen <= 24) {
105 tsp_data = tpu_reg_cache[2];
106 tsp_data |= tpu_reg_cache[3] << 8;
107 tsp_data |= tpu_reg_cache[4] << 16;
108 printf(" TSP_DATA=0x%06x ", tsp_data);
110 tsp_data = tpu_reg_cache[5];
111 tsp_data |= tpu_reg_cache[2] << 8;
112 tsp_data |= tpu_reg_cache[3] << 16;
113 tsp_data |= tpu_reg_cache[4] << 24;
114 printf(" TSP_DATA=0x%08x ", tsp_data);
128 void hdlc_tpudbg_cb(uint8_t dlci, struct msgb *msg)
130 uint32_t *fn = (uint32_t *) msg->data;
133 printf("TPU FN %u\n", *fn);
134 for (tpu = (uint16_t *) (msg->data + 4); tpu < (uint16_t *) msg->tail; tpu++)
135 tpu_show_instr(*tpu);