Define block storage access protocol

Adds packed-c serialization definitions for the access protocol
for the block storage service.

Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I81cb3196aa56a8fbe8112f6f92d5147d09d6c9df
diff --git a/protocols/service/block_storage/packed-c/messages.h b/protocols/service/block_storage/packed-c/messages.h
new file mode 100644
index 0000000..7769912
--- /dev/null
+++ b/protocols/service/block_storage/packed-c/messages.h
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef TS_BLOCK_STORAGE_PACKEDC_MESSAGES_H
+#define TS_BLOCK_STORAGE_PACKEDC_MESSAGES_H
+
+#include <stdint.h>
+
+/**
+ * Protocol definitions for block storage operations
+ * using the packed-c serialization.
+ */
+
+/****************************************
+ * Common defines
+ */
+#define TS_BLOCK_STORAGE_GUID_OCTET_LEN   (16)
+
+/****************************************
+ * \brief get_partition_info operation
+ *
+ * Get information about the storage partition identified by the specified
+ * unique partition GUID.
+ */
+
+/* Mandatory fixed sized input parameters */
+struct __attribute__ ((__packed__)) ts_block_storage_get_partition_info_in
+{
+  uint8_t partition_guid[TS_BLOCK_STORAGE_GUID_OCTET_LEN];
+};
+
+/* Mandatory fixed sized output parameters */
+struct __attribute__ ((__packed__)) ts_block_storage_get_partition_info_out
+{
+  uint32_t num_blocks;
+  uint32_t block_size;
+};
+
+/****************************************
+ * \brief open operation
+ *
+ * Open the storage partition identified by the specified unique partition
+ * GUID. A handle is returned that should be used as a qualifier for subsequent
+ * partition-oriented operations.
+ */
+
+/* Mandatory fixed sized input parameters */
+struct __attribute__ ((__packed__)) ts_block_storage_open_in
+{
+  uint8_t partition_guid[TS_BLOCK_STORAGE_GUID_OCTET_LEN];
+};
+
+/* Mandatory fixed sized output parameters */
+struct __attribute__ ((__packed__)) ts_block_storage_open_out
+{
+  uint64_t handle;
+};
+
+/****************************************
+ * \brief close operation
+ *
+ * Close a previously opened storage partition. Used when access to the storage
+ * partition is no longer required.
+ */
+
+/* Mandatory fixed sized input parameters */
+struct __attribute__ ((__packed__)) ts_block_storage_close_in
+{
+  uint64_t handle;
+};
+
+/****************************************
+ * \brief read operation
+ *
+ * Read data from the block identified by the specified LBA.
+ */
+
+/* Mandatory fixed sized input parameters */
+struct __attribute__ ((__packed__)) ts_block_storage_read_in
+{
+  uint64_t handle;
+  uint32_t lba;
+  uint32_t offset;
+  uint32_t len;
+};
+
+/* Read data returned in response */
+
+/****************************************
+ * \brief write operation
+ *
+ * Write data to the block identified by the specified LBA.
+ */
+
+/* Mandatory fixed sized input parameters */
+struct __attribute__ ((__packed__)) ts_block_storage_write_in
+{
+  uint64_t handle;
+  uint32_t lba;
+  uint32_t offset;
+};
+
+/* Write data follows fixed size input message */
+
+/* Mandatory fixed sized output parameters */
+struct __attribute__ ((__packed__)) ts_block_storage_write_out
+{
+  uint64_t num_written;
+};
+
+/****************************************
+ * \brief erase operation
+ *
+ * Erase the set of blocks identified by the specified set of LBAs.
+ */
+
+/* Mandatory fixed sized input parameters */
+struct __attribute__ ((__packed__)) ts_block_storage_erase_in
+{
+  uint64_t handle;
+  uint32_t begin_lba;
+  uint32_t num_blocks;
+};
+
+#endif /* TS_BLOCK_STORAGE_PACKEDC_MESSAGES_H */
diff --git a/protocols/service/block_storage/packed-c/opcodes.h b/protocols/service/block_storage/packed-c/opcodes.h
new file mode 100644
index 0000000..2836b1c
--- /dev/null
+++ b/protocols/service/block_storage/packed-c/opcodes.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef TS_BLOCK_STORAGE_OPCODES_H
+#define TS_BLOCK_STORAGE_OPCODES_H
+
+/**
+ * C/C++ definition of block storage service opcodes.
+ */
+
+#define TS_BLOCK_STORAGE_OPCODE_BASE                 (0x0100)
+#define TS_BLOCK_STORAGE_OPCODE_GET_PARTITION_INFO   (TS_BLOCK_STORAGE_OPCODE_BASE + 1)
+#define TS_BLOCK_STORAGE_OPCODE_OPEN                 (TS_BLOCK_STORAGE_OPCODE_BASE + 2)
+#define TS_BLOCK_STORAGE_OPCODE_CLOSE                (TS_BLOCK_STORAGE_OPCODE_BASE + 3)
+#define TS_BLOCK_STORAGE_OPCODE_READ                 (TS_BLOCK_STORAGE_OPCODE_BASE + 4)
+#define TS_BLOCK_STORAGE_OPCODE_WRITE                (TS_BLOCK_STORAGE_OPCODE_BASE + 5)
+#define TS_BLOCK_STORAGE_OPCODE_ERASE                (TS_BLOCK_STORAGE_OPCODE_BASE + 6)
+
+#endif /* TS_BLOCK_STORAGE_OPCODES_H */