view target-utils/dspdump/dspops.c @ 926:6a0aa8d36d06

rvinterf backslash escape: introduce libprint The new helper function library named libprint is meant to replace the badly misnamed libg23, and will soon contain functions for printing all of the same kinds of GPF TST packets that are now handled in libg23. However, we are also moving safe_print_trace() from libasync to this new library, and changing it to emit our new backslash escape format.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 23 May 2023 03:47:46 +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);
}