Skip to content

Commit 4933f49

Browse files
committed
test: Make bootdata accessible in C programs
This is useful to build crt0 in external SDKs, or external bootroms in SoCs.
1 parent 48aebb1 commit 4933f49

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

hw/snitch_cluster/test/bootdata.cc.tpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// Copyright 2021 ETH Zurich and University of Bologna.
1+
// Copyright 2025 ETH Zurich and University of Bologna.
22
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
33
// SPDX-License-Identifier: SHL-0.51
44

55
#include <tb_lib.hh>
66

77
namespace sim {
88
9-
const BootData BOOTDATA = {.boot_addr = ${hex(cfg['cluster']['boot_addr'])},
9+
// Allow other C sources to use BOOTDATA (ex. crt0s defined in other SDKs)
10+
extern "C" const BootData BOOTDATA = {.boot_addr = ${hex(cfg['cluster']['boot_addr'])},
1011
.core_count = ${cfg['cluster']['nr_cores']},
1112
.hartid_base = ${cfg['cluster']['cluster_base_hartid']},
1213
.tcdm_start = ${hex(cfg['cluster']['cluster_base_addr'])},

target/common/test/bootdata.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2025 ETH Zurich and University of Bologna.
2+
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
3+
// SPDX-License-Identifier: SHL-0.51
4+
5+
#pragma once
6+
7+
#include <inttypes.h>
8+
9+
struct BootData {
10+
uint32_t boot_addr;
11+
uint32_t core_count;
12+
uint32_t hartid_base;
13+
uint32_t tcdm_start;
14+
uint32_t tcdm_size;
15+
uint32_t tcdm_offset;
16+
uint64_t global_mem_start;
17+
uint64_t global_mem_end;
18+
uint32_t cluster_count;
19+
uint32_t clint_base;
20+
};

target/common/test/sim.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <unordered_map>
1515
#include <vector>
1616

17+
#include "bootdata.h"
1718
#include "ipc.hh"
1819

1920
namespace sim {

target/common/test/tb_lib.hh

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,6 @@ struct GlobalMemory {
116116
extern GlobalMemory MEM;
117117

118118
// The boot data generated along with the system RTL.
119-
struct BootData {
120-
uint32_t boot_addr;
121-
uint32_t core_count;
122-
uint32_t hartid_base;
123-
uint32_t tcdm_start;
124-
uint32_t tcdm_size;
125-
uint32_t tcdm_offset;
126-
uint64_t global_mem_start;
127-
uint64_t global_mem_end;
128-
uint32_t cluster_count;
129-
uint32_t clint_base;
130-
};
131119
extern const BootData BOOTDATA;
132120

133121
} // namespace sim

0 commit comments

Comments
 (0)