Software APIs
otbn_fi_commands.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 
5 #ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_OTBN_FI_COMMANDS_H_
6 #define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_OTBN_FI_COMMANDS_H_
7 #include "sw/device/lib/ujson/ujson_derive.h"
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 // clang-format off
13 
14 #define OTBNFI_SUBCOMMAND(_, value) \
15  value(_, CharBeq) \
16  value(_, CharBnRshi) \
17  value(_, CharBnSel) \
18  value(_, CharBnWsrr) \
19  value(_, CharBne) \
20  value(_, CharDmemAccess) \
21  value(_, CharDmemWrite) \
22  value(_, CharHardwareDmemOpLoop) \
23  value(_, CharHardwareRegOpLoop) \
24  value(_, CharJal) \
25  value(_, CharLw) \
26  value(_, CharMem) \
27  value(_, CharRF) \
28  value(_, CharUnrolledDmemOpLoop) \
29  value(_, CharUnrolledRegOpLoop) \
30  value(_, Init) \
31  value(_, InitKeyMgr) \
32  value(_, KeySideload) \
33  value(_, LoadIntegrity) \
34  value(_, PC)
35 UJSON_SERDE_ENUM(OtbnFiSubcommand, otbn_fi_subcommand_t, OTBNFI_SUBCOMMAND);
36 
37 #define OTBNFI_LOOP_COUNTER_OUTPUT(field, string) \
38  field(loop_counter, uint32_t) \
39  field(err_otbn, uint32_t) \
40  field(err_ibx, uint32_t) \
41  field(alerts, uint32_t, 3) \
42  field(ast_alerts, uint32_t, 2)
43 UJSON_SERDE_STRUCT(OtbnFiLoopCounterOutput, otbn_fi_loop_counter_t, OTBNFI_LOOP_COUNTER_OUTPUT);
44 
45 #define OTBNFI_RESULT_OUTPUT(field, string) \
46  field(result, uint32_t) \
47  field(err_otbn, uint32_t) \
48  field(err_ibx, uint32_t) \
49  field(alerts, uint32_t, 3) \
50  field(ast_alerts, uint32_t, 2)
51 UJSON_SERDE_STRUCT(OtbnFiResultOutput, otbn_fi_result_t, OTBNFI_RESULT_OUTPUT);
52 
53 #define OTBNFI_KEY_OUTPUT(field, string) \
54  field(res, uint32_t) \
55  field(keys, uint32_t, 4) \
56  field(err_otbn, uint32_t) \
57  field(err_ibx, uint32_t) \
58  field(alerts, uint32_t, 3) \
59  field(ast_alerts, uint32_t, 2)
60 UJSON_SERDE_STRUCT(OtbnFiKeyOutput, otbn_fi_keys_t, OTBNFI_KEY_OUTPUT);
61 
62 #define OTBNFI_MEM_CFG(field, string) \
63  field(byte_offset, uint32_t) \
64  field(num_words, uint32_t) \
65  field(imem, bool) \
66  field(dmem, bool)
67 UJSON_SERDE_STRUCT(OtbnFiMemCfg, otbn_fi_mem_cfg_t, OTBNFI_MEM_CFG);
68 
69 #define OTBNFI_MEM_OUTPUT(field, string) \
70  field(res, uint32_t) \
71  field(imem_data, uint32_t, 8) \
72  field(imem_addr, uint32_t, 8) \
73  field(dmem_data, uint32_t, 8) \
74  field(dmem_addr, uint32_t, 8) \
75  field(err_otbn, uint32_t) \
76  field(err_ibx, uint32_t) \
77  field(alerts, uint32_t, 3) \
78  field(ast_alerts, uint32_t, 2)
79 UJSON_SERDE_STRUCT(OtbnFiMemOutput, otbn_fi_mem_t, OTBNFI_MEM_OUTPUT);
80 
81 #define OTBNFI_DATA_OUTPUT(field, string) \
82  field(res, uint32_t) \
83  field(data, uint32_t, 256) \
84  field(insn_cnt, uint32_t) \
85  field(err_otbn, uint32_t) \
86  field(err_ibx, uint32_t) \
87  field(alerts, uint32_t, 3) \
88  field(ast_alerts, uint32_t, 2)
89 UJSON_SERDE_STRUCT(OtbnFiDataOutput, otbn_fi_data_t, OTBNFI_DATA_OUTPUT);
90 
91 #define OTBNFI_RF_CHAR_OUTPUT(field, string) \
92  field(res, uint32_t) \
93  field(faulty_gpr, uint32_t, 29) \
94  field(faulty_wdr, uint32_t, 256) \
95  field(err_otbn, uint32_t) \
96  field(err_ibx, uint32_t) \
97  field(alerts, uint32_t, 3) \
98  field(ast_alerts, uint32_t, 2)
99 UJSON_SERDE_STRUCT(OtbnFiRfCharOutput, otbn_fi_rf_char_t, OTBNFI_RF_CHAR_OUTPUT);
100 
101 #define OTBNFI_RESULT_CNT_OUTPUT(field, string) \
102  field(result, uint32_t) \
103  field(insn_cnt, uint32_t) \
104  field(err_otbn, uint32_t) \
105  field(err_ibx, uint32_t) \
106  field(alerts, uint32_t, 3) \
107  field(ast_alerts, uint32_t, 2)
108 UJSON_SERDE_STRUCT(OtbnFiResultCntOutput, otbn_fi_result_cnt_t, OTBNFI_RESULT_CNT_OUTPUT);
109 
110 #define OTBNFI_RESULT_ARRAY(field, string) \
111  field(result, uint32_t, 32) \
112  field(insn_cnt, uint32_t) \
113  field(err_otbn, uint32_t) \
114  field(err_ibx, uint32_t) \
115  field(alerts, uint32_t, 3) \
116  field(ast_alerts, uint32_t, 2)
117 UJSON_SERDE_STRUCT(OtbnFiResultArray, otbn_fi_result_array_t, OTBNFI_RESULT_ARRAY);
118 
119 #define OTBNFI_BIG_NUM(field, string) \
120  field(big_num, uint32_t, 16)
121 UJSON_SERDE_STRUCT(OtbnFiBigNum, otbn_fi_big_num_t, OTBNFI_BIG_NUM);
122 
123 #define OTBNFI_BIG_NUM_OUTPUT(field, string) \
124  field(big_num, uint32_t, 16) \
125  field(insn_cnt, uint32_t) \
126  field(err_otbn, uint32_t) \
127  field(err_ibx, uint32_t) \
128  field(alerts, uint32_t, 3) \
129  field(ast_alerts, uint32_t, 2)
130 UJSON_SERDE_STRUCT(OtbnFiBigNumOutput, otbn_fi_big_num_out_t, OTBNFI_BIG_NUM_OUTPUT);
131 
132 #define OTBNFI_PC(field, string) \
133  field(pc, uint32_t)
134 UJSON_SERDE_STRUCT(OtbnFiPc, otbn_fi_pc_t, OTBNFI_PC);
135 
136 #define OTBNFI_PC_OUTPUT(field, string) \
137  field(pc_dmem, uint32_t) \
138  field(pc_otbn, uint32_t) \
139  field(insn_cnt, uint32_t) \
140  field(err_otbn, uint32_t) \
141  field(err_ibx, uint32_t) \
142  field(alerts, uint32_t, 3) \
143  field(ast_alerts, uint32_t, 2)
144 UJSON_SERDE_STRUCT(OtbnFiPcOutput, otbn_fi_pc_out_t, OTBNFI_PC_OUTPUT);
145 
146 // clang-format on
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 #endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_OTBN_FI_COMMANDS_H_