1 /*
2  * Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved.
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef TS_BLOCK_STORAGE_PACKEDC_MESSAGES_H
7 #define TS_BLOCK_STORAGE_PACKEDC_MESSAGES_H
8 
9 #include <stdint.h>
10 
11 /**
12  * Protocol definitions for block storage operations
13  * using the packed-c serialization.
14  */
15 
16 /****************************************
17  * Common defines
18  */
19 #define TS_BLOCK_STORAGE_GUID_OCTET_LEN   (16)
20 
21 /****************************************
22  * \brief get_partition_info operation
23  *
24  * Get information about the storage partition identified by the specified
25  * unique partition GUID.
26  */
27 
28 /* Mandatory fixed sized input parameters */
29 struct __attribute__ ((__packed__)) ts_block_storage_get_partition_info_in
30 {
31 	uint8_t partition_guid[TS_BLOCK_STORAGE_GUID_OCTET_LEN];
32 };
33 
34 /* Mandatory fixed sized output parameters */
35 struct __attribute__ ((__packed__)) ts_block_storage_get_partition_info_out
36 {
37 	uint64_t num_blocks;
38 	uint32_t block_size;
39 	uint8_t partition_guid[TS_BLOCK_STORAGE_GUID_OCTET_LEN];
40 	uint8_t parent_guid[TS_BLOCK_STORAGE_GUID_OCTET_LEN];
41 };
42 
43 /****************************************
44  * \brief open operation
45  *
46  * Open the storage partition identified by the specified unique partition
47  * GUID. A handle is returned that should be used as a qualifier for subsequent
48  * partition-oriented operations.
49  */
50 
51 /* Mandatory fixed sized input parameters */
52 struct __attribute__ ((__packed__)) ts_block_storage_open_in
53 {
54 	uint8_t partition_guid[TS_BLOCK_STORAGE_GUID_OCTET_LEN];
55 };
56 
57 /* Mandatory fixed sized output parameters */
58 struct __attribute__ ((__packed__)) ts_block_storage_open_out
59 {
60 	uint64_t handle;
61 };
62 
63 /****************************************
64  * \brief close operation
65  *
66  * Close a previously opened storage partition. Used when access to the storage
67  * partition is no longer required.
68  */
69 
70 /* Mandatory fixed sized input parameters */
71 struct __attribute__ ((__packed__)) ts_block_storage_close_in
72 {
73 	uint64_t handle;
74 };
75 
76 /****************************************
77  * \brief read operation
78  *
79  * Read data from the block identified by the specified LBA.
80  */
81 
82 /* Mandatory fixed sized input parameters */
83 struct __attribute__ ((__packed__)) ts_block_storage_read_in
84 {
85 	uint64_t handle;
86 	uint64_t lba;
87 	uint32_t offset;
88 	uint32_t len;
89 };
90 
91 /* Read data returned in response */
92 
93 /****************************************
94  * \brief write operation
95  *
96  * Write data to the block identified by the specified LBA.
97  */
98 
99 /* Mandatory fixed sized input parameters */
100 struct __attribute__ ((__packed__)) ts_block_storage_write_in
101 {
102 	uint64_t handle;
103 	uint64_t lba;
104 	uint32_t offset;
105 };
106 
107 /* Write data follows fixed size input message */
108 
109 /* Mandatory fixed sized output parameters */
110 struct __attribute__ ((__packed__)) ts_block_storage_write_out
111 {
112 	uint64_t num_written;
113 };
114 
115 /****************************************
116  * \brief erase operation
117  *
118  * Erase the set of blocks identified by the specified set of LBAs.
119  */
120 
121 /* Mandatory fixed sized input parameters */
122 struct __attribute__ ((__packed__)) ts_block_storage_erase_in
123 {
124 	uint64_t handle;
125 	uint64_t begin_lba;
126 	uint32_t num_blocks;
127 };
128 
129 #endif /* TS_BLOCK_STORAGE_PACKEDC_MESSAGES_H */
130