view rvinterf/tmsh/pktsort.c @ 505:7bf0d909c87e

fc-loadtool flash ID check: change of reset after the check logic This change only affects those flash configurations that have ID checks enabled. The logic for resetting the flash after the ID check has been changed as follows: 1) If the check fails, we return without attempting to reset the flash. 2) If the check is successful, we reset the flash using the configured method (could be AMD or Intel or Intel W30) instead of always doing an AMD flash reset as the original code did.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 27 May 2019 19:58:01 +0000
parents 27c41e4b21ae
children
line wrap: on
line source

/*
 * Here we sort out incoming packets from the target relayed via rvinterf.
 */

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

extern u_char rvi_msg[];
extern int rvi_msg_len;

int got_tm_response;

static void
print_etm_trace()
{
	char buf[MAX_PKT_FROM_TARGET*4];

	strcpy(buf, "ETM Tr: ");
	safe_print_trace(rvi_msg + 7, rvi_msg_len - 7, buf + 8);
	async_msg_output(buf);
}

static void
process_rvt()
{
	u32 useid;

	if (rvi_msg_len < 7) {
		tty_cleanup();
		fprintf(stderr, "Error: rvinterf sent us an invalid RVT msg\n");
		exit(ERROR_RVINTERF);
	}
	useid = rvi_msg[2] << 24 | rvi_msg[3] << 16 | rvi_msg[4] << 8
		| rvi_msg[5];
	switch (useid) {
	case 0:
		handle_useid_0();
		return;
	case ETM_USE_ID:
		print_etm_trace();
		return;
	default:
		tty_cleanup();
		fprintf(stderr, "unexpected fwd of USEID %08X from rvinterf\n",
			useid);
		exit(ERROR_RVINTERF);
	}
}

void
process_pkt_from_target()
{
	switch (rvi_msg[1]) {
	case RVT_RV_HEADER:
		process_rvt();
		return;
	case RVT_TM_HEADER:
		etm_packet_rx();
		got_tm_response = 1;
		return;
	default:
		tty_cleanup();
		fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n",
			rvi_msg[1]);
		exit(ERROR_RVINTERF);
	}
}