Skip to content

Commit 462b7de

Browse files
committed
[bazel] Move scramble_flash_vmem to cc.bzl
Signed-off-by: James Wainwright <[email protected]> (cherry picked from commit 5ea5f04)
1 parent 7eb2c45 commit 462b7de

File tree

5 files changed

+43
-10
lines changed

5 files changed

+43
-10
lines changed

rules/opentitan/legacy.bzl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
load(
66
"@lowrisc_opentitan//rules/opentitan:transform.bzl",
77
"convert_to_vmem",
8+
"scramble_flash",
89
_obj_transform = "obj_transform",
910
)
1011
load("@lowrisc_opentitan//rules:rv.bzl", "rv_rule")
@@ -79,3 +80,38 @@ vmem_file = rv_rule(
7980
),
8081
},
8182
)
83+
84+
def _scramble_flash_vmem_impl(ctx):
85+
outputs = [scramble_flash(ctx, suffix = "src.vmem")]
86+
return [
87+
DefaultInfo(
88+
files = depset(outputs),
89+
data_runfiles = ctx.runfiles(files = outputs),
90+
),
91+
]
92+
93+
scramble_flash_vmem = rv_rule(
94+
implementation = _scramble_flash_vmem_impl,
95+
attrs = {
96+
"src": attr.label(allow_single_file = True),
97+
"otp": attr.label(allow_single_file = True),
98+
"otp_mmap": attr.label(
99+
allow_single_file = True,
100+
default = "//hw/ip/otp_ctrl/data:otp_ctrl_mmap.hjson",
101+
doc = "OTP memory map configuration HJSON file.",
102+
),
103+
"otp_seed": attr.label(
104+
default = "//hw/ip/otp_ctrl/data:otp_seed",
105+
doc = "Configuration override seed used to randomize OTP netlist constants.",
106+
),
107+
"otp_data_perm": attr.label(
108+
default = "//hw/ip/otp_ctrl/data:data_perm",
109+
doc = "Option to indicate OTP VMEM file bit layout.",
110+
),
111+
"_tool": attr.label(
112+
default = "@//util/design:gen-flash-img",
113+
executable = True,
114+
cfg = "exec",
115+
),
116+
},
117+
)

rules/opentitan/transform.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def scramble_flash(ctx, **kwargs):
160160
output = "{}.{}".format(name, suffix)
161161

162162
output = ctx.actions.declare_file(output)
163-
src = get_override(ctx, "attr.src", kwargs)
163+
src = get_override(ctx, "file.src", kwargs)
164164
otp = get_override(ctx, "file.otp", kwargs)
165165

166166
inputs = [src]

sw/device/silicon_creator/manuf/base/binaries/BUILD

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
44

5-
load("//rules:opentitan.bzl", "scramble_flash_vmem")
65
load("//rules/opentitan:cc.bzl", "exec_env_filegroup")
7-
load("//rules/opentitan:legacy.bzl", "vmem_file")
6+
load("//rules/opentitan:legacy.bzl", "scramble_flash_vmem", "vmem_file")
87
load("//rules:files.bzl", "copy_files")
98

109
package(default_visibility = ["//visibility:public"])
@@ -49,7 +48,7 @@ vmem_file(
4948
scramble_flash_vmem(
5049
name = "ft_personalize_sival_silicon_creator_scr_vmem64_signed",
5150
testonly = True,
52-
vmem = ":ft_personalize_sival_silicon_creator_vmem64_signed",
51+
src = ":ft_personalize_sival_silicon_creator_vmem64_signed",
5352
)
5453

5554
filegroup(

sw/device/silicon_creator/rom/e2e/BUILD

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
load("@bazel_skylib//lib:dicts.bzl", "dicts")
66
load("//rules:const.bzl", "CONST", "hex_digits")
7-
load("//rules:opentitan.bzl", "scramble_flash_vmem")
8-
load("//rules/opentitan:legacy.bzl", "vmem_file")
7+
load("//rules/opentitan:legacy.bzl", "scramble_flash_vmem", "vmem_file")
98
load("//rules/opentitan:keyutils.bzl", "ECDSA_ONLY_KEY_STRUCTS")
109
load(
1110
"//rules:otp.bzl",
@@ -249,7 +248,7 @@ opentitan_test(
249248
scramble_flash_vmem(
250249
name = "empty_test_slot_{}_{}_corrupted_sim_dv_scr_vmem64_signed".format(slot, key),
251250
testonly = True,
252-
vmem = ":empty_test_slot_{}_{}_corrupted_sim_dv_vmem64_signed".format(slot, key),
251+
src = ":empty_test_slot_{}_{}_corrupted_sim_dv_vmem64_signed".format(slot, key),
253252
)
254253
for slot in SLOTS
255254
for key in SIGVERIFY_LC_KEYS

sw/device/silicon_creator/rom/e2e/ate/binaries/BUILD

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
44

5-
load("//rules:opentitan.bzl", "scramble_flash_vmem")
65
load("//rules/opentitan:cc.bzl", "exec_env_filegroup")
7-
load("//rules/opentitan:legacy.bzl", "vmem_file")
6+
load("//rules/opentitan:legacy.bzl", "scramble_flash_vmem", "vmem_file")
87

98
package(default_visibility = ["//visibility:public"])
109

@@ -44,7 +43,7 @@ _DV_EXEC_ENVS = [
4443
scramble_flash_vmem(
4544
name = "ate_gpio_toggle_test_{}_scr_vmem64_signed".format(env),
4645
testonly = True,
47-
vmem = ":ate_gpio_toggle_test_{}_vmem64_signed".format(env),
46+
src = ":ate_gpio_toggle_test_{}_vmem64_signed".format(env),
4847
)
4948
for env in _DV_EXEC_ENVS
5049
]

0 commit comments

Comments
 (0)