view target-utils/dspdump/dspops.c @ 752:c79aaed75bd8

compile-fc-batt: allow possible third field in source lines Battery tables maintained in the fc-battery-conf repository will now have a third field added, defining thresholds for the battery bars icon, and there will be a new utility to compile them into the new /etc/batterytab2 file read by the FC Tourmaline version of our FCHG driver. For backward compatibility with the original Magnetite version of FCHG, compile-fc-batt remains the tool for compiling the original /etc/batterytab file format, and it needs to ignore the newly added third field in battery table sources.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Nov 2020 20:37:55 +0000
parents 27b5526ba1a8
children
line wrap: on
line source

#include "types.h"
#include "leadapi.h"
#include "dumpagent.h"

wait_for_dsp_ready()
{
	unsigned cnt;

	for (cnt = 0; cnt < 10000; cnt++)
		if (DOWNLOAD_STATUS == LEAD_READY)
			return(0);
	return(-1);
}

boot_dsp_dump_agent()
{
	const u16 *src;
	volatile u16 *api;
	unsigned n;

	/* put it into reset first */
	CLKM_CNTL_RST |= CLKM_LEAD_RST;
	/* generous 1 ms for the reset pulse */
	wait_ARM_cycles(13000);
	/* lift it out of reset */
	CLKM_CNTL_RST &= ~CLKM_LEAD_RST;
	/* another generous 1 ms */
	wait_ARM_cycles(13000);
	/* bootloader should be ready for us now */
	if (wait_for_dsp_ready() < 0) {
		printf("ERROR: DSP bootloader not ready out of reset\n");
		return(-1);
	}
	/* upload the agent code */
	src = dsp_agent_code;
	api = (volatile u16 *) APIF_ADDR;
	for (n = 0; n < DSP_DUMPCODE_LEN; n++)
		*api++ = *src++;
	DOWNLOAD_EXT_PAGE = 0;
	DOWNLOAD_SIZE = DSP_DUMPCODE_LEN;
	DOWNLOAD_ADDR = DSP_DUMPCODE_START;
	DOWNLOAD_STATUS = BLOCK_READY;
	if (wait_for_dsp_ready() < 0) {
		printf("ERROR: DSP bl not ready after block write\n");
		return(-1);
	}
	/* start it! */
	DOWNLOAD_EXT_PAGE = 0;
	DOWNLOAD_SIZE = 0;
	DOWNLOAD_ADDR = DSP_DUMPCODE_START;
	DOWNLOAD_STATUS = BLOCK_READY;
	if (wait_for_dsp_ready() < 0) {
		printf("ERROR: DSP not ready after commanded jump to agent\n");
		return(-1);
	}
}

dsp_read_op(mode, addr, blklen)
	u16 mode, blklen;
	u32 addr;
{
	int rc;

	APIRAM_FIRST_WORD = mode;
	DOWNLOAD_STATUS = PAGE_SELECTION;
	rc = wait_for_dsp_ready();
	if (rc < 0)
		return(rc);
	DOWNLOAD_EXT_PAGE = addr >> 16;
	DOWNLOAD_SIZE = blklen;
	DOWNLOAD_ADDR = addr;
	DOWNLOAD_STATUS = BLOCK_READY;
	rc = wait_for_dsp_ready();
	return(rc);
}