Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022, 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 | { |
Julian Hall | 71787fc | 2022-11-18 10:27:00 +0000 | [diff] [blame^] | 31 | uint8_t partition_guid[TS_BLOCK_STORAGE_GUID_OCTET_LEN]; |
Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | /* Mandatory fixed sized output parameters */ |
| 35 | struct __attribute__ ((__packed__)) ts_block_storage_get_partition_info_out |
| 36 | { |
Julian Hall | 71787fc | 2022-11-18 10:27:00 +0000 | [diff] [blame^] | 37 | uint32_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]; |
Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 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 | { |
Julian Hall | 71787fc | 2022-11-18 10:27:00 +0000 | [diff] [blame^] | 54 | uint8_t partition_guid[TS_BLOCK_STORAGE_GUID_OCTET_LEN]; |
Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | /* Mandatory fixed sized output parameters */ |
| 58 | struct __attribute__ ((__packed__)) ts_block_storage_open_out |
| 59 | { |
Julian Hall | 71787fc | 2022-11-18 10:27:00 +0000 | [diff] [blame^] | 60 | uint64_t handle; |
Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 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 | { |
Julian Hall | 71787fc | 2022-11-18 10:27:00 +0000 | [diff] [blame^] | 73 | uint64_t handle; |
Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 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 | { |
Julian Hall | 71787fc | 2022-11-18 10:27:00 +0000 | [diff] [blame^] | 85 | uint64_t handle; |
| 86 | uint32_t lba; |
| 87 | uint32_t offset; |
| 88 | uint32_t len; |
Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 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 | { |
Julian Hall | 71787fc | 2022-11-18 10:27:00 +0000 | [diff] [blame^] | 102 | uint64_t handle; |
| 103 | uint32_t lba; |
| 104 | uint32_t offset; |
Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 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 | { |
Julian Hall | 71787fc | 2022-11-18 10:27:00 +0000 | [diff] [blame^] | 112 | uint64_t num_written; |
Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 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 | { |
Julian Hall | 71787fc | 2022-11-18 10:27:00 +0000 | [diff] [blame^] | 124 | uint64_t handle; |
| 125 | uint32_t begin_lba; |
| 126 | uint32_t num_blocks; |
Julian Hall | e450ec8 | 2022-07-04 14:57:40 +0100 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | #endif /* TS_BLOCK_STORAGE_PACKEDC_MESSAGES_H */ |