blob: 5c27e02d30eeaee78fe781703e0431598853e50b [file] [log] [blame]
Willy Tu4dd03ca2021-08-06 09:37:35 -07001FILESEXTRAPATHS:prepend:gbmc := "${THISDIR}/${PN}:"
William A. Kennington III97b47e02021-07-15 16:23:01 -07002
Tom Tung4d433a42022-03-31 15:16:41 +08003SRC_URI:append:gbmc = " \
4 file://gbmc_bridge_config.json \
5 file://gbmc_bridge_access.json \
6"
William A. Kennington III97b47e02021-07-15 16:23:01 -07007
Willy Tu4dd03ca2021-08-06 09:37:35 -07008DEPENDS:append:gbmc = " jq-native"
William A. Kennington III97b47e02021-07-15 16:23:01 -07009
10GBMCBR_IPMI_CHANNEL ?= "11"
11
Willy Tu1da83062022-04-07 23:48:56 -070012ENTITY_MAPPING ?= "default"
13
William A. Kennington III97b47e02021-07-15 16:23:01 -070014# Replace a channel in config.json to add gbmcbr reporting
Willy Tu4dd03ca2021-08-06 09:37:35 -070015do_install:append:gbmc() {
Tom Tung4d433a42022-03-31 15:16:41 +080016 config_json=${D}${datadir}/ipmi-providers/channel_config.json
17 overlapping="$(jq '."${GBMCBR_IPMI_CHANNEL}" | .is_valid and .name != "gbmcbr"' $config_json)"
William A. Kennington III97b47e02021-07-15 16:23:01 -070018 if [ "$overlapping" != "false" ]; then
19 echo "gBMC channel config overlaps on ${GBMCBR_IPMI_CHANNEL}" >&2
Tom Tung4d433a42022-03-31 15:16:41 +080020 cat $config_json
William A. Kennington III97b47e02021-07-15 16:23:01 -070021 exit 1
22 fi
Tom Tung4d433a42022-03-31 15:16:41 +080023 jq --slurpfile brcfg ${WORKDIR}/gbmc_bridge_config.json \
24 '. + {"${GBMCBR_IPMI_CHANNEL}": $brcfg[0]}' $config_json >${WORKDIR}/tmp
25 mv ${WORKDIR}/tmp $config_json
26
27 access_json=${D}${datadir}/ipmi-providers/channel_access.json
28 overlapping="$(jq '."${GBMCBR_IPMI_CHANNEL}" | .access_mode and .access_mode != "always_available"' $access_json)"
29 if [ "$overlapping" != "false" ]; then
30 echo "gBMC channel access overlaps on ${GBMCBR_IPMI_CHANNEL}" >&2
31 cat $access_json
32 exit 1
33 fi
34 jq --slurpfile brcfg ${WORKDIR}/gbmc_bridge_access.json \
35 '. + {"${GBMCBR_IPMI_CHANNEL}": $brcfg[0]}' $access_json >${WORKDIR}/tmp
36 mv ${WORKDIR}/tmp $access_json
Willy Tuc93f10b2022-03-28 11:18:53 -070037
38 # Set entity-map.json to empty json for gBMC by default.
39 # Each system will override it if needed.
Willy Tu1da83062022-04-07 23:48:56 -070040 if [[ "${ENTITY_MAPPING}" != "default" ]]; then
41 echo "[]" > ${D}${datadir}/ipmi-providers/entity-map.json
42 fi
William A. Kennington III97b47e02021-07-15 16:23:01 -070043}
Willy Tu2dc424c2022-06-09 13:21:39 -070044
45python do_gbmc_version () {
46 import json
47
48 if d.getVar('GBMC_VERSION') is None:
49 return
50
51 version = d.getVar('GBMC_VERSION').split('.')
52 major = min(int(version[0]), 0x7F) & 0x7F
53 minor = min(int(version[1]), 99)
54 minor = int(minor / 10) * 16 + minor % 10;
55 point = int(version[2])
56 subpoint = int(version[3])
57
58 dir = d.getVar('D') + d.getVar('datadir') + '/ipmi-providers'
59 path = os.path.join(dir, 'dev_id.json')
60
61 dev_id = {}
62
63 # Open existing dev_id and override the fields not needed for version.
64 with open(path, 'r') as f:
65 dev_id = json.load(f)
66 dev_id["firmware_revision"] = {
67 "major": major,
68 "minor": minor
69 }
70 dev_id["aux"] = subpoint << 16 | (0xFFFF & point)
71
72 with open(path, 'w') as f:
73 json.dump(dev_id, f, sort_keys=True, indent=4)
74}
75
76addtask gbmc_version after do_install before do_package