Software APIs
mem.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_LIB_TESTING_JSON_MEM_H_
6 #define OPENTITAN_SW_DEVICE_LIB_TESTING_JSON_MEM_H_
7 
8 #include "sw/device/lib/ujson/ujson_derive.h"
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 // clang-format off
13 
14 #define MODULE_ID MAKE_MODULE_ID('j', 'm', 'h')
15 
16 #define STRUCT_MEM_READ32_REQ(field, string) \
17  field(address, uint32_t)
18 UJSON_SERDE_STRUCT(MemRead32Req, mem_read32_req_t, STRUCT_MEM_READ32_REQ);
19 
20 #define STRUCT_MEM_READ32_RESP(field, string) \
21  field(value, uint32_t)
22 UJSON_SERDE_STRUCT(MemRead32Resp, mem_read32_resp_t, STRUCT_MEM_READ32_RESP);
23 
24 #define STRUCT_MEM_READ_REQ(field, string) \
25  field(address, uint32_t) \
26  field(data_len, uint16_t)
27 UJSON_SERDE_STRUCT(MemReadReq, mem_read_req_t, STRUCT_MEM_READ_REQ);
28 
29 #define STRUCT_MEM_READ_RESP(field, string) \
30  field(data, uint8_t, 256) \
31  field(data_len, uint16_t)
32 UJSON_SERDE_STRUCT(MemReadResp, mem_read_resp_t, STRUCT_MEM_READ_RESP);
33 
34 #define STRUCT_MEM_WRITE32_REQ(field, string) \
35  field(address, uint32_t) \
36  field(value, uint32_t)
37 UJSON_SERDE_STRUCT(MemWrite32Req, mem_write32_req_t, STRUCT_MEM_WRITE32_REQ);
38 
39 #define STRUCT_MEM_WRITE_REQ(field, string) \
40  field(address, uint32_t) \
41  field(data, uint8_t, 256) \
42  field(data_len, uint16_t)
43 UJSON_SERDE_STRUCT(MemWriteReq, mem_write_req_t, STRUCT_MEM_WRITE_REQ);
44 
45 #ifndef RUST_PREPROCESSOR_EMIT
46 
47 status_t ujcmd_mem_read32(ujson_t *uj);
48 status_t ujcmd_mem_read(ujson_t *uj);
49 status_t ujcmd_mem_write32(ujson_t *uj);
50 status_t ujcmd_mem_write(ujson_t *uj);
51 
52 #endif
53 
54 #undef MODULE_ID
55 
56 // clang-format on
57 #ifdef __cplusplus
58 }
59 #endif
60 #endif // OPENTITAN_SW_DEVICE_LIB_TESTING_JSON_MEM_H_