Sridevi Ramesh | 0d88ab3 | 2017-09-21 11:07:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Sridevi Ramesh | 0e4d887 | 2019-01-10 09:06:58 -0600 | [diff] [blame] | 2 | # Refer to help text in the usage function for details. |
Sridevi Ramesh | 0d88ab3 | 2017-09-21 11:07:28 -0500 | [diff] [blame] | 3 | |
| 4 | function usage() |
| 5 | { |
Patrick Williams | 90dfee3 | 2022-12-08 06:52:46 -0600 | [diff] [blame] | 6 | echo |
| 7 | echo "This script runs on HOST OS and gives translated SCOM address." |
| 8 | echo "usage: $0: <scom_addr> <core_id>" |
| 9 | echo |
| 10 | echo " <scom_addr>:" |
| 11 | echo " SCOM address that needs translation (e.g. '10010800')." |
| 12 | echo " <core_id>:" |
| 13 | echo " Core id as obtained from probe_cpu.sh." |
| 14 | echo " Should be between 0-23 (e.g. '0')." |
| 15 | exit 1 |
Sridevi Ramesh | 0d88ab3 | 2017-09-21 11:07:28 -0500 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | [ $# -lt 2 ] && usage |
| 19 | |
| 20 | SCOM_ADDR=$1 |
| 21 | SCOM_ADDR=$(echo $SCOM_ADDR | sed 's/^0x//') |
| 22 | CORE_ID=$2 |
| 23 | CORE_ID=$(echo $CORE_ID | sed 's/^0x//') |
| 24 | |
| 25 | [ $CORE_ID -gt 23 ] && echo "<core-id> should be between 0-23" && exit |
| 26 | |
| 27 | # per Chip level |
| 28 | perl -e '{printf("EQ[%2d]: 0x%x\n", ((('$CORE_ID' & 0x1c)) >> 2), 0x'$SCOM_ADDR' | ((('$CORE_ID' & 0x1c) + 0x40) << 22));}' |
| 29 | perl -e '{printf("EX[%2d]: 0x%x\n", ((('$CORE_ID')) >> 1), (0x'$SCOM_ADDR' | (('$CORE_ID' & 2) << 9 )) | ((('$CORE_ID' & 0x1c) + 0x40) << 22));}' |
| 30 | perl -e '{printf(" C[%2d]: 0x%x\n", '$CORE_ID', 0x'$SCOM_ADDR' | ((('$CORE_ID' & 0x1f) + 0x20) << 24));}' |
| 31 | |
| 32 | |