#!/bin/bash
#./xilinx-reg-read-reader $DEV

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

if [ -z "$1" ]
then
    echo "No device specified. use xilinx0 as deault."
    DEV="xilinx0"
else
    DEV="$1"
fi

if [ -z "$2" ]
then
    echo "No show specified. use sh $DIR/table -15 -red,-green,-blue as deault."
    SHOW="sh $DIR/table -15 -red,-green,-blue"
else
    SHOW="$2"
fi

echo -e "~~~~~~~~~~~~~~~~~~~~~Version Info~~~~~~~~~~~~~~~~~
Ver Compile Date                             \t 0x100  \t $(printf "%x" $($DIR/reg-read $DEV 0x100))
Ver Compile Version                          \t 0x102  \t $(printf '%x' $($DIR/reg-read $DEV 0x102))
~~~~~~~~~~~~~~~~~~~~~Fiber State Info~~~~~~~~~~~~~~~~~
Fiber State                                  \t 0x103  \t $(printf '%x' $($DIR/reg-read $DEV 0x103))
L5 UpdateTime                                \t 0x104  \t $(printf '%d' $($DIR/reg-read $DEV 0x104))
L1 UpdateTime                                \t 0x105  \t $(printf '%d' $($DIR/reg-read $DEV 0x105))
Soft StartDate                               \t 0x106  \t $(printf '%d' $($DIR/reg-read $DEV 0x106))
Dma Out Ready                                \t 0x107  \t $(printf '%d' $($DIR/reg-read $DEV 0x107))

~~~~~~~~~~~~~~~~~~~~~Link connect Info~~~~~~~~~~~~~~~~~
L5_SWITCH                                   \t 0x300  \t $(printf '%x' $($DIR/reg-read $DEV 0x300))
L5_DST_MAC0                                 \t 0x301  \t $(printf '%x' $($DIR/reg-read $DEV 0x301))
L5_DST_MAC1                                 \t 0x302  \t $(printf '%x' $($DIR/reg-read $DEV 0x302))
L5_DST_IP                                   \t 0x303  \t $(printf '%x' $($DIR/reg-read $DEV 0x303))
L5_DST_PORT                                 \t 0x304  \t $(printf '%x' $($DIR/reg-read $DEV 0x304))

L5_SRC_MAC0                                 \t 0x305  \t $(printf '%x' $($DIR/reg-read $DEV 0x305))
L5_SRC_MAC1                                 \t 0x306  \t $(printf '%x' $($DIR/reg-read $DEV 0x306))
L5_SRC_IP                                   \t 0x307  \t $(printf '%x' $($DIR/reg-read $DEV 0x307))
L5_SRC_PORT                                 \t 0x308  \t $(printf '%x' $($DIR/reg-read $DEV 0x308))

L1_SWITCH                                   \t 0x310  \t $(printf '%x' $($DIR/reg-read $DEV 0x310))
L1_DST_MAC0                                 \t 0x311  \t $(printf '%x' $($DIR/reg-read $DEV 0x311))
L1_DST_MAC1                                 \t 0x312  \t $(printf '%x' $($DIR/reg-read $DEV 0x312))
L1_DST_IP                                   \t 0x313  \t $(printf '%x' $($DIR/reg-read $DEV 0x313))
L1_DST_PORT                                 \t 0x314  \t $(printf '%x' $($DIR/reg-read $DEV 0x314))

L1_SRC_MAC0                                 \t 0x315  \t $(printf '%x' $($DIR/reg-read $DEV 0x315))
L1_SRC_MAC1                                 \t 0x316  \t $(printf '%x' $($DIR/reg-read $DEV 0x316))
L1_SRC_IP                                   \t 0x317  \t $(printf '%x' $($DIR/reg-read $DEV 0x317))
L1_SRC_PORT                                 \t 0x318  \t $(printf '%x' $($DIR/reg-read $DEV 0x318))

