Skip to content

Commit 90e809e

Browse files
pamauryluismarques
authored andcommitted
[silicon_creator] Rename chip_info to build_info
The name chip_info is misleading because the data is embedded in every binary. So it actually is a build info. The chip_info is simply then the ROM's build_info. Signed-off-by: Amaury Pouly <[email protected]>
1 parent 4b9a77f commit 90e809e

File tree

19 files changed

+107
-107
lines changed

19 files changed

+107
-107
lines changed

rules/autogen.bzl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,21 @@ autogen_hjson_rust_header = rule(
140140
} | stamp_attr(-1, "//rules:stamp_flag"),
141141
)
142142

143-
def _chip_info_src(ctx):
143+
def _build_info_src(ctx):
144144
stamp_args = []
145145
stamp_files = []
146146
if stamping_enabled(ctx):
147147
stamp_files = [ctx.version_file]
148148
stamp_args.append("--ot_version_file")
149149
stamp_args.append(ctx.version_file.path)
150150
else:
151-
print("NOTE: stamping is disabled, the chip_info section will use a fixed version string")
151+
print("NOTE: stamping is disabled, the build_info section will use a fixed version string")
152152
stamp_args.append("--default_version")
153153

154154
# The script expects a 20-character long hash: "OpenTitanOpenTitanOT"
155155
stamp_args.append("4f70656e546974616e4f70656e546974616e4f54")
156156

