view ffstools/tiffs-mkfs/ffsparam.c @ 1014:961efadd530a default tip

fc-shell TCH DL handler: add support for CSD modes TCH DL capture mechanism in FC Tourmaline firmware has been extended to support CSD modes in addition to speech - add the necessary support on the host tools side. It needs to be noted that this mechanism in its present state does NOT provide the debug utility value that was sought: as we learned only after the code was implemented, TI's DSP has a misfeature in that the buffer we are reading (a_dd_0[]) is zeroed out when the IDS block is enabled, i.e., we are reading all zeros and not the real DL bits we were after. But since the code has already been written, we are keeping it - perhaps we can do some tests with IDS disabled.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 26 Nov 2024 06:27:43 +0000
parents 178ed445021d
children
line wrap: on
line source

#include <sys/types.h>
#include <sys/param.h>
#include <ctype.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "struct.h"
#include "globals.h"

void
parse_org_arg(arg)
	char *arg;
{
	char *cp;

	cp = index(arg, 'x');
	if (!cp || !isdigit(cp[1]) || !isdigit(arg[0])) {
		fprintf(stderr,
		"error: TIFFS organization argument \"%s\" is invalid\n", arg);
		exit(1);
	}
	*cp++ = '\0';
	if (!strcmp(arg, "8"))
		ffs_sector_size = 0x2000;
	else if (!strcmp(arg, "16"))
		ffs_sector_size = 0x4000;
	else if (!strcmp(arg, "32"))
		ffs_sector_size = 0x8000;
	else if (!strcmp(arg, "64"))
		ffs_sector_size = 0x10000;
	else if (!strcmp(arg, "128"))
		ffs_sector_size = 0x20000;
	else if (!strcmp(arg, "256"))
		ffs_sector_size = 0x40000;
	else {
		fprintf(stderr,
			"error: \"%s\" is not a recognized flash sector size\n",
			arg);
		exit(1);
	}
	ffs_nsectors = atoi(cp);
	if (ffs_nsectors < 3 || ffs_nsectors > 128) {
		fprintf(stderr,
		"error: \"%s\" is not a reasonable number of FFS sectors\n",
			cp);
		exit(1);
	}
}

void
preen_chunk_size_max()
{
	if (chunk_size_max) {
		if (chunk_size_max > ffs_sector_size / 2) {
			fprintf(stderr,
		"error: max chunk size specified with -c is too large\n");
			exit(1);
		}
		return;
	}
	/* default matching TI's code */
	if (ffs_sector_size * ffs_nsectors > 1024*1024)
		chunk_size_max = 8192;
	else if (ffs_sector_size / 8 < 2048)
		chunk_size_max = ffs_sector_size / 8;
	else
		chunk_size_max = 2048;
}

void
preen_journal_size()
{
	if (journal_size)
		return;
	/* default matching TI's code */
	journal_size = ffs_sector_size >> 4;
	if (journal_size < 1024)
		journal_size = 1024;
}

void
preen_block_files_max()
{
	unsigned local_journal_size;

	if (block_files_max)
		return;
	/* default matching TI's code */
	local_journal_size = ffs_sector_size >> 4;
	if (local_journal_size < 1024)
		local_journal_size = 1024;
	block_files_max = (local_journal_size >> 4) - 6;
}