#!/bin/sh
#
#    Broadcom Proprietary and Confidential. Copyright © 2018 Broadcom.
#    All Rights Reserved. The term "Broadcom" refers to Broadcom Inc.
#    and/or its subsidiaries.
#

export PATH=$PATH:/fabos/link_bin:/bin:/usr/bin:/sbin:/usr/sbin:/fabos/link_abin:/fabos/link_sbin:/fabos/link_rbin:/fabos/factory:/fabos/xtool

infile=$1
# skip is offset of chip_ver lowest byte which we use to determine chip rev
bs=100000
skip=19  
length=1
tmp=42

# read chip_ver from asic_dump_hdr_t
tmp=`(
  dd bs=1 skip=$skip count=0 2> /dev/null
  dd bs=$bs count=$(($length / $bs)) 2> /dev/null
  dd bs=$(($length % $bs)) count=1 2> /dev/null
) < "$infile"`
rev=$(printf "%b" "${tmp:-\000}" |
          od -t x1 |
          { read offset hex; echo $hex; })

# invoke correct regdecode based on chip_ver 
if [ $rev -eq "0" ]; then 
      /fabos/rbin/c5aregdecode $1 $2 $3 $4
fi
if [ $rev -eq "30" ]; then 
      /fabos/rbin/c5cregdecode $1 $2 $3 $4
fi



