1 /* 2 * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef BLOCK_STORAGE_PROVIDER_SERIALIZER_H 8 #define BLOCK_STORAGE_PROVIDER_SERIALIZER_H 9 10 #include <stddef.h> 11 #include <stdint.h> 12 #include "common/uuid/uuid.h" 13 #include "components/rpc/common/endpoint/rpc_service_interface.h" 14 #include "service/block_storage/block_store/block_store.h" 15 16 /* Provides a common interface for parameter serialization operations 17 * for the block storage service provider. Allows alternative serialization 18 * protocols to be used without hard-wiring a particular protocol 19 * into the service provider code. A concrete serializer must 20 * implement this interface. 21 */ 22 struct block_storage_serializer { 23 24 /* Operation: get_partition_info */ 25 rpc_status_t (*deserialize_get_partition_info_req)(const struct rpc_buffer *req_buf, 26 struct uuid_octets *partition_guid); 27 28 rpc_status_t (*serialize_get_partition_info_resp)(struct rpc_buffer *resp_buf, 29 struct storage_partition_info *info); 30 31 /* Operation: open */ 32 rpc_status_t (*deserialize_open_req)(const struct rpc_buffer *req_buf, 33 struct uuid_octets *partition_guid); 34 35 rpc_status_t (*serialize_open_resp)(struct rpc_buffer *resp_buf, 36 storage_partition_handle_t handle); 37 38 /* Operation: close */ 39 rpc_status_t (*deserialize_close_req)(const struct rpc_buffer *req_buf, 40 storage_partition_handle_t *handle); 41 42 /* Operation: read */ 43 rpc_status_t (*deserialize_read_req)(const struct rpc_buffer *req_buf, 44 storage_partition_handle_t *handle, 45 uint64_t *lba, 46 size_t *offset, 47 size_t *len); 48 49 /* Operation: write */ 50 rpc_status_t (*deserialize_write_req)(const struct rpc_buffer *req_buf, 51 storage_partition_handle_t *handle, 52 uint64_t *lba, 53 size_t *offset, 54 const uint8_t **data, 55 size_t *data_len); 56 57 rpc_status_t (*serialize_write_resp)(struct rpc_buffer *resp_buf, 58 size_t num_written); 59 60 /* Operation: erase */ 61 rpc_status_t (*deserialize_erase_req)(const struct rpc_buffer *req_buf, 62 storage_partition_handle_t *handle, 63 uint64_t *begin_lba, 64 size_t *num_blocks); 65 }; 66 67 #endif /* BLOCK_STORAGE_PROVIDER_SERIALIZER_H */ 68