diff options
author | William Bryan <wilbryan@us.ibm.com> | 2016-10-05 15:32:32 -0500 |
---|---|---|
committer | William A. Bryan <wilbryan@us.ibm.com> | 2016-10-14 17:35:17 -0400 |
commit | 055aad1e072a479e2f7ab89f60e75ff2ad6c85d6 (patch) | |
tree | 3d41ad9da905f301dd9ed2a7d46d5e6391bb4f4b /src/tools | |
parent | 5cca3dd9adc644ef8cb7bb251f6b43e85ba9f780 (diff) | |
download | talos-occ-055aad1e072a479e2f7ab89f60e75ff2ad6c85d6.tar.gz talos-occ-055aad1e072a479e2f7ab89f60e75ff2ad6c85d6.zip |
Sensor List Checking & Make Improvements
Change-Id: Id75021aeeb75c8d63b85e8a80bf09646b8bcf215
RTC:160341
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/30752
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Wael El-Essawy <welessa@us.ibm.com>
Reviewed-by: Christopher J. Cain <cjcain@us.ibm.com>
Reviewed-by: William A. Bryan <wilbryan@us.ibm.com>
Diffstat (limited to 'src/tools')
-rwxr-xr-x | src/tools/check-sensors.sh | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/tools/check-sensors.sh b/src/tools/check-sensors.sh new file mode 100755 index 0000000..450c4e6 --- /dev/null +++ b/src/tools/check-sensors.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/tools/check-sensors.sh $ +# +# OpenPOWER OnChipController Project +# +# Contributors Listed Below - COPYRIGHT 2016 +# [+] International Business Machines Corp. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# +# IBM_PROLOG_END_TAG + +# This script checks to ensure that the lists of sensors used by +# the OCC are fully populated in order to ensure that when a sensor +# is added, it is added to all relevant sensor lists. + +# Usage: check-sensors.sh objdump path/to/occ_405/sensor/ +# +# A version of objdump that supports powerpc object disassembly +# must be used. + +# Get file name of script +SCRIPTNAME=`basename "$0"` + +# Check that we have two arguments +if [ $# -ne 2 ]; then + echo ${SCRIPTNAME}: usage: ${SCRIPTNAME} /path/to/powerpc-objdump /path/to/occ_405/sensor/ + exit 1 +fi + +# Get paths to required tools +WC=`which wc` +READELF=`which readelf` + +# Assign arguments to coherent variables +OBJDUMP=$1 +SENSOR_PATH=$2 + +# Object files that contain the sensor lists +SENSOR_TABLE=${SENSOR_PATH}/sensor_table.o +SENSOR_INFO=${SENSOR_PATH}/sensor_info.o + +# Keep track of if a sensor is missing from a list +ERROR=0 + +# This disassembles G_amec_sensor_list and takes advantage +# of the 4-byte data alignment that objdump uses in its +# output in addition to the fact that G_amec_sensor_list +# is an array of pointers. On the 405 processor, pointers +# are 4 bytes, so this looks for any lines in the objdump +# output that are NULL pointers, indicating either a missing +# sensor or one that was improperly implemented. +NUM_ZERO_ENTRIES=$(${OBJDUMP} -Dz ${SENSOR_TABLE} \ + | awk -v RS= '/^[[:xdigit:]].*<G_amec_sensor_list>/' \ + | grep .long\ 0x0 \ + | ${WC} -l) + +# Error message if there are missing/incomplete sensors in G_amec_sensor_list +if [ ${NUM_ZERO_ENTRIES} -ne 0 ]; then + echo ERROR: There are ${NUM_ZERO_ENTRIES} missing entries in G_amec_sensor_list! + ERROR=1 +fi + +# This dumps the .rodata section of sensor_info.o, which for +# this particular file, only contains G_sensor_info. It then +# takes advantage of the fact that G_sensor_info is an array +# of sensor_info_t structures, which is 33 bytes. readelf's +# output here is rows of 16 bytes each, so if there are any +# missing sensors, there will be at least one row of all 0s. +NUM_ZERO_ENTRIES=$(${READELF} ${SENSOR_INFO} -x .rodata \ + | grep 00000000\ 00000000\ 00000000\ 00000000 \ + | ${WC} -l) + +if [ ${NUM_ZERO_ENTRIES} -ne 0 ]; then + NUM_MISSING=`expr ${NUM_ZERO_ENTRIES} / 2` + NUM_MISSING2=`expr ${NUM_MISSING} + 1` + RANGE=${NUM_MISSING}-${NUM_MISSING2} + echo ERROR: There are approximately ${RANGE} missing entries in G_sensor_info! + ERROR=1 +fi + +if [ ${ERROR} -ne 0 ]; then + exit 1 +fi |