summaryrefslogtreecommitdiff
path: root/meta-google
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2021-10-13 09:18:52 +0300
committerWilliam A. Kennington III <wak@google.com>2021-10-14 01:26:38 +0300
commita3a8ca972abf4f66788b14cf65bcbc62d6f6af0c (patch)
tree2b914754523d080dd10f006a9a5f25e802dbec1c /meta-google
parentfc4bbb90ad53731fdfba04d974ef1e1fb41664c8 (diff)
downloadopenbmc-a3a8ca972abf4f66788b14cf65bcbc62d6f6af0c.tar.xz
meta-google: ipmi-fru-sh: Add method for initializing eeproms
This makes it possible to create new specifications besides the default mapping of OF name to eeprom path. Right now this provides backward compatability with anything that uses of_name_to_eeprom and only provides a new explicit specifier for that specification. Change-Id: If02d9cb392a48e0698b10644d7ade3220bde3eb5 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'meta-google')
-rw-r--r--meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh30
1 files changed, 28 insertions, 2 deletions
diff --git a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
index 335e0b21c..3ae0f0864 100644
--- a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
+++ b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
@@ -42,6 +42,32 @@ of_name_to_eeprom() {
echo "$eeproms"
}
+declare -A IPMI_FRU_EEPROM_FILE=()
+
+ipmi_fru_alloc() {
+ local name="$1"
+ local -n ret="$2"
+
+ # Pick the first free index to return as the allocated entry
+ for (( ret = 0; ret < "${#IPMI_FRU_EEPROM_FILE[@]}"; ++ret )); do
+ [ -n "${IPMI_FRU_EEPROM_FILE[@]+1}" ] || break
+ done
+
+ if [[ "$name" =~ ^of-name:(.*)$ || "$name" =~ ^([^:]*)$ ]]; then
+ local ofn="${BASH_REMATCH[1]}"
+ local file
+ file="$(of_name_to_eeprom "$ofn")" || return
+ IPMI_FRU_EEPROM_FILE["$ret"]="$file"
+ else
+ echo "Invalid IPMI FRU eeprom specification: $name" >&2
+ return 1
+ fi
+}
+
+ipmi_fru_free() {
+ unset 'IPMI_FRU_EEPROM_FILE[$1]'
+}
+
checksum() {
local -n checksum_arr="$1"
local checksum=0
@@ -61,7 +87,7 @@ fix_checksum() {
}
read_bytes() {
- local file="$1"
+ local file="${IPMI_FRU_EEPROM_FILE["$1"]-$1}"
local offset="$2"
local size="$3"
@@ -71,7 +97,7 @@ read_bytes() {
}
write_bytes() {
- local file="$1"
+ local file="${IPMI_FRU_EEPROM_FILE["$1"]-$1}"
local offset="$2"
local -n bytes_arr="$3"