Software APIs
chip_specific_startup.h
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 #ifndef OPENTITAN_SW_DEVICE_LIB_TESTING_JSON_CHIP_SPECIFIC_STARTUP_H_
5 #define OPENTITAN_SW_DEVICE_LIB_TESTING_JSON_CHIP_SPECIFIC_STARTUP_H_
6 
7 #include "sw/device/lib/ujson/ujson_derive.h"
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 // clang-format off
12 
13 #define MODULE_ID MAKE_MODULE_ID('j', 'c', 'h')
14 
15 // OTP words that we care about for low-level init.
16 #define STRUCT_ROM_OTP_CONFIG(field, string) \
17  field(creator_sw_cfg_ast_init_en, uint32_t) \
18  field(creator_sw_cfg_jitter_en, uint32_t)
19 UJSON_SERDE_STRUCT(RomOtpConfig, rom_otp_config_t, STRUCT_ROM_OTP_CONFIG);
20 
21 // Configuration values from the entropy/rng IPs.
22 #define STRUCT_ROM_ENTROPY_CONFIG(field, string) \
23  field(entropy_src, uint32_t) \
24  field(csrng, uint32_t) \
25  field(edn, uint32_t)
26 UJSON_SERDE_STRUCT(RomEntropyConfig, rom_entropy_config_t, STRUCT_ROM_ENTROPY_CONFIG);
27 
28 // ePMP configuration from the ROM.
29 #define STRUCT_ROM_EPMP_CONFIG(field, string) \
30  field(cfg, uint32_t, 4) \
31  field(addr, uint32_t, 16) \
32  field(mseccfg, uint32_t)
33 UJSON_SERDE_STRUCT(RomEpmpConfig, rom_epmp_config_t, STRUCT_ROM_EPMP_CONFIG);
34 
35 // SRAM initialization values.
36 #define STRUCT_SRAM_INIT(field, string) \
37  field(scr_key_valid, bool) \
38  field(scr_key_seed_valid, bool) \
39  field(init_done, bool)
40 UJSON_SERDE_STRUCT(SramInit, sram_init_t, STRUCT_SRAM_INIT);
41 
42 #define STRUCT_CHIP_STARTUP(field, string) \
43  field(otp, rom_otp_config_t) \
44  field(lc_state, uint32_t) \
45  field(mstatus, uint32_t) \
46  field(jitter, bool) \
47  field(entropy, rom_entropy_config_t) \
48  field(epmp, rom_epmp_config_t) \
49  field(ast_init_done, bool) \
50  field(sram, sram_init_t)
51 UJSON_SERDE_STRUCT(ChipStartup, chip_startup_t, STRUCT_CHIP_STARTUP);
52 
53 #undef MODULE_ID
54 
55 // clang-format on
56 #ifdef __cplusplus
57 }
58 #endif
59 #endif // OPENTITAN_SW_DEVICE_LIB_TESTING_JSON_CHIP_SPECIFIC_STARTUP_H_