157-
out_source = ctx.actions.declare_file("chip_info.c")
157+
out_source = ctx.actions.declare_file("build_info.c")
158158
ctx.actions.run(
159159
outputs = [
160160
out_source,
@@ -173,32 +173,32 @@ def _chip_info_src(ctx):
173173
DefaultInfo(files = depset([out_source])),
174174
]
175175

176-
autogen_chip_info_src = rule(
177-
implementation = _chip_info_src,
176+
autogen_build_info_src = rule(
177+
implementation = _build_info_src,
178178
attrs = {
179179
"_tool": attr.label(
180-
default = "//util:rom_chip_info",
180+
default = "//util:build_info",
181181
executable = True,
182182
cfg = "exec",
183183
),
184184
} | stamp_attr(-1, "//rules:stamp_flag"),
185185
)
186186

187-
def autogen_chip_info(name):
188-
"""Generates a cc_library named `name` that defines chip info."""
187+
def autogen_build_info(name):
188+
"""Generates a cc_library named `name` that defines the build ID."""
189189

190-
# Generate a C source file that defines the chip info struct. This is an
190+
# Generate a C source file that defines the build ID struct. This is an
191191
# implementation detail and should not be depended on externally.
192-
chip_info_src_target = name + "_gen_src"
193-
autogen_chip_info_src(name = chip_info_src_target)
192+
build_info_src_target = name + "_gen_src"
193+
autogen_build_info_src(name = build_info_src_target)
194194

195195
# Package up the generated source file with its corresponding header file
196-
# and dependencies. Any target that wants access to the chip info should
196+
# and dependencies. Any target that wants access to the build ID should
197197
# depend on this.
198198
native.cc_library(
199199
name = name,
200-
srcs = [chip_info_src_target],
201-
hdrs = ["//sw/device/silicon_creator/lib:chip_info.h"],
200+
srcs = [build_info_src_target],
201+
hdrs = ["//sw/device/silicon_creator/lib:build_info.h"],
202202
deps = [
203203
"//sw/device/lib/base:macros",
204204
],

sw/device/lib/testing/test_rom/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ cc_library(
204204
"//sw/device/lib/testing:pinmux_testutils",
205205
"//sw/device/lib/testing/test_framework:check",
206206
"//sw/device/lib/testing/test_framework:status",
207-
"//sw/device/silicon_creator/lib:chip_info",
207+
"//sw/device/silicon_creator/lib:build_info",
208208
"//sw/device/silicon_creator/lib/base:sec_mmio",
209209
"//sw/device/silicon_creator/lib/base:static_critical",
210210
],

sw/device/lib/testing/test_rom/test_rom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "sw/device/lib/testing/test_framework/check.h"
2323
#include "sw/device/lib/testing/test_framework/status.h"
2424
#include "sw/device/silicon_creator/lib/base/sec_mmio.h"
25-
#include "sw/device/silicon_creator/lib/chip_info.h"
25+
#include "sw/device/silicon_creator/lib/build_info.h"
2626
#include "sw/device/silicon_creator/lib/drivers/flash_ctrl.h"
2727
#if !OT_IS_ENGLISH_BREAKFAST
2828
#include "sw/device/silicon_creator/lib/drivers/retention_sram.h"
@@ -155,7 +155,7 @@ bool rom_test_main(void) {
155155
}
156156

157157
// Print the chip version information
158-
LOG_INFO("kChipInfo: scm_revision=%x", kChipInfo.scm_revision);
158+
LOG_INFO("kBuildInfo: scm_revision=%x", kBuildInfo.scm_revision);
159159

160160
// Skip sram_init for test_rom
161161
dif_rstmgr_reset_info_bitfield_t reset_reasons;

sw/device/lib/testing/test_rom/test_rom.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ SECTIONS {
134134
* Immutable chip_info data, containing build-time-recorded information.
135135
*/
136136
.chip_info _chip_info_start : ALIGN(4) {
137-
KEEP(*(.chip_info))
137+
KEEP(*(.build_info))
138138
} > rom
139139

140140
/**

sw/device/silicon_creator/lib/BUILD

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ load(
66
"@bazel_skylib//lib:dicts.bzl",
77
"dicts",
88
)
9-
load("//rules:autogen.bzl", "autogen_chip_info")
9+
load("//rules:autogen.bzl", "autogen_build_info")
1010
load("//rules:cross_platform.bzl", "dual_cc_device_library_of", "dual_cc_library", "dual_inputs")
1111
load("//rules/opentitan:defs.bzl", "OPENTITAN_CPU")
1212
load(
@@ -97,7 +97,7 @@ cc_library(
9797
":boot_data",
9898
":nonce",
9999
"//sw/device/lib/base:macros",
100-
"//sw/device/silicon_creator/lib:chip_info",
100+
"//sw/device/silicon_creator/lib:build_info",
101101
"//sw/device/silicon_creator/lib:error",
102102
"//sw/device/silicon_creator/lib/drivers:hmac",
103103
"//sw/device/silicon_creator/lib/ownership:datatypes",
@@ -109,7 +109,7 @@ cc_test(
109109
srcs = ["boot_log_unittest.cc"],
110110
deps = [
111111
":boot_log",
112-
"//sw/device/silicon_creator/lib:chip_info",
112+
"//sw/device/silicon_creator/lib:build_info",
113113
"//sw/device/silicon_creator/lib/drivers:hmac",
114114
"@googletest//:gtest_main",
115115
],
@@ -352,7 +352,7 @@ filegroup(
352352
],
353353
)
354354

355-
autogen_chip_info(name = "chip_info")
355+
autogen_build_info(name = "build_info")
356356

357357
dual_cc_library(
358358
name = "shutdown",
@@ -371,7 +371,7 @@ dual_cc_library(
371371
"@googletest//:gtest",
372372
],
373373
shared = [
374-
":chip_info",
374+
":build_info",
375375
":error",
376376
":epmp_defs",
377377
":stack_utilization",

sw/device/silicon_creator/lib/boot_log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ rom_error_t boot_log_check(const boot_log_t *boot_log) {
7272
}
7373

7474
void boot_log_check_or_init(boot_log_t *boot_log, uint32_t rom_ext_slot,
75-
const chip_info_t *info) {
75+
const build_info_t *info) {
7676
rom_error_t error = boot_log_check(boot_log);
7777
if (launder32(error) == kErrorOk) {
7878
HARDENED_CHECK_EQ(error, kErrorOk);

sw/device/silicon_creator/lib/boot_log.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "sw/device/lib/base/macros.h"
1111
#include "sw/device/silicon_creator/lib/boot_data.h"
12-
#include "sw/device/silicon_creator/lib/chip_info.h"
12+
#include "sw/device/silicon_creator/lib/build_info.h"
1313
#include "sw/device/silicon_creator/lib/drivers/hmac.h"
1414
#include "sw/device/silicon_creator/lib/error.h"
1515
#include "sw/device/silicon_creator/lib/nonce.h"
@@ -28,7 +28,7 @@ typedef struct boot_log {
2828
/** Identifier (`BLOG`). */
2929
uint32_t identifier;
3030
/** Chip version (from the ROM). */
31-
chip_info_scm_revision_t chip_version;
31+
build_info_scm_revision_t chip_version;
3232
/** Which ROM_EXT slot booted (boot_slot_t). */
3333
uint32_t rom_ext_slot;
3434
/** ROM_EXT major version number. */
@@ -109,10 +109,10 @@ rom_error_t boot_log_check(const boot_log_t *boot_log);
109109
*
110110
* @param boot_log A buffer that holds the boot_log.
111111
* @param rom_ext_slot The current ROM_EXT slot.
112-
* @param info A pointer to the chip_info_t structure in ROM.
112+
* @param info A pointer to the build_info_t structure in ROM.
113113
*/
114114
void boot_log_check_or_init(boot_log_t *boot_log, uint32_t rom_ext_slot,
115-
const chip_info_t *info);
115+
const build_info_t *info);
116116

117117
#ifdef __cplusplus
118118
}

sw/device/silicon_creator/lib/boot_log_unittest.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <cstring>
88

99
#include "gtest/gtest.h"
10-
#include "sw/device/silicon_creator/lib/chip_info.h"
10+
#include "sw/device/silicon_creator/lib/build_info.h"
1111
#include "sw/device/silicon_creator/lib/drivers/hmac.h"
1212
#include "sw/device/silicon_creator/lib/drivers/mock_hmac.h"
1313

@@ -19,8 +19,8 @@ bool operator!=(hmac_digest_t lhs, hmac_digest_t rhs) {
1919
return std::memcmp(&lhs, &rhs, sizeof(hmac_digest_t)) != 0;
2020
}
2121

22-
bool operator==(chip_info_scm_revision_t lhs, chip_info_scm_revision_t rhs) {
23-
return std::memcmp(&lhs, &rhs, sizeof(chip_info_scm_revision_t)) == 0;
22+
bool operator==(build_info_scm_revision_t lhs, build_info_scm_revision_t rhs) {
23+
return std::memcmp(&lhs, &rhs, sizeof(build_info_scm_revision_t)) == 0;
2424
}
2525

2626
namespace boot_log_unittest {
@@ -46,7 +46,7 @@ class BootLogTest : public rom_test::RomTest {
4646
},
4747
};
4848

49-
chip_info_scm_revision_t expected_chip_version = {
49+
build_info_scm_revision_t expected_chip_version = {
5050
.scm_revision_low = 0x76543210,
5151
.scm_revision_high = 0xcafecafe,
5252
};

sw/device/silicon_creator/lib/chip_info.h renamed to sw/device/silicon_creator/lib/build_info.h

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

5-
#ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_CHIP_INFO_H_
6-
#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_CHIP_INFO_H_
5+
#ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BUILD_INFO_H_
6+
#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BUILD_INFO_H_
77

88
#include <stdint.h>
99

@@ -13,7 +13,7 @@
1313
* A truncated commit hash from the open-source OpenTitan repo that can be
1414
* used to reproduce the ROM binary.
1515
*/
16-
typedef struct chip_info_scm_revision {
16+
typedef struct build_info_scm_revision {
1717
/**
1818
* Least significant word of the truncated commit hash.
1919
*/
@@ -22,13 +22,13 @@ typedef struct chip_info_scm_revision {
2222
* Most significant word of the truncated commit hash.
2323
*/
2424
uint32_t scm_revision_high;
25-
} chip_info_scm_revision_t;
25+
} build_info_scm_revision_t;
2626

27-
typedef struct chip_info {
27+
typedef struct build_info {
2828
/**
2929
* Truncated commit hash.
3030
*/
31-
chip_info_scm_revision_t scm_revision;
31+
build_info_scm_revision_t scm_revision;
3232
/**
3333
* Chip info format version.
3434
*
@@ -38,23 +38,21 @@ typedef struct chip_info {
3838
* field. See `sw/device/silicon_creator/rom/rom.ld` for details.
3939
*/
4040
uint32_t version;
41-
} chip_info_t;
42-
OT_ASSERT_MEMBER_OFFSET(chip_info_t, scm_revision, 0);
43-
OT_ASSERT_MEMBER_OFFSET(chip_info_t, version, 8);
44-
OT_ASSERT_SIZE(chip_info_t, 12);
41+
} build_info_t;
42+
OT_ASSERT_MEMBER_OFFSET(build_info_t, scm_revision, 0);
43+
OT_ASSERT_MEMBER_OFFSET(build_info_t, version, 8);
44+
OT_ASSERT_SIZE(build_info_t, 12);
4545

4646
enum {
4747
/**
4848
* Chip info format version 1 value.
4949
*/
50-
kChipInfoVersion1 = 0x4efecea6,
50+
kBuildInfoVersion1 = 0x4efecea6,
5151
};
5252

5353
/**
54-
* Extern declaration for the `kChipInfo` instance placed at the end of ROM.
55-
*
56-
* The actual definition is in an auto-generated file.
54+
* The build information.
5755
*/
58-
extern const chip_info_t kChipInfo;
56+
extern const build_info_t kBuildInfo;
5957

60-
#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_CHIP_INFO_H_
58+
#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BUILD_INFO_H_

sw/device/silicon_creator/lib/shutdown.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "sw/device/lib/base/memory.h"
1616
#include "sw/device/lib/base/multibits.h"
1717
#include "sw/device/lib/base/stdasm.h"
18-
#include "sw/device/silicon_creator/lib/chip_info.h"
18+
#include "sw/device/silicon_creator/lib/build_info.h"
1919
#include "sw/device/silicon_creator/lib/drivers/alert.h"
2020
#include "sw/device/silicon_creator/lib/drivers/lifecycle.h"
2121
#include "sw/device/silicon_creator/lib/drivers/otp.h"
@@ -416,7 +416,7 @@ SHUTDOWN_FUNC(NO_MODIFIERS, shutdown_report_error(rom_error_t reason)) {
416416
shutdown_print(kShutdownLogPrefixBootFault, redacted_error);
417417
shutdown_print(kShutdownLogPrefixLifecycle, raw_state);
418418
shutdown_print(kShutdownLogPrefixVersion,
419-
kChipInfo.scm_revision.scm_revision_high);
419+
kBuildInfo.scm_revision.scm_revision_high);
420420
}
421421

422422
SHUTDOWN_FUNC(NO_MODIFIERS, shutdown_software_escalate(void)) {

0 commit comments

Comments
 (0)