#!/bin/sh

dump_reg() {
	# disp
	cat /proc/mi_modules/mi_disp/debug_hal/cfg >> $1
	cat /proc/mi_modules/mi_disp/debug_hal/clk >> $1
	cat /proc/mi_modules/mi_disp/debug_hal/dbgmg >> $1
	cat /proc/mi_modules/mi_disp/debug_hal/func >> $1
	cat /proc/mi_modules/mi_disp/debug_hal/ints >> $1
	/customer/riu_r 101e >> $1
	/customer/riu_r 1037 >> $1
	/customer/riu_r 1033 >> $1
	/customer/riu_r 1038 >> $1
	/customer/riu_r 103c >> $1
	/customer/riu_r 1137 >> $1
	/customer/riu_r 1150 >> $1
	/customer/riu_r 1151 >> $1
	/customer/riu_r 1152 >> $1
	/customer/riu_r 1153 >> $1
	/customer/riu_r 1154 >> $1
	/customer/riu_r 1156 >> $1
	/customer/riu_r 1157 >> $1
	/customer/riu_r 1158 >> $1
	/customer/riu_r 1160 >> $1
	/customer/riu_r 1161 >> $1
	/customer/riu_r 1162 >> $1
	/customer/riu_r 1170 >> $1
	/customer/riu_r 1171 >> $1
	/customer/riu_r 1172 >> $1
	/customer/riu_r 1173 >> $1
	/customer/riu_r 1174 >> $1
	/customer/riu_r 1175 >> $1
	/customer/riu_r 1176 >> $1
	/customer/riu_r 1177 >> $1
	/customer/riu_r 1178 >> $1
	/customer/riu_r 1179 >> $1
	/customer/riu_r 117a >> $1
	/customer/riu_r 117b >> $1
	/customer/riu_r 117c >> $1
	/customer/riu_r 117d >> $1
	/customer/riu_r 117e >> $1
	/customer/riu_r 117f >> $1
	/customer/riu_r 11cb >> $1
	/customer/riu_r 140d >> $1
	/customer/riu_r 145b >> $1
	/customer/riu_r 1532 >> $1
	/customer/riu_r 1533 >> $1
	/customer/riu_r 1534 >> $1
	/customer/riu_r 1535 >> $1
	/customer/riux32_r 1a38 >> $1
}

auto_run_log_file=$1
dump_count=$2
if [ -z $auto_run_log_file ];then
	echo "Please run with log file name!"
	echo "./jaguar1_disp_reg.sh [log file] [count]"
	exit 1
fi

if [ -z $dump_count ];then
	echo "Please run with dump count!"
	echo "./jaguar1_disp_reg.sh [log file] [count]"
	exit 1
fi

if [ -e $auto_run_log_file ];then
	rm -f $auto_run_log_file
fi

count=0
until [ $count -ge $dump_count ]
do
	echo "dump count:$count"
	echo "dump count:$count" >> $auto_run_log_file
	dump_reg $auto_run_log_file
	let count++
done

echo "Dump success!"
