#!/bin/sh

gen_confall_UC7402() {
	echo "# eg: output target-2.0.frm" > ./confall
	echo "# eg: input source-file-name filename versionname version mtdno" >> ./confall

	if [ $OEM -eq 0 ]; then
		echo "output FWR_UC7402_V"$MAJOR"."$MINOR"_Build_"$BUILDTIME >>./confall
	else
		echo "output FWR_UC7402_V"$MAJOR"."$MINOR"."$OEM"_Build_"$BUILDTIME >> ./confall
	fi

	echo "apid 0xE0007402" >> ./confall

	if [ $BOEM -eq 0 ]; then
		echo "input /tftpboot/UC7000_$BMAJOR.$BMINOR.bos redboot bios_ver $BMAJOR.$BMINOR.$BOEM.$BTESTING 0" >> ./confall
	elif [ $BTESTING -eq 0 ]; then
		echo "input /tftpboot/UC7000_$BMAJOR.$BMINOR.$BOEM.bos redboot bios_ver $BMAJOR.$BMINOR.$BOEM.$BTESTING 0" >> ./confall
	else
		echo "input /tftpboot/UC7000_$BMAJOR.$BMINOR.$BOEM.$TESTING.bos redboot bios_ver $BMAJOR.$BMINOR.$BOEM.$BTESTING 0" >> ./confall
	fi

	echo "input /tftpboot/noaddversion/$KERNEL-$MAJOR.$MINOR.$OEM.$TESTING kernel kernel_ver $MAJOR.$MINOR.$OEM.$TESTING 1" >> ./confall

	echo "input /tftpboot/noaddversion/$MXDISK-$MAJOR.$MINOR.$OEM.$TESTING mini-file-system mxdisk_ver $MAJOR.$MINOR.$OEM.$TESTING 2" >> ./confall

	echo "input /tftpboot/noaddversion/$USRDISK-$MAJOR.$MINOR.$OEM.$TESTING user-file-system usrdisk_ver $MAJOR.$MINOR.$OEM.$TESTING 3" >> ./confall

	echo "# You must fix to use 'configuration' file name" >> ./confall
	echo "input ../mkrom/rfis directory dir_ver $MAJOR.$MINOR.$OEM.$TESTING 6" >> ./confall
}

gen_confusrdisk_UC7402() {
	echo "# eg: output target-file-name" > ./confusrdisk
	echo "# eg: input source-file-name filename versionname version mtdno" >> ./confusrdisk

	if [ $OEM -eq 0 ]; then
		echo "output FWR_UC7402_usrdisk_V"$MAJOR"."$MINOR"_Build_"$BUILDTIME >> ./confusrdisk
	else
		echo "output FWR_UC7402_usrdisk_V"$MAJOR"."$MINOR"."$OEM"_Build_"$BUILDTIME >> ./confusrdisk
	fi

	echo "apid 0xE0007402" >> ./confusrdisk

	echo "input /tftpboot/noaddversion/$USRDISK-$MAJOR.$MINOR.$OEM.$TESTING user-file-system usrdisk_ver $MAJOR.$MINOR.$OEM.$TESTING 3" >> ./confusrdisk
}

gen_confhfmall_UC7402() {
	echo "# eg: output target-2.0.hfm" > ./confhfmall
	echo "#input /path/to/input_file filename version MTD_number flashstart flashend flashlength DRAMstartaddr" >> ./confhfmall

	if [ "$OEM" -eq "0" ]; then
		echo "output FWR_UC7402_V"$MAJOR"."$MINOR"_Build_"$BUILDTIME".hfm" >>./confhfmall
	else
		echo "output FWR_UC7402_V"$MAJOR"."$MINOR"."$OEM"_Build_"$BUILDTIME".hfm" >> ./confhfmall
	fi

	echo "apid 0xE0007402" >> ./confhfmall
	echo "modelname UC-74XX-LX" >> ./confhfmall

	echo "input /tftpboot/noaddversion/$KERNEL-$MAJOR.$MINOR.$OEM.$TESTING kernel $MAJOR.$MINOR.$OEM.$TESTING 1 0x50060000 0x50160000 0x00100000 0x00000000" >> ./confhfmall

	echo "input /tftpboot/noaddversion/$MXDISK-$MAJOR.$MINOR.$OEM.$TESTING mini-file-system $MAJOR.$MINOR.$OEM.$TESTING 2 0x50160000 0x50560000 0x00400000 0x00000000" >> ./confhfmall

	echo "input /tftpboot/noaddversion/$USRDISK-$MAJOR.$MINOR.$OEM.$TESTING root-file-system $MAJOR.$MINOR.$OEM.$TESTING 3 0x50560000 0x51F60000 0x01a00000 0x00000000" >> ./confhfmall

}

gen_confhfm_usrdisk_UC7402() {
	echo "# eg: output target-2.0.hfm" > ./confhfm_usrdisk
	echo "#input /path/to/input_file filename version MTD_number flashstart flashend flashlength DRAMstartaddr" >> ./confhfm_usrdisk

	if [ "$OEM" -eq "0" ]; then
		echo "output FWR_UC7402_usrdisk_V"$MAJOR"."$MINOR"_Build_"$BUILDTIME".hfm" >>./confhfm_usrdisk
	else
		echo "output FWR_UC7402_usrdisk_V"$MAJOR"."$MINOR"."$OEM"_Build_"$BUILDTIME".hfm" >> ./confhfm_usrdisk
	fi

	echo "apid 0xE0007402" >> ./confhfm_usrdisk
	echo "modelname UC-74XX-LX" >> ./confhfm_usrdisk

	echo "input ./erase erase $MAJOR.$MINOR.$OEM.$TESTING 3 0x50560000 0x51F60000 0x01a00000 0x00000000" >> ./confhfm_usrdisk
}

# Generate: confall
gen_confall_UC7402

# Generate: confusrdisk
gen_confusrdisk_UC7402

# Generate: confhfmall
gen_confhfmall_UC7402
gen_confhfm_usrdisk_UC7402

./mkfrm confall
./mkfrm confusrdisk
./mkhfm confhfmall
./mkhfm confhfm_usrdisk
mv -f FWR* /tftpboot