~~~~~~~~~~~~~~~~~~~~~Level5 Info~~~~~~~~~~~~~~~~~
Global Reset                                 \t 0x10   \t $(printf '%x' $($DIR/reg-read $DEV 0x10))
Global Start                                 \t 0x11   \t $(printf '%x' $($DIR/reg-read $DEV 0x11))
contract_index_pkt_transmit_switch           \t 0x12   \t $(printf '%x' $($DIR/reg-read $DEV 0x12))
Msg Count                                    \t 0x2000 \t $(printf '%x' $($DIR/reg-read $DEV 0x2000))
UDP Count                                    \t 0x2001 \t $(printf '%x' $($DIR/reg-read $DEV 0x2001))
Index Msg Count                              \t 0x2002 \t $(printf '%x' $($DIR/reg-read $DEV 0x2002))
Index Count                                  \t 0x2003 \t $(printf '%x' $($DIR/reg-read $DEV 0x2003))
Single Msg Count                             \t 0x2004 \t $(printf '%x' $($DIR/reg-read $DEV 0x2004))
Single Index Count                           \t 0x2005 \t $(printf '%x' $($DIR/reg-read $DEV 0x2005))
Combine Msg Count                            \t 0x2006 \t $(printf '%x' $($DIR/reg-read $DEV 0x2006))
Combine Index Count                          \t 0x2007 \t $(printf '%x' $($DIR/reg-read $DEV 0x2007))
Raw Index Msg Count                          \t 0x2008 \t $(printf '%x' $($DIR/reg-read $DEV 0x2008))
Raw UDP Count                                \t 0x2009 \t $(printf '%x' $($DIR/reg-read $DEV 0x2009))
Contract Count                               \t 0x200a \t $(printf '%x' $($DIR/reg-read $DEV 0x200a))
DMA Count                                    \t 0x200b \t $(printf '%x' $($DIR/reg-read $DEV 0x200b))
Single InstID Count                          \t 0x200c \t $(printf '%x' $($DIR/reg-read $DEV 0x200c))
Combine InstID Count                         \t 0x200d \t $(printf '%x' $($DIR/reg-read $DEV 0x200d))
Order Count                                  \t 0x200e \t $(printf '%x' $($DIR/reg-read $DEV 0x200e))
Throw Count                                  \t 0x200f \t $(printf '%x' $($DIR/reg-read $DEV 0x200f))
~~~~~~~~~~~~~~~~~~~~~Level1 Info~~~~~~~~~~~~~~~~~
Global Reset                                 \t 0x10   \t $(printf '%x' $($DIR/reg-read $DEV 0x10))
Msg Count                                    \t 0x2100 \t $(printf '%x' $($DIR/reg-read $DEV 0x2100))
UDP Count                                    \t 0x2101 \t $(printf '%x' $($DIR/reg-read $DEV 0x2101))
Index Msg Count                              \t 0x2102 \t $(printf '%x' $($DIR/reg-read $DEV 0x2102))
Index Count                                  \t 0x2103 \t $(printf '%x' $($DIR/reg-read $DEV 0x2103))
Single Msg Count                             \t 0x2104 \t $(printf '%x' $($DIR/reg-read $DEV 0x2104))
Single Index Count                           \t 0x2105 \t $(printf '%x' $($DIR/reg-read $DEV 0x2105))
Combine Msg Count                            \t 0x2106 \t $(printf '%x' $($DIR/reg-read $DEV 0x2106))
Combine Index Count                          \t 0x2107 \t $(printf '%x' $($DIR/reg-read $DEV 0x2107))
Raw Index Msg Count                          \t 0x2108 \t $(printf '%x' $($DIR/reg-read $DEV 0x2108))
Raw UDP Count                                \t 0x2109 \t $(printf '%x' $($DIR/reg-read $DEV 0x2109))
Contract Count                               \t 0x210a \t $(printf '%x' $($DIR/reg-read $DEV 0x210a))
DMA Count                                    \t 0x210b \t $(printf '%x' $($DIR/reg-read $DEV 0x210b))
Single InstID Count                          \t 0x210c \t $(printf '%x' $($DIR/reg-read $DEV 0x210c))
Combine InstID Count                         \t 0x210d \t $(printf '%x' $($DIR/reg-read $DEV 0x210d))
Order Count                                  \t 0x210e \t $(printf '%x' $($DIR/reg-read $DEV 0x210e))
Throw Count                                  \t 0x210f \t $(printf '%x' $($DIR/reg-read $DEV 0x210f))

DMACOPY_UNDERFOLW                           \t 0x4000 \t $(printf '%x' $($DIR/reg-read $DEV 0x4000))
DMACOPY_OVERFLOW                            \t 0x4001 \t $(printf '%x' $($DIR/reg-read $DEV 0x4001))
DMACOPY_THROWCNT00                          \t 0x4002 \t $(printf '%x' $($DIR/reg-read $DEV 0x4002))
DMACOPY_THROWCNT01                          \t 0x4003 \t $(printf '%x' $($DIR/reg-read $DEV 0x4003))
DMACOPY_THROWCNT02                          \t 0x4004 \t $(printf '%x' $($DIR/reg-read $DEV 0x4004))
DMACOPY_THROWCNT03                          \t 0x4005 \t $(printf '%x' $($DIR/reg-read $DEV 0x4005))
DMACOPY_THROWCNT04                          \t 0x4006 \t $(printf '%x' $($DIR/reg-read $DEV 0x4006))
DMACOPY_THROWCNT05                          \t 0x4007 \t $(printf '%x' $($DIR/reg-read $DEV 0x4007))
DMACOPY_THROWCNT06                          \t 0x4008 \t $(printf '%x' $($DIR/reg-read $DEV 0x4008))
DMACOPY_THROWCNT07                          \t 0x4009 \t $(printf '%x' $($DIR/reg-read $DEV 0x4009))
DMACOPY_THROWCNT08                          \t 0x400a \t $(printf '%x' $($DIR/reg-read $DEV 0x400a))
DMACOPY_THROWCNT09                          \t 0x400b \t $(printf '%x' $($DIR/reg-read $DEV 0x400b))
DMACOPY_THROWCNT10                          \t 0x400c \t $(printf '%x' $($DIR/reg-read $DEV 0x400c))
DMACOPY_THROWCNT11                          \t 0x400d \t $(printf '%x' $($DIR/reg-read $DEV 0x400d))
DMACOPY_THROWCNT12                          \t 0x400e \t $(printf '%x' $($DIR/reg-read $DEV 0x400e))
DMACOPY_THROWCNT13                          \t 0x400f \t $(printf '%x' $($DIR/reg-read $DEV 0x400f))
DMACOPY_THROWCNT14                          \t 0x4010 \t $(printf '%x' $($DIR/reg-read $DEV 0x4010))
DMACOPY_THROWCNT15                          \t 0x4011 \t $(printf '%x' $($DIR/reg-read $DEV 0x4011))" | ${SHOW}