view rvinterf/tmsh/omr.c @ 619:f82551c77e58

libserial-newlnx: ASYNC_LOW_LATENCY patch reverted Reports from Das Signal indicate that loadtools performance on Debian is about the same as on Slackware, and that including or omitting the ASYNC_LOW_LATENCY patch from Serg makes no difference. Because the patch in question does not appear to be necessary, it is being reverted until and unless someone other than Serg reports an actual real-world system on which loadtools operation times are slowed compared to the Mother's Slackware reference and on which Slackware-like performance can be restored by setting the ASYNC_LOW_LATENCY flag.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 27 Feb 2020 01:09:48 +0000
parents 2159f260ed13
children
line wrap: on
line source

/*
 * Old-style memory read command
 */

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include "pktmux.h"
#include "limits.h"
#include "localtypes.h"
#include "tm3.h"
#include "exitcodes.h"

extern u_char rvi_msg[];
extern int rvi_msg_len;

static void
memdump_line(off, inbuf, len)
	u_char *inbuf;
{
	char outbuf[80], *dp;
	int i, c;

	sprintf(outbuf, "omr %02X:  ", off);
	dp = index(outbuf, '\0');
	for (i = 0; i < 16; i++) {
		if (i < len)
			sprintf(dp, "%02X ", inbuf[i]);
		else
			strcpy(dp, "   ");
		dp += 3;
		if (i == 7 || i == 15)
			*dp++ = ' ';
	}
	for (i = 0; i < len; i++) {
		c = inbuf[i];
		if (c < ' ' || c > '~')
			c = '.';
		*dp++ = c;
	}
	*dp = '\0';
	async_msg_output(outbuf);
}

void
handle_omr_response()
{
	int off, len;

	if (rvi_msg[3]) {
		print_etm_pkt_raw("TM3 memread error");
		return;
	}
	if (rvi_msg_len < 10) {
bad:		print_etm_pkt_raw("omr bad resp");
		return;
	}
	if (rvi_msg[5] || rvi_msg[6] || rvi_msg[7])
		goto bad;
	if (rvi_msg_len != rvi_msg[4] + 9)
		goto bad;
	for (off = 0; off < rvi_msg[4]; off += len) {
		len = rvi_msg[4] - off;
		if (len > 16)
			len = 16;
		memdump_line(off, rvi_msg + 8 + off, len);
	}
}

cmd_omr(argc, argv)
	char **argv;
{
	u32 addr, size;
	u_char cmdpkt[11];

	addr = strtoul(argv[1], 0, 16);
	size = strtoul(argv[2], 0, 16);
	if (size < 1 || size > TM3_MEMREAD_MAX) {
		printf("error: count argument outside valid range\n");
		return(ERROR_USAGE);
	}
	cmdpkt[1] = MEM_READ;
	cmdpkt[2] = addr;
	cmdpkt[3] = addr >> 8;
	cmdpkt[4] = addr >> 16;
	cmdpkt[5] = addr >> 24;
	cmdpkt[6] = size;
	cmdpkt[7] = 0;
	cmdpkt[8] = 0;
	cmdpkt[9] = 0;
	send_etm_cmd(cmdpkt, 9);
	return(0);
}