Skip to content

Commit d15734f

Browse files
author
Jon Flatley
committed
[bazel] Add rule for OTP alert_hander digests
Signed-off-by: Jon Flatley <[email protected]>
1 parent 5d25613 commit d15734f

File tree

2 files changed

+52
-5
lines changed

2 files changed

+52
-5
lines changed

hw/ip/otp_ctrl/data/BUILD

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
load("//rules:autogen.bzl", "autogen_hjson_header")
6-
load("//rules:otp.bzl", "otp_image", "otp_json", "otp_partition")
6+
load("//rules:otp.bzl", "otp_image", "otp_json", "otp_partition", "otp_alert_digest")
77
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
88

99
package(default_visibility = ["//visibility:public"])
@@ -122,10 +122,6 @@ otp_json(
122122
"0x0",
123123
"0x0",
124124
],
125-
"OWNER_SW_CFG_ROM_ALERT_DIGEST_DEV": "0xf23b13fb",
126-
"OWNER_SW_CFG_ROM_ALERT_DIGEST_PROD": "0x9c933414",
127-
"OWNER_SW_CFG_ROM_ALERT_DIGEST_PROD_END": "0x68d8d091",
128-
"OWNER_SW_CFG_ROM_ALERT_DIGEST_RMA": "0x36ed9cb0",
129125
},
130126
),
131127
],
@@ -344,12 +340,19 @@ otp_json(
344340
seed = "01931961561863975174",
345341
)
346342

343+
# Create an overlay for the alert_handler digest.
344+
otp_alert_digest(
345+
name = "otp_json_alert_digest_cfg",
346+
otp_img = ":otp_json_owner_sw_cfg",
347+
)
348+
347349
otp_image(
348350
name = "img_dev",
349351
src = ":otp_json_dev",
350352
overlays = [
351353
":otp_json_creator_sw_cfg",
352354
":otp_json_owner_sw_cfg",
355+
":otp_json_alert_digest_cfg",
353356
":otp_json_hw_cfg",
354357
],
355358
)
@@ -360,6 +363,7 @@ otp_image(
360363
overlays = [
361364
":otp_json_creator_sw_cfg",
362365
":otp_json_owner_sw_cfg",
366+
":otp_json_alert_digest_cfg",
363367
":otp_json_hw_cfg",
364368
],
365369
)
@@ -370,6 +374,7 @@ otp_image(
370374
overlays = [
371375
":otp_json_creator_sw_cfg",
372376
":otp_json_owner_sw_cfg",
377+
":otp_json_alert_digest_cfg",
373378
":otp_json_hw_cfg",
374379
],
375380
)
@@ -380,6 +385,7 @@ otp_image(
380385
overlays = [
381386
":otp_json_creator_sw_cfg",
382387
":otp_json_owner_sw_cfg",
388+
":otp_json_alert_digest_cfg",
383389
":otp_json_hw_cfg",
384390
],
385391
)
@@ -390,6 +396,7 @@ otp_image(
390396
overlays = [
391397
":otp_json_creator_sw_cfg",
392398
":otp_json_owner_sw_cfg",
399+
":otp_json_alert_digest_cfg",
393400
":otp_json_hw_cfg",
394401
],
395402
)
@@ -400,6 +407,7 @@ otp_image(
400407
overlays = [
401408
":otp_json_creator_sw_cfg",
402409
":otp_json_owner_sw_cfg",
410+
":otp_json_alert_digest_cfg",
403411
":otp_json_hw_cfg",
404412
],
405413
)
@@ -421,6 +429,7 @@ otp_image(
421429
overlays = [
422430
":otp_json_creator_sw_cfg",
423431
":otp_json_owner_sw_cfg",
432+
":otp_json_alert_digest_cfg",
424433
":otp_json_hw_cfg",
425434
":otp_json_exec_disabled",
426435
],
@@ -443,6 +452,7 @@ otp_image(
443452
overlays = [
444453
":otp_json_creator_sw_cfg",
445454
":otp_json_owner_sw_cfg",
455+
":otp_json_alert_digest_cfg",
446456
":otp_json_hw_cfg",
447457
":otp_json_bootstrap_disabled",
448458
],

rules/otp.bzl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,43 @@ otp_json = rule(
102102
},
103103
)
104104

105+
def _otp_alert_digest_impl(ctx):
106+
file = ctx.actions.declare_file("{}.json".format(ctx.attr.name))
107+
108+
outputs = [file]
109+
110+
inputs = [
111+
ctx.file._opentitantool,
112+
ctx.file.otp_img,
113+
]
114+
115+
args = ctx.actions.args()
116+
args.add_all(("otp", "alert-digest", ctx.file.otp_img))
117+
args.add("--output", file)
118+
119+
ctx.actions.run(
120+
outputs = outputs,
121+
inputs = inputs,
122+
arguments = [args],
123+
executable = ctx.file._opentitantool.path,
124+
)
125+
126+
return [DefaultInfo(files = depset([file]))]
127+
128+
otp_alert_digest = rule(
129+
implementation = _otp_alert_digest_impl,
130+
attrs = {
131+
"otp_img": attr.label(
132+
allow_single_file = [".json", ".hjson"],
133+
doc = "The OTP image file containing alert_handler values."
134+
),
135+
"_opentitantool": attr.label(
136+
default = "//sw/host/opentitantool:opentitantool",
137+
allow_single_file = True,
138+
),
139+
},
140+
)
141+
105142
def _otp_image(ctx):
106143
output = ctx.actions.declare_file(ctx.attr.name + ".24.vmem")
107144
args = ctx.actions.args()

0 commit comments

Comments
 (0)