1 /*
2  * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef SECURE_STORAGE_PROTO_H
8 #define SECURE_STORAGE_PROTO_H
9 
10 #include <stdint.h>
11 
12 /* Operation SET request parameters */
13 struct __attribute__ ((__packed__)) secure_storage_request_set {
14 	uint64_t uid;
15 	uint64_t data_length;
16 	uint32_t create_flags;
17 	uint8_t p_data[];
18 };
19 
20 /* Operation GET request parameters */
21 struct __attribute__ ((__packed__)) secure_storage_request_get {
22 	uint64_t uid;
23 	uint64_t data_offset;
24 	uint64_t data_size;
25 };
26 
27 /* Operation GET_INFO request and response parameters */
28 struct __attribute__ ((__packed__)) secure_storage_request_get_info {
29 	uint64_t uid;
30 };
31 
32 struct __attribute__ ((__packed__)) secure_storage_response_get_info {
33 	uint64_t capacity;
34 	uint64_t size;
35 	uint32_t flags;
36 };
37 
38 /* Operation REMOVE request parameters */
39 struct __attribute__ ((__packed__)) secure_storage_request_remove {
40 	uint64_t uid;
41 };
42 
43 /* Operation CREATE request parameters */
44 struct __attribute__ ((__packed__)) secure_storage_request_create {
45 	uint64_t uid;
46 	uint64_t capacity;
47 	uint32_t create_flags;
48 };
49 
50 /* Operation SET_EXTENDED request parameters */
51 struct __attribute__ ((__packed__)) secure_storage_request_set_extended {
52 	uint64_t uid;
53 	uint64_t data_offset;
54 	uint64_t data_length;
55 	uint8_t p_data[];
56 };
57 
58 /* Operation GET_SUPPORT response parameters */
59 struct __attribute__ ((__packed__)) secure_storage_response_get_support {
60 	uint32_t support;
61 };
62 
63 #define TS_SECURE_STORAGE_OPCODE_BASE			(0x100u)
64 
65 #define TS_SECURE_STORAGE_OPCODE_SET			(TS_SECURE_STORAGE_OPCODE_BASE + 0u)
66 #define TS_SECURE_STORAGE_OPCODE_GET			(TS_SECURE_STORAGE_OPCODE_BASE + 1u)
67 #define TS_SECURE_STORAGE_OPCODE_GET_INFO		(TS_SECURE_STORAGE_OPCODE_BASE + 2u)
68 #define TS_SECURE_STORAGE_OPCODE_REMOVE			(TS_SECURE_STORAGE_OPCODE_BASE + 3u)
69 #define TS_SECURE_STORAGE_OPCODE_CREATE			(TS_SECURE_STORAGE_OPCODE_BASE + 4u)
70 #define TS_SECURE_STORAGE_OPCODE_SET_EXTENDED	(TS_SECURE_STORAGE_OPCODE_BASE + 5u)
71 #define TS_SECURE_STORAGE_OPCODE_GET_SUPPORT	(TS_SECURE_STORAGE_OPCODE_BASE + 6u)
72 
73 #define TS_SECURE_STORAGE_FLAG_NONE			(0u)
74 #define TS_SECURE_STORAGE_FLAG_WRITE_ONCE		(1u << 0)
75 #define TS_SECURE_STORAGE_FLAG_NO_CONFIDENTIALITY	(1u << 1)
76 #define TS_SECURE_STORAGE_FLAG_NO_REPLAY_PROTECTION	(1u << 2)
77 #define TS_SECURE_STORAGE_SUPPORT_SET_EXTENDED		(1u << 0)
78 
79 #endif /* SECURE_STORAGE_PROTO_H */
80