view rvinterf/etmsync/dspapidump.c @ 965:2969032bdfac

fcup-smsend[mult]: fix buglet in K&R C NULL pointer passing The only 100% safe way to pass a NULL pointer as a function argument in K&R C is to cast 0 to a pointer type; failing to do so may cause mysterious bugs (invalid stack frames or garbage in argument registers) on 64-bit machines. This issue has already been fixed in most of FC host tools, but I just found some missed spots: passing of NULL UDH to PDU encoding functions in fcup-smsend[mult] in the case of single (not concatenated) SMS.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 01 Sep 2023 07:33:51 +0000
parents e7502631a0f9
children
line wrap: on
line source

/*
 * This utility uses ETM in synchronous mode to read and dump the contents
 * of the DSP API RAM in a target Calypso GSM device while the firmware is
 * running.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdint.h>
#include <endian.h>
#include "exitcodes.h"

#define	APIF_ADDR		0xFFD00000
#define	API_SIZE_IN_WORDS	0x2000

single_op_main()
{
	uint16_t buf[64], *linebase;
	unsigned off;
	int rc, i, j;

	for (off = 0; off < API_SIZE_IN_WORDS; ) {
		rc = do_memory_read_16(APIF_ADDR + off * 2, buf, 0x40);
		if (rc)
			return(rc);
		for (i = 0; i < 8; i++) {
			printf("%04X:", off);
			linebase = buf + i * 8;
			for (j = 0; j < 8; j++)
				printf(" %04X", le16toh(linebase[j]));
			putchar('\n');
			off += 8;
		}
	}
	return(0);
}