view target-utils/libcommon/abbcmd.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 44a1de4264d8
children
line wrap: on
line source

/*
 * abbr pg reg		-- read ABB register
 * abbw pg reg val	-- write ABB register
 */

#include <sys/types.h>
#include "types.h"
#include "abbdefs.h"

extern u_long strtoul();

extern u16 abb_reg_read();
extern void abb_reg_write();

void
cmd_abbr(argbulk)
	char *argbulk;
{
	char *argv[3];
	u32 pg, reg, val;

	if (parse_args(argbulk, 2, 2, argv, 0) < 0)
		return;
	pg = strtoul(argv[0], 0, 0);
	reg = strtoul(argv[1], 0, 0);
	if (pg > 2 || reg > 31) {
		printf("ERROR: argument(s) out of range\n");
		return;
	}
	abb_init();
	val = abb_reg_read(PAGE(pg) | reg);
	printf("%03X\n", val);
}

void
cmd_abbw(argbulk)
	char *argbulk;
{
	char *argv[4];
	u32 pg, reg, val;

	if (parse_args(argbulk, 3, 3, argv, 0) < 0)
		return;
	pg = strtoul(argv[0], 0, 0);
	reg = strtoul(argv[1], 0, 0);
	val = strtoul(argv[2], 0, 16);
	if (pg > 2 || reg > 31 || val > 0x3FF) {
		printf("ERROR: argument(s) out of range\n");
		return;
	}
	abb_init();
	abb_reg_write(PAGE(pg) | reg, val);
}