#!/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 1037 >> $1
	/customer/riu_r 1038 >> $1
	/customer/riu_r 103c >> $1
	/customer/riu_r 103e >> $1
	/customer/riu_r 1208 >> $1
	/customer/riu_r 1210 >> $1
	/customer/riu_r 1211 >> $1
	/customer/riu_r 1213 >> $1
	/customer/riu_r 123c >> $1
	/customer/riu_r 123d >> $1
	/customer/riu_r 123e >> $1
	/customer/riu_r 125c >> $1
	/customer/riu_r 1532 >> $1
	/customer/riu_r 1534 >> $1
	/customer/riux32_r 1910 >> $1
}

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

if [ -z $dump_count ];then
	echo "Please run with dump count!"
	echo "./souffle_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!"
